Gpf_Http::getRemoteIp PHP Method

getRemoteIp() public static method

public static getRemoteIp ( )
        public static function getRemoteIp()
        {
            if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
                $ipAddresses = explode(',', $ip);
                foreach ($ipAddresses as $ipAddress) {
                    $ipAddress = trim($ipAddress);
                    if (self::isValidIp($ipAddress)) {
                        return $ipAddress;
                    }
                }
            }
            if (isset($_SERVER['REMOTE_ADDR'])) {
                return $_SERVER['REMOTE_ADDR'];
            }
            return '';
        }

Usage Example

Ejemplo n.º 1
0
 public function insert()
 {
     $password = $this->get(Gpf_Db_Table_AuthUsers::PASSWORD);
     if (strlen(trim($password)) == 0) {
         $this->set(Gpf_Db_Table_AuthUsers::PASSWORD, Gpf_Common_String::generatePassword(8));
     }
     $this->generateAuthToken();
     $this->setIp(Gpf_Http::getRemoteIp());
     parent::insert();
 }
All Usage Examples Of Gpf_Http::getRemoteIp