Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.58 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6. class MssqlConnect {
  7.  
  8.     public $db_name='ACCOUNT_DBF';
  9.  
  10.     public function __construct($db_server, $db_username, $db_password) {
  11.        
  12.             $this->Connect($db_server, $db_username, $db_password);
  13.             $this->SelectDatabase($this->db_name);
  14.         }
  15.  
  16.     public function Connect($db_server, $db_username, $db_password) {
  17.         mssql_connect($db_server, $db_username, $db_password) or die("<br>Something went wrong connecting to mssql.");
  18.     }
  19.    
  20.     public function SelectDatabase($database_name) {
  21.         mssql_select_db($this->db_name) or die("<br>Something went wrong connecting to database");
  22.     }
  23.    
  24. }
  25.  
  26.  
  27. class RegisterUser extends MssqlConnect {
  28.  
  29.    
  30.    
  31.     public $username;
  32.     public $password;
  33.     public $repeatpassword;
  34.     public $email;
  35.    
  36.     public function __construct($username, $password, $repeatpassword, $email) {
  37.         $this->SQLInjection($username, $password, $repeatpassword, $email);
  38.         $this->RegisterAccount($username, $password, $repeatpassword, $email);
  39.     }
  40.    
  41.     public function  SQLInjection($username, $password, $repeatpassword, $email) {
  42.    
  43.     $banned_strings = array(
  44.                     "insert", "select", "update", "delete", "distinct", "having", "truncate", "replace",
  45.                     "handler", "like", " as ", "or ", "procedure", "limit", "order by", "group by", "asc", "desc",
  46.                     "'", '"', "*", "`"
  47.             );
  48.    
  49.     $allowed_username = $this->username = strip_tags(trim(str_replace($banned_strings, '', $username)));
  50.     $allowed_password = $this->password = strip_tags(trim(str_replace($banned_strings, '', $password)));
  51.     $allowed_repeatpassword = $this->repeatpassword = strip_tags(trim(str_replace($banned_strings, '', $repeatpassword)));
  52.     $allowed_email = $this->email = strip_tags(trim(str_replace($banned_strings, '', $email)));
  53.    
  54.     }
  55.  
  56.     public function RegisterAccount($username, $password, $repeatpassword, $email) {
  57.    
  58.     $this->username = $_POST['username'];
  59.     $this->password = $_POST['password'];
  60.     $this->repeatpassword = $_POST['repeatpassword'];
  61.     $this->email = $_POST['email'];
  62.     $isuse = 'J';
  63.  
  64.     if (!empty($this->username)&&!empty($this->password)&&!empty($this->repeatpassword)&&!empty($this->email)) {
  65.    
  66.         if (ctype_alnum($this->username)&&ctype_alnum($this->password)&&ctype_alnum($this->repeatpassword)) {
  67.        
  68.             if ($this->password==$this->repeatpassword) {
  69.            
  70.                 if ($this->username!==$this->password) {
  71.                    
  72.                
  73.                 $query = mssql_query ("INSERT INTO dbo.ACCOUNT_TBL (account, password, isuse, member, id_no1, id_no2, realname, reload, OldPassword, TempPassword, cash) VALUES ('$this->username', '$this->password', '$isuse', '$this->username', '1', '2', '$this->username', 'false', '$this->password', '$this->password', '0')") or die("Something went wrong insertting the info into the table.");
  74.                 $query_email = mssql_query("INSERT INTO dbo.ACCOUNT_TBL_DETAIL (email, isuse) VALUES('$this->email', '$isuse')") or die("Something went wrong with insertting information");
  75.                 echo "You have been successfully registered with the username: <b>".$this->username."</b>. You  may now <a href='login.php'>login</a> and play.";
  76.                
  77.                 } else {
  78.                
  79.                     echo "Your username and password must be different."; }
  80.             } else {
  81.            
  82.                 echo "Your password and repeated password do not match. Try again."; }
  83.         } else {
  84.        
  85.             echo "Please only use letters and numbers.";}
  86.            
  87.     } else {
  88.         echo "Please fill in <b>All</b> of the fields."; }
  89.     }
  90. }
  91.  
  92.  
  93. $submit = $_POST['submit'];
  94. if ($submit) {
  95. $db_connect = new MssqlConnect('NICK\SQLEXPRESS2', 'sa', 'noobtuber');
  96. $register = new RegisterUser($_POST['username'], $_POST['password'], $_POST['repeatpassword'], $_POST['email']);
  97. }
  98.  
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement