[ ]   [ ]   [ ]   [ ]



: 0
25-02-12 07:01


igor64
: 0
16-01-12 20:13


Lil`Ga.k.a43
: 1
09-01-12 11:23



   Web -
PHP


ASP






XML



CSS

SSI





   











   Web -








   









   










Web - / PHP /

, , , . :

, , . - 500Mb, 7 000 , - 300 10 .

20 , . 10 . 0.28% 50% . , .

1. User Agent

User Agent - , . , , , .

, . , , , Download .

:

$agent=" ".$HTTP_USER_AGENT;

if (strpos($agent,"DISCo Pump") ||
    strpos($agent,"Offline Explorer") ||
    strpos($agent,"Teleport") ||
    strpos($agent,"WebZIP") ||
    strpos($agent,"WebCopier") ||
    strpos($agent,"Wget") ||
    strpos($agent,"FlashGet") ||
    strpos($agent,"CIS TE") ||
    strpos($agent,"DTS Agent") ||
    strpos($agent,"WebReaper") ||
    strpos($agent,"HTTrack") ||
    strpos($agent,"Web Downloader")) {
    die("Access Denied");
    }

2. .

. , 60 1 . Download .

Download , , .

3. .

, . , "" , Download . IP , , 3 .

- , , , . :

  • $HTTP_USER_AGENT. , . , Download . (. 2)
  • IP , , . , Download .

.

, , , , - ( -) . PHP , , .

PHP

flooders.inc.php:

<?
class Flooders {
var
$filename;/* , ꠠ*/
/* IP ⠠*/

var $timeout;/* , IP */
/* . - 600 (10 ) */

var $log;/* -.*/

var $AGENTS;/* - ⠠*/

/**/
/* - */
/**/
/*$filename - , ꠠ*/
/* .*/
/*$timeout - , , IP.*/
/**/
/* : $f=new Flooders("ban.txt",3600);*/
/**/

function Flooders($filename="flooders.txt",$timeout=600) {
$this->filename=$filename;
$this->timeout=$timeout;
$this->AGENTS=Array();
$this->log="";
}

/**/
/* -. , -렠*/
/* */
/**/

function SetLogFileName($filename) {
$this->log=$filename;
}

/**/
/* IP -.*/
/**/
/* $http_errror==0, true, IP 񠠠*/
/* , false, IP .*/
/**/
/* $http_error==404 IP , */
/* 404 Apache*/
/**/
/* $http_error==403 IP , */
/* 403 Apache*/
/**/

function Check($http_error=0) {
GLOBAL
$HTTP_SERVER_VARS;

$ip1=$HTTP_SERVER_VARS["REMOTE_ADDR"];
$ip2=$HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
$ip1=str_replace(":","_",$ip1);
$ip2=str_replace(":","_",$ip2);

$curtime=time();

$d=@file($this->filename);
if (!
is_array($d)) {print " "".$this->filename."".";return(false);}

$found=false;
for (
$i=0;$i<count($d);$i++) {
$e=explode(" : ",$d[$i]);
if (
$e[1]==$ip1 && trim($e[2])==$ip2 && $e[0]+$this->timeout>$curtime) {$found=true;break;}
}
if (
$http_error==404 && $found==true) {
header("HTTP/1.0 404 Not Found");
die(
"<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<HTML><HEAD>\n<TITLE>404 Not Found</TITLE>\n</HEAD><BODY>\n<H1>Not Found</H1>\nThe requested URL ".$HTTP_SERVER_VARS["REQUEST_URI"]." was not found on this server.<P>\n<HR>\n".$HTTP_SERVER_VARS["SERVER_SIGNATURE"]."\n</BODY></HTML>");
}
if (
$http_error==403 && $found==true) {
header("HTTP/1.0 403 Forbidden");
die(
"<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<HTML><HEAD>\n<TITLE>403 Forbidden</TITLE>\n</HEAD><BODY>\n<H1>Forbidden</H1>\nYou don't have permission to access ".$HTTP_SERVER_VARS["REQUEST_URI"]."\non this server.<P>\n<HR>\n".$HTTP_SERVER_VARS["SERVER_SIGNATURE"]."\n</BODY></HTML>");
}
return(
$found);
}

/**/
/* IP -򠠠*/
/**/

function Ban() {
GLOBAL
$HTTP_SERVER_VARS;

$agent=" ".$HTTP_SERVER_VARS["HTTP_USER_AGENT"];
for (
$i=0;$i<count($this->AGENTS);$i++) {
if (
strpos($agent,$this->AGENTS[$i])) return;
}

$ip1=$HTTP_SERVER_VARS["REMOTE_ADDR"];
$ip2=$HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
$ip1=str_replace(":","_",$ip1);
$ip2=str_replace(":","_",$ip2);

$curtime=time();

$d=@file($this->filename);
if (!
is_array($d)) {print " "".$this->filename."".";}

for (
$i=0;$i<count($d);$i++) {
$e=explode(" : ",$d[$i]);
if (
$e[1]==$ip1 && trim($e[2])==$ip2) unset($d[$i]);
}

if (
need_add) {
if (!empty(
$this->log)) {
$fw=fopen($this->log,"at");
if (
$fw) {
fputs($fw, date("Y-m-d H:i:s")." [".$ip1."|".$ip2."]".$agent."\n");
fclose($fw);
}
}
$d[]=$curtime." : ".$ip1." : ".$ip2."\n";
}

$fw=@fopen($this->filename,"wt");
if (!
$fw) {print " "".$this->filename."".";return;}

foreach (
$d as $e) fputs($fw,$e);
fclose($fw);
}

function
AddAlowAgent($agent) {
$this->AGENTS[]=$agent;
}
}
?>

1

:

<?
include "flooders.inc.php";

$f=new Flooders();
$f->Ban();
?>

:

<?
include "flooders.inc.php";

$f=new Flooders();
$f->Check(404);
?>

2 - .

:

<?
include "flooders.inc.php";

$f=new Flooders("/tmp/ban.txt");
$f->AddAlowAgent("StackRambler");
$f->AddAlowAgent("Googlebot");
$f->AddAlowAgent("Yandex");
$f->AddAlowAgent("Aport");
$f->AddAlowAgent("msnbot");
$f->AddAlowAgent("FAST-WebCrawler");
$f->AddAlowAgent("Slurp/cat");
$f->AddAlowAgent("ASPseek/1.2.10");
$f->AddAlowAgent("CNSearch");
$f->SetLogFileName("/tmp/ban.log");
$f->Ban();
?>

:

<?
include "flooders.inc.php";

$f=new Flooders("/tmp/ban.txt");
$f->Check(403);
?>

: Mike
: www.codenet.ru


[ ]



  !



: Web - / PHP /

GTK+:
02-03-2010   

GTK+ . GNOME, , GTK+ , GIMP GTK+, , Abobe, NVidia VMware, ...

: 1
. : - 4302 - 2

13-11-2009   

Slashdot.org 50 . . , IT...

: 0
. : - 4147 - 3

13-11-2009   

, , ( , , ) , .. . ...

: 0
. : - 3996 - 0

No spam.php
10-11-2009   

... . , , --. , . --. ...

: 0
. : - 4034 - 1

php Windows
10-11-2009   

, , PHP4 Windows...

: 0
. : - 4020 - 0



e-mail:
:

| ?







IT -




-




  WWW.COMPROG.RU - 2009-2012 | Designed and Powered by Zaipov Renat | Projects