Advertisement
Guest User

Untitled

a guest
May 11th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <?php
  2. /*
  3.  ________  
  4. |  ______|   SOCIAL
  5. | |____   ___    PWNAGE
  6. |  ____| / __|    
  7. | |      \__ \
  8. |_|      |___/
  9.  
  10. This is the database class for FriendSpace. (mySQL)
  11. This database can be accessed by developers for applications.
  12. Passwords are not avalible. Thank you
  13.  */
  14. class db{
  15.     /* Database variables */
  16.     private var $server = "";
  17.     private var $maindb = "";
  18.     private var $musername = "";
  19.     private var $mpassword = "";
  20.     private var $otherdb = "";
  21.     private var $ousername = "";
  22.     private var $opassword = "";
  23.     private var $usertable = "";
  24.     protected function checkKey($user,$key){ /* Check for key to access db */
  25.         // Missing arguments
  26.         if(!$user) errorhandler::fatal("Missing username");
  27.         elseif(!$key) errorhandler::fatal("Missing key");
  28.         else{
  29.             $arr = parse_ini_file("classes\dbkeys.ini");
  30.             if(!$arr[$user]) return false; // No user
  31.             elseif($arr[$user] !=== $key) return false;
  32.             elseif($arr[$user] === $key) return true; // Pass
  33.         }
  34.     }
  35.     protected function connect($db,$user,$key){ // Main or Other db
  36.         $keycheck = $this->checkKey($user,$key); // Check access
  37.         if(!$keycheck) return false and errorhandler::fatal("Invalid key");
  38.         else{ // Access granted
  39.             if($db === "main"){
  40.                 $con = mysql_connect($server, $maindb, $musername, $mpassword);
  41.                 return $con;
  42.             }
  43.             elseif($db === "other"){
  44.                 $con = mysql_connect($server, $otherdb, $ousername, $opassword);
  45.                 return $con;
  46.             }
  47.             else{
  48.                 errorhandler::notice("Invalid database id \"".$db."\", expecting \"main\" or \"other\"");
  49.                 return false;
  50.             }
  51.         }
  52.     }
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement