Skip to content

Commit

Permalink
[enh] Apply PER CS 2.0
Browse files Browse the repository at this point in the history
* Some fix to follow PER CS 2.0 coding rules
* More information at https://www.php-fig.org/per/coding-style/
  • Loading branch information
camlafit committed Nov 14, 2024
1 parent be9b67e commit 5dc2c16
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/usr/share/alternc/panel/class/m_nss.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ protected function define_group_file()
{
global $db;
$db->query("SELECT login,uid FROM `membres`");
$lines=array();
$lines = [];
while ($db->next_record()) {
$lines[] = $db->f('login').":x:".$db->f('uid').":";
$lines[] = $db->f('login') . ":x:" . $db->f('uid') . ":";
}

$this->group_file = implode("\n", $lines);
Expand All @@ -44,9 +44,9 @@ protected function define_passwd_file()
{
global $db;
$db->query("SELECT login,uid FROM `membres`");
$lines=array();
$lines = [];
while ($db->next_record()) {
$lines[] = $db->f('login').":x:".$db->f('uid').":".$db->f('uid')."::".getuserpath($db->f('login')).":/bin/false";
$lines[] = $db->f('login') . ":x:" . $db->f('uid') . ":" . $db->f('uid') . "::" . getuserpath($db->f('login')) . ":/bin/false";
}

$this->passwd_file = implode("\n", $lines);
Expand All @@ -56,19 +56,19 @@ protected function define_shadow_file()
{
global $db;
$db->query("SELECT login FROM `membres`");
$lines=array();
$lines = [];
while ($db->next_record()) {
// shadow fields (9) :
// 1. login
// 2. encrypted password or * to prevent login
// 3. date of last password change or '' meaning that password aging features are disabled
// 4. minimum password age or '' or 0 meaning no minimum age
// 5. maximum password age or '' meaning no maximum password age, no password warning period, and no password inactivity period
// 6. password warning period or '' or 0 meaning there are no password warning period
// 7. password inactivity period or '' for no enforcement
// 8. account expiration date or '' for no expiration
// 9. reserved
$fields = array($db->f('login'), '*', '', '', '', '', '', '', '');
// shadow fields (9) :
// 1. login
// 2. encrypted password or * to prevent login
// 3. date of last password change or '' meaning that password aging features are disabled
// 4. minimum password age or '' or 0 meaning no minimum age
// 5. maximum password age or '' meaning no maximum password age, no password warning period, and no password inactivity period
// 6. password warning period or '' or 0 meaning there are no password warning period
// 7. password inactivity period or '' for no enforcement
// 8. account expiration date or '' for no expiration
// 9. reserved
$fields = [$db->f('login'), '*', '', '', '', '', '', '', ''];
$lines[] = implode(':', $fields);
}

Expand All @@ -88,21 +88,21 @@ protected function update_group_file()
{
$file = "/var/lib/extrausers/group";
$content = $this->group_file;
return file_put_contents($file, $content."\n", LOCK_EX);
return file_put_contents($file, $content . "\n", LOCK_EX);
}

protected function update_passwd_file()
{
$file = "/var/lib/extrausers/passwd";
$content = $this->passwd_file;
return file_put_contents($file, $content."\n", LOCK_EX);
return file_put_contents($file, $content . "\n", LOCK_EX);
}

protected function update_shadow_file()
{
$file = "/var/lib/extrausers/shadow";
$content = $this->shadow_file;
return file_put_contents($file, $content."\n", LOCK_EX);
return file_put_contents($file, $content . "\n", LOCK_EX);
}

protected function hook_alternc_add_member()
Expand All @@ -111,4 +111,3 @@ protected function hook_alternc_add_member()
return true;
}
}

0 comments on commit 5dc2c16

Please sign in to comment.