/** * Session initializing static method. * * @static * @access public * @since 1.0.0-alpha * @version 1.0.0-alpha */ public static function init() { static::$ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR'); static::$userAgent = filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'); static::$sessionSettings = Config::get('session'); static::checkCookie(); }
public static function init() { static::$initialized = true; static::$ip = static::getIpAddress(); }
/** * Client IP * * @return string */ public static function ip() { // check cache if (static::$ip) { return static::$ip; } if (PHP_SAPI == 'cli') { return static::$ip = 'command line'; } // The request was started from the command line if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { return static::$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } // If the server is behind proxy if (isset($_SERVER['HTTP_CLIENT_IP'])) { return static::$ip = $_SERVER['HTTP_CLIENT_IP']; } if (isset($_SERVER['REMOTE_ADDR'])) { return static::$ip = $_SERVER['REMOTE_ADDR']; } return static::$ip = '0.0.0.0'; }
/** * Set the IP address of the current visitor * * @param string $ip * * @return void */ public static function setIp($ip) { static::$ip = $ip; }