* * Last Modified: 22nd February 2003 * */ error_reporting(0); if (!(include("./modules/header.lib.php"))) { die("

There was an error loading the header module

"); } // The user doesn't have permission to change their own password if ($params["change"] != 1) { redirect($scripts["main"] . "?msg=no_per_pass"); } if (param("op", "POST") == "changepass") { $newpass = param("newpass", "POST"); if (strlen($newpass) < 5) { // Password is too short redirect($scripts["main"] . "?msg=short_pass"); } else if ($newpass != param("newpass2", "POST")) { // Passwords do not match redirect($scripts["main"] . "?msg=not_match"); } else if (preg_match("/^[\w]+$/", $newpass) == FALSE) { // Passwords contain invalid data redirect($scripts["main"] . "?msg=pass_invalid"); } // Assign variables $newpass = md5(param("newpass", "POST")); $userfile = file($script_dir . "/settings/" . $scripts["userlist"]); $fdata = ""; while(list(,$value) = each($userfile)) { if ($value != "") { list($username, $password, $htpasswd, $changepass, $chmod, $upload, $rename, $edit, $delete, $copy, $move, $newfolder, $newfile, $overwrite, $compress, $mysql, $dbhost, $dbuser, $dbpass, $dbname, $root_url, $root_dir, $max_space, $lang) = split("[|]", $value); $lang = trim($lang); if($username != param($cookie_user, "COOKIE")) { $fdata .= "$username|$password|$htpasswd|$changepass|$chmod|$upload|$rename|$edit|$delete|$copy|$move|$newfolder|$newfile|$overwrite|$compress|$mysql|$dbhost|$dbuser|$dbpass|$dbname|$root_url|$root_dir|$max_space|$lang\r\n"; } else { $fdata .= "$username|$newpass|$htpasswd|$changepass|$chmod|$upload|$rename|$edit|$delete|$copy|$move|$newfolder|$newfile|$overwrite|$compress|$mysql|$dbhost|$dbuser|$dbpass|$dbname|$root_url|$root_dir|$max_space|$lang\r\n"; } } } if(($fp = fopen($script_dir . "/settings/" . $scripts["userlist"], "w")) == TRUE) { // The file was opened, now to lock it if ($flock == TRUE) { flock($fp, LOCK_EX); } // The file was opened and locked so write the data fwrite($fp, $fdata); if ($flock == TRUE) { flock($fp, LOCK_UN); } fclose($fp); // Password updated! Change the users cookie if ($cookie_time != "") { // Find out the time the cookie should last $cookie_time = time() + $cookie_time; } setcookie($cookie_pass, ""); setcookie($cookie_pass, $newpass, (int) $cookie_time); redirect($scripts["main"] . "?msg=pass"); } // There was an error redirect($scripts["main"] . "?msg=err_pass"); } // Display the change password form $form = template($changepass, $script_dir . "/settings/templates/pwd.tpl"); $page = array("javascript" => template($javascript, $script_dir . "/settings/templates/javascript/pwd.js"), "content" => $form, "title" => $changepass["title"], "this" => $PHP_SELF, "copyright" => $copyright, "areas" => area_buttons()); // Finish up by outputting the completed page template($page, $script_dir . "/settings/templates/global.tpl"); ?>