Location: PHPKode > projects > PWF > PWF_0.3.0/Core/Server.php
<?php
/**
 * _Core_Server simplifies access to $_SERVER array variables  
 * @copyright	Copyright (c) 2012, PWF
 * @license		http://phpwebframework.com/License 
 * @version PWF_0.3.0
 */
class _Core_Server
{
	/**
	 * Returns if there is REDIRECT_URL or null if isn't 
	 * @return null,string
	 */
	public function getRedirectUrl()
	{
		return isset($_SERVER["REDIRECT_URL"]) ? $_SERVER["REDIRECT_URL"] : null;
	}
	
	/**
	 * Returns HTTP_HOST
	 * @return string
	 */
	public function getHttpHost()
	{
		return $_SERVER['HTTP_HOST'];
	}

	/**
	 * Returns REQUEST_URI
	 * @return string
	 */	
	public function getRequestUri()
	{
		return $_SERVER['REQUEST_URI'];
	}
	
	/**
	 * Returns PHP_SELF
	 * @return string
	 */	
	public function getPhpSelf()
	{
		return $_SERVER['PHP_SELF'];
	}
	
	/**
	 * Returns HTTPS
	 * @return string
	 */	
	public function getHttps()
	{
		return $_SERVER['HTTPS'];
	}
	
	/**
	 * Returns the protocol of the request (e.g. http or https)
	 * @return string
	 */	
	public function getProtocol()
	{
		return _String::beforeFirst($_SERVER["SERVER_PROTOCOL"], "/").(empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "");
	}
	
	/**
	 * Returns REMOTE_ADDR the user's ip 
	 * @return string
	 */	
	public function getUserIp()
	{
		return $_SERVER["REMOTE_ADDR"];
	}
	
	/**
	 * Returns if there is proper headers for AJAX request (HTTP_X_REQUESTED_WITH) 
   * <b>Notice:</b> This check is a first level security check but headers can be manipulated 
	 * @return string
	 */	
	public function hasAjaxHeaders()
	{
		return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
	}
}
?>
Return current item: PWF