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();
     }
 }
if ($jvcshowthismonth) {
    if ($iscache) {
        $visitorsarray = $iscache->call(array('JvcounterModelJvcounter', 'getVisits'), $datetime["localmonthstart"], $datetime["localdaystart"]);
    } else {
        $visitorsarray = JvcounterModelJvcounter::getVisits($datetime["localmonthstart"], $datetime["localdaystart"]);
    }
    $thismonthvisitors = $visitorsarray['visits'];
    $thismonthvisitors += $todayvisitors;
}
if ($jvcshowlastmonth) {
    if ($iscache) {
        $visitorsarray = $iscache->call(array('JvcounterModelJvcounter', 'getVisits'), $datetime["locallastmonthstart"], $datetime["localmonthstart"]);
    } else {
        $visitorsarray = JvcounterModelJvcounter::getVisits($datetime["locallastmonthstart"], $datetime["localmonthstart"]);
    }
    $lastmonthvisitors = $visitorsarray['visits'];
}
if ($iscache) {
    $visitorsarray = $iscache->call(array('JvcounterModelJvcounter', 'getVisits'), 0, $datetime["localdaystart"]);
} else {
    $visitorsarray = JvcounterModelJvcounter::getVisits(0, $datetime["localdaystart"]);
}
$allvisitors = $visitorsarray['visits'];
$allvisitors += $todayvisitors;
$online_time = ONLINE_DEFAULT_TIME;
$online_time *= 60;
if ($jvcshowonlinevisitors) {
    $onlinevisitorsarray = JvcounterModelJvcounter::getVisits(0, 0, $online_time);
    $onlinevisits = $onlinevisitorsarray['visits'];
}
require JModuleHelper::getLayoutPath('mod_jvcounter', $params->get('layout', 'default'));
Beispiel #3
0
 static function getDateTime($offset, $isSunday, $now)
 {
     $datetime = JvcounterModelJvcounter::getStartTime($offset, $isSunday, $now);
     return $datetime;
 }