Location: PHPKode > scripts > Bioloide > botlane/ara-authorize.php
<?php 
session_start(); 
function authorize( $login = '',  $passwd = '' )
{ 

	$result = "ara-result.txt";
	$users = "ara-users.php";

	$fr = fopen($result, "w");
	fwrite($fr, "no\n");
	fclose($fr);

	$pass5 = "x". MD5($passwd);

	if(stristr($login,'<'))
	{
		die("Hacking");
	}
	
	if((!empty($login)) && (strlen($login) < 3))
	{
		die("Login must be 3 letters at least");
	}

	$fp = fopen( $users, 'r' ); 

	while( !feof( $fp ) ) 
	{ 
		$line = trim( fgets( $fp, 1000 ) ); 
		list( $l, $p, $u ) = explode( ',', $line ); 
		
		//echo "$l $p $u --- ".$_SERVER[REMOTE_ADDR]." ".md5($_SERVER[REMOTE_ADDR])."<br>";

		if(strcmp($u , "admin") != 0) continue;
		if($l == 'ip')
		{
			$computer = $_SERVER[REMOTE_ADDR]; 
			$ip = md5($computer);
			if($p == $ip) 
			{ 
   				$fr = fopen($result, "w");
  				fwrite($fr, "yes");
	   			fclose($fr);
	   			$login = $computer;
	   			$passwd = $computer;
				$_SESSION["login"]=$login;
				$_SESSION["password"]=$passwd;	   		
				return true;
			}  
  		}
		
		if($l != $login) continue;
 		if($p == $pass5)	// same login, same pass, and admin
		{ 

			$authlist = array("login" => $login); 
			session_register( 'authlist' ); 
			fclose( $fp );

			$_SESSION["login"]=$login;
			$_SESSION["password"]=$passwd;

			$fr = fopen($result, "w");
			fwrite($fr, "yes");
			fclose($fr);

			return true; 
		} 
		else
		{
			return false;
		}
	} 

	fclose( $fp ); 
	unset( $authlist); 
	return false; 

}	
authorize($login, $password);
?>
Return current item: Bioloide