function updateUserLog($userId, $ip) { if (!$userId) { return; // nothing to do if user is not logged in } $timestamp = ExtraWatchDate::getUTCTimestamp(); $query = sprintf("select id from #__extrawatch_user_log where (`userId` = '%d' and `ip` = '%s') ", (int) $userId, $this->database->getEscaped($ip)); $id = $this->database->resultQuery($query); if (@(!$id)) { $query = sprintf("insert into #__extrawatch_user_log (`userId`, `timestamp`, `ip`, `alertSent`) values ('%d', '%d', '%s', NULL)", (int) $userId, (int) $timestamp, $this->database->getEscaped($ip)); $this->database->executeQuery($query); } else { $query = sprintf("update #__extrawatch_user_log set `timestamp` = '%d' where `ip` = '%s' and userId = '%d'", (int) $timestamp, $this->database->getEscaped($ip), (int) $userId); $this->database->executeQuery($query); } $this->sendAlertEmails($ip); }
function getTrialVersionTimeLeft() { return (int) (16 - (ExtraWatchDate::getUTCTimestamp() - $this->getConfigValue("EXTRAWATCH_TRIAL_TIME")) / 3600 / 24 - 0.01); //because it will display 15 days as time left }
function addIp2GoalId($ip, $goalId) { $query = sprintf("select id from #__extrawatch where `ip` = '%s'", $this->database->getEscaped($ip)); $visitId = $this->database->resultQuery($query); $query = sprintf("insert into #__extrawatch_visit2goal (visitId,goalId,timestamp) values ('%d', '%d', '%d')", (int) $visitId, (int) $goalId, (int) ExtraWatchDate::getUTCTimestamp()); $this->database->executeQuery($query); }
/** * date * @return */ static function getUserTimestamp() { return ExtraWatchDate::UTCTimestampToUserTimestamp(ExtraWatchDate::getUTCTimestamp()); }
/** * visitor */ function increaseUri2TitleCount($uri) { $query = sprintf("update #__extrawatch_uri2title set count = count+1, timestamp = '%d' where (`uri` = '%s')", (int) ExtraWatchDate::getUTCTimestamp(), $this->database->getEscaped($uri)); $this->database->executeQuery($query); }
$extraWatch = new ExtraWatchMain(); $extraWatch->helper->setNoindexHttpHeaders(); //setting explicitly for ajax requests $extraWatch->config->initializeTranslations(); $extraWatchHTML = new ExtraWatchHTML(); $extraWatchVisitHTML = new ExtraWatchVisitHTML($extraWatch); $extraWatchBlockHTML = new ExtraWatchBlockHTML($extraWatch); $extraWatchHeatmapHTML = new ExtraWatchHeatmapHTML($extraWatch->database); $extraWatch->block->checkBackendTokenFromUrl(); $t1 = time() + microtime(); $last = $extraWatch->visit->getLastVisitId(); echo "<span style='display: none;'>{$last}</span>\n\n"; $day = $extraWatch->date->jwDateToday(); ExtraWatchLog::debug("<br/>date today: " . $day); ExtraWatchLog::debug("<br/>actual dateTime: " . ExtraWatchDate::getActualDateTime()); ExtraWatchLog::debug("<br/>server time: " . ExtraWatchDate::getUTCTimestamp()); ExtraWatchLog::debug("<br/>date today: " . $extraWatch->date->getDateByDay($day, "d.m.Y H:i:s")); ExtraWatchLog::debug("<br/>"); require_once JPATH_BASE2 . DS . "components" . DS . "com_extrawatch" . DS . "view" . DS . "visits.php"; ?> <br/><br/> <span style='color: #ddd'><?php echo _EW_RENDERED_IN; ?> <?php echo sprintf("%.2f", time() + microtime() - $t1); ?> s</span>
function renderFrontendStats($extraWatch) { $cssURL = $this->extraWatch->config->getLiveSiteWithSuffix() . "components/com_extrawatch/css/extrawatch.css"; $output = $this->extraWatch->env->addStyleSheet($cssURL); $outputFirst = ""; $outputSecond = ""; if (@$this->extraWatch->config->getConfigValue('EXTRAWATCH_FRONTEND_COUNTRIES')) { $cachedItem = $this->extraWatch->cache->getCachedItem("CACHE_FRONTEND_COUNTRIES"); $cachedItem = $this->extraWatch->config->replaceHttpByHttps($cachedItem); if (@$cachedItem) { $outputFirst .= stripslashes($cachedItem); } else { $numberOfCountries = @$this->extraWatch->config->getConfigValue('EXTRAWATCH_FRONTEND_COUNTRIES_NUM'); if (!$numberOfCountries) { $numberOfCountries = 5; } $ctryOutput = "<table class='extrawatch'>"; $ctryOutputFetched = $this->renderIntValuesByNameForFrontend("country", FALSE, TRUE, 0, $numberOfCountries, TRUE); $ctryOutput .= $ctryOutputFetched; $ctryOutput .= "</table>"; if ($ctryOutputFetched) { $this->extraWatch->cache->storeCachedItem("CACHE_FRONTEND_COUNTRIES", $ctryOutput); } $outputFirst .= $ctryOutput; } } if (@$this->extraWatch->config->getConfigValue('EXTRAWATCH_FRONTEND_VISITORS')) { $cachedItem = $this->extraWatch->cache->getCachedItem("CACHE_FRONTEND_VISITORS"); $cachedItem = $this->extraWatch->config->replaceHttpByHttps($cachedItem); if (@$cachedItem) { $outputSecond .= stripslashes($cachedItem); } else { $todayDate = $this->extraWatch->date->jwDateToday(); $yesterdayDate = $todayDate - 1; $dow = $this->extraWatch->date->dayOfWeek(); $dom = $this->extraWatch->date->dayOfMonth(); $numOfDaysActualMonth = ExtraWatchDate::date("t", ExtraWatchDate::getUTCTimestamp()); $numOfDaysPrevMonth = ExtraWatchDate::date("t", ExtraWatchDate::getUTCTimestamp() - $numOfDaysActualMonth * 24 * 3600); $dayInCurrentMonth = ExtraWatchDate::date("d", ExtraWatchDate::getUTCTimestamp()); $lastMonthsDate = $todayDate - $dayInCurrentMonth; $timePeriodArray = array('TODAY', 'YESTERDAY', 'THIS_WEEK', 'LAST_WEEK', 'THIS_MONTH', 'LAST_MONTH', 'TOTAL'); $visOutput = ""; $visOutput .= "<table class='extrawatch'>"; foreach ($timePeriodArray as $key) { if (!@$this->extraWatch->config->getConfigValue('EXTRAWATCH_FRONTEND_VISITORS_' . $key)) { continue; // isn't enabled } switch ($key) { case 'TODAY': $value = $this->extraWatch->stat->getCountByKeyAndDate(EW_DB_KEY_UNIQUE, $todayDate); break; case 'YESTERDAY': $value = $this->extraWatch->stat->getCountByKeyAndDate(EW_DB_KEY_UNIQUE, $yesterdayDate); break; case 'THIS_WEEK': $value = $this->extraWatch->stat->getCountByKeyBetweenDates(EW_DB_KEY_UNIQUE, $todayDate - $dow, $todayDate); break; case 'LAST_WEEK': $value = $this->extraWatch->stat->getCountByKeyBetweenDates(EW_DB_KEY_UNIQUE, $todayDate - $dow - 7, $todayDate - $dow); break; case 'THIS_MONTH': $value = $this->extraWatch->stat->getCountByKeyBetweenDates(EW_DB_KEY_UNIQUE, $todayDate - $dom, $todayDate); break; case 'LAST_MONTH': $value = $this->extraWatch->stat->getCountByKeyBetweenDates(EW_DB_KEY_UNIQUE, $lastMonthsDate - $numOfDaysPrevMonth, $lastMonthsDate); break; case 'TOTAL': $totalFromSettings = $this->extraWatch->config->getConfigValue('EXTRAWATCH_FRONTEND_VISITORS_TOTAL_INITIAL'); $totalReal = $this->extraWatch->stat->getTotalCountByKey(EW_DB_KEY_UNIQUE); if (@$totalFromSettings) { /** use total from settings, but still append the real value as a comment */ $value = $totalFromSettings + $totalReal . "<!-- {$totalReal} -->"; } else { $value = $totalReal; } break; } if (isset($value)) { $visOutput .= "<tr><td style='text-align: left' class='extrawatch'>" . @constant("_EW_FRONTEND_" . $key) . ": </td><td style='text-align: left'> " . @$value . "</td></tr>"; } } $visOutput .= "</table>"; if (@$value) { $this->extraWatch->cache->storeCachedItem("CACHE_FRONTEND_VISITORS", $visOutput); } $outputSecond .= $visOutput; } } // to be able to swap order of Countries/Visitors if (@$this->extraWatch->config->getConfigValue('EXTRAWATCH_FRONTEND_COUNTRIES_FIRST')) { $output .= "" . $outputFirst . "<br/>" . $outputSecond . ""; } else { $output .= "" . $outputSecond . "<br/>" . $outputFirst . ""; } return $output; }