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; }