Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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('dir notfount );
- $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>Pless refreh page</p>
- </body>
- </html>
- <?php
- ad_WiteIP($ad_DirName);
- exit;
- }else{
- ad_WiteIP($ad_DirName);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment