$error"; break; } // Check user password history if (!secpass_check_history($user_id, $password)) { $bad_password = true; $errorMessage = "" . __('You cannot use a previously entered password!') . ""; break; } // Password and Confirmed password checks if ($password !== $password_confirm) { $bad_password = true; $errorMessage = "" . __('Your new passwords do not match, please retype.') . ""; break; } // Compare current password with stored password if ((!empty($user['password']) || !empty($current_password)) && !compat_password_verify($current_password, $user['password'])) { $bad_password = true; $errorMessage = "" . __('Your current password is not correct. Please try again.') . ""; break; } // Check new password does not match stored password if (compat_password_verify($password, $user['password'])) { $bad_password = true; $errorMessage = "" . __('Your new password cannot be the same as the old password. Please try again.') . ""; break; } // If password isn't blank, password change is good to go if ($password != '') { if (read_config_option('secpass_expirepass') > 0) { db_execute_prepared("UPDATE user_auth SET lastchange = ? WHERE id = ? AND realm = 0 AND enabled = 'on'", array(time(), $user_id)); } $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($user_id)); $op = $h['password']; $h = explode('|', $h['password_history']); while (cacti_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, $user_id)); } db_execute_prepared('INSERT IGNORE INTO user_log (username, result, time, ip) VALUES (?, 3, NOW(), ?)', array($user['username'], get_client_addr())); db_check_password_length(); db_execute_prepared("UPDATE user_auth SET must_change_password = '', password = ? WHERE id = ?", array(compat_password_hash($password,PASSWORD_DEFAULT), $user_id)); kill_session_var('sess_change_password'); raise_message('password_success'); /* 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_prepared('SELECT realm_id FROM user_auth_realm WHERE user_id = ? AND realm_id = ?', array($user_id, $realm_id)); if (basename(get_nfilter_request_var('ref')) == 'auth_changepassword.php' || basename(get_nfilter_request_var('ref')) == '') { if ($has_console) { set_request_var('ref', 'index.php'); } else { set_request_var('ref', 'graph_view.php'); } } if (!empty($has_console)) { switch ($user['login_opts']) { case '1': /* referer */ header('Location: ' . sanitize_uri(get_nfilter_request_var('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 (get_request_var('action') == 'force') { $errorMessage = "*** " . __('Forced password change') . " ***"; } /* Create tooltip for password complexity */ $secpass_tooltip = "" . __('Password requirements include:') . "
"; $secpass_body = ''; if (read_config_option('secpass_minlen') > 0) { $secpass_body .= __('Must be at least %d characters in length', read_config_option('secpass_minlen')); } if (read_config_option('secpass_reqmixcase') == 'on') { $secpass_body .= ($secpass_body != '' ? '
':'') . __('Must include mixed case'); } if (read_config_option('secpass_reqnum') == 'on') { $secpass_body .= ($secpass_body != '' ? '
':'') . __('Must include at least 1 number'); } if (read_config_option('secpass_reqspec') == 'on') { $secpass_body .= ($secpass_body != '' ? '
':'') . __('Must include at least 1 special character'); } if (read_config_option('secpass_history') != '0') { $secpass_body .= ($secpass_body != '' ? '
':'') . __('Cannot be reused for %d password changes', read_config_option('secpass_history')+1); } $secpass_tooltip .= $secpass_body; $selectedTheme = get_selected_theme(); ?>
'> '>
Cacti password.'); } else { $title_message = __('Please enter your new Cacti password.'); } ?>

'> ":"";?>
\n";