示例#1
0
 static function Start($auth = [])
 {
     $called_class = get_called_class();
     if (count($auth)) {
         $where = [];
         foreach ($auth as $k => $v) {
             $where[] = "`" . es($k) . "` = '" . es($v) . "'";
         }
         $res = q("\n\t\t\t\tSELECT `access`" . (count($called_class::$datas) ? ',`' . implode('`,`', $called_class::$datas) . '`' : '') . "\n\t\t\t\tFROM `fw_users`\n\t\t\t\tWHERE " . implode(" AND ", $where) . "\n\t\t\t");
         if (!$res->num_rows) {
             Authorization::logout();
             redirect('/');
         }
         $row = $res->fetch_assoc();
         if ($row['access'] != 1) {
             Authorization::logout();
             $_SESSION['error'] = 'no-access';
             redirect('/');
         }
         foreach ($called_class::$datas as $k => $v) {
             $called_class::${$v} = $row[$v];
             // unset($row[$v]); -- Раскомментировать после обновления функционала на сайте
         }
         if (count($row)) {
             self::$data = $row;
         }
     } elseif (isset($_COOKIE['autologinid'], $_COOKIE['autologinhash'])) {
         $auth = new Authorization();
         if (!$auth->authByHash($_COOKIE['autologinid'], $_COOKIE['autologinhash'])) {
             Authorization::logout();
             redirect('/');
         }
     }
     if (!empty(self::$data['id']) && !empty(self::$autoupdate)) {
         q("\n\t\t\t\tUPDATE `fw_users` SET\n\t\t\t\t`browser` = '" . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '') . "',\n\t\t\t\t`ip` = '" . es($_SERVER['REMOTE_ADDR']) . "'\n\t\t\t\tWHERE `id` = " . (int) self::$data['id'] . "\n\t\t\t");
     }
 }
示例#2
0
 /**
  * logout es para finalizar sesion.
  */
 public function logout()
 {
     $auth = new Authorization();
     $auth->logout();
 }
示例#3
0
 public function logout()
 {
     /**
      * function to logout of the session
      * @return void
      */
     $auth = new Authorization();
     $auth->logout();
 }
示例#4
0
文件: logout.php 项目: GeoPvN/epro
<?php

require_once 'classes/authorization.class.php';
$logout = new Authorization();
$logout->logout();
echo '<meta http-equiv=refresh content="0; URL=index.php">';
<?php

require_once CODE_ROOT . '/classes/authorization.php';
$authorization = new Authorization();
if (empty($request_uri[2])) {
    $request_uri[2] = '';
}
switch ($request_uri[2]) {
    case 'logout':
        $authorization->logout();
        header('Location: /authorization/login');
        die;
        break;
    default:
        $authorization->result['views'] = array('main' => 'login.php');
        break;
}
$result = $authorization->result;