function renderCell($style, $content, $doNotTruncate = FALSE)
 {
     if (!$doNotTruncate) {
         $content = $this->extraWatch->helper->truncate($content, $this->extraWatch->config->getConfigValue('EXTRAWATCH_TRUNCATE_GOALS'));
     }
     $output = "<td class='ewCentered' style='{$style}'>" . ExtraWatchHelper::htmlspecialchars($content) . "</td>";
     return $output;
 }
 /**
  * helper
  *
  * @return unknown  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
  * @deprecated
  */
 function getURI()
 {
     $redirURI = addslashes(@strip_tags(@$_SERVER[$this->config->getConfigValue('EXTRAWATCH_SERVER_URI_KEY')]));
     $uri = ExtraWatchHelper::htmlspecialchars(addslashes(@strip_tags(ExtraWatchInput::validate(_EW_INPUT_URI, @$_SERVER['REQUEST_URI']))));
     ///
     if (@$redirURI && @substr($redirURI, -9, 9) != "index.php") {
         $uri = $redirURI;
     }
     return $uri;
 }
 function blockSpamWord($value, $spamWord, $ip, $today)
 {
     $value = trim($value);
     if (@$spamWord && @$value && ExtraWatchHelper::wildcardSearch("*" . $spamWord . "*", $value)) {
         $this->blockIp($ip, ExtraWatchHelper::htmlspecialchars($value), $today, $spamWord);
         try {
             $this->dieWithBlockingMessage($ip);
         } catch (ExtraWatchIPBlockedException $exception) {
             die($exception->getBlockingMessage());
         }
     }
 }
 function renderRefererRow($referer, $color)
 {
     if (!$referer) {
         return;
     }
     $output = "<tr>\n        <td ></td>  \t \t    \t    \t\t  \t \t  \t \t  \t\t \t \t\t    \t \t\t\t \t   \t\t  \t \t \t\t \t \t   \t      \t  \t \t\t \t\t \t\t\t\t \t\t\t \t\t  \t\t    \t \t\t \t\t  \n        <td ></td>  \t \t    \t    \t\t  \t \t  \t \t  \t\t \t \t\t    \t \t\t\t \t   \t\t  \t \t \t\t \t \t   \t      \t  \t \t\t \t\t \t\t\t\t \t\t\t \t\t  \t\t    \t \t\t \t\t  \n        <td ></td>  \t \t    \t    \t\t  \t \t  \t \t  \t\t \t \t\t    \t \t\t\t \t   \t\t  \t \t \t\t \t \t   \t      \t  \t \t\t \t\t \t\t\t\t \t\t\t \t\t  \t\t    \t \t\t \t\t  \n        <td ></td>  \t \t    \t    \t\t  \t \t  \t \t  \t\t \t \t\t    \t \t\t\t \t   \t\t  \t \t \t\t \t \t   \t      \t  \t \t\t \t\t \t\t\t\t \t\t\t \t\t  \t\t    \t \t\t \t\t  \n        <td ></td>  \t \t    \t    \t\t  \t \t  \t \t  \t\t \t \t\t    \t \t\t\t \t   \t\t  \t \t \t\t \t \t   \t      \t  \t \t\t \t\t \t\t\t\t \t\t\t \t\t  \t\t    \t \t\t \t\t  \n        <td ></td>  \t \t    \t    \t\t  \t \t  \t \t  \t\t \t \t\t    \t \t\t\t \t   \t\t  \t \t \t\t \t \t   \t      \t  \t \t\t \t\t \t\t\t\t \t\t\t \t\t  \t\t    \t \t\t \t\t  \n        <td ></td>  \t \t    \t    \t\t  \t \t  \t \t  \t\t \t \t\t    \t \t\t\t \t   \t\t  \t \t \t\t \t \t   \t      \t  \t \t\t \t\t \t\t\t\t \t\t\t \t\t  \t\t    \t \t\t \t\t  \n        <td ></td>  \t \t    \t    \t\t  \t \t  \t \t  \t\t \t \t\t    \t \t\t\t \t   \t\t  \t \t \t\t \t \t   \t      \t  \t \t\t \t\t \t\t\t\t \t\t\t \t\t  \t\t    \t \t\t \t\t  \n        <td >";
     $refererTruncated = $this->extraWatch->helper->truncate(urldecode($referer));
     $output .= sprintf("<i style='color: gray;'> " . _EW_VISITS_CAME_FROM . ": <a href='%s' target='_blank' title='%s'>%s</a></i>", ExtraWatchHelper::htmlspecialchars(urldecode($referer)), ExtraWatchHelper::htmlspecialchars(urldecode($referer)), $refererTruncated);
     $position = $this->extraWatch->seo->extractGooglePageNumberFromReferer($referer);
     if (@$position) {
         $output .= "<i style='color: gray;'> " . _EW_POSITION . ":{$position}</i> ";
     }
     $phrase = $this->extraWatch->visit->extractPhraseFromUrl($referer);
     if (@$phrase) {
         $hostname = $this->extraWatch->visit->extractHostnameFromUrl($referer);
         $referer = $hostname . "/search?q=" . urlencode($phrase);
         $output .= sprintf("<br/><i style='color: gray;'>" . _EW_VISITS_CAME_FROM_KEYWORDS . ": [<a href='%s' target='_blank' title='%s'>%s</a>]</i>", ExtraWatchHelper::htmlspecialchars($referer), ExtraWatchHelper::htmlspecialchars($referer), ExtraWatchHelper::htmlspecialchars(urldecode($phrase)));
     }
     $output .= "</tr>";
     return $output;
 }
