Beispiel #1
0
 function userStats()
 {
     //to get ip
     $ip = $this->input->ip_address();
     //to get browser
     $this->load->library('user_agent');
     if ($this->agent->is_browser()) {
         $agent = $this->agent->browser() . ' ' . $this->agent->version();
     } elseif ($this->agent->is_robot()) {
         $agent = $this->agent->robot();
     } elseif ($this->agent->is_mobile()) {
         $agent = $this->agent->mobile();
     } else {
         $agent = 'Unidentified User Agent';
     }
     //to get location
     $this->load->library('Ip2locationlite');
     $ipLite = new Ip2locationlite();
     //start
     $ipLite->setKey('c51de224446fbd8c9a268c26538eaeb443cdf8068b0f22e384935cdcf471144f');
     //Get errors and locations
     $ip = '124.43.205.61';
     $locations = $ipLite->getCity($ip);
     $errors = $ipLite->getError();
     //Getting the result
     $city = "";
     $country = "";
     if (!empty($locations) && is_array($locations)) {
         foreach ($locations as $field => $val) {
             if ($field == 'countryName') {
                 $country = $val;
             }
             if ($field == 'cityName') {
                 $city = $val;
             }
         }
     }
     //end
     if ($this->is_bot($agent)) {
         $isbot = 1;
     } else {
         $isbot = 0;
     }
     $this->load->helper('date');
     $date = date("Y-m-d");
     $time = date("H:i:s");
     $request_uri = "Home";
     //call model class
     //   $this->load->model('stats_model');
     // $data_object = $this->stats_model->insertDetails($ip,$country,$city,$agent,$isbot,$request_uri,$date,$time);
 }
Beispiel #2
0
 function userStats()
 {
     //to get ip
     $ip = $this->input->ip_address();
     //   echo "lold".$ip;
     //to get browser
     $this->load->library('user_agent');
     if ($this->agent->is_browser()) {
         $agent = $this->agent->browser() . ' ' . $this->agent->version();
     } elseif ($this->agent->is_robot()) {
         $agent = $this->agent->robot();
     } elseif ($this->agent->is_mobile()) {
         $agent = $this->agent->mobile();
     } else {
         $agent = 'Unidentified User Agent';
     }
     //to get location
     $this->load->library('Ip2locationlite');
     $ipLite = new Ip2locationlite();
     //   $ipLite->some_function();
     //start
     $ipLite->setKey('c51de224446fbd8c9a268c26538eaeb443cdf8068b0f22e384935cdcf471144f');
     //Get errors and locations
     $ip = '124.43.205.61';
     $locations = $ipLite->getCity($ip);
     $errors = $ipLite->getError();
     //Getting the result
     $city = "";
     $country = "";
     if (!empty($locations) && is_array($locations)) {
         foreach ($locations as $field => $val) {
             if ($field == 'countryName') {
                 $country = $val;
             }
             if ($field == 'cityName') {
                 $city = $val;
             }
         }
     }
     //  echo $city."  ppp";
     //    echo $country."  ppp";
     //end
     //      echo $agent;
     if ($this->is_bot($agent)) {
         $isbot = 1;
     } else {
         $isbot = 0;
     }
     $this->load->helper('date');
     // $datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";
     //  $time = time();
     // echo mdate($datestring, $time);
     $date = date("Y-m-d");
     $time = date("H:i:s");
     //    echo $date;
     //     echo $time;
     //     echo $this->agent->platform(); // Platform info (Windows, Linux, Mac, etc.)
     $request_uri = "CSR Projects";
     $this->load->model('stats_model');
     //   $data_object = $this->stats_model->insertDetails($ip,$country,$city,$agent,$isbot,$request_uri,$date,$time);
 }