Login   Register  
PHP Classes
elePHPant
Icontem

File: botid_class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of ofertino  >  BotID  >  botid_class.php  >  Download  
File: botid_class.php
Role: Class source
Content type: text/plain
Description: MAIN CLASS
Class: BotID
Determine if the current user is robot
Author: By
Last change: Added support for blocked IP's
Date: 2012-08-29 02:29
Size: 1,406 bytes
 

Contents

Class file image Download
<?
/*
C OFERTINO 2012
*/
class BotID
{
    var 
$IP;
    var 
$UA;
    var 
$Bot;
    var 
$BlockedIP false;
    function 
__construct(){
        
$this->IP $_SERVER['REMOTE_ADDR'];
        
$this->UA $_SERVER['HTTP_USER_AGENT'];
        
$this->Bot false;
        
$this->I1();
    }
    function 
I1(){
        if(
stristr($this->UA,"bot")||stristr($this->UA,"Bot")||stristr($this->UA,"http")||stristr($this->UA,"bing")||stristr($this->UA,"Ezooms")||stristr($this->UA,"Google")&&!stristr($this->UA,"Web Preview")&&stristr($this->UA,"IE 6")){
            
$this->Bot true;
        }
        if(
strpos('x'.$_SERVER['REMOTE_ADDR'], '67.195') > || strpos('x'.$_SERVER['REMOTE_ADDR'], '66.249') > || strpos('x'.$_SERVER['REMOTE_ADDR'], '150.70.64') > || strpos('x'.$_SERVER['REMOTE_ADDR'], '157.55.18') > 0){
            
$this->Bot true;
        }
        
//OWN CUSTOMIZABLE FILE WITH IP's
        
$f file_get_contents("bot_ip.dat");
        
$ips explode(";",$f);
        
$CountIps count($ips);
        for(
$i=0;$i<$CountIps;$i++){
            if(
$_SERVER['REMOTE_ADDR'] == $ips[$i]){
                
$this->Bot true;
            }
        }
        
//OWN CUSTOMIZABLE FILE WITH Blocked IP's
        
$f file_get_contents("block_ip.dat");
        
$ips explode(";",$f);
        
$CountIps count($ips);
        for(
$i=0;$i<$CountIps;$i++){
            if(
$_SERVER['REMOTE_ADDR'] == $ips[$i]){
                
$this->BlockedIP true;
            }
        }
    }
    function 
is_bot(){
        return 
$this->Bot;
    }
    function 
is_blocked(){
        return 
$this->BlockedIP;
    }
}
?>