Пример #1
0
 /**
  * visitor
  */
 function increaseUri2TitleCount($uri)
 {
     $query = sprintf("update #__joomlawatch_uri2title set count = count+1, timestamp = '%d' where (`uri` = '%s')", (int) JoomlaWatchHelper::getServerTime(), JoomlaWatchHelper::sanitize($uri));
     $this->database->setQuery($query);
     $this->database->query();
 }
Пример #2
0
 function checkPostRequestForSpam($post)
 {
     /** if nothing is there in the post request */
     if (@(!$post)) {
         return true;
     }
     $ip = $_SERVER['REMOTE_ADDR'];
     if (@$this->searchBlockedIp($ip)) {
         $this->dieWithBlockingMessage($ip);
     }
     $today = $this->helper->jwDateToday();
     if (@$this->config->getCheckboxValue('JOOMLAWATCH_SPAMWORD_BANS_ENABLED')) {
         $spamList = explode("\n", $this->config->getConfigValue('JOOMLAWATCH_SPAMWORD_LIST'));
         foreach ($post as $key => $value) {
             foreach ($spamList as $spamWord) {
                 $spamWord = trim($spamWord);
                 $value = trim($value);
                 if (@$spamWord && @$value && JoomlaWatchHelper::wildcardSearch("*" . $spamWord . "*", $value)) {
                     $this->blockIp($ip, htmlspecialchars($value), $today);
                     $this->dieWithBlockingMessage($ip);
                 }
             }
         }
     }
 }
Пример #3
0
 /**
  * stats/info
  */
 function isIPUniqueForToday($ip)
 {
     $date = $this->helper->jwDateToday();
     $query = sprintf("select count(value) as count from #__joomlawatch_info where `group` = 'ip' and name = '%s' and `date` = '%d' ", JoomlaWatchHelper::sanitize($ip), (int) $date);
     $this->database->setQuery($query);
     $rows = @$this->database->loadObjectList();
     $count = $this->database->loadResult();
     if (isset($count)) {
         return false;
     } else {
         return true;
     }
 }
Пример #4
0
 /**
  * goals
  */
 function saveGoal($post)
 {
     $id = @$post['id'];
     if (@$id) {
         //update
         $query = sprintf("update #__joomlawatch_goals  set ");
         $length = sizeof($post);
         if (@$post['option']) {
             $length = $length - 1;
         }
         $i = 0;
         foreach ($post as $key => $value) {
             $i++;
             if ($key == "id") {
                 continue;
             }
             $key = strtolower($key);
             $query .= sprintf("%s = '%s' ", JoomlaWatchHelper::sanitize($key), JoomlaWatchHelper::sanitize($value));
             if ($i < $length - 1) {
                 $query .= ", ";
             }
         }
         $query .= sprintf(" where id = '%d'", (int) $id);
         $this->database->setQuery($query);
         $result = $this->database->query();
         //			echo($query);
     } else {
         // insert
         unset($post['id']);
         // when it comes from new goal
         $query = sprintf("insert into #__joomlawatch_goals (id, ");
         $length = sizeof($post);
         if (@$post['option']) {
             $length = $length - 1;
         }
         $i = 0;
         foreach ($post as $key => $value) {
             if ($key == "id" || $key == "option") {
                 continue;
             }
             $i++;
             $key = strtolower($key);
             $query .= sprintf("%s", JoomlaWatchHelper::sanitize($key));
             if ($i < $length) {
                 $query .= ", ";
             }
         }
         $query .= ") values ('',";
         $i = 0;
         foreach ($post as $key => $value) {
             if ($key == "id" || $key == "option") {
                 continue;
             }
             $i++;
             $key = strtolower($key);
             $query .= sprintf("'%s'", JoomlaWatchHelper::sanitize($value));
             if ($i < $length) {
                 $query .= ",";
             }
         }
         $query .= ")";
         $this->database->setQuery($query);
         $result = $this->database->query();
     }
     return $result;
 }
Пример #5
0
 /**
  * config
  */
 function saveConfigValue($key, $value)
 {
     $query = sprintf("select count(name) as count from #__joomlawatch_config where name = '%s' limit 1", JoomlaWatchHelper::sanitize($key));
     $this->database->setQuery($query);
     $this->database->query();
     $count = $this->database->loadResult();
     if ($count) {
         //update
         $query = sprintf("update #__joomlawatch_config set value = '%s' where name = '%s'", JoomlaWatchHelper::sanitize($value), JoomlaWatchHelper::sanitize($key));
         $this->database->setQuery($query);
         $this->database->query();
     } else {
         //insert
         $query = sprintf("insert into #__joomlawatch_config values ('','{$key}','{$value}')", JoomlaWatchHelper::sanitize($key), JoomlaWatchHelper::sanitize($value));
         $this->database->setQuery($query);
         $this->database->query();
     }
 }
Пример #6
0
 /**
  * helper
  */
 function countryCodeToCountryName($code)
 {
     $query = sprintf("select country from #__joomlawatch_cc2c where cc = '%s' limit 1", JoomlaWatchHelper::sanitize($code));
     $this->database->setQuery($query);
     $this->database->query();
     $countryName = $this->database->loadResult();
     return $countryName;
 }