Beispiel #1
0
 function onAfterInitialise()
 {
     $config = JFactory::getConfig();
     $lifeTime = (int) $config->get('lifetime');
     $offset = (double) $config->get('offset');
     $jvcSessionTime = $this->params->get('jvc_session_time', 15);
     $jvcSessionTime = min($jvcSessionTime, $lifeTime);
     /** determine date  */
     $now = time();
     $hourStart = $now - $now % 3600;
     $filePath = JPATH_SITE . DIRECTORY_SEPARATOR . 'administrator' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jvcounter' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'jvcounter.php';
     if (file_exists($filePath)) {
         require_once $filePath;
     } else {
         return;
     }
     $lastTime = JvcounterModelJvcounter::lastTimeLog();
     if (!$lastTime) {
         $visits = JvcounterModelJvcounter::getOnlineVisits($jvcSessionTime);
         JvcounterModelJvcounter::insertLog($now, $visits);
         $lasttime = $now;
     } else {
         $now = time();
         if ($lastTime < $hourStart) {
             $visits = JvcounterModelJvcounter::getVisitsFromSession($lastTime + 1, $hourStart);
             JvcounterModelJvcounter::insertLog($hourStart, $visits);
             $lastTime = $hourStart;
         } else {
             if ($now >= $lastTime + $jvcSessionTime) {
                 $visits = JvcounterModelJvcounter::getVisitsFromSession($lastTime + 1);
                 JvcounterModelJvcounter::insertLog($now, $visits);
                 $lastTime = $now;
             }
         }
     }
     $now = time();
     if ($now % 86400 < 60) {
         JvcounterModelJvcounter::removeNullLogs();
     }
 }