Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.36 KB | None | 0 0
  1. <?php
  2.  
  3. ##############################################
  4. # THIS WAS BUILT FOR EDUCATIONAL PURPOSES    #
  5. # WHAT YOU DO WITH IT IS NONE OF MY BUSINESS #
  6. ##############################################
  7.  
  8. Class CMS
  9. {
  10.     Public $SQL = array();
  11.    
  12.     Function __Construct($SQL) { $this->SQL = $SQL; }
  13.    
  14.     # MySQL Function
  15.     Function MySQL($do, $data)
  16.     {
  17.         $Connection = MySQL_Connect($this->SQL[0], $this->SQL[1], $this->SQL[2]);
  18.         MySQL_Select_Db($this->SQL[3], $Connection);
  19.         Switch(strtolower($do)):
  20.             Default:
  21.                 Return False;
  22.             Break;
  23.             Case "fetch":
  24.                 Return MySQL_Fetch_Array($this->MySQL("query", $data));
  25.             Break;
  26.             Case "query":
  27.                 Return MySQL_Query($data);
  28.             Break;
  29.             Case "num":
  30.                 Return MySQL_Num_Rows($this->MySQL("query", $data));
  31.             Break;
  32.         EndSwitch;
  33.         MySQL_Close($Connection);
  34.     }
  35.    
  36.     # User management functions.
  37.     Function User($Action, $Data)
  38.     {
  39.         Switch($Action):
  40.             Default:
  41.                 Return False;
  42.             Break;
  43.             Case "set":
  44.                 $d = explode(",", $Data);
  45.                 Return ($this->MySQL("query", "UPDATE `users` SET `".$d[0]."` = '".$d[1]."' WHERE `".$d[2]."` = '".$d[3]."'")) ? True : False;
  46.             Break;
  47.             Case "get":
  48.                 $d = explode(",", $Data);
  49.                 Return ($this->MySQL("query", "SELECT `".$d[0]."` FROM `users` WHERE `".$d[1]."` = '".$d[2]."'")) ? True : False;
  50.             Break;
  51.             Case "exists":
  52.                 Return ($this->User("get", "id,".$Data)) ? True : False;
  53.             Break;
  54.             Case "ban":
  55.                 $d = explode(",", $Data);
  56.                 # placeholder
  57.             Break;
  58.             Case "unban":
  59.                 $d = explode(",", $Data);
  60.                 Return ($this->MySQL("query", "DELETE FROM `bans` WHERE `".$d[0]."` = '".$d[1]."'")) ? True : False;
  61.             Break;
  62.             Case "badge_add":
  63.                 $d = explode(",", $Data);
  64.                 Return ($this->MySQL("query", "INSERT INTO `user_badges` (`user_id`, `badge_id`, `badge_slot`) VALUES(`".$d[0]."`, `".$d[1]."`, `".$d[2]."`);")) ? True : False;
  65.             Break;
  66.             Case "badge_delete":
  67.                 $d = explode(",", $Data);
  68.                 Return ($this->MySQL("query", "DELETE FROM `user_badges` WHERE `user_id` = '".$d[0]."', `badge_id` = '".$d[1]."', `badge_slot` = '".$d[2]."'")) ? True : False;
  69.             Break;
  70.             Case "badge_exists":
  71.                 $d = explode(",", $Data);
  72.                 Return ($this->MySQL("query", "SELECT `badge_id` FROM `user_badges` WHERE `user_id` = '".$d[0]."', `badge_id` = '".$d[1]."', `badge_slot` = '".$d[2]."'")) ? True : False;
  73.             Break;
  74.         EndSwitch;
  75.     }
  76. }
  77.  
  78. # X1M! is PHPWhiz
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement