Exemple #1
0
 public function insertUserInformation($ipAddress, $userAgentString, $sapiName, GeocoderResult $geocoderResult = null)
 {
     $userAgent = new UserAgent();
     $userAgent->setUserAgent($userAgentString);
     $browser = $userAgent->browser();
     $platform = $userAgent->platform();
     $data = ['ip_address' => $ipAddress, 'sapi_name' => substr($sapiName, 0, 32), 'user_agent' => substr($userAgentString, 0, 255), 'user_agent_browser' => substr($browser, 0, 32), 'user_agent_device' => substr($userAgent->device(), 0, 32), 'user_agent_browser_version' => substr($userAgent->version($browser), 0, 32), 'user_agent_platform_version' => substr($userAgent->version($platform), 0, 32), 'user_agent_platform' => substr($platform, 0, 32), 'user_agent_robot' => substr($userAgent->robot(), 0, 32)];
     if ($geocoderResult) {
         $region = $geocoderResult->getAdminLevels()->first();
         $data['geo_city'] = substr($geocoderResult->getLocality(), 0, 32);
         $data['geo_region'] = $region ? substr($region->getCode(), 0, 32) : null;
         $data['geo_country'] = substr($geocoderResult->getCountry(), 0, 32);
         $data['geo_country_code'] = substr($geocoderResult->getCountryCode(), 0, 6);
         $data['geo_latitude'] = substr($geocoderResult->getLatitude(), 0, 32);
         $data['geo_longitude'] = substr($geocoderResult->getLongitude(), 0, 32);
     }
     $this->getAdapter()->insert('dewdrop_activity_log_user_information', $data);
     return $this->getAdapter()->lastInsertId();
 }
Exemple #2
0
 /**
  * Set country code
  *
  * @param \Geocoder\Model\Address $address
  * @return Geo
  */
 private function setCountryCode($address)
 {
     $this->countryCode = $address->getCountryCode();
     return $this;
 }