function identifySocialMedia($url) { $socialmedia = unserialize(EXTRAWATCH_SOCIAL_MEDIA_REGEX); foreach ($socialmedia as $key => $value) { if (preg_match($key, $url) == 1) { $host = $value; ExtraWatchLog::debug("Media recognized: {$host} from {$url}"); return $host; } } return false; }
public function runAdditionalSQLScripts() { try { $files = scandir(ExtraWatchInput::validate(_EW_INPUT_DIR, $this->sqlScriptsModuleDir)); /// foreach ($files as $file) { if (strstr($file, ".sql")) { // should be replaced by ends with if (!$this->wasAdditionalSQLScriptRun($file)) { $this->runSQLscriptsFromFile($this->sqlScriptsModuleDir . DS . $file); /// $this->database->executeQuery(sprintf("insert into #__extrawatch_sql_scripts (scriptname) values ('%s')", $this->database->getEscaped($file))); /// } } } } catch (Exception $e) { ExtraWatchLog::error("An exception while running additional SQL scripts: " . $e->getMessage()); } }
static function getAjax() { if (@$_REQUEST["env"] == "ExtraWatchJoomlaEnv") { /// defined('_JEXEC') or die('Restricted access'); } if (!defined("_JEXEC")) { define("_JEXEC", 1); } if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } $modulePath = realpath(dirname(__FILE__) . DS . '..' . DS . '..'); if (!defined("JPATH_BASE2")) { define("JPATH_BASE2", $modulePath); } if (@EXTRAWATCH_PROFILING_ENABLED) { $t1 = round(microtime(true) * 1000); } require_once $modulePath . DS . 'administrator' . DS . 'components' . DS . 'com_extrawatch' . DS . 'admin.extrawatch.php'; if (@_EW_CLOUD_MODE) { $queryParams = ExtraWatchHelper::getUrlQueryParams(); if (@(!$task)) { $task = @$queryParams['task']; /// } echo @extrawatch_mainController(@$task); } if (@EXTRAWATCH_PROFILING_ENABLED) { $time = round(microtime(true) * 1000) - $t1; } if (@EXTRAWATCH_PROFILING_ENABLED) { ExtraWatchLog::debug("({$time} ms) controller call "); } die; }
function renderHeatmapTableRow($row, $day, $maxClickForDay, $i, $highlightAreasLinks = FALSE) { $uri = $this->visit->getUriNameByUri2TitleId($row->uri2titleId); $title = ExtraWatchHelper::truncate($this->visit->getTitleByUriId($row->uri2titleId), self::TRUNCATE_LEN); ExtraWatchLog::debug("renderHeatmapTableRow - uri2titleId: " . $row->uri2titleId . " uri found; " . $uri . "title: " . $title); $ratio = $row->count / $maxClickForDay; $color = ExtraWatchHelper::rgbFromRatio($ratio); $trendsCells = $this->extraWatchStatHTML->renderDiffTableCellsAndIcon(EW_DB_KEY_HEATMAP, $row->uri2titleId, $day); $liveSite = $this->extraWatch->config->getLiveSiteWithSuffix(); if ($highlightAreasLinks) { $uriWithLiveSite = str_replace("//", "/", $liveSite . $row->uri); $link = $this->renderHighlightElementLink($uriWithLiveSite, "all", $title); } else { $link = $this->renderHeatmapLink($uri, $row->uri2titleId, $day, $title, "", TRUE); } $output = sprintf("<tr class='tableRow" . $i % 2 . "'><td class='ewCentered' style='color: %s' width='5%%'>%d</td><td>%s</td><td>%s</td>", $color, $row->count, $link, ExtraWatchHelper::truncate($uri, 30)); if ($day) { $output .= $trendsCells; } else { $output .= "<td></td><td></td><td></td><td></td>"; } $output .= "</tr>"; return $output; }
/// try { $extraWatch->visit->insertVisit(); } catch (ExtraWatchIPBlockedException $e) { die($this->config->getConfigValue('EXTRAWATCH_BLOCKING_MESSAGE')); } /* * The following piece of code identifies the userAgent and inserts the backlink to extrawatch.com * I would really appreciate, that you would keep the this unchanged. * It took me some time to create and maintain this component and to share it with everyone. * This is the least you could kindly do. Thank you. * * CodeGravity.com */ $output = ""; // reset output; $title = ""; if (!_EW_CLOUD_MODE) { $title = "Heatmap, Real-time analytics, Conversion tracking and anti-spam for Joomla, Wordpress, Drupal, Magento and Prestashop"; } $output .= $extraWatch->helper->renderHTMLCodeSnippet(_EW_PROJECT_ID); return $output; } } try { if (!defined('ENV') | $env->getEnvironmentName() == "nocms") { echo renderExtraWatchAgent(); } } catch (ExtraWatchInputException $e) { ExtraWatchLog::error($e->getMessage()); }
/// $uri = ExtraWatchInput::validate(_EW_INPUT_URI, ExtraWatchHelper::unescapeSlash($uri)); /// $title = ExtraWatchHelper::unescapeSlash($title); /// $referer = ExtraWatchInput::validate(_EW_INPUT_REFERRER, ExtraWatchHelper::unescapeSlash($referer)); /// $params = ExtraWatchHelper::unescapeSlash($params); /// $uri = $uri . $params; //adding params to uri $env = ExtraWatchEnvFactory::getEnvironment(); $modulePath = realpath(dirname(__FILE__) . DS . ".." . DS . ".." . DS . ".." . DS); ExtraWatchLog::debug("img.php - referer: {$referer} title: {$title} uri: {$uri} prams: " . print_r($params, true)); if (@_EW_CLOUD_MODE) { $projectId = (int) @$_REQUEST['projectId']; /// $projectInitialized = $extraWatch->visit->isProjectInitialized($projectId); if ($projectInitialized) { $extraWatch->visit->updateVisitByBrowser($uri, $referer, $title, $params); } else { $extraWatch->setup->initializeDB(TRUE); } } else { $extraWatch->visit->updateVisitByBrowser($uri, $referer, $title, $params); } if (@EXTRAWATCH_PROFILING_ENABLED) { $time = round(microtime(true) * 1000) - $t1; ExtraWatchLog::debug("({$time} ms) img.php duration "); } //die();
defined('_JEXEC') or die('Restricted access'); } if (!defined("_JEXEC")) { define("_JEXEC", 1); } /* wordpress performance optimization */ ini_set('html_errors', 0); define('SHORTINIT', true); define('MYSQL_NEW_LINK', false); /* wordpress performance optimization */ if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } $modulePath = realpath(dirname(__FILE__) . DS . '..' . DS . '..'); if (!defined("JPATH_BASE2")) { define("JPATH_BASE2", $modulePath); } if (@EXTRAWATCH_PROFILING_ENABLED) { $t1 = round(microtime(true) * 1000); } require_once $modulePath . DS . 'administrator' . DS . 'components' . DS . 'com_extrawatch' . DS . 'admin.extrawatch.php'; if (@_EW_CLOUD_MODE) { echo @extrawatch_mainController(@$task); } if (@EXTRAWATCH_PROFILING_ENABLED) { $time = round(microtime(true) * 1000) - $t1; } if (@EXTRAWATCH_PROFILING_ENABLED) { ExtraWatchLog::debug("({$time} ms) controller call "); } die;
private function loadObjectList($key = '') { if (@EXTRAWATCH_PROFILING_ENABLED) { $t1 = round(microtime(true) * 1000); } if (!($cur = $this->query())) { return null; } $array = array(); while ($row = mysql_fetch_object($cur)) { if ($key) { $array[$row->{$key}] = $row; } else { $array[] = $row; } } mysql_free_result($cur); $debugMessage = ""; if (@EXTRAWATCH_PROFILING_ENABLED) { $time = round(microtime(true) * 1000) - $t1; $debugMessage = " ({$time} ms) "; } $debugMessage .= "loadObjectList: " . @$this->sql; ExtraWatchLog::debug($debugMessage); return $array; }
} } catch (e) { alert('Element ' + xpath + ' no longer exists on page'); } }); <?php } ?> <?php } else { if (@$heatmapEnabled) { ?> xx = h337.create({"element":document.body, "radius":50, "visible":true}); window.addEventListener('load',function(){ setTimeout(ew_Heatmap.renderHeatmap(randHash, data), 0); //waiting 1 seconds for everything to load }); <?php } } ?> <?php if (@EXTRAWATCH_PROFILING_ENABLED) { $time = round(microtime(true) * 1000) - $t1; $debugMessage = " ({$time} ms) "; } $debugMessage .= "heatmap.include.js.php"; ExtraWatchLog::debug($debugMessage);
function __construct($filterName, $input) { $this->filterName = $filterName; $this->input = $input; ExtraWatchLog::error("Input Exception: " . $filterName . " input: " . $input); }
/** * stats * upper side visits statistics - unique/loads/hits * @param unknown_type $week * @return unknown */ function renderVisitsGraph($week = 0) { $output = ""; $weekOfYear = ExtraWatchDate::getWeekFromTimestamp($week * 3600 * 24 * 7); $startDay = ExtraWatchDate::getWeekStartingDay($weekOfYear); $searchEngineStats = $this->extraWatch->stat->getSearchEnginesStatsBetweenDays($startDay - 1, $startDay + 6); $i = 0xff; $statsMax['unique'] = $this->extraWatch->stat->getMaxValueInGroupForWeek(EW_DB_KEY_UNIQUE, EW_DB_KEY_UNIQUE, $startDay); $statsMax['loads'] = $this->extraWatch->stat->getMaxValueInGroupForWeek(EW_DB_KEY_LOADS, EW_DB_KEY_LOADS, $startDay); //$statsMax['hits'] = $this->extraWatch->stat->getMaxValueInGroupForWeek(EW_DB_KEY_HITS, EW_DB_KEY_HITS, $startDay); ExtraWatchLog::debug("Start day: {$startDay} " . ExtraWatchDate::getDateByDay($startDay)); for ($day = $startDay; $day < $startDay + 7; $day++) { $i -= 3; $percent = 0; // $stats['search_engines'] = $this->extraWatch->seo->getTotalVisitsByKeyphrasesByDay($day); $stats['search_engines'] = $searchEngineStats[$day]; $statsMax['search_engines'] = $stats['search_engines']; $stats['unique'] = $this->extraWatch->stat->getKeyValueInGroupByDate(EW_DB_KEY_UNIQUE, EW_DB_KEY_UNIQUE, $day); $stats['loads'] = $this->extraWatch->stat->getKeyValueInGroupByDate(EW_DB_KEY_LOADS, EW_DB_KEY_LOADS, $day); //$stats['hits'] = $this->extraWatch->stat->getKeyValueInGroupByDate(EW_DB_KEY_HITS, EW_DB_KEY_HITS, $day); if (!$stats['unique'] && !$stats['loads'] && !$stats['search_engines']) { //do not render empty values continue; } $once = ""; foreach ($stats as $key => $value) { $progressBarIcon = $this->extraWatch->config->getLiveSiteWithSuffix() . "components/com_extrawatch/img/icons/progress_bar_{$key}.gif"; $output .= "<tr><td>"; $dow = ExtraWatchDate::getDateByDay($day, "D"); ExtraWatchLog::debug("day of week: " . $day * 3600 * 24 . " returns: {$dow}"); if (@(!$once[$dow])) { $output .= substr(ExtraWatchDate::getDateByDay($day), 0, 6) . " " . $dow; $once[$dow] = 1; } $output .= "</td>"; $ratio = 0; if ($stats['unique']) { $ratio = sprintf("%.2f", $stats['loads'] / $stats['unique']); } $percentWidth = 0; if ($statsMax[$key]) { if ($statsMax['loads']) { $percent = floor($value / $statsMax['loads'] * 145); } else { if (@$stats['search_engines']) { $percent = floor($value / $statsMax['search_engines'] * 145); } } $percentWidth = floor($percent); } if (@$value) { switch ($key) { /* case 'hits' : { $fontColor = "#aaaaaa"; $output .= "";//"<td align='right' style='color:" . $fontColor . "; background-color: " . $color . ";'>" . $value . "</td><td style='background-color: " . $color . ";'> <table cellpadding='0' cellspacing='0' ><tr><td style='background-color: " . $color . ";'></td><td style='color:" . $fontColor . "; background-color: " . $color . ";'> </td></tr></table></td>"; break; }*/ case 'search_engines': $fontColor = "#DFC4A5"; if ($stats['loads']) { $percentagefromHits = floor($stats['search_engines'] / $stats['loads'] * 100); } $output .= "<td align='right' style='color:" . $fontColor . "; background-color: " . $color . ";'>" . $value . "</td><td style='background-color: " . $color . ";'> <table cellpadding='0' cellspacing='0' ><tr><td style='background-color: " . $color . ";'><img src='{$progressBarIcon}' style='width: " . $percentWidth . "px; height:10px' /></td><td style='color:" . $fontColor . "; background-color: " . $color . ";'> " . @$percentagefromHits . "%</td></tr></table></td>"; break; case 'loads': $fontColor = "#A4C9CF"; $output .= "<td align='right' style='color:" . $fontColor . "; background-color: " . $color . ";'>" . $value . "</td><td style='background-color: " . $color . ";'> <table cellpadding='0' cellspacing='0' ><tr><td style='background-color: " . $color . ";'><img src='{$progressBarIcon}' style='width: " . $percentWidth . "px; height:10px' /></td><td style='color:" . $fontColor . "; background-color: " . $color . ";'></td></tr></table></td>"; break; default: $fontColor = "#BFCBA7"; $output .= "<td align='right' style='color:" . $fontColor . "; background-color: " . $color . ";'>" . $value . "</td><td style='background-color: " . $color . ";'> <table cellpadding='0' cellspacing='0' ><tr><td style='background-color: " . $color . ";'><img src='{$progressBarIcon}' style='width: " . $percentWidth . "px; height:10px' /></td><td style='color: " . $fontColor . "; background-color: " . $color . ";'> " . $ratio . "x</td></tr></table></td>"; } } else { $output .= "<td align='right' style='background-color: " . $color . ";'></td><td align='right' style='background-color: " . $color . ";'></td>"; } $output .= "</tr>"; } } $output .= "<tr><td colspan='3' align='right'>* <span style='color:#DFC4A5;'>" . "from search engines" . "</span>, <span style='color:#BFCBA7;'>" . _EW_STATS_UNIQUE . "</span>, <span style='color:#A4C9CF;'>" . _EW_STATS_LOADS . "</span></td></tr>"; return $output; }
/** * @param $uri * @param $referer * @param $title * @param $ip * @param $time * @return array */ public function insertBotVisit($uri, $referer, $title, $ip, $username = "") { ExtraWatchLog::debug("Insert bot visit: uri: {$uri} referer: {$referer} title: {$title} ip: {$ip} username: {$username}"); if (!$this->checkIfVisitAlreadyInserted($ip)) { $referer = strip_tags($referer); $ip = strip_tags($ip); $query = sprintf("insert into #__extrawatch (ip, country, browser, referer, username, inactive) values ('%s', NULL, NULL, '%s', '%s', %d) ", $this->database->getEscaped($ip), $this->database->getEscaped($referer), $this->database->getEscaped($username), 1); $this->database->executeQuery($query); } if (@$username) { $this->updateUsernameForIp($username, $ip); } $query = sprintf("select id from #__extrawatch where ip = '%s' limit 1", $this->database->getEscaped($ip)); $rows = @$this->database->objectListQuery($query); $row = @$rows[0]; $id = @$row->id; $time = $this->date->getUTCTimestamp(); $query = sprintf("insert into #__extrawatch_uri (fk, timestamp, uri, title) values ('%d', '%d', '%s', '%s') ", (int) $id, (int) $time, $this->database->getEscaped($uri), $this->database->getEscaped($title)); $this->database->executeQuery($query); $this->savePostParams($uri); }
static function debug($message) { ExtraWatchLog::writeEntry("DEBUG", $message); }
$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>
/// $day = (int) @ExtraWatchHelper::requestGet('day'); /// } else { $day = $extraWatch->date->jwDateToday(); } if (@ExtraWatchHelper::requestGet('week')) { /// $week = (int) @ExtraWatchHelper::requestGet('week'); /// } else { $week = $extraWatch->date->getWeekSince1970($extraWatch->date->getUserTimestamp()); } $prevWeek = $week - 1; $nextWeek = $week + 1; ExtraWatchLog::debug("day: {$day}"); $t1 = time() + microtime(); ?> <table border='0' cellpadding='1' cellspacing='0' width='100%'> <?php require_once JPATH_BASE2 . DS . "components" . DS . "com_extrawatch" . DS . "view" . DS . "stats-header.php"; if (@ExtraWatchHelper::requestGet('tab') == "1") { require_once JPATH_BASE2 . DS . "components" . DS . "com_extrawatch" . DS . "view" . DS . "stats-total.php"; } else { require_once JPATH_BASE2 . DS . "components" . DS . "com_extrawatch" . DS . "view" . DS . "stats-today.php"; } require_once JPATH_BASE2 . DS . "components" . DS . "com_extrawatch" . DS . "view" . DS . "stats-footer.php"; ?>
/** * config */ function activate($value) { if (@$value) { $domain = $this->getDomainFromLiveSite(_EW_PROJECT_ID); $this->saveConfigValue('EXTRAWATCH_ADFREE_' . $domain, $this->database->getEscaped($value), true); } else { ExtraWatchLog::error("License activation value is empty!"); } $this->saveConfigValue('EXTRAWATCH_FRONTEND_HIDE_LOGO', "on"); $this->saveConfigValue('EXTRAWATCH_FRONTEND_NOFOLLOW', "on"); $this->saveConfigValue('EXTRAWATCH_FRONTEND_NO_BACKLINK', "on"); if ($this->isAdFree()) { //echo("<span style='color: green'>" . _EW_CONFIG_LICENSE_ACTIVATED . "</span>"); $ip = ExtraWatchVisit::getRemoteIPAddress(); $market = @$this->getConfigValue("EXTRAWATCH_MARKETPLACE"); echo "<iframe style='display:none' src='http://www.extrawatch.com/track/extrawatch/2.3/install/?domain=" . $domain . "&license=PRO&version=2.3.2572&ip=" . $ip . "&env=" . get_class($this->env) . "&key=" . $value . "&market=" . @$market . "' width='1px' frameborder='0' height='1px'>\n </iframe>"; $this->saveConfigValue('EXTRAWATCH_FREE', 0); } else { if (!$this->isUnregistered()) { echo "<span style='color: red'>" . _EW_CONFIG_LICENCE_DONT_MATCH . "</span>"; } } }
static function getWeekStartingDay($week = 0) { ExtraWatchLog::debug("getting week starting day: " . $week); if (!$week) { $weekDiff = 0; } else { $currentWeek = ExtraWatchDate::getCurrentWeek(); // OK $weekDiff = $currentWeek - $week; // difference between selected week number since 1.1.1970 and current week number ExtraWatchLog::debug("current week: {$currentWeek} weekDiff: {$weekDiff}"); } $dayOfWeek = ExtraWatchDate::dayOfWeek(); $dateToday = ExtraWatchDate::jwDateToday(); return $dateToday - $dayOfWeek - $weekDiff * 7 + 1; // +1 to make it start on monday }