diff -ruBbdNa cacti-0.8.7h/auth_changepassword.php cacti-0.8.7h-pia//auth_changepassword.php --- cacti-0.8.7h/auth_changepassword.php 2011-09-25 21:04:22.000000000 -0400 +++ cacti-0.8.7h-pia//auth_changepassword.php 2011-09-25 21:10:07.620946156 -0400 @@ -59,6 +59,8 @@ 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"); diff -ruBbdNa cacti-0.8.7h/auth_login.php cacti-0.8.7h-pia//auth_login.php --- cacti-0.8.7h/auth_login.php 2011-09-25 21:04:22.000000000 -0400 +++ cacti-0.8.7h-pia//auth_login.php 2011-09-25 21:46:39.701939535 -0400 @@ -124,12 +124,14 @@ } default: + if (!api_plugin_hook_function('login_process', false)) { /* Builtin Auth */ if ((!$user_auth) && (!$ldap_error)) { /* if auth has not occured process for builtin - AKA Ldap fall through */ $user = db_fetch_row("SELECT * FROM user_auth WHERE username = " . $cnn_id->qstr($username) . " AND password = '" . md5(get_request_var_post("login_password")) . "' AND realm = 0"); } } + } /* end of switch */ /* Create user from template if requested */ @@ -168,7 +170,7 @@ /* Process the user */ if (sizeof($user) > 0) { cacti_log("LOGIN: User '" . $user["username"] . "' Authenticated", false, "AUTH"); - db_execute("INSERT INTO user_log (username,user_id,result,ip,time) VALUES (" . $cnn_id->qstr($username) ."," . $user["id"] . ",1,'" . $_SERVER["REMOTE_ADDR"] . "',NOW())"); + db_execute("INSERT INTO user_log (username,user_id,result,ip,time) VALUES (" . $cnn_id->qstr($username) . "," . $user["id"] . ",1,'" . $_SERVER["REMOTE_ADDR"] . "',NOW())"); /* is user enabled */ $user_enabled = $user["enabled"]; if ($user_enabled != "on") { @@ -189,29 +191,42 @@ decide what to do next */ switch ($user["login_opts"]) { case '1': /* referer */ - if (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE realm_id = 8 AND user_id = " . $_SESSION["sess_user_id"])) == 0) { - header("Location: graph_view.php"); - }else{ + /* because we use plugins, we can't redirect back to graph_view.php if they don't + * have console access + */ if (isset($_SERVER["HTTP_REFERER"])) { $referer = $_SERVER["HTTP_REFERER"]; if (basename($referer) == "logout.php") { - $referer = "index.php"; + $referer = $config['url_path'] . "index.php"; } } else if (isset($_SERVER["REQUEST_URI"])) { $referer = $_SERVER["REQUEST_URI"]; if (basename($referer) == "logout.php") { - $referer = "index.php"; + $referer = $config['url_path'] . "index.php"; } } else { - $referer = "index.php"; + $referer = $config['url_path'] . "index.php"; } + + if (substr_count($referer, "plugins")) { header("Location: " . $referer); + } elseif (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE realm_id = 8 AND user_id = " . $_SESSION["sess_user_id"])) == 0) { + header("Location: graph_view.php"); + } else { + header("Location: $referer"); } + break; case '2': /* default console page */ - header("Location: index.php"); break; + header("Location: " . $config['url_path'] . "index.php"); + + break; case '3': /* default graph page */ - header("Location: graph_view.php"); break; + header("Location: " . $config['url_path'] . "graph_view.php"); + + break; + default: + api_plugin_hook_function('login_options_navigate', $user['login_opts']); } exit; }else{ @@ -222,7 +237,7 @@ exit; }else{ /* BAD username/password builtin and LDAP */ - db_execute("INSERT INTO user_log (username,user_id,result,ip,time) VALUES ('" . $username . "',0,0,'" . $_SERVER["REMOTE_ADDR"] . "',NOW())"); + db_execute("INSERT INTO user_log (username,user_id,result,ip,time) VALUES (" . $cnn_id->qstr($username) . ",0,0,'" . $_SERVER["REMOTE_ADDR"] . "',NOW())"); } } } @@ -249,7 +264,7 @@ - Login to Cacti + <?php print api_plugin_hook_function("login_title", "Login to Cacti");?>