<?php
class pythonHandler{//start the class
private $user; //plaintext username
private $pass; //plaintext password.
private $getUserQuery; //the get user query from teh checkUser() funcion
public function dbConn(){ //function to connect to the database.
$link = mysql_connect("localhost","Your User","Your Pass") or die(mysql_error());
mysql_select_db("Your DB", $link) or die(mysql_error());
}
public function doLogin($user, $pass){ //lets login now!
$this->user = $user; //set the user for later use
$this->pass = $pass; //set the pass for later use
if(empty($user)){ //no user
return "No User Specified"; //tell the user.
}else{ //user found
if($this->checkUser() == TRUE){ //check the user and see if its true
if(empty($pass)){ //theres no password
return "No Pass Specified";
}else{//there is a password
if($this->checkPass() == TRUE){ //verify the password is right
return "Login Successful"; //success!
}else{ //nope...made a booboo
return "Invalid Pass Specified"; //invalid password
}//end password check
}//end empty pass check
}else{ //user invalid
return "Invalid User Specified"; //Uh-oh!
}//end user invalid check
}//end user check
}//end doLogin function
private function checkUser(){ //the check user function
$this->getUserQuery = mysql_query("SELECT * FROM `members` WHERE `username` = '$this->user';"); //get the user from the database
if(mysql_num_rows($this->getUserQuery) == 0){ //is it there?
return FALSE; //no, no the user isn't there.
}else{//maybe it is...
return TRUE; //yes it is! :)
} //end the get user check
} //end the checkUser function
private function checkPass(){ //check the password!
$arrayUser = mysql_fetch_object($this->getUserQuery); //array the data for use
$userPass = $this->Encrypt($this->pass, $arrayUser->salt); //encrypt the plain text password to compare
if($userPass != $arrayUser->password){ //lets compare!
return FALSE;//not right :(
}else{ //maybe.
return TRUE; //Yes, it is right!
}//end the check.
}//end the checkPass function
public function handlerStats(){ //some stats.
return "Handler Version: 0.2\nHandler Creator: ShadowMage"; //yes I did make this :)
}//end handlerStats
function Encrypt($pw, $salt = null) //lets salt and encrypt the password
{
$pw = str_replace(array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"), "", $pw); //get rid of the numbers
$hash_a = hash("md4", "Hey Look a " . $pw . " Password " . $salt .
" Hash"); //md4 the password
$hash_b = hash("md5", $hash_a); //add a little md5
$hash_c = hash("sha1", $hash_b); //with some sha1
$hash_d = hash("sha512", $hash_c); //and sha512
$return_a = strtoupper(strrev($hash_d)); //Lets uppercase it all then reverse it now
return md5(hash("haval256,5", sha1($pw) . hash("haval256,5", $return_a) . sha1($salt))); //then output a regular md5 password with some sha1 and haval in it!
}//end the encrypt function
}//end the class.
?>