SHARE
TWEET

Untitled

a guest Jun 5th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require("config.php");
  3.  
  4. # classes are declared here
  5. #
  6. #   Author: Gilles De Mey
  7. #   Copyrighted by the GNU Public License
  8. #
  9. #   --- Database Class ---
  10.  
  11. class Database
  12. {
  13.     private $db_host = 71.61.41.121;         // Database Host
  14.     private $db_user = root;          // Username
  15.     private $db_pass = Tramodel327;          // Password
  16.     private $db_name = logon;          // Database
  17.    
  18.     private $con = false;               // Checks to see if the connection is active
  19.    
  20.     public function connect()
  21.     {
  22.         if(!$this->con)
  23.         {
  24.             $myconn = mysql_connect($this->db_host,$this->db_user,$this->db_pass) or die();
  25.             if($myconn)
  26.             {
  27.                 $seldb = mysql_select_db($this->db_name,$myconn);
  28.                 if($seldb)
  29.                 {
  30.                     $this->con = true;
  31.                     return true;
  32.                 }
  33.                 else
  34.                 {
  35.                     return false;
  36.                 }
  37.             }
  38.             else
  39.             {
  40.                 return false;
  41.             }
  42.         }
  43.         else
  44.         {
  45.             return true;
  46.         }
  47.     }
  48.        
  49.     public function disconnect()
  50.     {
  51.         if($this->con)
  52.         {
  53.             if(@mysql_close())
  54.             {
  55.                            $this->con = false;
  56.                 return true;
  57.             }
  58.             else
  59.             {
  60.                 return false;
  61.             }
  62.         }
  63.     }
  64.    
  65.     public function setDatabase($name)
  66.     {
  67.         if($this->con)
  68.         {
  69.             if(@mysql_close())
  70.             {
  71.                 $this->con = false;
  72.                 $this->results = null;
  73.                 $this->db_name = $name;
  74.                 $this->connect();
  75.             }
  76.         }
  77.    
  78.     }
  79. }
  80.  
  81. class Session
  82. {  
  83.     private $refurl;
  84.    
  85.     public function init(){
  86.         return session_start();
  87.     }
  88.     public function setLogin($username,$password){
  89.         $password = cleanuserinput(sha1($password));
  90.         $login = cleanuserinput($username);
  91.         $result = mysql_query("SELECT acct FROM accounts WHERE login='".$login."' and encrypted_password='".$password."'");
  92.         $row = mysql_fetch_assoc($result);
  93.         return $_SESSION['userid'] = $row['acct'];
  94.     }
  95.     public function destroy(){
  96.         return session_unset();
  97.     }
  98.     public function setRef($url){
  99.         $this->refurl = $url;
  100.     }
  101.     public function getRef(){
  102.         return $this->refurl;
  103.     }
  104.     public function askLogin(){
  105.         return header("Location: login.php");
  106.     }
  107.     public function redirect(){
  108.         return header("Location: ".$this->refurl);
  109.     }
  110. }
  111.  
  112. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top