Makes sure that we get the real IP of the user
Пример #1
0
 public function check()
 {
     if (empty($this->user_id)) {
         $user = $this->container->platform->getUser();
         $this->user_id = $user->id;
     }
     if (empty($this->item_id)) {
         // Yeah, I know, the Model shouldn't access the input directly but this saves us a lot of code in the
         // front-end models where we're logging downloads.
         $this->item_id = $this->input->getInt('id', 0);
     }
     if (empty($this->accessed_on) || $this->accessed_on == '0000-00-00 00:00:00') {
         \JLoader::import('joomla.utilities.date');
         $date = new \JDate();
         $this->accessed_on = $date->toSql();
     }
     if (empty($this->referer)) {
         if (isset($_SERVER['HTTP_REFERER'])) {
             $this->referer = $_SERVER['HTTP_REFERER'];
         }
     }
     if (empty($this->ip)) {
         $this->ip = Ip::getIp();
         if (class_exists('\\AkeebaGeoipProvider')) {
             $geoip = new \AkeebaGeoipProvider();
             $this->country = $geoip->getCountryCode($this->ip);
         }
     }
     return parent::check();
 }