Your current password is not correct. Please try again."; } if ($user['password'] == md5($_POST['password'])) { $bad_password = true; $errorMessage = "Your new password can not be the same as the old password. Please try again."; } // Secpass checking $error = secpass_check_pass($_POST['password']); if ($error != '') { $bad_password = true; $errorMessage = "$error"; } if (!secpass_check_history($_SESSION['sess_user_id'], $_POST['password'])) { $bad_password = true; $errorMessage = "You can not use a previously entered password!"; } if ($bad_password == false && $_POST['password'] == $_POST['confirm'] && $_POST['password'] != '') { // Password change is good to go if (read_config_option('secpass_expirepass') > 0) { db_execute("UPDATE user_auth SET lastchange = " . time() . " WHERE id = " . intval($_SESSION['sess_user_id']) . " AND realm = 0 AND enabled = 'on'"); } $history = intval(read_config_option('secpass_history')); if ($history > 0) { $h = db_fetch_row_prepared("SELECT password, password_history FROM user_auth WHERE id = ? AND realm = 0 AND enabled = 'on'", array($_SESSION['sess_user_id'])); $op = $h['password']; $h = explode('|', $h['password_history']); while (count($h) > $history - 1) { array_shift($h); } $h[] = $op; $h = implode('|', $h); db_execute_prepared("UPDATE user_auth SET password_history = ? WHERE id = ? AND realm = 0 AND enabled = 'on'", array($h, $_SESSION['sess_user_id'])); } db_execute_prepared('INSERT IGNORE INTO user_log (username, result, ip) VALUES (?, 3, ?)', array($user['username'], $_SERVER['REMOTE_ADDR'])); db_execute_prepared("UPDATE user_auth SET must_change_password = '', password = ? WHERE id = ?", array(md5($_POST['password']), $_SESSION['sess_user_id'])); kill_session_var('sess_change_password'); /* ok, at the point the user has been sucessfully authenticated; so we must decide what to do next */ /* if no console permissions show graphs otherwise, pay attention to user setting */ $realm_id = $user_auth_realm_filenames['index.php']; $has_console = db_fetch_cell('SELECT realm_id FROM user_auth_realm WHERE user_id = ? AND realm_id = ?', array($_SESSION['sess_user_id'], $realm_id)); if (basename($_POST['ref']) == 'auth_changepassword.php' || basename($_POST['ref']) == '') { if ($has_console) { $_POST['ref'] = 'index.php'; }else{ $_POST['ref'] = 'graph_view.php'; } } if (!empty($has_console)) { switch ($user['login_opts']) { case '1': /* referer */ header('Location: ' . sanitize_uri($_POST['ref'])); break; case '2': /* default console page */ header('Location: index.php'); break; case '3': /* default graph page */ header('Location: graph_view.php'); break; default: api_plugin_hook_function('login_options_navigate', $user['login_opts']); } }else{ header('Location: graph_view.php'); } exit; }else{ $bad_password = true; } break; } if (api_plugin_hook_function('custom_password', OPER_MODE_NATIVE) == OPER_MODE_RESKIN) { exit; } if ($bad_password && $errorMessage == "") { $errorMessage = "Your new passwords do not match, please retype."; }elseif ($_REQUEST['action'] == 'force') { $errorMessage = "*** Forced password change ***"; } print "\n"; print "\n"; print "\n"; print "\tChange Password\n"; print "\t\n"; print "\t\n"; print "\t\n"; print "\t\n"; print "\t\n"; print "\t\n"; print "\t\n"; print "\t\n"; print "\t\n"; print "\n"; print "\n"; print "
Change Password

Please enter your current password and your new
Cacti password.

Current password
New password
Confirm new password
" . $errorMessage . "
Version " . $version . " | Copyright 2014, The Cacti Group, Inc.
\n";