Example #1
0
function qa_is_mobile_probably()
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    // inspired by: http://dangerousprototypes.com/docs/PhpBB3_MOD:_Replacement_mobile_browser_detection_for_mobile_themes
    $loweragent = strtolower(@$_SERVER['HTTP_USER_AGENT']);
    if (strpos($loweragent, 'ipad') !== false) {
        // consider iPad as desktop
        return false;
    }
    $mobileheaders = array('HTTP_X_OPERAMINI_PHONE', 'HTTP_X_WAP_PROFILE', 'HTTP_PROFILE');
    foreach ($mobileheaders as $header) {
        if (isset($_SERVER[$header])) {
            return true;
        }
    }
    if (qa_string_matches_one($loweragent, array('android', 'phone', 'mobile', 'windows ce', 'palm', ' mobi', 'wireless', 'blackberry', 'opera mini', 'symbian', 'nokia', 'samsung', 'ericsson,', 'vodafone/', 'kindle', 'ipod', 'wap1.', 'wap2.', 'sony', 'sanyo', 'sharp', 'panasonic', 'philips', 'pocketpc', 'avantgo', 'blazer', 'ipaq', 'up.browser', 'up.link', 'mmp', 'smartphone', 'midp'))) {
        return true;
    }
    return qa_string_matches_one(strtolower(@$_SERVER['HTTP_ACCEPT']), array('application/vnd.wap.xhtml+xml', 'text/vnd.wap.wml'));
}
 public function test__qa_string_matches_one()
 {
     $matches = array('dyed', 'shallot', 'belt', 'fashion');
     $nonMatches = array('dyed', 'shallot', 'buckle', 'fashion');
     $this->assertTrue(qa_string_matches_one($this->strBasic, $matches));
     $this->assertFalse(qa_string_matches_one($this->strBasic, $nonMatches));
 }