function insertVisitor($sessiontime, $ip, $time) { $sessiontime = (int) $sessiontime; $time = (int) $time; // Check session time, insert new record if timeout $db =& JFactory::getDBO(); $query = ' SELECT COUNT(*) FROM #__vvisitcounter '; $query .= ' WHERE ip=' . $db->quote($ip); $query .= ' AND (tm + ' . $db->quote($sessiontime) . ') > ' . $db->quote($time); $db->setQuery($query); $items = $db->loadResult(); if ($db->getErrorNum()) { modVisitCounterHelper::createTable(); } if (empty($items)) { $query = " INSERT INTO #__vvisitcounter (id, tm, ip) "; $query .= " VALUES ('', " . $db->quote($time) . ", " . $db->quote($ip) . ")"; $db->setQuery($query); $db->query(); } if ($db->getErrorNum()) { JError::raiseWarning(500, $db->stderr()); } }
$s_digit = modVisitCounterHelper::isEnabled($digit_type); $s_stats = modVisitCounterHelper::isEnabled($stats_type); $s_today = modVisitCounterHelper::isEnabled($today); $s_yesterday = modVisitCounterHelper::isEnabled($yesterday); $s_week = modVisitCounterHelper::isEnabled($x_week); $s_lweek = modVisitCounterHelper::isEnabled($l_week); $s_month = modVisitCounterHelper::isEnabled($x_month); $s_lmonth = modVisitCounterHelper::isEnabled($l_month); $s_all = modVisitCounterHelper::isEnabled($all); $s_online = modVisitCounterHelper::isEnabled($online); $s_ip = modVisitCounterHelper::isEnabled($guestip); $s_guestinfo = modVisitCounterHelper::isEnabled($guestinfo); $s_timenow = modVisitCounterHelper::isEnabled($formattime); break; } $iscache = modVisitCounterHelper::isEnabled($cache_time); /* ------------------------------------------------------------------------------------------------ */ // Get Time Offset from Global Configuration of Joomla! $config =& JFactory::getConfig(); $offset = $config->getValue('config.offset'); // May be use $offset = $mainframe->getCfg( 'offset' ); // Get a reference to the global cache object. $cache =& JFactory::getCache(); $cache_time *= 60; if ($cache_time < 0 || $cache_time > 3600) { $cache_time = CACHE_TIMEOUT_DEFAULT * 60; } $cache->setLifeTime($cache_time); // Detect Guest's IP Address if (!empty($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR'];
$timeline = modVisitCounterHelper::showTimeLine($local_lweekstart, $local_weekstart, $offset); $html .= modVisitCounterHelper::showStatisticsRows($stats_type, "vlweek", $timeline, $l_week, $lweek_visitors); } if ($s_month) { $timeline = modVisitCounterHelper::showTimeLine($local_monthstart, $local_daystart, $offset); $html .= modVisitCounterHelper::showStatisticsRows($stats_type, "vmonth", $timeline, $x_month, $month_visitors); } if ($s_lmonth) { $timeline = modVisitCounterHelper::showTimeLine($local_lmonthstart, $local_monthstart, $offset); $html .= modVisitCounterHelper::showStatisticsRows($stats_type, "vlmonth", $timeline, $l_month, $lmonth_visitors); } if ($s_all) { if (!$beginday) { $beginday = "Visitors Counter"; } $html .= modVisitCounterHelper::showStatisticsRows($stats_type, "vall", $beginday, $all, $all_visitors); } $html .= "</tbody></table></div>"; } // END: TABLE STATISTICS /* ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ */ // BEGIN: SHOW GUEST'S INFO // Show Guest's Info if ($s_online || $s_ip || $s_guestinfo || $s_timenow) { $html .= '<hr style="width: 90%" />'; $html .= '<div style="text-align: center;">'; if ($s_online) { $html .= $online . " " . $online_visitors . "<br />"; } if ($s_ip) {
} if ($s_lweek) { $timeline = modVisitCounterHelper::showTimeLine($local_lweekstart, $local_weekstart, $offset); $html .= modVisitCounterHelper::showStatisticsRows($stats_type, "vlweek", $timeline, $l_week, $lweek_visits); } if ($s_month) { $timeline = modVisitCounterHelper::showTimeLine($local_monthstart, $local_daystart, $offset); $html .= modVisitCounterHelper::showStatisticsRows($stats_type, "vmonth", $timeline, $x_month, $month_visits); } if ($s_lmonth) { $timeline = modVisitCounterHelper::showTimeLine($local_lmonthstart, $local_monthstart, $offset); $html .= modVisitCounterHelper::showStatisticsRows($stats_type, "vlmonth", $timeline, $l_month, $lmonth_visits); } if ($s_all) { $timeline = empty($beginday) ? "Vinaora Visitors Counter" : JText::sprintf('Since', $beginday); $html .= modVisitCounterHelper::showStatisticsRows($stats_type, "vall", $timeline, $all, $all_visits); } $html .= "</tbody></table></div>"; } // END: TABLE STATISTICS /* ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ */ // BEGIN: SHOW HORIZONTAL LINE if ($hrline) { $html .= '<hr/>'; } // END: SHOW HORIZONTAL LINE /* ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ */ // BEGIN: SHOW GUEST'S INFO // Show Guest's Info
: </span> <span class='songuoitruycap'> <?php // echo $online ; echo $online_visitors; ?> </span> </br> <!-- So luot truy cap --> <span class="songuoionlinetitle"> <?php echo JText::_('Số lượt truy cập'); ?> : </span> <span class='songuoitruycap'> <?php $arr =& modVisitCounterHelper::getDigits($all_visitors, $number_digits); $ShowVisiteUser = ''; foreach ($arr as $digit) { $ShowVisiteUser .= $digit; // echo modVisitCounterHelper::showDigitImage( $digit_type, $digit ); } echo format_gia($ShowVisiteUser); ?> </span> </div>
$lmonth_visitors = modVisitCounterHelper::getVisitors($local_lmonthstart, $local_monthstart); } } // Count Online in 20 minutes $online_time = ONLINE_TIME_DEFAULT; if ($s_online) { $online_visitors = modVisitCounterHelper::getVisitors($now - $online_time * 60); } // END: CACULATE VISITORS /* ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ */ // BEGIN: Delete old records if today is the 7th, 14th, 21th or 28th of the month. $time =& JFactory::getDate(); $time->setOffset($offset); if ($s_delrecords) { $day = (int) $time->toFormat("%d"); $minute = (int) $time->toFormat("%M"); if ($day % 7 == 0) { if ($minute % 20 == 0) { $temp = $daystart - $deldays * 24 * 60 * 60; modVisitCounterHelper::delVisitors(0, $temp); } } } // END: Delete old records /* ------------------------------------------------------------------------------------------------ */ $template = $params->get('template'); if ($template == 1) { $layoutname = $params->get('layoutname'); require JModuleHelper::getLayoutPath('mod_vvisit_counter', $layoutname); }