Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ##############################################
- # THIS WAS BUILT FOR EDUCATIONAL PURPOSES #
- # WHAT YOU DO WITH IT IS NONE OF MY BUSINESS #
- ##############################################
- Class CMS
- {
- Public $SQL = array();
- Function __Construct($SQL) { $this->SQL = $SQL; }
- # MySQL Function
- Function MySQL($do, $data)
- {
- $Connection = MySQL_Connect($this->SQL[0], $this->SQL[1], $this->SQL[2]);
- MySQL_Select_Db($this->SQL[3], $Connection);
- Switch(strtolower($do)):
- Default:
- Return False;
- Break;
- Case "fetch":
- Return MySQL_Fetch_Array($this->MySQL("query", $data));
- Break;
- Case "query":
- Return MySQL_Query($data);
- Break;
- Case "num":
- Return MySQL_Num_Rows($this->MySQL("query", $data));
- Break;
- EndSwitch;
- MySQL_Close($Connection);
- }
- # User management functions.
- Function User($Action, $Data)
- {
- Switch($Action):
- Default:
- Return False;
- Break;
- Case "set":
- $d = explode(",", $Data);
- Return ($this->MySQL("query", "UPDATE `users` SET `".$d[0]."` = '".$d[1]."' WHERE `".$d[2]."` = '".$d[3]."'")) ? True : False;
- Break;
- Case "get":
- $d = explode(",", $Data);
- Return ($this->MySQL("query", "SELECT `".$d[0]."` FROM `users` WHERE `".$d[1]."` = '".$d[2]."'")) ? True : False;
- Break;
- Case "exists":
- Return ($this->User("get", "id,".$Data)) ? True : False;
- Break;
- Case "ban":
- $d = explode(",", $Data);
- # placeholder
- Break;
- Case "unban":
- $d = explode(",", $Data);
- Return ($this->MySQL("query", "DELETE FROM `bans` WHERE `".$d[0]."` = '".$d[1]."'")) ? True : False;
- Break;
- Case "badge_add":
- $d = explode(",", $Data);
- Return ($this->MySQL("query", "INSERT INTO `user_badges` (`user_id`, `badge_id`, `badge_slot`) VALUES(`".$d[0]."`, `".$d[1]."`, `".$d[2]."`);")) ? True : False;
- Break;
- Case "badge_delete":
- $d = explode(",", $Data);
- Return ($this->MySQL("query", "DELETE FROM `user_badges` WHERE `user_id` = '".$d[0]."', `badge_id` = '".$d[1]."', `badge_slot` = '".$d[2]."'")) ? True : False;
- Break;
- Case "badge_exists":
- $d = explode(",", $Data);
- 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;
- Break;
- EndSwitch;
- }
- }
- # X1M! is PHPWhiz
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement