Location: PHPKode > projects > Katropine DBmanager > Auth_simple/Auth_Simple.php
<?php
class Auth_Simple{

	public static function __chkForFirstEntery(){
		if(file_exists(self::fileName())){
			return true;
		}else{
			return false;
		}
	}
	public static function __addUser($username, $password){
		$long_hash = sha1($username.$password, true);
		self::createConfig($long_hash);
		return true;
	}
	public static function __authenticate($username, $password){
		$long_hash = sha1($username.$password, true);
		if($long_hash == self::readConfig()){
			return true;
		}else{
			return false;
		}
	}
	public static function __resetAuth(){
		$file = self::fileName();
		unlink($file);
	}
	
	private static function fileName(){
		return "Auth_simple/.config"; 
	}
	private static function readConfig(){
		$file = self::fileName(); 
		$handle = fopen($file, 'r');
		$theData = fread($handle, filesize($file));
		fclose($handle);
		return $theData;
		
	}
	private static function createConfig($hash){
		$file = self::fileName(); 
		$handle = fopen($file, 'w');
		fwrite($handle, $hash); 
		fclose($handle); 
	}
	
}
?>
Return current item: Katropine DBmanager