Esempio n. 5
0
echo _EW_SEO_MOST_POPULAR_KEYPHRASES;
?>
</h2>  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
            <div style='width: 50%'>  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                <i><?php 
echo _EW_SEO_MOST_POPULAR_KEYPHRASES_DESC;
?>
</i>  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
            </div>
            <br/>
            <?php 
$mostPopularKeyphrases = $extraWatch->seo->getMostPopularKeywords();
$output = "";
if ($mostPopularKeyphrases) {
    foreach ($mostPopularKeyphrases as $key => $value) {
        $output .= ExtraWatchHelper::htmlspecialchars($value->name) . "\n";
    }
}
if (@$mostPopularKeyphrases) {
    ?>
                <textarea rows="20" cols="150"><?php 
    echo $output;
    ?>
</textarea>  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                <?php 
} else {
    echo ExtraWatchHelper::renderNoData();
}
?>
        </td>
    </tr>
 /**
  * visitor
  */
 function getUriIdByUriName($uri)
 {
     $query = sprintf("select id from #__extrawatch_uri2title where (`uri` = '%s') limit 1 ", ExtraWatchHelper::htmlspecialchars($this->database->getEscaped($uri)));
     $id = $this->database->resultQuery($query);
     return (int) $id;
 }
 /**
  * SEO Report
  * @param  $day
  * @return string|void  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
  */
 function renderSEOReport($day, $renderAsEmail = FALSE)
 {
     $rows = $this->extraWatch->seo->retrieveTopUrisReferedByKeyphrase($day);
     if (!@$rows) {
         return;
     }
     $output = "<table width='700px' border=\"0\">";
     $output .= "<tr><td colspan=\"5\"></td></tr>";
     $output .= "<tr><th align=\"left\">" . _EW_STATS_KEYPHRASE . "</th><th>" . _EW_EMAIL_REPORTS_VALUE . "</th><th>perc.</th><th>" . _EW_EMAIL_REPORTS_1DAY_CHANGE . "</th><th>" . _EW_EMAIL_REPORTS_7DAY_CHANGE . "</th><th>" . _EW_EMAIL_REPORTS_28DAY_CHANGE . "</th></tr>";
     foreach ($rows as $row) {
         $totalIntValuesForDay = $this->extraWatch->stat->getCountByKeyAndDate(EW_DB_KEY_UNIQUE, $day);
         if (!$totalIntValuesForDay) {
             continue;
         }
         /* removing trailing / from uri to include it into link */
         $liveSite = $this->extraWatch->config->getDomainFromLiveSiteByUsername(_EW_PROJECT_ID);
         $uri = $row->uri;
         if (strpos($uri, "/") == 0) {
             //starts with /
             $uri = substr($uri, 1);
         }
         $percentOfHitsPerDay = sprintf("%.2f%%", $row->total / $totalIntValuesForDay * 100);
         $output .= "<tr><td colspan=\"2\"><h4><a href='" . $liveSite . $uri . "' target=\"_blank\">" . $row->title . "</a></h4></td><td align=\"left\"><b>Hits: " . $row->total . "</b></td><td align=\"left\" colspan=\"3\">" . $percentOfHitsPerDay . " of traffic</td></tr>";
         $keyphrases = $this->extraWatch->seo->retrieveKeyphrasesForUri($day, $row->uriId);
         $group = EW_DB_KEY_URI2KEYPHRASE;
         foreach ($keyphrases as $keyphrase) {
             if (is_numeric($keyphrase->value)) {
                 $percent = sprintf("(%.2f%%)", $keyphrase->value / $row->total * 100);
             } else {
                 $percent = $keyphrase->value;
             }
             $oneDayDiff = $this->extraWatch->stat->getRelDiffOfTwoDays($day - 1, $day, EW_DB_KEY_URI2KEYPHRASE, $keyphrase->uri2keyphraseId);
             $sevenDayDiff = $this->extraWatch->stat->getRelDiffOfTwoDays($day - 7, $day, EW_DB_KEY_URI2KEYPHRASE, $keyphrase->uri2keyphraseId);
             $twentyEightDayDiff = $this->extraWatch->stat->getRelDiffOfTwoDays($day - 28, $day, EW_DB_KEY_URI2KEYPHRASE, $keyphrase->uri2keyphraseId);
             $oneDayDiffRendered = $this->renderPercentage($oneDayDiff);
             $sevenDayDiffRendered = $this->renderPercentage($sevenDayDiff);
             $twentyEightDayDiffRendered = $this->renderPercentage($twentyEightDayDiff);
             $origName = $keyphrase->uri2keyphraseId;
             $trendsIcon = "<img src='" . $this->extraWatch->config->getLiveSiteWithSuffix() . "components/com_extrawatch/img/icons/trend_icon.gif' border='0'  " . $this->extraWatch->helper->getTooltipOnEvent() . "=\"ajax_showTooltip('" . $this->extraWatch->config->getLiveSiteWithSuffix() . $this->extraWatch->env->renderBackendAjaxLink($this->extraWatch->config, 'ajax', 'trendtooltip') . "&group={$group}&name=" . urlencode($origName) . "&date={$day}&env=" . $this->extraWatch->config->getEnvironment() . "&projectId=" . _EW_PROJECT_ID . "',this);return false;\"/>";
             $output .= "<tr><td title='" . ExtraWatchHelper::htmlspecialchars($keyphrase->name) . "'><a href='http://www.google.com/search?q=" . ExtraWatchHelper::htmlspecialchars(urlencode($keyphrase->name)) . "'>" . ExtraWatchHelper::htmlspecialchars(ExtraWatchHelper::truncate($keyphrase->name, 100)) . "</a></td>  \t \t    \t    \t\t  \t \t  \t \t  \t\t \t \t\t    \t \t\t\t \t   \t\t  \t \t \t\t \t \t   \t      \t  \t \t\t \t\t \t\t\t\t \t\t\t \t\t  \t\t    \t \t\t \t\t  \n                    <td style='width: 30px;' align='right'>" . ExtraWatchHelper::htmlspecialchars($keyphrase->value) . "</td><td style='width: 20px' align='right'>{$percent}</td><td  align='center'>{$oneDayDiffRendered}</td><td class='ewCentered'>{$sevenDayDiffRendered}</td><td class='ewCentered'>{$twentyEightDayDiffRendered}</td>";
             if (!$renderAsEmail) {
                 $output .= "<td>" . $trendsIcon . "</td>";
             }
             $output .= "</tr>";
         }
     }
     $output .= "<tr><td>&nbsp;</td></tr><tr><td colspan=\"5\">";
     $output .= "</td></tr></table>";
     return $output;
 }
 function renderBlockedIPs($date = 0, $expanded = FALSE, $displayedInStats = TRUE)
 {
     $output = "";
     if (!$expanded) {
         $output .= "<a href='javascript:extrawatch_blockIpManually();'>" . _EW_STATS_IP_BLOCKING_ENTER . "</a><br/>";
     }
     $total = FALSE;
     if (!@$date) {
         $total = TRUE;
     }
     $count = $this->extraWatch->block->countBlockedIPs($date);
     if (!$count && !$displayedInStats) {
         $output = ExtraWatchHelper::renderNoData();
         $output .= $this->renderAntispamHowTo();
         return $output;
     }
     $limit = $this->extraWatch->config->getConfigValue('EXTRAWATCH_STATS_MAX_ROWS');
     $output .= "<tr><th></th><th></th><th>IP</th><th>" . strtolower(_EW_STATS_HITS) . "</th>";
     if (!$displayedInStats) {
         $output .= "<th>" . _EW_BLOCKING_BAD_WORD . "</th>";
         $output .= "<th>" . _EW_BLOCKING_REASON . "</th>";
     }
     $output .= "</tr>";
     if ($count > $limit && !$expanded) {
         $output = "<tr><td colspan='4'>" . $this->extraWatchStatHTML->renderExpand('ip_blocking_title', $total) . "</td></tr>";
     }
     if (@$expanded) {
         $rows = $this->extraWatch->block->getBlockedIPs($date, 100);
         // this cannot be unlimited, because otherwise the page would not open
     } else {
         $rows = $this->extraWatch->block->getBlockedIPs($date, $limit);
     }
     $lastDate = 0;
     $i = 0;
     if (@$rows) {
         foreach ($rows as $row) {
             $icon = "";
             if (!strstr($row->ip, "*")) {
                 if (@(!$row->country)) {
                     $country = $this->extraWatch->helper->countryByIp($row->ip);
                     $this->extraWatch->block->updateCountryForBlockedIp($row->ip, $country);
                 } else {
                     $country = $row->country;
                 }
                 $countryName = $this->extraWatch->helper->countryCodeToCountryName($country);
                 if (!$country) {
                     $country = "none";
                 }
                 $icon = "<img src='" . $this->extraWatch->config->getLiveSiteWithSuffix() . "components/com_extrawatch/img/flags/" . @strtolower($country) . ".png' title='{$countryName}' alt='{$countryName}'/>";
             }
             $mapsIcon = "<img src='" . $this->extraWatch->config->getLiveSiteWithSuffix() . "components/com_extrawatch/img/icons/map_icon.gif' border='0'  " . $this->extraWatch->helper->getTooltipOnEvent() . "=\"ajax_showTooltip('" . $this->extraWatch->config->getLiveSite() . $this->extraWatch->env->getEnvironmentSuffix() . $this->extraWatch->env->renderBackendAjaxLink($this->extraWatch->config, 'ajax', 'tooltip') . "&ip=" . @$row->ip . "&env=" . $this->extraWatch->config->getEnvironment() . "&projectId=" . _EW_PROJECT_ID . "',this);return FALSE\"/>";
             if (!$displayedInStats && $lastDate != $row->date) {
                 $output .= "<tr><td colspan='4'><u>" . ExtraWatchDate::getDateByDay($row->date) . "</u></td></tr>";
                 $lastDate = $row->date;
             }
             $output .= "<tr class='tableRow" . $i++ % 2 . "'><td class='ewCentered'>" . $mapsIcon . "</td><td class='ewCentered' title='{$row->reason}'>" . $icon . "</td><td align='left' title='{$row->reason}'>" . $row->ip . "</td><td class='ewCentered' title='{$row->reason}'>" . $row->hits . "</td>";
             if (!$displayedInStats) {
                 if (!$row->badWord) {
                     $spamWordAffected = $this->extraWatch->block->checkForSpamWord($row->reason);
                     if (@$spamWordAffected) {
                         $this->extraWatch->block->updateSpamWordForBlockedIp($row->ip, $spamWordAffected);
                         $row->badWord = $spamWordAffected;
                     }
                 }
                 $output .= "<td class='ewCentered' title='" . $row->badWord . "'>" . ExtraWatchHelper::truncate($row->badWord, 10) . "</td>";
                 $output .= "<td title=\"" . ExtraWatchHelper::htmlspecialchars($row->reason) . "\">" . $this->highlightSpamWord($row->badWord, $row->reason) . "</td>";
             }
             $output .= "<td>";
             if (!$expanded) {
                 $output .= "<a  id='{$row->ip}' href='javascript:extrawatch_blockIpToggle(\"{$row->ip}\");history.go(0);' title='{$row->reason}'>" . _EW_BLOCKING_UNBLOCK . "</a>";
             } else {
                 $output .= "<a  id='{$row->ip}' href='" . $this->extraWatch->config->renderLink("antiSpam", "&action=toggleBlocking&ip=" . $row->ip) . "' title='{$row->reason}'>" . _EW_BLOCKING_UNBLOCK . "</a>";
             }
             $output .= "</td>";
             $output .= "</tr>";
         }
     }
     return $output;
 }
 function renderMostClickedHTMLElementsTable($day = 0)
 {
     $rows = $this->extraWatchHeatmap->getMostClickedHTMLElements($day);
     $liveSite = $this->extraWatch->config->getLiveSiteWithSuffix();
     $output = "<table class='tablesorter table table-striped'>";
     $output .= sprintf("<thead><tr><th align='center'>%s</th><th align='center'>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th></th></tr></thead><tbody>", _EW_HEATMAP_CLICKS, _EW_GOALS, "element ID", _EW_HEATMAP_TITLE, _EW_EMAIL_REPORTS_1DAY_CHANGE, _EW_EMAIL_REPORTS_7DAY_CHANGE, _EW_EMAIL_REPORTS_28DAY_CHANGE);
     $i = 0;
     if (!$rows) {
         $output .= "</table>";
         $output .= ExtraWatchHelper::renderNoData();
         return $output;
     }
     if (@$rows) {
         $maxClicksForDay = $this->extraWatchHeatmap->getMaxClicksForDay($day);
         foreach ($rows as $row) {
             $trendsCells = $this->extraWatchStatHTML->renderDiffTableCellsAndIcon(EW_DB_KEY_HTML_ELEMENT, addslashes($row->xpath), $day);
             $ratio = $row->clickCount / $maxClicksForDay;
             $color = ExtraWatchHelper::rgbFromRatio($ratio);
             $highlightElementLink = $this->renderHighlightElementLink($liveSite . $row->uri, $row->xpath);
             if ($day) {
                 $link = "<td title='" . ExtraWatchHelper::htmlspecialchars($row->xpath) . "'>" . $highlightElementLink . "</td>";
             } else {
                 $link = "<td>" . $this->renderHighlightElementLink($liveSite . $row->uri, "all", ExtraWatchHelper::htmlspecialchars(ExtraWatchHelper::truncate($row->xpath))) . "</td>";
             }
             $output .= "<tr  class='tableRow" . $i % 2 . "'>" . "<td class='ewCentered' style='color: " . $color . "' width='5%%'>" . $row->clickCount . "</td><td class='ewCentered'>";
             if (@$row->clicked_element_xpath_condition) {
                 //render goal name instead of link
                 $output .= "<a href='" . $this->extraWatch->config->renderLink("goals", "edit&goalId=" . (int) $row->id . "") . "'>" . $row->name . "</a>";
             } else {
                 $output .= "<a href='" . $this->extraWatch->config->renderLink("goals", "insert&clicked_element_xpath_condition=" . urlencode($row->xpath) . "") . "' title='" . _EW_STATS_ADD_TO_GOALS . "'><img src='" . $this->extraWatch->config->getLiveSiteWithSuffix() . "components/com_extrawatch/img/icons/goal-add.gif' border='0'/></a>";
             }
             $output .= "</td>" . $link . "<td><a href='" . $liveSite . $row->uri . "' title='" . ExtraWatchHelper::htmlspecialchars($row->title) . "' target='_blank'>" . ExtraWatchHelper::truncate($row->title) . "</a></td>" . $trendsCells . "</tr>";
             $i++;
         }
     }
     $output .= "</tbody></table>";
     return $output;
 }
 function findOrAddReferrer($referrer)
 {
     $referrer = ExtraWatchHelper::htmlspecialchars(ExtraWatchInput::validate(_EW_INPUT_REFERRER, $referrer));
     ///
     $id = $this->getReferrerIdByName($referrer);
     if (!@$id) {
         $query = sprintf("insert into #__extrawatch_dm_referrer (referrer) values ('%s') ", $this->database->getEscaped($referrer));
         $this->database->executeQuery($query);
         $id = $this->getReferrerIdByName($referrer);
     }
     return $id;
 }