static function checkIfRequestPathAllowed($extraWatch, $env, $task)
 {
     if ($extraWatch->config->getLiveSite() != $env->getRootSite()) {
         $extraWatch->config->setLiveSite($env->getRootSite());
         ExtraWatchCache::clearCache($extraWatch->database);
     } else {
         if ($task != "js" && $task != "ajax") {
             if ($extraWatch->config->getLiveSite() && !ExtraWatchHelper::startsWith(ExtraWatchInput::validate(_EW_INPUT_URI, @$_SERVER['REQUEST_URI']), $extraWatch->config->getLiveSite() . $env->getAdminDir())) {
                 ///
                 die("Restricted access - live site mismatch");
             }
         }
     }
 }
 public static function validate($type, $input = "")
 {
     switch ($type) {
         case _EW_INPUT_IP:
             $inputModified = $input;
             if (@strstr($inputModified, _EW_IP_SEPARATOR)) {
                 //has multiple entries splitted by "," ?
                 self::splitAndValidateMultipleIp($inputModified);
                 return $inputModified;
             } else {
                 $inputModified = self::replaceWildcardWithRealNumber($inputModified);
                 if (!(filter_var($inputModified, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) || filter_var($inputModified, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))) {
                     throw new ExtraWatchInputException(_EW_INPUT_IP, $input);
                 }
             }
             return $input;
         case _EW_INPUT_URL:
             if (!filter_var($input, FILTER_VALIDATE_URL)) {
                 throw new ExtraWatchInputException(_EW_INPUT_URL, $input);
             }
             return $input;
         case _EW_INPUT_ONE_STRING:
             if (@$input && !filter_var($input, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)) {
                 throw new ExtraWatchInputException(_EW_INPUT_ONE_STRING, $input);
             }
             return $input;
         case _EW_INPUT_FILE_PATH:
             $dir = realpath(dirname(__FILE__) . DS . "..");
             if (!ExtraWatchHelper::startsWith($input, $dir)) {
                 throw new ExtraWatchInputException(_EW_INPUT_FILE_PATH, $input);
             }
             return $input;
         case _EW_INPUT_FILE_PATH_TMP:
             $dir = self::getUploadTmpDir();
             if (!ExtraWatchHelper::startsWith($input, $dir)) {
                 throw new ExtraWatchInputException(_EW_INPUT_FILE_PATH_TMP, $input);
             }
             return $input;
         case _EW_INPUT_FILE_ROOT_PATH_HTACCESS:
             $env = ExtraWatchEnvFactory::getEnvironment();
             $rootPath = $env->getRootPath();
             $dir = $rootPath . DS . ".htaccess";
             if (!ExtraWatchHelper::startsWith($input, $dir)) {
                 throw new ExtraWatchInputException(_EW_INPUT_FILE_ROOT_PATH_HTACCESS, $input);
             }
             return $input;
         case _EW_INPUT_EXTRACT:
             if (@$input && $input != "getParams=") {
                 $object = @$input['params'];
                 if ($object) {
                     if ($object && $object != "getParams=") {
                         $getParams = ExtraWatchHelper::convertUrlQuery($object);
                         if ($getParams) {
                             foreach ($getParams as $getParam => $getParamValue) {
                                 if ($getParam && !array_search($getParam, unserialize(_EW_ALLOWED_PARAMS_TO_EXTRACT))) {
                                     throw new ExtraWatchInputException(_EW_INPUT_EXTRACT, $getParam);
                                 }
                             }
                         } else {
                             $reflector = new ReflectionClass(get_class($object));
                             $classFileName = dirname($reflector->getFileName());
                             if (!self::validate(_EW_INPUT_FILE_PATH, $classFileName)) {
                                 throw new ExtraWatchInputException(_EW_INPUT_EXTRACT, $classFileName);
                             }
                         }
                     }
                 }
             }
             return $input;
             break;
         case _EW_INPUT_EMAIL:
             if (filter_var($input, FILTER_VALIDATE_EMAIL) === false) {
                 throw new ExtraWatchInputException(_EW_INPUT_EMAIL, $input);
             }
             return $input;
             break;
         case _EW_INPUT_FILE_NAME:
             $tmpUploadDir = self::getUploadTmpDir();
             $tmpUploadDir = str_replace("/", DS, $tmpUploadDir);
             if (!ExtraWatchHelper::startsWith($input['file']['tmp_name'], $tmpUploadDir)) {
                 throw new ExtraWatchInputException(_EW_INPUT_FILE_NAME, $input);
             }
             return $input;
         case _EW_INPUT_FILE_EXTERNAL_PATH:
         case _EW_INPUT_DIR:
             $env = ExtraWatchEnvFactory::getEnvironment();
             if (!ExtraWatchHelper::startsWith(realpath($input), realpath($env->getCMSFileSystemRootPath()))) {
                 throw new ExtraWatchInputException(_EW_INPUT_FILE_EXTERNAL_PATH, $input);
             }
             return $input;
         case _EW_INPUT_HOST:
             $isIpValid = filter_var($input, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) || filter_var($input, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
             $isHostValid = preg_match("/^([a-z\\d](-*[a-z\\d])*)(\\.([a-z\\d](-*[a-z\\d])*))*\$/i", $input) && preg_match("/^.{1,253}\$/", $input) && preg_match("/^[^\\.]{1,63}(\\.[^\\.]{1,63})*\$/", $input);
             //length of each label
             if (!($isIpValid || $isHostValid)) {
                 throw new ExtraWatchInputException(_EW_INPUT_HOST, $input);
             }
             return $input;
         case _EW_INPUT_REFERRER_SAME_SITE:
             $env = ExtraWatchEnvFactory::getEnvironment();
             if (!ExtraWatchHelper::startsWith($_SERVER["HTTP_REFERER"], $env->getCMSBaseURL())) {
                 throw new ExtraWatchInputException(_EW_INPUT_REFERRER_SAME_SITE, $_SERVER["HTTP_REFERER"]);
             }
             return $input;
         case _EW_INPUT_LANGUAGE:
             $input = ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, $input);
             //prevent from using anything else than single string !
             $langDir = realpath(dirname(__FILE__) . DS . ".." . DS . "lang" . DS . $input . ".php");
             if (!file_exists($langDir)) {
                 throw new ExtraWatchInputException(_EW_INPUT_LANGUAGE, $langDir);
             }
             return $input;
         default:
             return $input;
     }
 }
 function renderTable($bots = FALSE, $inactive, $ipFilter = FALSE, $renderAsEmail = FALSE, $renderedFromHistory = FALSE)
 {
     $output = "";
     $rows = $this->getJoinedURIRows($bots, $inactive, $ipFilter);
     $agentNotPublishedMessage = $this->extraWatch->env->getAgentNotPublishedMsg($this->extraWatch->database);
     $downloadLog = $this->extraWatch->downloads->getDownloadLogIpTimestampPath();
     $countryCodeToCountryNameArray = $this->extraWatch->helper->countryCodeToCountryNameList();
     if ($bots == FALSE && $agentNotPublishedMessage != FALSE && sizeof($rows) == 0 && $inactive == 0) {
         $output .= "<tr><td colspan='10'><span style='color:red; font-weight: bold;'>" . $agentNotPublishedMessage . "</span></td></tr> ";
         return $output;
     } else {
     }
     if (!$rows) {
         $noDataHTML = "";
         if (!$bots && _EW_CLOUD_MODE && $inactive == FALSE && !$renderedFromHistory) {
             $noDataHTML = "<table><tr><td>";
             $noDataHTML .= "<h2 style='color: #e74c3c; font-weight: bold;'>1. Select the HTML code below and copy it to a clipboard </h2>";
             $noDataHTML .= "<i>(Click on text area below, Ctrl+A, Ctrl+C)</i><br/><br/>";
             $noDataHTML .= "<textarea cols='90' rows='8'>";
             $noDataHTML .= htmlentities($this->extraWatch->helper->renderHTMLCodeSnippet(_EW_PROJECT_ID));
             $noDataHTML .= "</textarea><br/><br/>";
             $noDataHTML .= "<h2 style='color: #e74c3c; font-weight: bold;'>2. Open editor of your website's front-end</h2><br/>";
             $noDataHTML .= "This step may be different for every CMS. <br/>You need to find where's your website frontend saved as HTML and the modify that file. <br/><b>Or ask your webmaster do to it for you!</b>";
             $noDataHTML .= "<h2 style='color: #e74c3c; font-weight: bold;'>3. Find the &lt;/body&gt; tag</h2>";
             $noDataHTML .= "This is a footer of my website &copy;MyWebsite.com<br/><b>&lt;/body&gt;</b><br/>&lt;/html&gt;";
             $noDataHTML .= "<h2 style='color: #e74c3c; font-weight: bold;'>4. Paste this code before the &lt;/body&gt; tag</h2>";
             $noDataHTML .= "This is a footer of my website &copy;MyWebsite.com<br/><i>{code from clipboard}</i><br/><b>&lt;/body&gt;</b><br/>&lt;/html&gt;";
             $noDataHTML .= "</td><td valign='top'>";
             $noDataHTML .= "<h2 style='color: #e74c3c; font-weight: bold;'>.. Or Watch the video with instructions:</h2><br/><br/>";
             $noDataHTML .= "<iframe width=\"640\" height=\"360\" src=\"//www.youtube.com/embed/tvHNg-X4d8o\" frameborder=\"0\" allowfullscreen></iframe>";
             $noDataHTML .= "</td></tr></table>";
         } else {
             if ($inactive == FALSE) {
                 $noDataHTML .= _EW_NO_DATA;
             }
         }
         $output .= "<tr><td colspan='5'>" . $noDataHTML . "</td></tr>";
         return $output;
     }
     /** if visits are empty */
     //$output = "";
     $i = 0xff;
     $decrement = -1;
     $lastIp = "";
     //to be able to hide flags / address for same IP in next rows
     $lastReferer = "";
     $lastColor = "";
     $rowNumber = 0;
     $dateToday = $this->extraWatch->date->jwDateToday();
     $uri2HeatmapClicksAssoc = $this->heatmap->heatmapForDayAsAsoc($dateToday);
     $maxClicksOfDay = $this->heatmap->getMaxClicksForDay($dateToday);
     if (!$renderAsEmail) {
         $liveSiteWithSuffix = $this->extraWatch->config->getLiveSiteWithSuffix();
     } else {
         $liveSiteWithSuffix = $this->extraWatch->config->getDomainFromLiveSite(_EW_PROJECT_ID) . $this->extraWatch->config->getLiveSiteWithSuffix();
     }
     if (@$rows) {
         foreach ($rows as $row) {
             $rowNumber++;
             /* reset the values from previous iteration */
             $country = "none";
             $countryName = "";
             $countryUpper = "";
             $color = "";
             $inactiveClass = "";
             $inactiveImageClass = "";
             if ($row->inactive) {
                 $inactiveClass = "class='extraWatchInactiveVisit'";
                 $inactiveImageClass = "class='extraWatchInactiveImage'";
             }
             $flag = "<img src='" . $liveSiteWithSuffix . "components/com_extrawatch/img/flags/{$country}.png' title='{$countryName}' alt='{$countryName}' {$inactiveImageClass}/>";
             if ($this->extraWatch->block->getBlockedIp($row->ip)) {
                 //TODO optimize whole block
                 $ipString = "<s>" . ExtraWatchHelper::htmlspecialchars($row->ip) . "</s>";
             } else {
                 $ipString = ExtraWatchHelper::htmlspecialchars($row->ip);
             }
             //TODO optimize whole block
             if ($i < 0xcc || $i <= 0x0) {
                 $decrement = $decrement * -1;
             }
             $i = $i + $decrement;
             $color = sprintf("%x", $i) . sprintf("%x", $i) . sprintf("%x", $i);
             if ($bots == TRUE) {
                 $color = "ffffff";
             }
             $country = $row->country;
             if (!$country) {
                 $country = $this->extraWatch->helper->countryByIp($row->ip);
                 $this->extraWatch->visit->updateCountryForIP($country, $row->ip);
             }
             if (@$country) {
                 $countryName = @$countryCodeToCountryNameArray[$country];
                 $this->extraWatch->helper->countryCodeToCountryName($country);
                 //TODO optimize
                 $flag = "<img src='" . $liveSiteWithSuffix . "components/com_extrawatch/img/flags/{$country}.png' title='{$countryName}' alt='{$countryName}' {$inactiveImageClass}/>";
                 $countryUpper = strtoupper($country);
             }
             $userAgent = ExtraWatchHelper::htmlspecialchars($row->browser);
             $browser = "";
             $os = "";
             $browserIcon = "";
             $osIcon = "";
             if (@$userAgent) {
                 $browser = $this->extraWatch->referer->identifyBrowser(@$userAgent);
                 if (@$browser) {
                     $browserIcon = $liveSiteWithSuffix . "components/com_extrawatch/img/icons/" . strtolower($browser) . ".gif";
                 }
                 if (@$browserIcon) {
                     $browser = "<img src='{$browserIcon}' alt='{$userAgent}' title='{$userAgent}' {$inactiveImageClass}/>";
                 }
                 $os = json_decode(@$this->extraWatch->referer->identifyOSAsJSON(@$userAgent));
                 if (@$os->name) {
                     $osIcon = $liveSiteWithSuffix . "components/com_extrawatch/img/icons/" . strtolower($os->icon);
                 }
                 if (@$osIcon) {
                     $os = sprintf("<img src='%s' alt='%s' title='%s' {$inactiveImageClass}/>", $osIcon, $userAgent, $userAgent);
                 }
             }
             //$output .= $rowNumber;
             if ($bots == TRUE && $osIcon) {
                 continue;
             }
             // bot icon fix
             if ($bots == TRUE) {
                 $osIcon = $liveSiteWithSuffix . "components/com_extrawatch/img/icons/blank.gif";
                 $browserIcon = $liveSiteWithSuffix . "components/com_extrawatch/img/icons/blank.gif";
                 $browser = sprintf("<img src='%s' alt='%s' title='%s' {$inactiveImageClass}/>", ExtraWatchHelper::htmlspecialchars($browserIcon), ExtraWatchHelper::htmlspecialchars($userAgent), ExtraWatchHelper::htmlspecialchars($userAgent));
                 $os = sprintf("<img src='%s' alt='%s' title='%s' {$inactiveImageClass}/>", ExtraWatchHelper::htmlspecialchars($osIcon), ExtraWatchHelper::htmlspecialchars($userAgent), ExtraWatchHelper::htmlspecialchars($userAgent));
             }
             $username = "";
             if (@$row->username) {
                 if (@get_class($this->extraWatch->env) == "ExtraWatchJoomlaEnv") {
                     $username = "******" . $this->extraWatch->config->getAdministratorIndex() . "?option=com_users&task=view&filter_search={$row->username}' style='color: black; text-decoration:none;'><i>" . @ExtraWatchHelper::htmlspecialchars($row->username) . "</i></a>";
                 } else {
                     $username = "******" . @ExtraWatchHelper::htmlspecialchars($row->username) . "</i></span>";
                 }
             }
             $ipString = sprintf("<a id='%s' href='javascript:extrawatch_blockIpToggle(\"%s\");extrawatch_sendVisitsReq();' style='color:black;' {$inactiveClass}>%s</a>", ExtraWatchHelper::htmlspecialchars($row->ip), ExtraWatchHelper::htmlspecialchars($row->ip), $ipString);
             $mapsIcon = "<img src='" . $liveSiteWithSuffix . "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\"/>";
             $timeOfVisit = $this->extraWatch->helper->secondsToHumanFormat(@$row->timeDiff);
             $timeOfVisit = str_replace(" ", "&nbsp;", $timeOfVisit);
             $displayCountryFlag = FALSE;
             if ($lastIp != $row->ip) {
                 $lastTimestamp = $row->timestamp;
                 $displayCountryFlag = TRUE;
                 $lastIp = $row->ip;
                 $rowNumber = 1;
             } else {
                 $flag = "";
                 // do not display flag, ip if the IP is same sa previous
                 $ipString = "";
             }
             if (!$displayCountryFlag) {
                 $username = "";
                 $browser = "";
                 $os = "";
                 $mapsIcon = "";
                 $timeOfVisit = "";
             }
             if ($lastReferer != $row->referer) {
                 $output .= $this->renderRefererRow($lastReferer, $color);
                 $lastReferer = $row->referer;
                 $lastColor = $color;
             }
             $dateOfVisit = ExtraWatchDate::date("d.m.Y", $row->timestamp);
             if (@$this->lastDate != $dateOfVisit) {
                 $output .= "<tr><td ></td><td ></td><td ></td><td ><td ></td></td><td ></td><td ></td><td ></td><td colspan='8'  colspan='3'><h3>{$dateOfVisit}</h3></td></tr>";
                 $this->lastDate = $dateOfVisit;
             }
             $output .= "<tr><td valign='top' align='left' ></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\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td valign='top' align='left' >" . @$mapsIcon . "</td><td valign='top' align='left' >";
             if (!$countryUpper) {
                 $output .= "<a href='" . $this->extraWatch->config->renderLink("goals", "insert&country=" . @$countryUpper) . "' style='color: #999999;' title='" . _EW_VISITS_ADD_GOAL_COUNTRY . "'>" . @$countryUpper . "</a>";
             }
             $onlineString = "";
             if ($row->inactive == 0 && $ipString) {
                 $onlineString = "<img src='" . $liveSiteWithSuffix . "components/com_extrawatch/img/icons/online.png' valign='top' border='0'/>";
             }
             $output .= "</td><td valign='top' align='left' >" . @$flag . "</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\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td valign='top' align='left' ><span {$inactiveClass}>{$ipString}</span>";
             $output .= "{$username}</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\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td valign='top' align='left' >{$onlineString}</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\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td valign='top' align='left' >" . @$browser . "</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\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td valign='top' align='left' >" . @$os . "</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\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td valign='top' align='left'  width='80%'>";
             $day = $this->extraWatch->date->jwDateFromTimestamp($row->timestamp);
             $downloadsForIp = $this->extraWatch->downloads->getDownloadLogForIPBetweenTimestampsFromRef($downloadLog, $rowNumber, $row->ip, $lastTimestamp, $row->timestamp);
             //TODO optimize
             $timestampHumanReadable = ExtraWatchDate::date("H:i:s", $row->timestamp);
             $downloadIcon = "<img src='" . $liveSiteWithSuffix . "components/com_extrawatch/img/icons/downloads.png' {$inactiveImageClass} />";
             if (@$downloadsForIp) {
                 foreach ($downloadsForIp as $download) {
                     $downloadTimestampHumanReadable = ExtraWatchDate::date("H:i:s", $download['timestamp']);
                     $output .= "<div {$inactiveClass}>" . $downloadTimestampHumanReadable . " {$downloadIcon} " . $download['dname'] . "</div><br/>";
                 }
             }
             $goalsForIp = $this->extraWatch->goal->getGoalsForVisitIdBetweenTimestamps($row->visitId, $lastTimestamp, $row->timestamp);
             //TODO optimize
             if (@$goalsForIp) {
                 foreach ($goalsForIp as $goalForIp) {
                     $goalTimestampHumanReadable = ExtraWatchDate::date("H:i:s", $goalForIp->timestamp);
                     $goalLink = "<a href='" . $this->extraWatch->config->renderLink("goals", "edit&goalId=" . (int) $goalForIp->goalId . "") . "' target='_blank'>" . $goalForIp->name . "</a>";
                     $output .= "<div style='background-color: #FFF9E1;' {$inactiveClass}>" . $goalTimestampHumanReadable . sprintf(_EW_VISITS_GOAL_REACHED, $goalLink) . "</div><br/>";
                 }
             }
             $lastTimestamp = $row->timestamp;
             $trucateCharLimit = $this->extraWatch->config->getConfigValue('EXTRAWATCH_TRUNCATE_VISITS');
             $uriTruncated = $this->extraWatch->helper->truncate(urldecode($row->uri), $trucateCharLimit);
             $titleOriginal = $row->title;
             $row->title = $this->extraWatch->helper->truncate($row->title, $trucateCharLimit);
             $row->title = $this->extraWatch->helper->removeRepetitiveTitle($row->title);
             $uri2titleId = $this->extraWatch->visit->getUri2TitleId($row->uri, $titleOriginal);
             //TODO optimize
             $output .= "<div id='id{$row->id}' style='text-decoration: none;' {$inactiveClass} onmouseout=\"toggleElementVisibility('goal_" . $row->id . "',0);\"  onmouseover=\"toggleDiv('" . $row->id . "','" . $row->ip . "',1, " . (int) $uri2titleId . ", {$day});\" >";
             if (@_EW_CLOUD_MODE) {
                 $projectSite = $this->extraWatch->config->getDomainFromLiveSite(_EW_PROJECT_ID);
                 if (!ExtraWatchHelper::startsWith($projectSite, "http://")) {
                     //add http prefix
                     $projectSite = "http://" . $projectSite;
                 }
             }
             if (!$row->title) {
                 $row->title = $uriTruncated;
             }
             $output .= "{$timestampHumanReadable} <a href='" . @$projectSite . $row->uri . "' target='_blank' {$inactiveClass} title='{$uriTruncated}'>{$row->title}</a>";
             /*
                     $userHeatmapClicks = $this->heatmap->getHeatmapClickNums($row->ip, $row->uri, ExtraWatchDate::jwDateFromTimestamp($timestampHumanReadable));//TODO optimize  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                     if (@$userHeatmapClicks > 0) {  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                       if (@$maxClicksOfDay) {  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                             $ratio = $userHeatmapClicks / $maxClicksOfDay;  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                       } else {
                           $ratio = 1;  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                       }
                       $userClicksColor = ExtraWatchHelper::rgbFromRatio($ratio);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                       $output .= $this->heatmapHTML->renderHeatmapLink($row->uri, (int) $uri2titleId, $day, "&nbsp;<img src='" . $liveSiteWithSuffix . "components/com_extrawatch/img/icons/click.png' title='" . _EW_HEATMAP_CLICK_OPEN . "'/> <span style='color: " . $userClicksColor . "' title='" . _EW_HEATMAP_CLICK_OPEN . "' $inactiveClass>$userHeatmapClicks</span>", $row->ip);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                     }
             */
             $clicks = @$uri2HeatmapClicksAssoc[$row->uri];
             if (@$clicks) {
                 if (@$maxClicksOfDay) {
                     $ratio = $clicks / $maxClicksOfDay;
                     $color = ExtraWatchHelper::rgbFromRatio($ratio);
                 }
                 $heatmapLinkOutput = $this->heatmapHTML->renderHeatmapLink($row->uri, (int) $uri2titleId, $day, "<span style='color: " . $color . "' title='" . _EW_HEATMAP_CLICK_OPEN . "'>{$clicks}</span>");
             }
             $paramData = $this->extraWatch->visit->areParamDataForUri($row->id);
             //TODO optimize
             if ($paramData) {
                 $output .= "<img src='" . $liveSiteWithSuffix . "components/com_extrawatch/img/icons/submit.png' />";
             }
             if (!$renderAsEmail) {
                 /* ad as goal link */
                 $output .= "<div id='goal_" . $row->id . "' style='display: none; margin: 0px; padding: 2px; left: 40%;' class='uriDetailDiv'>" . _EW_STATS_LOADING;
                 $output .= "</div>";
             }
             if ($timeOfVisit) {
             }
             $output .= "<td>{$heatmapLinkOutput}</td>";
             $output .= "<td>";
             if (@$timeOfVisit) {
                 $output .= "<td valign='top'><img src='" . $liveSiteWithSuffix . "components/com_extrawatch/img/icons/clock.png' title='" . _EW_LIVE_STATS_SESSION_TIME . "'/></td><td valign='top'  style='color: grey'>";
                 $output .= $timeOfVisit;
             }
             $output .= "</td>";
             $output .= "</div>";
             //TODO handle post data
             if ($paramData) {
                 $postImage = "<div id='idp{$row->id}' onmouseout=\"toggleDiv('post_" . $row->id . "',0, " . (int) $uri2titleId . ", {$day});\" onmouseover=\"toggleDiv('post_" . $row->id . "',1, " . (int) $uri2titleId . ", {$day});\">";
             } else {
                 $postImage = "";
             }
             $output .= $postImage;
             /* show only last URI, not all by user */
             if ($this->extraWatch->config->getCheckboxValue('EXTRAWATCH_ONLY_LAST_URI')) {
                 break;
             }
             $output .= "</td>";
             $output .= "</tr>";
         }
     }
     $output .= @$this->renderRefererRow($lastReferer, $lastColor);
     unset($uri2HeatmapClicksAssoc);
     unset($downloadLog);
     unset($countryCodeToCountryNameArray);
     return $output;
 }