Advertisement
Blade83

User is_bot,is_mobile,has_flash,get_isp,is_proxy_con,get_ip

Nov 25th, 2012
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.28 KB | None | 0 0
  1. <?php
  2. /*
  3.  * Author: $ Blade83
  4.  * Filename: client.class.php
  5.  * Requires: client.js (http://pastebin.com/xyXDDxmP)
  6.  *
  7.  * Methods of this wonderful Class
  8.  *
  9.  * - is_Tor_connection() // Checks if the Client connect over a Tor Network
  10.  * - is_bot() // Checks if the Client is a bot (google, Bing, yahoo etc...) or not.
  11.  * - is_mobile() // Checks if the Client connects from a mobile phone or tablet pc etc...
  12.  * - get_agent() // Returns the name of the Browser (Firefox, Crome, Safarie etc...)
  13.  * - get_isp() // Returns the Provider name from the Client connection (T-Online, 1&1 etc.)
  14.  * - get_real_ip() // If the Client connect over Proxy, this Method will try to get the real user IP
  15.  * - is_anonyme_ip() // This Method checks if the IP address is equal to the dns address
  16.  *
  17.  * Further this Script reads Flashplayer settings from cookies that previously saved by client.js !
  18.  *
  19.  *
  20. */
  21.  
  22. class client
  23. {
  24.     public
  25.         $flash_enabled          = NULL,
  26.         $flash_raw              = NULL,
  27.         $flash_majorversion     = NULL,
  28.         $flash_minorversion     = NULL,
  29.         $flash_revisionStr      = NULL,
  30.         $flash_revision         = NULL,
  31.         $mobile                 = NULL,
  32.         $windowWidth            = NULL,
  33.         $windowHeight           = NULL;
  34.  
  35.     public static function get_browser_detection_script($js_path='')
  36.     {
  37.         return '<script type="text/javascript" src="'.$js_path.'client.js"></script>'."\n";
  38.     }
  39.  
  40.     public function __construct()
  41.     {
  42.         $this->set_flash_fields();
  43.         if (isset($_COOKIE['windowWidth']) && !empty($_COOKIE['windowWidth']))
  44.         {
  45.             $this->windowWidth = $_COOKIE['windowWidth'];
  46.         }
  47.         if (isset($_COOKIE['windowHeight']) && !empty($_COOKIE['windowHeight']))
  48.         {
  49.             $this->windowHeight = $_COOKIE['windowHeight'];
  50.         }
  51.         // delete the cookies
  52.         @setcookie('windowWidth', "", time()-10000, '/');
  53.         @setcookie('windowHeight', "", time()-10000, '/');
  54.     }
  55.  
  56.     public function set_flash_fields()
  57.     {
  58.         if (isset($_COOKIE['flash_installed']) && !empty($_COOKIE['flash_installed']))
  59.         {
  60.             if ($_COOKIE['flash_installed']=='true'){
  61.                 $this->flash_enabled        = true;
  62.                 $this->flash_raw            = $_COOKIE['flash_raw'];
  63.                 $this->flash_majorversion   = $_COOKIE['flash_major'];
  64.                 $this->flash_minorversion   = $_COOKIE['flash_minor'];
  65.                 $this->flash_revisionStr    = $_COOKIE['flash_revisionStr'];
  66.                 $this->flash_revision       = $_COOKIE['flash_revision'];
  67.             }else{
  68.                 $this->flash_enabled        = false;
  69.             }
  70.         }
  71.         if (!headers_sent())
  72.         {
  73.             // delete the cookies
  74.             @setcookie('flash_installed', "", time()-10000, '/');
  75.             @setcookie('flash_raw', "", time()-10000, '/');
  76.             @setcookie('flash_major', "", time()-10000, '/');
  77.             @setcookie('flash_minor', "", time()-10000, '/');
  78.             @setcookie('flash_revisionStr', "", time()-10000, '/');
  79.             @setcookie('flash_revision', "", time()-10000, '/');
  80.         }
  81.     }
  82.  
  83.     public function get_real_ip()
  84.     {
  85.         // if is the connection a proxy connection, try to get the real client ip
  86.         global $REMOTE_ADDR, $HTTP_CLIENT_IP;
  87.         global $HTTP_X_FORWARDED_FOR, $HTTP_X_FORWARDED, $HTTP_FORWARDED_FOR, $HTTP_FORWARDED;
  88.         global $HTTP_VIA, $HTTP_X_COMING_FROM, $HTTP_COMING_FROM;
  89.         if (empty($REMOTE_ADDR)) {
  90.             if (!empty($_SERVER) && isset($_SERVER['REMOTE_ADDR'])) {
  91.                 $REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
  92.             }
  93.             else if (!empty($_ENV) && isset($_ENV['REMOTE_ADDR'])) {
  94.                 $REMOTE_ADDR = $_ENV['REMOTE_ADDR'];
  95.             }
  96.             else if (@getenv('REMOTE_ADDR')) {
  97.                 $REMOTE_ADDR = getenv('REMOTE_ADDR');
  98.             }
  99.         }
  100.         if (empty($HTTP_CLIENT_IP)) {
  101.             if (!empty($_SERVER) && isset($_SERVER['HTTP_CLIENT_IP'])) {
  102.                 $HTTP_CLIENT_IP = $_SERVER['HTTP_CLIENT_IP'];
  103.             }
  104.             else if (!empty($_ENV) && isset($_ENV['HTTP_CLIENT_IP'])) {
  105.                 $HTTP_CLIENT_IP = $_ENV['HTTP_CLIENT_IP'];
  106.             }
  107.             else if (@getenv('HTTP_CLIENT_IP')) {
  108.                 $HTTP_CLIENT_IP = getenv('HTTP_CLIENT_IP');
  109.             }
  110.         }
  111.         if (empty($HTTP_X_FORWARDED_FOR)) {
  112.             if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  113.                 $HTTP_X_FORWARDED_FOR = $_SERVER['HTTP_X_FORWARDED_FOR'];
  114.             }
  115.             else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED_FOR'])) {
  116.                 $HTTP_X_FORWARDED_FOR = $_ENV['HTTP_X_FORWARDED_FOR'];
  117.             }
  118.             else if (@getenv('HTTP_X_FORWARDED_FOR')) {
  119.                 $HTTP_X_FORWARDED_FOR = getenv('HTTP_X_FORWARDED_FOR');
  120.             }
  121.         }
  122.         if (empty($HTTP_X_FORWARDED)) {
  123.             if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED'])) {
  124.                 $HTTP_X_FORWARDED = $_SERVER['HTTP_X_FORWARDED'];
  125.             }
  126.             else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED'])) {
  127.                 $HTTP_X_FORWARDED = $_ENV['HTTP_X_FORWARDED'];
  128.             }
  129.             else if (@getenv('HTTP_X_FORWARDED')) {
  130.                 $HTTP_X_FORWARDED = getenv('HTTP_X_FORWARDED');
  131.             }
  132.         }
  133.         if (empty($HTTP_FORWARDED_FOR)) {
  134.             if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED_FOR'])) {
  135.                 $HTTP_FORWARDED_FOR = $_SERVER['HTTP_FORWARDED_FOR'];
  136.             }
  137.             else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED_FOR'])) {
  138.                 $HTTP_FORWARDED_FOR = $_ENV['HTTP_FORWARDED_FOR'];
  139.             }
  140.             else if (@getenv('HTTP_FORWARDED_FOR')) {
  141.                 $HTTP_FORWARDED_FOR = getenv('HTTP_FORWARDED_FOR');
  142.             }
  143.         }
  144.         if (empty($HTTP_FORWARDED)) {
  145.             if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED'])) {
  146.                 $HTTP_FORWARDED = $_SERVER['HTTP_FORWARDED'];
  147.             }
  148.             else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED'])) {
  149.                 $HTTP_FORWARDED = $_ENV['HTTP_FORWARDED'];
  150.             }
  151.             else if (@getenv('HTTP_FORWARDED')) {
  152.                 $HTTP_FORWARDED = getenv('HTTP_FORWARDED');
  153.             }
  154.         }
  155.         if (empty($HTTP_VIA)) {
  156.             if (!empty($_SERVER) && isset($_SERVER['HTTP_VIA'])) {
  157.                 $HTTP_VIA = $_SERVER['HTTP_VIA'];
  158.             }
  159.             else if (!empty($_ENV) && isset($_ENV['HTTP_VIA'])) {
  160.                 $HTTP_VIA = $_ENV['HTTP_VIA'];
  161.             }
  162.             else if (@getenv('HTTP_VIA')) {
  163.                 $HTTP_VIA = getenv('HTTP_VIA');
  164.             }
  165.         }
  166.         if (empty($HTTP_X_COMING_FROM)) {
  167.             if (!empty($_SERVER) && isset($_SERVER['HTTP_X_COMING_FROM'])) {
  168.                 $HTTP_X_COMING_FROM = $_SERVER['HTTP_X_COMING_FROM'];
  169.             }
  170.             else if (!empty($_ENV) && isset($_ENV['HTTP_X_COMING_FROM'])) {
  171.                 $HTTP_X_COMING_FROM = $_ENV['HTTP_X_COMING_FROM'];
  172.             }
  173.             else if (@getenv('HTTP_X_COMING_FROM')) {
  174.                 $HTTP_X_COMING_FROM = getenv('HTTP_X_COMING_FROM');
  175.             }
  176.         }
  177.         if (empty($HTTP_COMING_FROM)) {
  178.             if (!empty($_SERVER) && isset($_SERVER['HTTP_COMING_FROM'])) {
  179.                 $HTTP_COMING_FROM = $_SERVER['HTTP_COMING_FROM'];
  180.             }
  181.             else if (!empty($_ENV) && isset($_ENV['HTTP_COMING_FROM'])) {
  182.                 $HTTP_COMING_FROM = $_ENV['HTTP_COMING_FROM'];
  183.             }
  184.             else if (@getenv('HTTP_COMING_FROM')) {
  185.                 $HTTP_COMING_FROM = getenv('HTTP_COMING_FROM');
  186.             }
  187.         }
  188.         // Gets the default ip sent by the user
  189.         if (!empty($REMOTE_ADDR)) {
  190.             $direct_ip = $REMOTE_ADDR;
  191.         }
  192.         // Gets the proxy ip sent by the user
  193.         $proxy_ip = '';
  194.         if (!empty($HTTP_X_FORWARDED_FOR)) {
  195.             $proxy_ip = $HTTP_X_FORWARDED_FOR;
  196.         } else if (!empty($HTTP_X_FORWARDED)) {
  197.             $proxy_ip = $HTTP_X_FORWARDED;
  198.         } else if (!empty($HTTP_FORWARDED_FOR)) {
  199.             $proxy_ip = $HTTP_FORWARDED_FOR;
  200.         } else if (!empty($HTTP_FORWARDED)) {
  201.             $proxy_ip = $HTTP_FORWARDED;
  202.         } else if (!empty($HTTP_VIA)) {
  203.             $proxy_ip = $HTTP_VIA;
  204.         } else if (!empty($HTTP_X_COMING_FROM)) {
  205.             $proxy_ip = $HTTP_X_COMING_FROM;
  206.         } else if (!empty($HTTP_COMING_FROM)) {
  207.             $proxy_ip = $HTTP_COMING_FROM;
  208.         }
  209.         // Returns the true IP if it has been found, else ...
  210.         if (empty($proxy_ip)) {
  211.             // True IP without proxy
  212.             return $direct_ip;
  213.         }
  214.         else {
  215.             $is_ip = ereg('^([0-9]{1,3}.){3,3}[0-9]{1,3}', $proxy_ip, $regs);
  216.             if ($is_ip && (count($regs) > 0)) {
  217.                 // True IP behind a proxy
  218.                 return $regs[0];
  219.             }
  220.             else {
  221.                 if (empty($HTTP_CLIENT_IP)) {
  222.                     // Can't define IP: there is a proxy but we don't have
  223.                     // information about the true IP
  224.                     return "(unbekannt) " . $proxy_ip;
  225.                 }
  226.                 else {
  227.                     // better than nothing
  228.                     return $HTTP_CLIENT_IP;
  229.                 }
  230.             }
  231.         }
  232.     }
  233.  
  234.     public function is_anonyme_ip()
  235.     {
  236.         $ip = substr(getenv("REMOTE_ADDR"), 0, 14);
  237.         $dns = @gethostbyaddr($ip);
  238.         $true_ip = $this->get_real_ip();
  239.         $true_dns = @gethostbyaddr($true_ip);
  240.         if ( ($ip != $true_ip) || ($dns != $true_dns) )
  241.             return $true_ip;
  242.         else
  243.             return false;
  244.     }
  245.  
  246.     public function get_ip()
  247.     {
  248.         if(getenv("HTTP_CLIENT_IP"))
  249.             $ip = getenv("HTTP_CLIENT_IP");
  250.         elseif(getenv("HTTP_X_FORWARDED_FOR"))
  251.             $ip = getenv("HTTP_X_FORWARDED_FOR");
  252.         else
  253.             $ip = getenv("REMOTE_ADDR");
  254.         return $ip;
  255.     }
  256.    
  257.     public function check_ip($ip)
  258.     {
  259.         #$IP = '198.168.1.78';
  260.         if ( preg_match('/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/', $ip) ) {
  261.             return $ip;
  262.         }
  263.         else {
  264.             return FALSE;
  265.         }
  266.     }
  267.  
  268.     public function get_host()
  269.     {
  270.         return $this->host = @gethostbyaddr($_SERVER['REMOTE_ADDR']);
  271.     }
  272.  
  273.     public function get_isp()
  274.     {
  275.         $this->isp = ("unbekannt");
  276.         $host  = $this->get_host();
  277.         $prft = substr("$host", -10);
  278.         #$pral = substr("$host", -12);
  279.         $prta = substr("$host", -11);
  280.         $prar = substr("$host", -13);
  281.         $prcl = substr("$host", -9);
  282.         $prewe = substr("$host", -11);
  283.         $prbw = substr("$host", -11);
  284.         $prntp = substr("$host", -11);
  285.         $prntdr = substr("$host", -17);
  286.         $prtcho = substr("$host", -10);
  287.         $prtisis = substr("$host", -20);
  288.         $prtnorom = substr("$host", -19);
  289.         $prtosnt = substr("$host", -11);
  290.         $prtnfk2 = substr("$host", -11);
  291.         $prbrnt = substr("$host", -16);
  292.         $prtclx = substr("$host", -9);
  293.         $prtnfk1 = substr("$host", -11);
  294.         $prips = substr("$host", -15);
  295.         $prtcall = substr("$host", -14);
  296.         $prtold = substr("$host", -13);
  297.         $prslbg = substr("$host", -19);
  298.         $prknt = substr("$host", -15);
  299.         $prtisc = substr("$host", -11);
  300.         $prprcm = substr("$host", -13);
  301.         $prvetl = substr("$host", -12);
  302.         $prmnet = substr("$host", -15);
  303.         $prtmrbg = substr("$host", -11);
  304.         $prtkmp = substr("$host", -12);
  305.         $prdthw = substr("$host", -16);
  306.         $prtchtl = substr("$host", -10);
  307.         $prtccom = substr("$host", -13);
  308.         $prnwton = substr("$host", -15);
  309.         $prnwqsc = substr("$host", -7);
  310.         $praol = substr("$host", -12);
  311.         $prtonld = substr("$host", -18);
  312.         if($host == "localhost") $this->isp = "localhost";
  313.         elseif($prft == ".pppool.de") $this->isp = "Freenet";
  314.         elseif($praol == ".ipt.aol.com") $this->isp = "AOL";
  315.         elseif($prta == ".telekom.at") $this->isp = "Telekom Austria";
  316.         elseif($prar == ".arcor-ip.net") $this->isp = "Arcor";
  317.         elseif($prcl == ".ddkom.ne") $this->isp = "ChemTel";
  318.         elseif($prbw == ".bluewin.ch") $this->isp = "BlueWin";
  319.         elseif($prewe == ".ewetel.net") $this->isp = "EWEtel";
  320.         elseif($prntp == ".net-htp.de") $this->isp = "HTP";
  321.         elseif($prntdr == ".internode.on.net") $this->isp = "Internode";
  322.         elseif($prips == ".iprimus.net.au") $this->isp = "iPrimus";
  323.         elseif($prvetl == ".versanet.de") $this->isp = "Versatel";
  324.         elseif($prmnet == ".mnet-online.de") $this->isp = "M-net";
  325.         elseif($prknt == ".netcologne.de") $this->isp = "K�ln net";
  326.         elseif($prprcm == ".primacom.net") $this->isp = "primacom";
  327.         elseif($prslbg == ".salzburg-online.at") $this->isp = "Salzburg-online";
  328.         elseif($prtold == ".t-dialin.net") $this->isp = "T-Online";
  329.         elseif($prtonld == ".t-online.de") $this->isp = "T-Online";
  330.         elseif($prtisc == ".tiscali.de") $this->isp = "Tiscali";
  331.         elseif($prbrnt == ".datahighways.de") $this->isp = "Broadnet";
  332.         elseif($prdthw == ".datahighways.de") $this->isp = "Datahighway";
  333.         elseif($prtccom == ".hispeed.ch") $this->isp = "Cablecom";
  334.         elseif($prtcall == ".mediaways.net") $this->isp = "Callando";
  335.         elseif($prtcho == ".surfer.at") $this->isp = "Chello";
  336.         elseif($prtchtl == ".ddkom.net") $this->isp = "ChemTel";
  337.         elseif($prtisis == ".isionline-dialin.de") $this->isp = "isis";
  338.         elseif($prtkmp == ".kamp-dsl.de") $this->isp = "Kamp";
  339.         elseif($prtmrbg == ".mab.km3.de") $this->isp = "Marienburg";
  340.         elseif($prtnfk1 == ".nefkom.net") $this->isp = "Nefkom";
  341.         elseif($prtnfk2 == ".NEFkom.net") $this->isp = "Nefkom";
  342.         elseif($prtclx == ".celox.de") $this->isp = "Celox";
  343.         elseif($prtnorom == ".ewe-ip-backbone.de") $this->isp = "NordCom";
  344.         elseif($prtosnt == ".osnanet.de") $this->isp = "Osnanet";
  345.         elseif($prnwton == ".t-ipconnect.de") $this->isp = "T-Online";
  346.         elseif($prnwqsc == ".qsc.de") $this->isp = "QSC";
  347.         if($this->isp == "unbekannt")
  348.         {
  349.             // it looks like that this list is out of date!
  350.             // pls send a email to me that includes the hostname.
  351.             // i will update this list
  352.             @mail('mail@blade83.de', 'Script: Unknown ISP Hostaddress in client::get_isp() !!!', 'Hostname: '.$this->get_host());
  353.         }
  354.         return $this->isp;
  355.     }
  356.  
  357.     public function get_agent()
  358.     {
  359.         /*
  360.           // Internet Exlporer
  361.             $msie = strpos($ua, 'MSIE') ? true : false; // All Internet Explorer
  362.             $msie_7 = strpos($ua, 'MSIE 7.0') ? true : false; // Internet Explorer 7
  363.             $msie_8 = strpos($ua, 'MSIE 8.0') ? true : false; // Internet Explorer 8
  364.          */
  365.         if(preg_match("#Firefox#",$_SERVER['HTTP_USER_AGENT']))
  366.             $this->agent = "Firefox";
  367.         elseif(preg_match("#MSIE#",$_SERVER['HTTP_USER_AGENT']))
  368.             $this->agent = "MS IE" ;
  369.         elseif(preg_match("#Opera#",$_SERVER['HTTP_USER_AGENT']))
  370.             $this->agent = "Opera";
  371.         elseif(preg_match("#Netscape#",$_SERVER['HTTP_USER_AGENT']))
  372.             $this->agent = "Netscape Navigator";
  373.         elseif(preg_match("#Chrome#",$_SERVER['HTTP_USER_AGENT']))
  374.             $this->agent = "Chrome";
  375.         elseif(preg_match("#Safari#",$_SERVER['HTTP_USER_AGENT']))
  376.             $this->agent = "Safari";
  377.         else {
  378.             $this->agent = "unbekannt";
  379.             // it looks like that this list is out of date!
  380.             // pls send a email to me that includes the $_SERVER['HTTP_USER_AGENT']
  381.             // i will update this list
  382.             @mail('mail@blade83.de', 'Script: Unknown HTTP_USER_AGENT in client::get_agent() !!!', 'Agent: '.$_SERVER['HTTP_USER_AGENT']);
  383.         }
  384.         return $this->agent;   
  385.     }
  386.  
  387.     public function is_mobile()
  388.     {
  389.         $agents = array('Windows CE',
  390.                         'webos',
  391.                         's8000',
  392.                         'bada',
  393.                         'googlebot-mobile',
  394.                         'incognito',
  395.                         'webmate',
  396.                         'android',
  397.                         'dream',
  398.                         'cupcake',
  399.                         'Pocket',
  400.                         'Mobile',
  401.                         'Portable',
  402.                         'Smartphone',
  403.                         'SDA',
  404.                         'PDA',
  405.                         'Handheld',
  406.                         'Symbian',
  407.                         'WAP',
  408.                         'Palm',
  409.                         'Avantgo',
  410.                         'cHTML',
  411.                         'BlackBerry',
  412.                         'Opera Mini',
  413.                         'Nokia',
  414.                         'ipod',
  415.                         'iPhone'
  416.         );
  417.         /*
  418.          * If u have a newer list, please send it to 'mail@blade83.de'
  419.          * Subject: mobile_agents_list
  420.          */
  421.         for ($i=0; $i < count($agents); $i++)
  422.         {
  423.             if(isset($_SERVER["HTTP_USER_AGENT"]) && strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), strtolower($agents[$i])) !== false)
  424.             {
  425.                 $this->mobile = $agents[$i];
  426.                 return true;
  427.             }
  428.         }
  429.         return false;
  430.     }
  431.  
  432.     public function is_bot()
  433.     {
  434.         $bots = array('bingbot', 'msn', 'abacho', 'abcdatos', 'abcsearch', 'acoon', 'adsarobot', 'aesop', 'ah-ha',
  435.             'alkalinebot', 'almaden', 'altavista', 'antibot', 'anzwerscrawl', 'aol', 'search', 'appie', 'arachnoidea',
  436.             'araneo', 'architext', 'ariadne', 'arianna', 'ask', 'jeeves', 'aspseek', 'asterias', 'astraspider', 'atomz',
  437.             'augurfind', 'backrub', 'baiduspider', 'bannana_bot', 'bbot', 'bdcindexer', 'blindekuh', 'boitho', 'boito',
  438.             'borg-bot', 'bsdseek', 'christcrawler', 'computer_and_automation_research_institute_crawler', 'coolbot',
  439.             'cosmos', 'crawler', 'crawler@fast', 'crawlerboy', 'cruiser', 'cusco', 'cyveillance', 'deepindex', 'denmex',
  440.             'dittospyder', 'docomo', 'dogpile', 'dtsearch', 'elfinbot', 'entire', 'web', 'esismartspider', 'exalead',
  441.             'excite', 'ezresult', 'fast', 'fast-webcrawler', 'fdse', 'felix', 'fido', 'findwhat', 'finnish', 'firefly',
  442.             'firstgov', 'fluffy', 'freecrawl', 'frooglebot', 'galaxy', 'gaisbot', 'geckobot', 'gencrawler', 'geobot',
  443.             'gigabot', 'girafa', 'goclick', 'goliat', 'googlebot', 'griffon', 'gromit', 'grub-client', 'gulliver',
  444.             'gulper', 'henrythemiragorobot', 'hometown', 'hotbot', 'htdig', 'hubater', 'ia_archiver', 'ibm_planetwide',
  445.             'iitrovatore-setaccio', 'incywincy', 'incrawler', 'indy', 'infonavirobot', 'infoseek', 'ingrid', 'inspectorwww',
  446.             'intelliseek', 'internetseer', 'ip3000.com-crawler', 'iron33', 'jcrawler', 'jeeves', 'jubii', 'kanoodle',
  447.             'kapito', 'kit_fireball', 'kit-fireball', 'ko_yappo_robot', 'kototoi', 'lachesis', 'larbin', 'legs',
  448.             'linkwalker', 'lnspiderguy', 'look.com', 'lycos', 'mantraagent', 'markwatch', 'maxbot', 'mercator', 'merzscope',
  449.             'meshexplorer', 'metacrawler', 'mirago', 'mnogosearch', 'moget', 'motor', 'muscatferret', 'nameprotect',
  450.             'nationaldirectory', 'naverrobot', 'nazilla', 'ncsa', 'beta', 'netnose', 'netresearchserver', 'ng/1.0',
  451.             'northerlights', 'npbot', 'nttdirectory_robot', 'nutchorg', 'nzexplorer', 'odp', 'openbot', 'openfind',
  452.             'osis-project', 'overture', 'perlcrawler', 'phpdig', 'pjspide', 'polybot', 'pompos', 'poppi', 'portalb',
  453.             'psbot', 'quepasacreep', 'rabot', 'raven', 'rhcs', 'robi', 'robocrawl', 'robozilla', 'roverbot', 'scooter',
  454.             'scrubby', 'search.ch', 'search.com.ua', 'searchfeed', 'searchspider', 'searchuk', 'seventwentyfour',
  455.             'sidewinder', 'sightquestbot', 'skymob', 'sleek', 'slider_search', 'slurp', 'solbot', 'speedfind', 'speedy',
  456.             'spida', 'spider_monkey', 'spiderku', 'stackrambler', 'steeler', 'suchbot', 'suchknecht.at-robot', 'suntek',
  457.             'szukacz', 'surferf3', 'surfnomore', 'surveybot', 'suzuran', 'synobot', 'tarantula', 'teomaagent', 'teradex',
  458.             't-h-u-n-d-e-r-s-t-o-n-e', 'tigersuche', 'topiclink', 'toutatis', 'tracerlock', 'turnitinbot', 'tutorgig',
  459.             'uaportal', 'uasearch.kiev.ua', 'uksearcher', 'ultraseek', 'unitek', 'vagabondo', 'verygoodsearch', 'vivisimo',
  460.             'voilabot', 'voyager', 'vscooter', 'w3index', 'w3c_validator', 'wapspider', 'wdg_validator', 'webcrawler',
  461.             'webmasterresourcesdirectory', 'webmoose', 'websearchbench', 'webspinne', 'whatuseek', 'whizbanglab', 'winona',
  462.             'wire', 'wotbox', 'wscbot', 'www.webwombat.com.au', 'xenu', 'link', 'sleuth', 'xyro', 'yahoobot', 'yahoo!',
  463.             'slurp', 'yandex', 'yellopet-spider', 'zao/0', 'zealbot', 'zippy', 'zyborg', 'mediapartners-google'
  464.         );
  465.         $regex = '('.implode($bots, ')|(').')';
  466.         return eregi($regex, $_SERVER['HTTP_USER_AGENT']);
  467.     }
  468.  
  469.     public function is_Tor_connection()
  470.     {
  471.         $reverse_client_ip = implode('.', array_reverse(explode('.', $_SERVER['REMOTE_ADDR'])));
  472.         $reverse_server_ip = implode('.', array_reverse(explode('.', $_SERVER['SERVER_ADDR'])));
  473.         $hostname = $reverse_client_ip . "." . $_SERVER['SERVER_PORT'] . "." . $reverse_server_ip . ".ip-port.exitlist.torproject.org";
  474.         return gethostbyname($hostname) == "127.0.0.2";
  475.     }
  476. }
  477. /*
  478.  * Ok, this was the class. Now lets look how it work´s.
  479. */
  480. ?>
  481. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  482. <html>
  483.     <head>
  484.         <title>Tor, Bot, Mobile, Agent, Internet Sharing Provider, Flash detection PHP Script</title>
  485.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  486.     <!-- At this time we should include the client.js file. If you saved the js file in the
  487.     same folder as this php file use -->
  488.     <?= client::get_browser_detection_script(); ?>
  489.     <!-- Have you saved your client.js file in a Subfolder called 'js', then
  490.     you can write this
  491.     <?= client::get_browser_detection_script('js/'); ?> -->
  492.     </head>
  493.     <body>
  494.    
  495.     <?php
  496.         /*
  497.          * PHP usage:
  498.          */
  499.         $client = new client();
  500.         echo 'Tor detect: '.($client->is_Tor_connection()?'1':'0')."\n";
  501.         echo '<br>ip: '. $client->get_ip()."\n";
  502.         echo '<br>is anonyme ip: '.($client->is_anonyme_ip()?'1':'0')."\n";
  503.         echo '<br>is bot: '.($client->is_bot()?'1':'0')."\n";
  504.         echo '<br>Der Ger&auml;t ist mobiles Ger&auml;t: '.($client->is_mobile() ? $client->mobile :'0')."\n";
  505.         echo '<br>agent: '.$client->get_agent()."\n";
  506.         echo '<br>host: '.$client->get_host()."\n";
  507.         echo '<br>Internet Sharing Provider: '.$client->get_isp()."\n";
  508.         echo '<br>flashversion: ';
  509.         if ($client->flash_enabled) {
  510.             echo $client->flash_raw."\n";
  511.         }
  512.         else{
  513.             echo 'not installed'."\n";
  514.         }
  515.         echo '<br>WindowWidth: ' . $client->windowWidth ."\n";
  516.         echo '<br>WindowHeight: ' . $client->windowHeight ."\n";
  517.     ?>
  518.  
  519.     </body>
  520. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement