/** * 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(); }
/** * block */ function getBlockedIPs($date = 0, $limitCount = 0) { if (@$limitCount) { $limit = " limit {$limitCount} "; } else { $limit = ""; } if (@$date != 0) { $query = sprintf("select ip,hits,reason from #__joomlawatch_blocked where `date` = '%d' order by hits desc %s", (int) $date, JoomlaWatchHelper::sanitize($limit)); } else { $query = sprintf("select * from #__joomlawatch_blocked order by hits desc %s", JoomlaWatchHelper::sanitize($limit)); } $this->database->setQuery($query); return $rows = $this->database->loadObjectList(); }
/** * 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; } }
/** * 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; }
/** * 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(); } }
/** * 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; }