Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ________
- | ______| SOCIAL
- | |____ ___ PWNAGE
- | ____| / __|
- | | \__ \
- |_| |___/
- This is the database class for FriendSpace. (mySQL)
- This database can be accessed by developers for applications.
- Passwords are not avalible. Thank you
- */
- class db{
- /* Database variables */
- private var $server = "";
- private var $maindb = "";
- private var $musername = "";
- private var $mpassword = "";
- private var $otherdb = "";
- private var $ousername = "";
- private var $opassword = "";
- private var $usertable = "";
- protected function checkKey($user,$key){ /* Check for key to access db */
- // Missing arguments
- if(!$user) errorhandler::fatal("Missing username");
- elseif(!$key) errorhandler::fatal("Missing key");
- else{
- $arr = parse_ini_file("classes\dbkeys.ini");
- if(!$arr[$user]) return false; // No user
- elseif($arr[$user] !=== $key) return false;
- elseif($arr[$user] === $key) return true; // Pass
- }
- }
- protected function connect($db,$user,$key){ // Main or Other db
- $keycheck = $this->checkKey($user,$key); // Check access
- if(!$keycheck) return false and errorhandler::fatal("Invalid key");
- else{ // Access granted
- if($db === "main"){
- $con = mysql_connect($server, $maindb, $musername, $mpassword);
- return $con;
- }
- elseif($db === "other"){
- $con = mysql_connect($server, $otherdb, $ousername, $opassword);
- return $con;
- }
- else{
- errorhandler::notice("Invalid database id \"".$db."\", expecting \"main\" or \"other\"");
- return false;
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement