Location: PHPKode > scripts > Application Framework Classes > application-framework-classes/security.class.php
<?php
/* 
 *(c) 2002 christoph althammer hide@address.com 
 *         http://www.milpa.de
 *
 *         GNU GENERAL PUBLIC LICENSE
 *         die deutsche √úbersetzung der GPL ist zu finden auf www.suse.org.
 *
 *   auth: c. althammer
 *   date: 2002-10-10
 *   lc  : 2002-10-17
 *   comm: Security IP Check
 *
 *
 */



class Security{
	var $AllowedHosts	="";
	var $IPCheckEnabled	= "";
	var $InternHostArray	= "";
	var $ClientIP		= "";
	
	function Security(){
		$Conf					= new Conf;
		$this->AllowedHosts		= $Conf->AllowedHosts;
		$this->InternHostArray	= $this->SplitHosts();
		$this->IPCheckEnabled	= $Conf->IPCheckEnabled;	
		$this->ClientIP			= $this->GetClientIP();
		if ($this->IPCheckEnabled != true) { 
			return false; }

		if (count($this->InternHostArray)<1) {
			echo"You have enabled the IP-Checking Feature in an ./etc/*.conf File. No Hosts specified!";
			die;		    
		}
		if (empty($this->ClientIP)) {
			echo("Couldn't read Client IP. Application halted!");	
			die;    
		}
		if (!($this->CheckIP())) $this->ExitApplication();
		return true;
	}
	
	function GetClientIP(){
		return $_SERVER['REMOTE_ADDR'];	
	}	
	function SplitHosts(){
		$InternHostArray	= array();
		$InternHostArray	= explode(",",$this->AllowedHosts);
		return $InternHostArray;
	} 	
	function CheckIP(){
		$Flag	= false;
		for(reset($this->InternHostArray);$IP	= current($this->InternHostArray);next($this->InternHostArray)){
			if (($IP	== $this->ClientIP)) {
				$Flag	= true;
				break;			    
			}
		
		}
		return $Flag;
	
	}
	function ExitApplication(){
		echo"<p>Access Denied. Your IP ".$_SERVER['REMOTE_ADDR']." is not allowed to access this Section. Application Terminated.";
		die;	
	}




}

?>
Return current item: Application Framework Classes