function action_check_login() { global $PAGE, $APAGES; if (!check_login()) { if ($PAGE->code != 'login') { setcookie('from_page', get_real_key(), time() + get_option('cookie_login_live'), '/'); replace_page('login'); } return false; } elseif (!check_rule($APAGES['index']->rule) && isset($APAGES[get_real_key()]) && !check_rule($APAGES[get_real_key()]->rule)) { if (get_real_key() == 'index' || isset($APAGES[get_real_key()])) { foreach ($APAGES as $key => $item) { if ($key != 'login' && $key != '404_error' && $item->category == $APAGES['index']->category && !$item->parent && check_rule($item->rule)) { replace_page($key); return false; } } } destroy_cookie('user_ID'); destroy_cookie('user_hash'); replace_page('login'); push_output_message(array('text' => 'У вас недостаточно прав для доступа к админ-панели', 'title' => 'Ошибка!', 'class' => 'alert alert-danger', 'type' => 'error')); return false; } return true; }
function get_current_key() { global $APAGES; $key = get_real_key(); if (!isset($APAGES[$key])) { $key = '404_error'; } if (check_rule($APAGES[$key]->rule)) { return $key; } else { return '404_error'; } }