protected function getUserLocation() { if (!empty($this->_userLocation)) { return $this->_userLocation; } $client = new EHttpClient(self::IP_ADDRESS_DATABASE); $client->setParameterGet('ip', $this->getUserHostAddress()); $response = $client->request(); $this->_userLocation = CJSON::decode($response->getBody()); return $this->_userLocation; }
public function SendRequestForUpdate($ip) { if (defined('HTTP_REQUEST_TO_POINT')) { $requestData = array("update_need" => true); $requestAddr = 'http://' . $ip . "/sc_upd"; try { $client = new EHttpClient($requestAddr, array('maxredirects' => 3, 'timeout' => 10, 'adapter' => 'EHttpClientAdapterCurl')); $client->setParameterGet($requestData); $response = $client->request(); $body = ""; if ($response->isSuccessful()) { $body = $response->getBody(); } else { $body = $response->getRawBody(); } } catch (Exception $ex) { error_log("http request exception - " . json_encode($ex) . ". " . "IP - " . $requestAddr . ", " . "Post - " . json_encode($requestData)); } } }