Esempio n. 1
0
 /**
  * @covers Mobile_Detect::getMobileDetectionRulesExtended
  */
 public function testRulesExtended()
 {
     $md = new Mobile_Detect();
     $count = array_sum(array(count(Mobile_Detect::getPhoneDevices()), count(Mobile_Detect::getTabletDevices()), count(Mobile_Detect::getOperatingSystems()), count(Mobile_Detect::getBrowsers()), count(Mobile_Detect::getUtilities())));
     $md->setDetectionType(Mobile_Detect::DETECTION_TYPE_EXTENDED);
     $rules = $md->getRules();
     $this->assertEquals($count, count($rules));
 }
Esempio n. 2
0
File: demo.php Progetto: ssrsfs/blg
    ?>
class="true"<?php 
}
?>
><?php 
var_dump($check);
?>
</td>
        </tr>
        </tbody>
        <tbody>
        <tr>
            <th colspan="2">Custom detection methods</th>
        </tr>
        <?php 
foreach ($detect->getRules() as $name => $regex) {
    $check = $detect->{'is' . $name}();
    ?>
            <tr>
                    <td>is<?php 
    echo $name;
    ?>
()</td>
                    <td <?php 
    if ($check) {
        ?>
class="true"<?php 
    }
    ?>
><?php 
    var_dump($check);
Esempio n. 3
0
    } else {
        // non json payload
        $response["body"] = empty($HTTP_body) ? null : $HTTP_body;
    }
    // geoip integration
    if ($geoip) {
        $ip_source = array("IP-source" => $override_clientip && !empty($headers[$clientip_header]) ? $clientip_header : "REMOTE_ADDR");
        $response["geoip_info"] = array_merge($ip_source, get_geoip_info($clientip));
    }
    // Device detection integration
    if ($devicedetect) {
        require_once 'vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php';
        $detect = new Mobile_Detect();
        $response["device"]["is_mobile"] = $detect->isMobile() ? true : false;
        $response["device"]["is_tablet"] = $detect->isTablet() ? true : false;
        $rules = $detect->getRules();
        foreach ($rules as $rule => $value) {
            if ($detect->is($rule)) {
                $response["device"][$rule] = true;
            }
        }
    }
    echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
    echo PHP_EOL;
} else {
    header('Content-Type: text/plain');
    echo $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' ' . $_SERVER['SERVER_PROTOCOL'] . PHP_EOL;
    $headers = apache_request_headers();
    foreach ($headers as $header => $value) {
        echo "{$header}: {$value}";
        echo PHP_EOL;