示例#1
0
function getBrowser($u_agent)
{
    $bname = 'Unknown';
    $version = "";
    // Next get the name of the useragent yes seperately and for good reason
    if (preg_match('/MSIE/i', $u_agent) && !preg_match('/Opera/i', $u_agent)) {
        $bname = 'Internet Explorer';
        $ub = "MSIE";
    } elseif (preg_match('/Firefox/i', $u_agent)) {
        $bname = 'Mozilla Firefox';
        $ub = "Firefox";
    } elseif (preg_match('/Chrome/i', $u_agent)) {
        $bname = 'Google Chrome';
        $ub = "Chrome";
    } elseif (preg_match('/Safari/i', $u_agent)) {
        $bname = 'Apple Safari';
        $ub = "Safari";
    } elseif (preg_match('/Opera/i', $u_agent)) {
        $bname = 'Opera';
        $ub = "Opera";
    } elseif (preg_match('/Netscape/i', $u_agent)) {
        $bname = 'Netscape';
        $ub = "Netscape";
    }
    // finally get the correct version number
    $known = array('Version', $ub, 'other');
    $pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
    if (!preg_match_all($pattern, $u_agent, $matches)) {
        // we have no matching number just continue
    }
    // see how many we have
    $i = count($matches['browser']);
    if ($i != 1) {
        //we will have two since we are not using 'other' argument yet
        //see if version is before or after the name
        if (strripos($u_agent, "Version") < strripos($u_agent, $ub)) {
            $version = $matches['version'][0];
        } else {
            $version = $matches['version'][1];
        }
    } else {
        $version = $matches['version'][0];
    }
    // check if we have a number
    if ($version == null || $version == "") {
        $version = "?";
    }
    return array('name' => $bname, 'version' => $version, 'vender' => $ub, 'os' => os_info($u_agent));
}
 function __construct($option = null, $state = 'off')
 {
     global $smarty;
     switch ($state) {
         case 1:
         case 'on':
             ob_start();
             switch ($option) {
                 case 'os':
                     os_info();
                     break;
                 case 'browser':
                     browser_info();
                     break;
                 case 'session':
                     session_info();
                     break;
                 case 'server':
                     server_info();
                     break;
                 case 'request':
                     request_info();
                     break;
                 case 'class':
                     class_info();
                     break;
                 case 'includes':
                     includes_info();
                     break;
                 case 'mail':
                     mail_info();
                     break;
                 case 'system':
                 default:
                     system_info();
                     break;
             }
             $output = ob_get_clean();
             $smarty->assign('output', $output);
             $smarty->display(DEBUG_PATH . 'debug.phtml');
             break;
         case 0:
         case 'off':
         default:
             break;
     }
 }
function system_info()
{
    os_info();
    browser_info();
    session_info();
    server_info();
    request_info();
    class_info();
    includes_info();
    mail_info();
}