Code: Select all
function Execute($showwhat) {
$this->ReadSettings();
if (!$this->IgnoreVisitor()) {
$this->IncreaseValue("count_total_pageviews");
$this->Log("*** STARTING SESSION ***");
if (!$this->ExistingVisitor()) {
$this->CleanVisitors(); //needed every time? Yes... too slow if done too seldom
$this->DoComplete();
} else {
$this->DoUpdate();
}
$this->Log("*** ENDING SESSION ***");
$this->Log("");
}
return $this->GetResult($showwhat);
}
Code: Select all
10;192.168;12.34/56.*.55
Since I did not found a good formula for that on the net, I wrote one myself. I think the performance should be quite good. The first change is the IgnoreVisitor function. This should be:
Code: Select all
function IgnoreVisitor() {
// ip addresses to ignore are separated by semicolons (like 172.10.1.93;172.10.1.94)
$ip = $_SERVER["REMOTE_ADDR"];
if (isset($ip)) {
$ignoreips=trim($this->ignoreips,' ;');
if($ignoreips=='')return false;
$aIp=explode('.',$ip);
foreach(explode(';',$ignoreips)as $ignoreip){
$ignoreip=trim($ignoreip,'. ');
$aIg = explode('.',$ignoreip);
for($i=0;$i<count($aIg);$i++){
$result = $this->IgnoreSubIp($aIp[$i],$aIg[$i]);
if(!$result)break;// we are sure not to ignore;
}
if($i==count($aIg)){
$this->Log("Ignoring visitor because of ignore IP-list");
return true; // This is a ban, don't look further
}
}
}
return false; // no match has occured
}
Code: Select all
function IgnoreSubIp($ip,$ban){
/** return false if sure not blocking **/
if($ban=='*')return true;
if(is_numeric($ban)&&$ban!=$ip)return false;
if(preg_match('/(\d{1,3})\/(\d{1,3})/',$ban,$matches)){
if($ip<$matches[1]||$ip>$matches[2])return false;
}
// Error invalid ban description
return true;
}
Good luck with this one!
ps, something tells me that is should be possible in one or two regexps, if you know them please let me know!