示例#1
0
文件: users.php 项目: 8dx/bugspray
 function __construct()
 {
     // whether the client is logged in
     $this->is_logged = false;
     $sessionactive = !empty($_SESSION['username']) && !empty($_SESSION['password']) && !empty($_SESSION['uid']);
     if (!empty($_COOKIE['mt_username']) && !empty($_COOKIE['mt_password'])) {
         if (!$sessionactive) {
             $_SESSION['username'] = $_COOKIE['mt_username'];
             $_SESSION['password'] = $_COOKIE['mt_password'];
             $_SESSION['uid'] = $_COOKIE['mt_uid'];
             $sessionactive = true;
         }
     }
     if ($sessionactive) {
         // okay, session active, but are they a valid user?
         if (!$this->is_user($_SESSION['username'], $_SESSION['password'], true)) {
             unset($_SESSION['username']);
             unset($_SESSION['password']);
             unset($_SESSION['uid']);
         } else {
             $this->is_logged = true;
         }
     }
     // so if we're logged in, grab our info!
     if ($this->is_logged) {
         parent::__construct($_SESSION['uid']);
     }
     // whether the client is an admin
     $this->is_admin = false;
     if (isset($_SESSION['username'])) {
         $info = db_query_single("SELECT global_admin FROM groups WHERE id = '{$this->info['group']}'", "Checking whether the client is an administrator");
         if ($info[0]) {
             $this->is_admin = true;
         }
     }
 }