Dropped browser class
Actually moved it off to joshtronic/php-remoteaddr
This commit is contained in:
parent
b5b7cacc28
commit
9d5dac05c3
3 changed files with 0 additions and 93 deletions
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Browser Utility Collection
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistribution of these files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2007-2014, Josh Sherman
|
||||
* @license http://www.opensource.org/licenses/mit-license.html
|
||||
* @link https://github.com/joshtronic/pickles
|
||||
* @package Pickles
|
||||
*/
|
||||
|
||||
namespace Pickles;
|
||||
|
||||
/**
|
||||
* Browser Utility Class
|
||||
*
|
||||
* Just a simple collection of static functions to accomplish some of the
|
||||
* more redundant browser-related tasks.
|
||||
*/
|
||||
class Browser extends Object
|
||||
{
|
||||
/**
|
||||
* Remote IP
|
||||
*
|
||||
* Returns the user's IP address.
|
||||
*
|
||||
* @return mixed IP address or false if unable to determine
|
||||
*/
|
||||
public static function remoteIP()
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP']))
|
||||
{
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
}
|
||||
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
|
||||
{
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
elseif (isset($_SERVER['REMOTE_ADDR']))
|
||||
{
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ip = false;
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
}
|
||||
|
|
@ -115,9 +115,6 @@ class Time
|
|||
* @static
|
||||
* @param string $date birth / inception date
|
||||
* @return integer $age number of years old
|
||||
* @todo Wondering if this really should live in the Date class since
|
||||
* it's a Date function. Could flip the aliasing to preserve any
|
||||
* older code.
|
||||
*/
|
||||
public static function age($date)
|
||||
{
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
class BrowserTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testRemoteIPNone()
|
||||
{
|
||||
$this->assertFalse(Pickles\Browser::remoteIP());
|
||||
}
|
||||
|
||||
public function testRemoteIPRemoteAddress()
|
||||
{
|
||||
$_SERVER['REMOTE_ADDR'] = '1.2.3.4';
|
||||
|
||||
$this->assertEquals('1.2.3.4', Pickles\Browser::remoteIP());
|
||||
}
|
||||
|
||||
public function testRemoteIPHTTPXForwardedFor()
|
||||
{
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] = '2.3.4.5';
|
||||
|
||||
$this->assertEquals('2.3.4.5', Pickles\Browser::remoteIP());
|
||||
}
|
||||
|
||||
public function testRemoteIPHTTPClientIP()
|
||||
{
|
||||
$_SERVER['HTTP_CLIENT_IP'] = '3.4.5.6';
|
||||
|
||||
$this->assertEquals('3.4.5.6', Pickles\Browser::remoteIP());
|
||||
}
|
||||
|
||||
public function testRemoteIPWithComma()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue