Example #1
0
 /**
  * 初始化客户端IP地址
  *
  * @return	string
  */
 public static function initClientIp()
 {
     if (self::$request === null) {
         self::$request = new Request();
     }
     $ip = self::$request->getClientAddress();
     if ($ip == "::1") {
         $ip = "127.0.0.1";
     }
     self::$clientIp = $ip;
 }
Example #2
0
 public function checkAnswer(\Phalcon\Http\Request $request)
 {
     if ($request->getPost('recaptcha_challenge_field') && $request->getPost('recaptcha_response_field')) {
         $this->response = recaptcha_check_answer($this->privateKey, $request->getClientAddress(), $request->getPost('recaptcha_challenge_field'), $request->getPost('recaptcha_response_field'));
     } else {
         $this->error = 'This field could not be empty';
     }
     return $this->isValid();
 }
Example #3
0
 /**
  * Convert to array
  *
  * @return array
  */
 public function toArray($shuffle = true)
 {
     $this->setIp($this->getIp() ? $this->getIp() : $this->request->getClientAddress());
     $this->setDomain($this->getDomain() ? $this->getDomain() : $_SERVER['SERVER_NAME']);
     $data = ['uid' => $this->getUid(), 'exp' => $this->getExp(), 'ip' => $this->getIp(), 'domain' => $this->getDomain(), 'salt' => $this->getSalt(), 'remember_token' => $this->getRememberToken()];
     if ($shuffle) {
         $data = $this->shuffle_assoc($data);
     }
     return $data;
 }
Example #4
0
 public function getClientAddress($trustForwardedHeader = false)
 {
     return parent::getClientAddress($trustForwardedHeader);
 }