Location: PHPKode > projects > SkullPuppy > Project/library/SP/Security/Gateway.php
<?php

class SP_Security_Gateway {
	private $_redirect,$_idToll,$_ipToll;

	public function __construct() {
		session_id() || session_start();
		$this->_redirect = array();
		if(SP_Registry::getKey('gateway_redirect_id'))
			$this->_redirect['id'] = SP_Registry::getKey('gateway_redirect_id');
		if(SP_Registry::getKey('gateway_redirect_ip'))
			$this->_redirect['ip'] = SP_Registry::getKey('gateway_redirect_ip');
		$this->_idToll = array();
		$this->_ipToll = array();
	}
	
	public function toll($toll, $currency) {
		if(!is_array($toll)) $toll = array($toll);
		if(strtolower($currency)=='ip') {
			$this->_ipToll = $toll;
		} else {
			$this->_idToll = $toll;
		}
	}
	
	public function collectToll() {
		if(in_array(SP_HTTP::getFullUrl(), $this->_redirect)) return;
		if($_SESSION['auth'] instanceof SP_Security_Auth_Result) {
			if(in_array($_SESSION['auth']->getId(), $this->_idToll)) {
				SP_HTTP::location($this->_redirect['id']);
			}
		}
		if(in_array($_SERVER['REMOTE_ADDR'], $this->_ipToll)) {
			SP_HTTP::location($this->_redirect['ip']);
		}
	}
	
	public function idRedirect($url) {
		if(!preg_match("/^http/", $url)) {
			if(substr($url,0,1)!='/') $url = '/'.$url;
			$url = SP_HTTP::getBaseUrl().$url;
		}
		$this->_redirect['id'] = $url;
	}
	
	public function ipRedirect($url) {
		if(!preg_match("/^http/", $url)) {
			if(substr($url,0,1)!='/') $url = '/'.$url;
			$url = SP_HTTP::getBaseUrl().$url;
		}
		$this->_redirect['ip'] = $url;
	}

}

?>
Return current item: SkullPuppy