Skip to content

Commit

Permalink
Added support to ban IPs from tracking files
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Dec 30, 2010
1 parent 5f4d2d5 commit 6066967
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions phpmyfaq/inc/Session.php
Expand Up @@ -84,10 +84,11 @@ public function userTracking($action, $id = 0)

if ($faqconfig->get('main.enableUserTracking')) {

$bots = 0;
$agent = $_SERVER['HTTP_USER_AGENT'];
$sid = PMF_Filter::filterInput(INPUT_GET, PMF_GET_KEY_NAME_SESSIONID, FILTER_VALIDATE_INT);
$sidc = PMF_Filter::filterInput(INPUT_COOKIE, PMF_COOKIE_NAME_SESSIONID, FILTER_VALIDATE_INT);
$bots = 0;
$banned = false;
$agent = $_SERVER['HTTP_USER_AGENT'];
$sid = PMF_Filter::filterInput(INPUT_GET, PMF_GET_KEY_NAME_SESSIONID, FILTER_VALIDATE_INT);
$sidc = PMF_Filter::filterInput(INPUT_COOKIE, PMF_COOKIE_NAME_SESSIONID, FILTER_VALIDATE_INT);

if (!is_null($sidc)) {
$sid = $sidc;
Expand All @@ -101,7 +102,12 @@ public function userTracking($action, $id = 0)
$bots++;
}
}
if (0 == $bots) {

if (IPCheck($_SERVER['REMOTE_ADDR'])) {
$banned = true;
}

if (0 == $bots && false == $banned) {
if (!isset($sid)) {
$sid = $this->db->nextID(SQLPREFIX."faqsessions", "sid");
// Sanity check: force the session cookie to contains the current $sid
Expand All @@ -118,7 +124,7 @@ public function userTracking($action, $id = 0)
SQLPREFIX,
$sid,
($user ? $user->getUserId() : -1),
$_SERVER["REMOTE_ADDR"],
$_SERVER['REMOTE_ADDR'],
$_SERVER['REQUEST_TIME']
);
$this->db->query($query);
Expand Down

0 comments on commit 6066967

Please sign in to comment.