forked from science-ation/science-ation
7f7c3c53e1
{$type}_password_expiry_days. This allows the $config variable to be updated and everyones password will expire based on the new value. To implement this, the password expiry column in the users table has been changed to passwordset, and a PHP script is used to convert the expiry dates to set dates (based on the _password_expiry_days) - Cleanup the password entry checking - Load all config variables for the db_update.php script. Just in case an update script wants access to $config
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?
|
|
function db_update_87_post()
|
|
{
|
|
global $config;
|
|
|
|
$q = mysql_query("SELECT id,types,passwordset FROM users");
|
|
while($i = mysql_fetch_object($q)) {
|
|
$id = $i->id;
|
|
$types = explode(',', $i->types);
|
|
$expiry = $i->passwordset;
|
|
|
|
if($expiry == NULL) {
|
|
$newval = 'created';
|
|
} else if($expiry == '0000-00-00') {
|
|
$newval = false;
|
|
} else {
|
|
/* Find the expiry based on the type */
|
|
$longest_expiry = 0;
|
|
foreach($types as $t) {
|
|
$e = $config["{$t}_password_expiry_days"];
|
|
if($e == 0) {
|
|
/* Catch a never expire case. */
|
|
$longest_expiry = 0;
|
|
break;
|
|
} else if($e > $longest_expiry) {
|
|
$longest_expiry = $e;
|
|
}
|
|
}
|
|
if($longest_expiry == 0) {
|
|
/* Password never expires, set the password
|
|
* set time to the creation time */
|
|
$newval = 'created';
|
|
} else {
|
|
/* Compute when the password was set */
|
|
$newval = date('Y-m-d',
|
|
strtotime("$expiry -$longest_expiry days"));
|
|
$newval = "'$newval'";
|
|
}
|
|
}
|
|
if($newval != false) {
|
|
$query = "UPDATE users SET passwordset=$newval WHERE id='$id'";
|
|
echo "$query\n";
|
|
mysql_query($query);
|
|
}
|
|
}
|
|
}
|
|
?>
|