= $bMaxVisit ) and (( $visits / $duration ) > ( $bMaxVisit / $bInterval ))) { $fileATime= $time = $time - $bInterval; $fileMTime= $time + $bMaxVisit + (( $bMaxVisit * $bPenalty ) / $bInterval ); touch( $ipFile, $fileMTime, $fileATime ); header( 'HTTP/1.0 503 Service Temporarily Unavailable' ); header( 'Connection: close' ); header( 'Content-Type: text/html' ); echo "

Server under heavy load
"; echo "$visits visits from your IP-Address within the last $duration secs. Please wait $bPenalty secs before retrying.

"; $remote = $_SERVER[ 'REMOTE_ADDR' ]; $useragent= ( isset( $_SERVER[ 'HTTP_USER_AGENT' ])) ? $_SERVER[ 'HTTP_USER_AGENT' ] : ''; $logLine= "$remote ". date( 'd/m/Y H:i:s' ) ." $useragent\n"; $log= file( $ipLogFile ); if( $fp = fopen( $ipLogFile, 'a' )) {// tiny danger of 2 threads interfering; live with it if( count( $log ) >= _B_LOGMAXLINES ) {// otherwise grows like Topsy fclose( $fp );// flock() disabled in some kernels (eg 2.4) array_shift( $log );// fopen,fclose put close together as possible array_push( $log, $logLine ); $logLine= implode( '', $log ); $fp= fopen( $ipLogFile, 'w' ); } fputs( $fp, $logLine ); fclose( $fp ); } exit(); } } touch( $ipFile, $fileMTime, $fileATime ); ignore_user_abort( $oldSetting ); ?>