require_once JPATH_BASE . DS . 'includes' . DS . 'framework.php';
}
require_once JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'application' . DS . 'module' . DS . 'helper.php';
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "config.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.ip2country.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.block.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.block.html.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.cache.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.config.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.goal.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.goal.html.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.helper.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.date.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.stat.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.stat.html.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.visit.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.visit.html.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.visit.history.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.visit.history.html.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.trend.html.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.html.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.log.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "admin.extrawatch.html.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.sizes.php";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "class.extrawatch.flow.php";
$extraWatch = new ExtraWatchMain();
$extraWatchHTML = new ExtraWatchHTML();
$extraWatchHTML->renderAdminStyles();
 * @revision 2572  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 * @license http://www.gnu.org/licenses/gpl-3.0.txt     GNU General Public License v3  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 * @copyright (C) 2015 by CodeGravity.com - All rights reserved!  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 * @website http://www.codegravity.com  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 */
defined('_JEXEC') or die('Restricted access');
sleep(1);
// it's a tooltip. Let's sleep for a while
/*define('DS', DIRECTORY_SEPARATOR);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
$jBasePath = realpath(dirname(__FILE__) . DS . ".." . DS . ".." . DS . "..". DS);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
define('JPATH_BASE2', $jBasePath);*/
include_once JPATH_BASE2 . DS . "components" . DS . "com_extrawatch" . DS . "includes.php";
$extraWatch = new ExtraWatchMain();
$extraWatch->helper->setNoindexHttpHeaders();
//setting explicitly for ajax requests
$extraWatchHTML = new ExtraWatchHTML();
$extraWatchTrendHTML = new ExtraWatchTrendHTML($extraWatch);
$extraWatch->block->checkBackendTokenFromUrl();
$extraWatch->config->initializeTranslations();
//echo $extraWatchHTML->renderAdminStyles();
echo $extraWatchHTML->renderPrint();
echo $extraWatchHTML->renderCloseWindow();
$group = (int) @ExtraWatchHelper::requestGet('group');
///
$name = ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, urldecode(@ExtraWatchHelper::requestGet('name')));
///
$date = (int) @ExtraWatchHelper::requestGet('date');
///
?>
<center>
<h2><?php 
 * @license http://www.gnu.org/licenses/gpl-3.0.txt     GNU General Public License v3  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 * @copyright (C) 2015 by CodeGravity.com - All rights reserved!  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 * @website http://www.codegravity.com  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 */
