DLEVIET - DataLife Engine Support Home Page

DataLife Engine Support » DataLife Engine » Modules » AntiOverload v.3

AntiOverload v.3

  • Author: admin;  
  • Views: 2636;  
  • Date: 28 August 2009;  
AntiOverload v.3


This module is designed to limit access to the site or to pages where it is on.
Principle of operation that is stored ip-address and time of treatment with this address. And if within the specified time is the treatment of the same address, then he / she receives an error 503. Ex : If you click the Refresh button 3 times will give you will give this message.

Installation:
* In the site root folder, create a tmp directory and CHMOD to 777

* Open index.php and before:
<?php


Insert:

<?php



$ad_delay=2;

$ad_DirName=$_SERVER['DOCUMENT_ROOT'].'/tmp';


$ad_Robots_UserAgent=array(
   'aipbot',
   'Aport',
   'eStyleSearch',
   'Gigabot',
   'Gokubot',
   'Google',
   'MJ12bot',
   'msnbot',
   'PlantyNet_WebRobot',
   'StackRambler',
   'TurtleScanner',
   'Yahoo',
   'Yandex',
   'YaDirectBot',
);

$ad_good_ip = array(
    '217.107.36.73',
);


function ad_WiteIP($dir){
   $f=fopen($dir.'/a'.$_SERVER['REMOTE_ADDR'], 'w');
   fclose($f);
}

$ad_IsRobot=false;
foreach ($ad_Robots_UserAgent as $match){
   if (strstr($_SERVER['HTTP_USER_AGENT'], $match)){
      $ad_IsRobot=true;
      break;
   }
}
if( in_array($_SERVER['REMOTE_ADDR'], $ad_good_ip) ) {
     $good_ip = true;
} else {
     $good_ip = false;
}

if (!$ad_IsRobot AND !$good_ip){
   session_start();
}

if (!$ad_IsRobot AND !$good_ip){
  
   $ad_dir      =opendir($ad_DirName)
      or die('There is no directory for temporary files');
   $ad_now      =time();
   $ad_forbid   =$ad_now-$ad_delay;
  
   while (false!==($ad_FName=readdir($ad_dir))){
      if (ereg('^a[1-9]',$ad_FName)
         && (@ filemtime($ad_DirName.'/'.$ad_FName)<$ad_forbid)){
         @ unlink($ad_DirName.'/'.$ad_FName);
      }
   }
   closedir($ad_dir);
  
   if (file_exists($ad_DirName.'/a'.$_SERVER['REMOTE_ADDR'])){
      
      header('HTTP/1.0 503 Service Unavailable');
      header('Status: 503 Service Unavailable');
      header('Retry-After: '.$ad_delay*3);
?>
<!doctype html public "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Ошибка 503</title>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1251" />
</head>
<body>
<h1>Error 503 (Service Unavailable)</h1>
<p>server can not currently issue the page you requested.
Try to access this page later (press F5).</p>
</body>
</html>
<?php
      ad_WiteIP($ad_DirName);   // Before exiting record ip
      exit;
   }else{
      ad_WiteIP($ad_DirName);
   }
}
?>
We encourage you to Register or Login to website under your name.

Michael

Posted 10 May 2010 02:15 Register: 14.03.2010
will it be helpful against DoS Attacks
i mean this will prevent giving away lots of bandwidth to a single client isn't it??

harsha500

Posted 18 June 2012 15:41 Register: 16.06.2012
Hi admin

i've a problem with this module. which index.php do i need to open ? please guide me how to install corecctly ?

thanks.
Information
Members of Guest cannot leave comments.

Useful Tools

Popular

Pagerank Update

    Updates Yandex SEO
    23.05.2013
    28.03.2013
    27.12.2012
    Updates Yandex search
    21.05.2013
    15.05.2013
    12.05.2013
    Updates Yandex Catalogue
    23.05.2013
    22.05.2013
    21.05.2013
    Updates Google
    06.02.2013
    08.11.2012
    02.08.2012

Find us on Facebook

Poll

How do you know DataLife Engine Support?

Search Engine
Other DLE Support websites
Forum
Friends
Others

Sponsor

Calendar

«    May 2013    »
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
Contact us in social network

Facebook

Twitter