Advertisement
Corey

Untitled

Mar 13th, 2011
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2. class User
  3. {
  4.     var $auth;
  5.     var $user_info;
  6.     function __construct(&$parent)
  7.     {
  8.         $this->parent =& $parent;
  9.     }
  10.     function logged_in()
  11.     {
  12.         if (isset($this->user_info['id']) && isset($_SESSION['username']))
  13.         {
  14.             return true;
  15.         }
  16.         else
  17.         {
  18.             return false;
  19.         }
  20.     }
  21.     function get_info($info=false)
  22.     {
  23.         if (isset($info))
  24.         {
  25.             if (is_numeric($info))
  26.             {
  27.                 $this->user_info['id'] = $info;
  28.             }
  29.             else
  30.             {
  31.                 $this->user_info['username'] = $info;
  32.             }
  33.         }
  34.         if (isset($this->user_info['id']) && is_numeric($this->user_info['id']))
  35.         {
  36.             $user = $this->parent->db->Execute("SELECT * FROM `" . $this->parent->config['database']['tables']['users'] . "` WHERE `id`='" . $this->user_info['id'] . "' LIMIT 1");
  37.         }      
  38.         elseif (isset($this->user_info['username']))
  39.         {
  40.             $user = $this->parent->db->Execute("SELECT * FROM `" . $this->parent->config['database']['tables']['users'] . "` WHERE `username`='" . $this->user_info['username'] . "' LIMIT 1");
  41.         }
  42.         if ($user->RecordCount() == 0)
  43.         {
  44.             $this->parent->Errors->error("Could not find the requested user.");
  45.             return false;
  46.         }
  47.         else
  48.         {
  49.             $this->user_info = $user->FetchRow();
  50.             return true;
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement