function onAfterInitialise() { // Get Lifetime / Session Time from Global Configuration of Joomla! $config =& JFactory::getConfig(); $lifetime = (int) $config->getValue('config.lifetime'); $offset = (double) $config->getValue('config.offset'); // Get duration to insert new log. Default = 15 minutes / 900 seconds $vlifetime = $this->params->get('session_time', 15); $vlifetime = min($vlifetime, $lifetime); $vlifetime *= 60; // Determine Date/Time Now $now = mktime(); $hour_start = $now - $now % 3600; $vvisit_path = JPATH_ADMINISTRATOR . DS . "components" . DS . "com_vvisit_counter" . DS . "helpers"; $vvisit_exists = file_exists($vvisit_path . DS . "vinaora_visitors_counter.php"); if ($vvisit_exists) { require_once $vvisit_path . DS . "vinaora_visitors_counter.php"; } else { return; } // Get Last Time in the table #__vvcounter_logs $ltime = extVinaoraVisitorsCounter::lastTimeLog(); if (!$ltime) { $visits = extVinaoraVisitorsCounter::getVisitsOnline($vlifetime); extVinaoraVisitorsCounter::insertLog($now, $visits); // Update $ltime $ltime = $now; } else { if ($ltime < $hour_start) { // Get visits from Session and insert new Log $visits = extVinaoraVisitorsCounter::getVisitsFromSession($ltime + 1, $hour_start); extVinaoraVisitorsCounter::insertLog($hour_start, $visits); $ltime = $hour_start; } // Update $now $now = mktime(); if ($now >= $ltime + $vlifetime) { $visits = extVinaoraVisitorsCounter::getVisitsFromSession($ltime + 1); extVinaoraVisitorsCounter::insertLog($now, $visits); $ltime = $now; } } }
function &getVisits($timestart = 0, $timestop = 0, $duration = 0) { $timestart = (int) $timestart; $timestop = (int) $timestop; if ($timestart || $timestop) { return extVinaoraVisitorsCounter::getVisitsFromLogs($timestart, $timestop); } else { if ($duration) { return extVinaoraVisitorsCounter::getVisitsOnline($duration); } else { return extVinaoraVisitorsCounter::getToday(); } } }