defined('_JEXEC') or die('Restricted access');
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
if (_EW_CLOUD_MODE) {
    $projectId = @$_REQUEST['projectId'];
    define('ENV', 1);
}
$title = "Free live stats and visitor counter for Joomla, Wordpress, Drupal, Magento and Prestashop";
require_once JPATH_BASE . DS . "components" . DS . "com_extrawatch" . DS . "includes.php";
$extraWatch = new ExtraWatchMain();
$extraWatchHTML = new ExtraWatchHTML();
$referringURLParsed = parse_url(@$_SERVER['HTTP_REFERER']);
$referringQuery = @$referringURLParsed['query'];
$env = $_REQUEST['env'];
?>
/** Credits: http://www.webtoolkit.info/javascript-url-decode-encode.html **/  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
var ew_Utf8Encoder = { //added ex_ to avoid conflicts  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  

// URL utf-8 encoding  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
encode : function (str) {  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
    return escape(this._utf8_encode(str));  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
},

// UTF-8 encoding
_utf8_encode : function (str) {  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
str = str.replace(/\r\n/g,"\n");  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 function renderDayTrends($group, $name, $date)
 {
     $dbKeysArray = array(1 => 'BROWSER', 'COUNTRY', 'GOALS', 'HITS', 'INTERNAL', 'IP', 'KEYWORDS', 'LOADS', 'OS', 'REFERERS', 'UNIQUE', 'URI', 'USERS', 'URI2KEYWORD');
     $resultsArray = array();
     $max = 0;
     $maxDate = 0;
     for ($i = $date - 20; $i <= $date; $i++) {
         $value = $this->extraWatch->stat->getKeyValueInGroupByDate($group, $name, $i);
         if ($max < $value) {
             $max = $value;
             $maxDate = $i;
         }
         $resultsArray[$i - ($date - 20)] = $value;
     }
     $nameTranslated = $name;
     switch ($group) {
         case EW_DB_KEY_INTERNAL:
             /* special handling for inbound */
             $inboundRow = $this->extraWatch->visit->getInternalNameById(@$name);
             $from = htmlentities($inboundRow->from);
             $to = htmlentities($inboundRow->to);
             $nameTranslated = "<br/>{$from} -> {$to}";
             break;
         case EW_DB_KEY_GOALS:
             $nameTranslated = "<br/>" . htmlentities($this->extraWatch->goal->getGoalNameById($name));
             break;
         case EW_DB_KEY_URI2KEYPHRASE:
             $nameTranslated = "<br/>" . htmlentities($this->extraWatch->visit->getKeyphraseFromUri2KeyphraseId($name));
             break;
         case EW_DB_KEY_HEATMAP:
             $nameTranslated = "<br/>" . htmlentities($this->extraWatch->visit->getTitleByUriId($name));
             break;
         case EW_DB_KEY_SEARCH_RESULT_NUM:
             $result = htmlentities($this->extraWatch->seo->getPositionByUri2KeyphraseId($name));
             $nameTranslated = "<br/>" . $result;
             break;
         default:
             $nameTranslated = $name;
     }
     $groupTranslated = @constant("_EW_STATS_" . strtoupper($dbKeysArray[$group]));
     $extraWatchHTML = new ExtraWatchHTML();
     $helpId = $extraWatchHTML->renderOnlineHelp("trends");
     $output = "<center><h2>" . _EW_TRENDS_DAILY_WEEKLY . " {$groupTranslated} : {$nameTranslated} {$helpId}</h2><br/>";
     $output .= "<table cellpadding='0' cellspacing='0'>";
     $output .= "<tr>";
     $progressBarIcon = $this->extraWatch->config->getLiveSiteWithSuffix() . "components/com_extrawatch/img/icons/progress_bar_vertical.gif";
     for ($i = $date - 20; $i <= $date; $i++) {
         $value = $resultsArray[$i - ($date - 20)];
         $percent = 0;
         if ($max) {
             $percent = floor($value / $max * 1000) / 10;
         }
         $output .= "<td valign='bottom' align='center' style='vertical-align: bottom'>";
         $output .= $this->formatValueBasedOnGroup($group, $value);
         $output .= "<br/><img src='{$progressBarIcon}' height='{$percent}' width='10' style='height:" . $percent . "px;width:10px'/><br/>";
         $output .= $this->renderDayDiff($group, $name, $i - 1, $i);
         $output .= $this->extraWatch->date->getDateByDay($i, "d.m ") . "&nbsp;<br/>";
         $output .= $this->extraWatch->date->getDateByDay($i, "D") . "<br/>";
         $output .= "</td>";
     }
     $output .= "</tr>";
     $output .= "</table>";
     $output .= "</center>";
     return $output;
 }
function extrawatch_mainController($task = "")
{
    $current_error_reporting = error_reporting();
    error_reporting(E_ALL & ~(E_STRICT | E_NOTICE));
    $extraWatch = new ExtraWatchMain();
    $extraWatchHTML = new ExtraWatchHTML();
    $extraWatchGoalHTML = new ExtraWatchGoalHTML($extraWatch);
    $extraWatchTrendHTML = new ExtraWatchTrendHTML($extraWatch);
    $env = ExtraWatchEnvFactory::getEnvironment();
    $queryParams = ExtraWatchHelper::getUrlQueryParams();
    $action = ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, @$queryParams['action']);
    ///
    if (!$task) {
        $task = ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, @$queryParams['task']);
        ///
    }
    ExtraWatchHelper::checkIfRequestPathAllowed($extraWatch, $env, $task);
    $taskFromNavigation = ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, @ExtraWatchHelper::request('task'));
    ///
    if ($taskFromNavigation) {
        $task = $taskFromNavigation;
    }
    $option = ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, @ExtraWatchHelper::requestGet('option'));
    ///
    $result = ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, @ExtraWatchHelper::requestGet('result'));
    ///
    $params = @$queryParams['params'];
    ///
    $output = "";
    if (!$extraWatch->config->getLiveSite()) {
        $extraWatch->config->setLiveSite($env->getRootSite());
        if ($env->getRootSite() != $extraWatch->config->getLiveSite()) {
            die("<span style='color: red; font-weight: bold;'>Error: It was not possible to write data to the database! Check your database permissions</span>");
        }
    }
    $extraWatch->setup->runAdditionalSQLScripts();
    $extraWatch->config->saveRandValue();
    switch ($task) {
        case "ajax":
            $includePath = JPATH_BASE2 . DS . "components" . DS . "com_extrawatch" . DS . "ajax";
            ExtraWatchHelper::checkIfFileExistsInDir($includePath, $action . ".php");
            if ($action == "download") {
                if (ExtraWatchInput::validate(_EW_INPUT_FILE_PATH, $includePath . DS . $action . ".php")) {
                    include_once $includePath . DS . $action . ".php";
                }
                die;
            } else {
                $extraWatch->config->validateRequestToken($queryParams);
                $output = ExtraWatchHelper::get_include_contents("ajax" . DS . $action . ".php", array("params" => $params));
                die($output);
            }
            break;
        case "js":
            $extraWatch->config->validateRequestToken($queryParams);
            $includePath = "js";
            ExtraWatchHelper::checkIfFileExistsInDir(JPATH_BASE2 . DS . "components" . DS . "com_extrawatch" . DS . $includePath, $action . ".php");
            $output = ExtraWatchHelper::get_include_contents($includePath . DS . $action . ".php", array());
            die($output);
            break;
        case "useFreeVersion":
            $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
            $extraWatch->config->useFreeVersion();
            $extraWatch->config->saveVersionIntoDatabase();
            $extraWatch->config->setLiveSite($env->getRootSite());
            break;
        case "activate":
            $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
            if ($action == "codecanyon") {
                $extraWatch->config->saveConfigValue("EXTRAWATCH_MARKETPLACE", $action);
            }
            $extraWatch->config->activate(ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, ExtraWatchHelper::requestGet('key')));
            ///
            $extraWatch->config->saveVersionIntoDatabase();
            $extraWatch->config->setLiveSite($env->getRootSite());
            break;
        case "licenseAccepted":
            $extraWatch->config->setLiveSite($env->getRootSite());
            $extraWatch->config->setLicenseAccepted();
            $extraWatch->config->setHtAccessPermissions();
            $extraWatch->config->saveVersionIntoDatabase();
            break;
        case "resetLiveSite":
            $extraWatch->block->checkPermissions();
            $extraWatch->config->setLiveSite($env->getRootSite());
            break;
    }
    if (!_EW_CLOUD_MODE && !$extraWatch->config->checkLicenseAccepted()) {
        //remove check license accepted if cloud mode
        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
        $output .= $extraWatchHTML->renderHeader($extraWatch);
        $output .= $extraWatchHTML->renderAcceptLicense();
        return $output;
    } else {
        if (!_EW_CLOUD_MODE && (!$extraWatch->config->isFree() && !$extraWatch->config->isAdFree() && !$extraWatch->config->isUnregistered())) {
            $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
            $output .= $extraWatchHTML->renderHeader($extraWatch);
            $output .= $extraWatchHTML->renderAdFreeLicense();
            return $output;
        }
        switch ($task) {
            case "storeIpInfoDbKey":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $keyValue = ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, ExtraWatchHelper::requestPost('storeIpInfoDbKey'));
                ///
                if ($keyValue) {
                    $extraWatch->config->saveConfigValue("EXTRAWATCH_IPINFODB_KEY", $keyValue);
                } else {
                    $output = "<br/><div style='border: 1px solid red; width: 50%; padding: 10px;'>" . _EW_STATS_MAP_INVALID_KEY . "</div>";
                }
                $output .= $extraWatchHTML->renderLocation();
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "users":
                switch ($action) {
                    case "save":
                        $result = $extraWatch->helper->saveUserSettings(ExtraWatchHelper::requestPost());
                        ///
                    default:
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchHTML->renderUsers($extraWatch);
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                }
                break;
            case "update":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderUpdate();
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "sizes":
                if (!$extraWatch->config->isFree()) {
                    $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                    $output .= $extraWatchHTML->renderHeader($extraWatch);
                    $output .= $extraWatchHTML->renderSizes();
                    $output .= $extraWatchHTML->renderFooter();
                }
                break;
            case "seo":
                switch ($action) {
                    case "save":
                        $result = $extraWatch->helper->saveSEOSettings(ExtraWatchHelper::requestPost());
                        ///
                    default:
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchHTML->renderSEO();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                }
                break;
            case "graphs":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $extraWatchTrendHTML = new ExtraWatchTrendHTML($extraWatch);
                $output .= $extraWatchHTML->renderGraphs($extraWatchTrendHTML);
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "trends":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $extraWatchTrendHTML->renderTrends();
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "credits":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderCredits();
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "goals":
                switch ($action) {
                    case "insert":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchGoalHTML->renderBackToGoals();
                        $output .= $extraWatchGoalHTML->renderGoalsInsert((int) @ExtraWatchHelper::requestGet('id'), (int) @ExtraWatchHelper::requestGet('postid'));
                        ///
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "save":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $extraWatch->goal->saveGoal(ExtraWatchHelper::requestPost());
                        ///
                        $output .= $extraWatchGoalHTML->renderGoals(@$result);
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "edit":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchGoalHTML->renderBackToGoals();
                        $output .= $extraWatchGoalHTML->renderGoalEdit(@ExtraWatchHelper::requestGet('goalId'));
                        ///
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "delete":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $result = $extraWatch->goal->deleteGoal(@ExtraWatchHelper::requestGet('goalId'));
                        ///
                        $output .= $extraWatchGoalHTML->renderGoals(@$result);
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "enable":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $result = $extraWatch->goal->enableGoal(@ExtraWatchHelper::requestGet('goalId'));
                        ///
                        $output .= $extraWatchGoalHTML->renderGoals(@$result);
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "disable":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $result = $extraWatch->goal->disableGoal(@ExtraWatchHelper::requestGet('goalId'));
                        ///
                        $output .= $extraWatchGoalHTML->renderGoals(@$result);
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "export":
                        //$output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        //$output .= $extraWatchHTML->renderHeader($extraWatch);
                        $extraWatch->goal->exportGoals(ExtraWatchHelper::requestPost());
                        ///
                        $extraWatchGoalHTML->renderExportGoals(@$result);
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "import":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchGoalHTML->renderImportGoals();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "saveImportGoal":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $extraWatch->goal->saveImportGoal(ExtraWatchHelper::requestPost());
                        ///
                        $output .= $extraWatchGoalHTML->renderGoals(@$result);
                        $output .= $extraWatchHTML->renderFooter();
                    default:
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchGoalHTML->renderGoals(@$result);
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                }
                break;
            case "settings":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderSettings(@$result);
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "settingsSave":
                $result = $extraWatch->helper->saveSettings(ExtraWatchHelper::requestPost());
                ///
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderSettings(@$result);
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "resetData":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $result = $extraWatch->helper->resetData(ExtraWatchHelper::requestPost());
                ///
                $output .= $extraWatchHTML->renderResetData($result);
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "antiSpam":
                switch ($action) {
                    case "toggleBlocking":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $ip = @ExtraWatchHelper::requestGet('ip');
                        ///
                        $extraWatch->block->extrawatch_blockIpToggle($ip);
                        $output .= $extraWatchHTML->renderAntiSpam();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "save":
                        $numRecordsImported = $extraWatch->block->saveBadWordsList(ExtraWatchHelper::requestPost());
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchHTML->renderAntiSpam();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "antiSpamSave":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= nl2br($extraWatch->block->saveImportAntiSpamIp(ExtraWatchHelper::requestPost()));
                        $output .= $extraWatchHTML->renderAntiSpam();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    default:
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchHTML->renderAntiSpam();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                }
                break;
            case "status":
                if (!$extraWatch->config->isFree()) {
                    $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                    $output .= $extraWatchHTML->renderHeader($extraWatch);
                    $output .= $extraWatchHTML->renderStatus();
                    $output .= $extraWatchHTML->renderFooter();
                }
                break;
                /*			case "upgrade" :  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                     {
                         $output .= $extraWatchHTML->renderAdminStyles($extraWatch);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                         $output .= $extraWatchHTML->renderHeader($extraWatch);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                         $output .= $extraWatchHTML->renderUpgrade();  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                         break;  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                     }*/
            /*			case "upgrade" :  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                 {
                     $output .= $extraWatchHTML->renderAdminStyles($extraWatch);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                     $output .= $extraWatchHTML->renderHeader($extraWatch);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                     $output .= $extraWatchHTML->renderUpgrade();  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                     break;  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                 }*/
            case "license":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderAdFreeLicense();
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "history":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderVisitsHistory();
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "flow":
                if (!$extraWatch->config->isFree()) {
                    $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                    $output .= $extraWatchHTML->renderHeader($extraWatch);
                    $output .= $extraWatchHTML->renderFlow();
                    $output .= $extraWatchHTML->renderFooter();
                }
                break;
            case "emails":
                switch ($action) {
                    case "save":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $result = $extraWatch->helper->saveEmailSettings(ExtraWatchHelper::requestPost());
                        ///
                        $output .= $extraWatchHTML->renderEmails();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "send":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $extraWatch->visit->sendNightlyEmails();
                        $output .= $extraWatchHTML->renderEmails();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    default:
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchHTML->renderEmails();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                }
                break;
            case "heatmap":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderHeatMap();
                $output .= $extraWatchHTML->renderFooter();
                return $output;
                break;
            case "clicks":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderClicks();
                $output .= $extraWatchHTML->renderFooter();
                return $output;
                break;
            case "downloads":
                $extraWatchDownloads = new ExtraWatchDownloads($extraWatch->database);
                $extraWatchDownloadsHTML = new ExtraWatchDownloadsHTML($extraWatch->database);
                switch ($action) {
                    case "addExtension":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloadsHTML->renderAddExtension();
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "saveAddExtension":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloads->addExtension(ExtraWatchHelper::requestPost('extname'));
                        ///
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        return $output;
                        break;
                    case "editExtension":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloadsHTML->renderEditExtension(ExtraWatchHelper::requestGet('eid'));
                        ///
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "saveEditExtension":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloads->updateExtension(ExtraWatchHelper::requestPost('eid'), ExtraWatchHelper::requestPost('extname'));
                        ///
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        return $output;
                        break;
                    case "deleteExtension":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloads->deleteExtension(ExtraWatchHelper::requestGet('co'));
                        ///
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "addFile":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloadsHTML->renderAddFile();
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "editFile":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloadsHTML->renderEditFile(ExtraWatchHelper::requestGet('did'));
                        ///
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    case "saveEditFile":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloads->updateFilePath(ExtraWatchHelper::requestPost('did'), ExtraWatchHelper::requestPost('filepathname'));
                        ///
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        return $output;
                        break;
                    case "saveAddFile":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloads->addFilePath(ExtraWatchHelper::requestPost('filepathname'));
                        ///
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        return $output;
                        break;
                    case "deleteFile":
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchDownloads->deleteFilePath(ExtraWatchHelper::requestGet('co'));
                        ///
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        break;
                    default:
                        $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                        $output .= $extraWatchHTML->renderHeader($extraWatch);
                        $output .= $extraWatchHTML->renderDownloads();
                        $output .= $extraWatchHTML->renderFooter();
                        return $output;
                        break;
                }
                break;
            case "location":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderLocation();
                $output .= $extraWatchHTML->renderFooter();
                break;
            case "stats":
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderStats();
                $output .= $extraWatchHTML->renderFooter();
                break;
            default:
                $output .= $extraWatchHTML->renderAdminStyles($extraWatch);
                $output .= $extraWatchHTML->renderHeader($extraWatch);
                $output .= $extraWatchHTML->renderBody($option);
                $output .= $extraWatchHTML->renderFooter();
                return $output;
                break;
        }
    }
    error_reporting($current_error_reporting);
    return $output;
}