/** * goals */ function checkGoals($title, $username, $ip, $came_from, $liveSite = "", $clickedXpath = "") { $query = sprintf("select * from #__extrawatch_goals"); $rows = $this->database->objectListQuery($query); if (@$rows) { foreach ($rows as $row) { $achieved = array(); if ($row->disabled) { continue; } if (@trim(@$row->clicked_element_xpath_condition)) { @($achieved[clicked_element_xpath_condition] = FALSE); if (@$this->helper->wildcardSearch(trim(@$row->clicked_element_xpath_condition), $clickedXpath)) { @($achieved[clicked_element_xpath_condition] = TRUE); } } else { if (@trim($row->uri_inversed) == "on") { if (@trim($row->uri_condition)) { @($achieved[uri_condition] = FALSE); if (@$this->helper->wildcardSearch($row->uri_condition, trim($this->helper->getURI()))) { } else { @($achieved[uri_condition] = TRUE); } } } else { if (@trim($row->uri_condition)) { @($achieved[uri_condition] = FALSE); if (@$this->helper->wildcardSearch($row->uri_condition, trim($this->helper->getURI()))) { @($achieved[uri_condition] = TRUE); } } } if (@trim($row->get_inversed) == "on") { if (@trim($row->get_condition)) { @($achieved[get_condition] = FALSE); if (@$this->helper->wildcardSearch($row->get_condition, trim(ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, ExtraWatchHelper::requestGet($row->get_var))))) { /// } else { if ($row->get_var == "*") { $found = FALSE; foreach (ExtraWatchHelper::requestGet() as $get) { /// if ($this->helper->wildcardSearch($row->get_condition, trim($get))) { $found = TRUE; } } if ($found) { @($achieved[uri_condition] = FALSE); } } else { @($achieved[uri_condition] = TRUE); } } } } else { if (@trim($row->get_condition)) { @($achieved[get_condition] = FALSE); if (@$this->helper->wildcardSearch($row->get_condition, trim(ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, ExtraWatchHelper::requestGet($row->get_var))))) { /// @($achieved[get_condition] = TRUE); } else { if ($row->get_var == "*") { foreach (ExtraWatchHelper::requestGet() as $get) { /// if ($this->helper->wildcardSearch($row->get_condition, trim($get))) { @($achieved[get_condition] = TRUE); } } } } } } if (@trim($row->post_inversed) == "on") { if (@trim($row->post_condition)) { @($achieved[post_condition] = FALSE); if (@$this->helper->wildcardSearch($row->post_condition, trim(ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, ExtraWatchHelper::requestPost($row->post_var))))) { /// } else { if ($row->post_var == "*") { $found = FALSE; foreach (ExtraWatchHelper::requestPost() as $post) { /// if ($this->helper->wildcardSearch($row->post_condition, trim($post))) { /// $found = TRUE; } } if ($found) { @($achieved[post_condition] = FALSE); } } else { @($achieved[post_condition] = TRUE); } } } } else { if (@trim($row->post_condition)) { @($achieved[post_condition] = FALSE); if (@$this->helper->wildcardSearch($row->post_condition, trim(ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, ExtraWatchHelper::requestPost($row->post_var))))) { /// @($achieved[post_condition] = TRUE); } else { if ($row->post_var == "*") { foreach (ExtraWatchHelper::requestPost() as $post) { if ($this->helper->wildcardSearch($row->post_condition, trim($post))) { @($achieved[post_condition] = TRUE); } } } } } } if (@trim($row->title_inversed) == "on") { if (@trim($row->title_condition)) { @($achieved[title_condition] = FALSE); if (@$this->helper->wildcardSearch($row->title_condition, trim($title))) { } else { @($achieved[title_condition] = TRUE); } } } else { if (@trim($row->title_condition)) { @($achieved[title_condition] = FALSE); if (@$this->helper->wildcardSearch($row->title_condition, trim($title))) { @($achieved[title_condition] = TRUE); } } } if (@trim($row->username_inversed) == "on") { if (@trim($row->username_condition)) { @($achieved[username_condition] = FALSE); if (@$this->helper->wildcardSearch($row->username_condition, trim($username))) { } else { @($achieved[username_condition] = TRUE); } } } else { if (@trim($row->username_condition)) { @($achieved[username_condition] = FALSE); if (@$this->helper->wildcardSearch($row->username_condition, trim($username))) { @($achieved[username_condition] = TRUE); } } } if (@trim($row->ip_inversed) == "on") { if (@trim($row->ip_condition)) { @($achieved[ip_condition] = FALSE); if (@$this->helper->wildcardSearch($row->ip_condition, trim($ip))) { } else { @($achieved[ip_condition] = TRUE); } } } else { if (@trim($row->ip_condition)) { @($achieved[ip_condition] = FALSE); if (@$this->helper->wildcardSearch($row->ip_condition, trim($ip))) { @($achieved[ip_condition] = TRUE); } } } if (@trim($row->came_from_inversed) == "on") { if (@trim($row->came_from_condition)) { @($achieved[came_from_condition] = FALSE); if (@$this->helper->wildcardSearch($row->came_from_condition, trim($came_from)) || $this->helper->wildcardSearch($liveSite . $row->came_from_condition, trim($came_from))) { } else { @($achieved[came_from_condition] = TRUE); } } } else { if (@trim($row->came_from_condition)) { @($achieved[came_from_condition] = FALSE); if (@$this->helper->wildcardSearch($row->came_from_condition, trim($came_from)) || $this->helper->wildcardSearch($liveSite . $row->came_from_condition, trim($came_from))) { @($achieved[came_from_condition] = TRUE); } } } if (@trim($row->country_inversed) == "on") { if (@trim($row->country_condition)) { @($achieved[came_from_condition] = FALSE); $country = $this->helper->countryByIp($ip); //performance optim. - checking country only if there is some condition if (@$this->helper->wildcardSearch($row->country_condition, trim($country))) { } else { @($achieved[came_from_condition] = TRUE); } } } else { if (@trim($row->country_condition)) { @($achieved[country_condition] = FALSE); $country = $this->helper->countryByIp($ip); //performance optim. - checking country only if there is some condition if (@$this->helper->wildcardSearch($row->country_condition, trim($country))) { @($achieved[country_condition] = TRUE); } } } } if ($this->evaluateAchievedGoals($achieved)) { $this->stat->increaseKeyValueInGroup(EW_DB_KEY_GOALS, $row->id); $this->addIp2GoalId($ip, $row->id); if ($this->config->getCheckboxBooleanValue($row->send_email)) { $totalAchievedCountToday = $this->stat->getIntValueByNameAndValue(EW_DB_KEY_GOALS, $row->id); $email = $this->config->getConfigValue("EXTRAWATCH_EMAIL_REPORTS_ADDRESS"); $env = ExtraWatchInput::validate(_EW_INPUT_ENV, ExtraWatchEnvFactory::getEnvironment()); $ip = ExtraWatchInput::validate(_EW_INPUT_IP, ExtraWatchVisit::getRemoteIPAddress()); /// $subject = sprintf(_EW_GOAL_EMAIL_SUBJECT, $row->name, $totalAchievedCountToday); require_once realpath(dirname(__FILE__)) . DS . "html" . DS . "class.extrawatch.visit.html.php"; $extraWatch = new ExtraWatchMain(); $extraWatchVisitHTML = new ExtraWatchVisitHTML($extraWatch); $visitsOutput = $extraWatchVisitHTML->renderTable(FALSE, 0, $ip, TRUE); $visitsOutput .= $extraWatchVisitHTML->renderTable(FALSE, 1, $ip, TRUE); $body = "ip: <b>{$ip}</b><br/>{$visitsOutput}"; ExtraWatchHelper::sendEmail($env, $email, $email, $subject, $body); } if (@$row->redirect) { $env = ExtraWatchInput::validate(_EW_INPUT_ENV, ExtraWatchEnvFactory::getEnvironment()); /// $env->redirect(@$row->redirect); } if (@$row->block) { $blockReason = sprintf(_EW_BLOCKED_BASED_ON_GOAL, $row->id); $this->block->blockIp($ip, $blockReason); try { $this->block->dieWithBlockingMessage($ip); } catch (ExtraWatchIPBlockedException $exception) { die($exception->getBlockingMessage()); } } } } } }
function sendNightlyEmail() { ExtraWatchLog::debug("function sendNightlyEmail in stat.html.php"); $output = $this->renderNightlyEmail(); $email = $this->extraWatch->config->getConfigValue("EXTRAWATCH_EMAIL_REPORTS_ADDRESS"); $projectName = ""; if (@_EW_CLOUD_MODE) { $projectName = " - " . ExtraWatchHelper::getProjectNameByProjectId($this->extraWatch->database, _EW_PROJECT_ID); } $date = ExtraWatchDate::date("d.m.Y", ExtraWatchDate::getUserTimestamp() - 24 * 3600); // date of report from yesterday, not today); ExtraWatchHelper::sendEmail($this->extraWatch->env, "{$email}", "{$email}", "ExtraWatch report " . $projectName . " - {$date}", $output); if ($this->extraWatch->config->getCheckboxValue("EXTRAWATCH_EMAIL_SEO_REPORTS_ENABLED")) { // old one: $outputSEOReport = "<table>".$this->renderSEOReport($this->extraWatch->date->jwDateToday()-1, TRUE)."</table>"; $extraWatchSEOHTML = new ExtraWatchSEOHTML($this->extraWatch); $day = $this->extraWatch->date->jwDateToday(); $outputSEOReport = $extraWatchSEOHTML->renderSEOReport($day - 1, TRUE); if (@_EW_CLOUD_MODE) { $emailSender = _EW_EMAIL_SENDER; //only in cloud mode } else { $emailSender = $email; //admin email from configuration } if (@$outputSEOReport) { ExtraWatchHelper::sendEmail($this->extraWatch->env, "{$email}", $emailSender, "ExtraWatch SEO report - " . $projectName . " - {$date}", $outputSEOReport); } } ExtraWatchLog::debug("function sendNightlyEmail output rendered"); return $output; }