/** * Main method of the class. grant the access to the page or make the redirect page setted in control panel * @return mix null or error object * @access public */ function Execute() { tNG_cookieLogin($this->connection); // access denied defaults to "redirect_failed" specified in Login Config $grantAccess = false; $redirect_page = $GLOBALS['tNG_login_config']['redirect_failed']; tNG_clearSessionVars(); if (isset($_SESSION['kt_login_user'])) { if (count($this->levels) > 0) { if (isset($_SESSION['kt_login_level'])) { if (in_array($_SESSION['kt_login_level'], $this->levels)) { $grantAccess = true; } else { // acceess denied. check for level default redirect pages if (is_array($GLOBALS['tNG_login_config_redirect_failed']) && array_key_exists($_SESSION['kt_login_level'], $GLOBALS['tNG_login_config_redirect_failed']) and $GLOBALS['tNG_login_config_redirect_failed'][$_SESSION['kt_login_level']] != "") { $redirect_page = $GLOBALS['tNG_login_config_redirect_failed'][$_SESSION['kt_login_level']]; } else { // the failure page for the current user level is not defined.. so fall back to default $redirect_page = $GLOBALS['tNG_login_config']['redirect_failed']; } } } // if levels are required, and the current user doesn't have one.. access is denied } else { // no levels are required for this page access // the user is logged in, so grant the access $grantAccess = true; } } if (!$grantAccess) { // save the accessed page into a session for later use $_SESSION['KT_denied_pageuri'] = KT_getFullUri(); KT_setSessionVar('KT_denied_pageuri'); $_SESSION['KT_denied_pagelevels'] = $this->levels; KT_setSessionVar('KT_denied_pagelevels'); if (isset($_SESSION['KT_max_tries_error'])) { $redirect_page = KT_addReplaceParam($redirect_page, 'info', 'MAXTRIES'); } else { if (isset($_SESSION['KT_account_expire_error'])) { $redirect_page = KT_addReplaceParam($redirect_page, 'info', 'ACCOUNT_EXPIRE'); } else { $redirect_page = KT_addReplaceParam($redirect_page, 'info', 'DENIED'); } } KT_redir($this->relPath . $redirect_page); } else { // clear the sessions used for redirect ?? } }
/** * Main method of the class. * If the user is not log in, call tNG_cookieLogin which will try to autologin based on the cookies; * verify if the user is logged in and have the proper levels; * @return boolean true if the user has the rights and is loggedin; * @access public */ function Execute() { tNG_cookieLogin($this->connection); // access denied defaults to "redirect_failed" specified in Login Config $grantAccess = false; tNG_clearSessionVars(); if (isset($_SESSION['kt_login_user'])) { if (count($this->levels) > 0) { if (isset($_SESSION['kt_login_level'])) { if (in_array($_SESSION['kt_login_level'], $this->levels)) { $grantAccess = true; } } } else { // no levels are required for this page access // the user is logged in, so grant the access $grantAccess = true; } } return $grantAccess; }
/** * try to log in an user using the cookies; * @param object $connection object; * @return nothing */ function tNG_cookieLogin(&$connection) { tNG_clearSessionVars(); if (isset($_SESSION['kt_login_user'])) { if (isset($GLOBALS['tNG_login_config']['logger_table']) && isset($GLOBALS['tNG_login_config']['logger_pk']) && isset($GLOBALS['tNG_login_config']['logger_user_id']) && isset($GLOBALS['tNG_login_config']['logger_ip']) && isset($GLOBALS['tNG_login_config']['logger_datein']) && isset($GLOBALS['tNG_login_config']['logger_datelastactivity']) && isset($GLOBALS['tNG_login_config']['logger_session']) && $GLOBALS['tNG_login_config']['logger_table'] != '' && $GLOBALS['tNG_login_config']['logger_pk'] != '' && $GLOBALS['tNG_login_config']['logger_user_id'] != '' && $GLOBALS['tNG_login_config']['logger_ip'] != '' && $GLOBALS['tNG_login_config']['logger_datein'] != '' && $GLOBALS['tNG_login_config']['logger_datelastactivity'] != '' && $GLOBALS['tNG_login_config']['logger_session'] != '') { $tNG = new tNG_custom($connection); $tNG->addColumn('kt_login_id', 'STRING_TYPE', 'EXPRESSION', '{SESSION.kt_login_id}'); $tNG->executeTransaction(); Trigger_Login_LoggerOut($tNG); return; } } if (isset($_COOKIE['kt_login_id']) && isset($_COOKIE['kt_login_test'])) { // make an instance of the transaction object $loginTransaction_cookie = new tNG_login($connection); // register triggers // automatically start the transaction $loginTransaction_cookie->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "VALUE", "1"); // add columns $loginTransaction_cookie->setLoginType('cookie'); $loginTransaction_cookie->addColumn("kt_login_id", $GLOBALS['tNG_login_config']['pk_type'], "COOKIE", "kt_login_id"); $loginTransaction_cookie->addColumn("kt_login_test", "STRING_TYPE", "COOKIE", "kt_login_test"); $loginTransaction_cookie->executeTransaction(); } }