When using the xlResults.php deployment, you must add the ip limiting code to xlResults.php.
Below is example set limit to 30 searches per hour.
//BEGIN EXAMPLE
$searchLimitCount = 30;
$searchLimitTime = 60 * 60; // an hour
$key = "xlocator";
$c = 0;
foreach ($_COOKIE as $k => $v)
{
if (substr($k, 0, strlen($key)) == $key)
{
$c++;
}
}
if ($c > $searchLimitCount)
{
header("Location: search_limit.php");
exit;
}
$t = time();
setcookie($key.$t, 0, $t + $searchLimitTime);
//END EXAMPLE
To now set some IPs that are not affected by the limiting:
//BEGIN EXAMPLE
$unlimitedIP = array("1.1.1.1", "2.2.2.2");
If (in_array($_SERVER["REMOTE_ADDR"], $unlimitedIP))
{
//do not limit
}
//END EXAMPLE
Article is in the following categories:
KB » PHP Code Customization Tips
KB » PHP Code Customization Tips
How to add Search Limiting when using xlResults.php



Email This Article