Advertisement
Clarkie

New UserCake class.prof.php

Jul 22nd, 2011
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.14 KB | None | 0 0
  1. <?php
  2. /*
  3.     UserCake Version: 1.4
  4.     http://usercake.com
  5.    
  6.     Developed by: Adam Davis
  7. */
  8.  
  9. class UID {
  10.  
  11.     public $email = NULL;
  12.     public $hash_pw = NULL;
  13.     public $user_id = NULL;
  14.     public $clean_username = NULL;
  15.     public $display_username = NULL;
  16.     public $balance = NULL;
  17.  
  18.  
  19.     //Return the timestamp when the user registered
  20.     public function signupTimeStamp()
  21.     {
  22.         global $db,$db_table_prefix;
  23.        
  24.         $sql = "SELECT
  25.                 SignUpDate
  26.                 FROM
  27.                 ".$db_table_prefix."Users
  28.                 WHERE
  29.                 User_ID = '".$db->sql_escape($UID->user_id)."'";
  30.        
  31.         $result = $db->sql_query($sql);
  32.        
  33.         $row = $db->sql_fetchrow($result);
  34.        
  35.         return ($row['SignUpDate']);
  36.     }
  37.    
  38.     //Fetch all user group information
  39.     public function groupID()
  40.     {
  41.         global $db,$db_table_prefix;
  42.        
  43.         $sql = "SELECT ".$db_table_prefix."Users.Group_ID,
  44.                ".$db_table_prefix."Groups.*
  45.                FROM ".$db_table_prefix."Users
  46.                INNER JOIN ".$db_table_prefix."Groups ON ".$db_table_prefix."Users.Group_ID = ".$db_table_prefix."Groups.Group_ID
  47.                WHERE
  48.                User_ID  = '".$db->sql_escape($UID->user_id)."'";
  49.        
  50.         $result = $db->sql_query($sql);
  51.        
  52.         $row = $db->sql_fetchrow($result);
  53.  
  54.         return($row);
  55.     }
  56.    
  57.     //Fetch user's amount of money or balance.
  58.     public function balance()
  59.     {
  60.         global $db,$db_table_prefix;
  61.        
  62.         $sql = "SELECT
  63.                 money
  64.                 FROM
  65.                 ".$db_table_prefix."Users
  66.                 WHERE
  67.                 User_ID = '".$db->sql_escape($UID->user_id)."'";
  68.        
  69.         $result = $db->sql_query($sql);
  70.        
  71.         $row = $db->sql_fetchrow($result);
  72.        
  73.         return ($row['money']);
  74.     }
  75.  
  76.    
  77.     //Is a user member of a group
  78.     public function isGroupMember($id)
  79.     {
  80.         global $db,$db_table_prefix;
  81.    
  82.         $sql = "SELECT ".$db_table_prefix."Users.Group_ID,
  83.                 ".$db_table_prefix."Groups.* FROM ".$db_table_prefix."Users
  84.                 INNER JOIN ".$db_table_prefix."Groups ON ".$db_table_prefix."Users.Group_ID = ".$db_table_prefix."Groups.Group_ID
  85.                 WHERE User_ID  = '".$db->sql_escape($UID->user_id)."'
  86.                 AND
  87.                 ".$db_table_prefix."Users.Group_ID = '".$db->sql_escape($db->sql_escape($id))."'
  88.                 LIMIT 1
  89.                 ";
  90.        
  91.         if(returns_result($sql))
  92.             return true;
  93.         else
  94.             return false;
  95.        
  96.     }
  97.    
  98.  
  99. }
  100. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement