本文整理汇总了PHP中Mobile_Detect::is方法的典型用法代码示例。如果您正苦于以下问题:PHP Mobile_Detect::is方法的具体用法?PHP Mobile_Detect::is怎么用?PHP Mobile_Detect::is使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mobile_Detect
的用法示例。
在下文中一共展示了Mobile_Detect::is方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lfGetRanking
/**
* おすすめ商品検索.
*
* @return array $arrBestProducts 検索結果配列
*/
public function lfGetRanking()
{
$arrRecommends = parent::lfGetRanking();
$detect = new Mobile_Detect();
$cur_category_id = 0;
if ($detect->is("AndroidOS")) {
$cur_category_id = 1;
} elseif ($detect->is("iOS")) {
$cur_category_id = 2;
} else {
return array();
}
$response = array();
if (count($arrRecommends) > 0) {
$objProduct = new SC_Product_Ex();
foreach ($arrRecommends as $value) {
$product_id = $value['product_id'];
$category_id = $objProduct->getCategoryIds($product_id);
if (in_array($cur_category_id, $category_id)) {
// nop
$response[] = $value;
}
}
}
return $response;
}
示例2:
/**
*
* @param Mobile_Detect $detect
*/
function check_os()
{
$detect = new Mobile_Detect();
if ($detect->is("iOS")) {
// OK
} else {
SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
}
}
示例3: elseif
function LC_Page_iOS_Products_List_action_after(LC_Page_Products_List $objPage)
{
$detect = new Mobile_Detect();
$category_id = self::sfGetCategoryId();
if ($detect->isMobile()) {
if ($detect->is("AndroidOS")) {
$cur_category_id = 1;
} elseif ($detect->is("iOS")) {
$cur_category_id = 2;
} else {
SC_Utils_Ex::sfDispSiteError(PAGE_ERROR);
}
if ($category_id != $cur_category_id) {
$category_id = $cur_category_id;
SC_Response_Ex::reload(compact("category_id"));
}
}
}
示例4: testBasicMethods
public function testBasicMethods()
{
$this->assertNotEmpty($this->detect->getScriptVersion());
$this->detect->setHttpHeaders(array('SERVER_SOFTWARE' => 'Apache/2.2.15 (Linux) Whatever/4.0 PHP/5.2.13', 'REQUEST_METHOD' => 'POST', 'HTTP_HOST' => 'home.ghita.org', 'HTTP_X_REAL_IP' => '1.2.3.4', 'HTTP_X_FORWARDED_FOR' => '1.2.3.5', 'HTTP_CONNECTION' => 'close', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A523 Safari/8536.25', 'HTTP_ACCEPT' => 'text/vnd.wap.wml, application/json, text/javascript, */*; q=0.01', 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest', 'HTTP_REFERER' => 'http://mobiledetect.net', 'HTTP_PRAGMA' => 'no-cache', 'HTTP_CACHE_CONTROL' => 'no-cache', 'REMOTE_ADDR' => '11.22.33.44', 'REQUEST_TIME' => '01-10-2012 07:57'));
//12 because only 12 start with HTTP_
$this->assertCount(12, $this->detect->getHttpHeaders());
$this->assertTrue($this->detect->checkHttpHeadersForMobile());
$this->detect->setUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A523 Safari/8536.25');
$this->assertNotEmpty($this->detect->getUserAgent());
$this->assertTrue($this->detect->isMobile());
$this->assertFalse($this->detect->isTablet());
$this->assertTrue($this->detect->isIphone());
$this->assertTrue($this->detect->isiphone());
$this->assertTrue($this->detect->isiOS());
$this->assertTrue($this->detect->isios());
$this->assertTrue($this->detect->is('iphone'));
$this->assertTrue($this->detect->is('ios'));
}
示例5: init
/**
* Page を初期化する.
*
* @return void
*/
function init()
{
parent::init();
$detect = new Mobile_Detect();
if ($detect->is("FireFox")) {
$this->tpl_mainpage = "unsupported/firefox.tpl";
// SC_Utils_Ex::sfDispSiteError ( FREE_ERROR_MSG, "", FALSE, "Firefox は対応していません", TRUE );
}
}
示例6: isSmartphone
public function isSmartphone()
{
$detect = new Mobile_Detect();
if ($detect->is("AndroidOS")) {
// AndroidOS の場合 Tab 問わず
return true;
} elseif (parent::isSmartphone()) {
// それ以外の端末の場合 標準の仕様
return true;
} elseif ($detect->match("bingbot|Twitterbot|msnbot")) {
// bing bot の場合 モバイル
return true;
}
return false;
}
示例7: lazy_load_init
function lazy_load_init()
{
elgg_extend_view('css/elgg', 'lazy_load/css');
require_once dirname(__FILE__) . '/vendors/Mobile_Detect.php';
$mobile = new Mobile_Detect();
if (!$mobile->is('iOS')) {
// register our js library
$js = elgg_get_simplecache_url('js', 'lazy_load/js');
elgg_register_simplecache_view('js/lazy_load/js');
elgg_register_js('lazy_load.js', $js);
//use lazy load on all pages
elgg_load_js('lazy_load.js');
elgg_register_plugin_hook_handler('view', 'page/default', 'lazy_load_defaultpage');
}
}
示例8: getArrProducts
public function getArrProducts()
{
$objPage = new LC_Page_Products_List_Ex();
$objPage->orderby = "date";
$objPage->init();
$objPage->arrSearchData = array();
$detect = new Mobile_Detect();
if ($detect->is("iOS")) {
$objPage->arrSearchData["category_id"] = 2;
} else {
$objPage->arrSearchData["category_id"] = 1;
}
$arrSearchCondition = $objPage->lfGetSearchCondition($objPage->arrSearchData);
$arrProducts = $objPage->lfGetProductsList($arrSearchCondition, NEW_CONTENTS_SEARCH_PMAX, 0, $this->objProduct);
unset($arrProducts["productStatus"]);
return $arrProducts;
}
示例9: action
function action()
{
parent::action();
if (is_array($this->arrResults) && count($this->arrResults) > 0) {
$objPurchase = new SC_Helper_Purchase_Ex();
$detect = new Mobile_Detect();
foreach ($this->arrResults as &$order) {
$order["detail"] = $objPurchase->getOrderDetail($order["order_id"]);
if (isset($order["useragent"])) {
$detect->setUserAgent($order["useragent"]);
$useragent = array();
if ($detect->is("AndroidOS")) {
preg_match("{.*;([^;]+) Build}", $order["useragent"], $useragent);
$order["device"] = $useragent[1];
}
}
}
}
}
示例10: array
';
$detect = new Mobile_Detect();
$html .= '<table border="1">';
$html .= '
<tr>
<th>UA</th>
<th>isMobile()</th>
<th>isTablet()</th>
<th>is(\'chrome\')</th>
<th>isiOS()</th>
<th>isAndroidOS()</th>
<th>is(\'bot\')</th>
</tr>
';
foreach ($userAgents as $userAgent) {
$isChrome = $detect->is('chrome', $userAgent);
$isiOS = $detect->isiOS();
$isAndroidOS = $detect->isAndroidOS();
$isBot = $detect->is('bot', $userAgent);
$isMobile = $detect->isMobile($userAgent, array());
$isTablet = $detect->isTablet($userAgent);
$html .= '<tr>';
$html .= '<td>' . $userAgent . '</td>';
$html .= '<td class="' . ($isMobile ? 'true' : 'false') . '">' . ($isMobile ? 'true' : 'false') . '</td>';
$html .= '<td class="' . ($isTablet ? 'true' : 'false') . '">' . ($isTablet ? 'true' : 'false') . '</td>';
$html .= '<td class="' . ($isChrome ? 'true' : 'false') . '">' . ($isChrome ? 'true' : 'false') . '</td>';
$html .= '<td class="' . ($isiOS ? 'true' : 'false') . '">' . ($isiOS ? 'true' : 'false') . '</td>';
$html .= '<td class="' . ($isAndroidOS ? 'true' : 'false') . '">' . ($isAndroidOS ? 'true' : 'false') . '</td>';
$html .= '<td class="' . ($isBot ? 'true' : 'false') . '">' . ($isBot ? 'true' : 'false') . '</td>';
$html .= '</tr>';
}
示例11: empty
$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;
}
$HTTP_body = file_get_contents('php://input');
示例12: init
function init()
{
parent::init();
$objCustomer = new SC_Customer_Ex();
if (isset($_GET["sid"]) && isset($_GET["admin"])) {
$sid = $_REQUEST["sid"];
$email = $objCustomer->getValue("email");
$osid = session_id();
if ($osid != $sid) {
session_destroy();
session_id($sid);
session_start();
}
$objCustomer->setLogin($email);
$get = $_GET;
unset($get["sid"]);
SC_Response_Ex::reload($get, true);
}
$objQuery = SC_Query_Ex::getSingletonInstance();
$objProduct = new SC_Product_Ex();
if (GC_Utils_Ex::isFrontFunction() && $this->skip_load_page_layout == false) {
$objCustomer = new SC_Customer_Ex();
// 画面更新毎に情報を更新する
if ($objCustomer->isLoginSuccess()) {
// 初回アクセス時に更新
$objCustomer->updateSession();
$this->tpl_login = true;
$this->tpl_point = $objCustomer->getValue("point");
$this->tpl_customer_id = $objCustomer->getValue("customer_id");
$this->tpl_first_buy_date = $objCustomer->getValue("first_buy_date");
$this->tpl_carrier = $objCustomer->getValue("carrier");
$downloadable_days = $this->arrSiteInfo["downloadable_days"];
$downloadable_days_unlimited = $this->arrSiteInfo["downloadable_days_unlimited"];
$date = null;
if ($downloadable_days_unlimited) {
$date = SC_Utils_Ex::sfGetTimestamp(RELEASE_YEAR, 1, 1, false);
$date2 = SC_Utils_Ex::sfGetTimestamp(9999, 12, 31, false);
} else {
$xdate = strtotime("-{$downloadable_days} day");
$date = SC_Utils_Ex::sfGetTimestamp(date("Y", $xdate), date("m", $xdate), date("d", $xdate), false);
$xdate = strtotime("+{$downloadable_days} day");
$date2 = SC_Utils_Ex::sfGetTimestamp(date("Y", $xdate), date("m", $xdate), date("d", $xdate), false);
}
$this->downloadable_days = $date;
$this->downloadable_days2 = $date2;
$objPurchase = new SC_Helper_Purchase_Ex();
$arrOrderId = $objQuery->getCol("order_id", "dtb_order", "payment_date > ? AND customer_id = ?", array($date, $this->tpl_customer_id));
$this->arrRedownloadProduct = array();
foreach ($arrOrderId as $order_id) {
$arrOrderDetail = $objPurchase->getOrderDetail($order_id, true);
$this->arrRedownloadProduct = array_merge($this->arrRedownloadProduct, $arrOrderDetail);
}
// 再ダウンロード可能な商品一覧
$this->arrRedownloadProduct = SC_Utils_Ex::makeArrayIDToKey("product_id", $this->arrRedownloadProduct);
foreach ($this->arrRedownloadProduct as $product_id => $row) {
$row["product"] = $objProduct->getDetail($product_id);
$this->arrRedownloadProduct[$product_id] = $row;
}
} else {
$this->tpl_login = false;
$this->tpl_point = 0;
$this->tpl_customer_id = 0;
$this->tpl_first_buy_date = null;
$this->tpl_carrier = 9;
$this->arrRedownloadProduct = array();
}
$objDb = new SC_Helper_DB_Ex();
if ($objDb->sfColumnExists("cp_dtb_customer_transaction", "id")) {
$where = " customer_id = ? AND transaction_status = ? AND continue_account_id IS NOT NULL AND del_flg = 0";
$arrWhereVal = array($this->tpl_customer_id, 40);
if ($objQuery->exists("cp_dtb_customer_transaction", $where, $arrWhereVal)) {
// OK
} else {
switch (basename(dirname($_SERVER["SCRIPT_NAME"]))) {
case "au":
break;
default:
if ($objCustomer->isLoginSuccess()) {
$objCustomer->EndSession();
SC_Response_Ex::reload();
}
break;
}
}
}
$objCategory = new SC_Helper_Category_Ex();
$this->arrCommonCategory = $objCategory->getList(true);
$this->arrCommonCategoryTree = $objCategory->getTree();
$detect = new Mobile_Detect();
$script_file = $_SERVER["SCRIPT_NAME"];
$script_file = ltrim($script_file, "/");
$script_file2 = str_replace("ios/", "", $script_file);
if ($detect->is("iOS")) {
if (file_exists(HTML_REALDIR . "ios/{$script_file}")) {
SC_Response_Ex::sendRedirect(HTTP_URL . "ios/{$script_file}", $_GET);
}
} elseif (strcmp($script_file, $script_file2) !== 0) {
SC_Response_Ex::sendRedirect(HTTP_URL . "{$script_file2}", $_GET);
}
$_SESSION["is_android"] = $detect->is("AndroidOS");
//.........这里部分代码省略.........
示例13:
* @filename layout.php
* @author Daniel Scheidler
* @copyright Oktober 2012
*/
$detect = new Mobile_Detect();
$bannerWidth = 780;
$bannerHeight = 195;
$mainSizeInternal = 620;
$_SESSION['additionalLayoutHeight'] = $bannerHeight;
$mainHeight = 390;
$mainWidth = $mainSizeInternal;
if (isset($_SESSION['MENU_PARENT']) && $_SESSION['MENU_PARENT'] != "Steuerung" && isset($_SESSION['runLink']) && $_SESSION['runLink'] != "start") {
$mainWidth = $bannerWidth;
}
if ($detect->isMobile()) {
if ($detect->is('iOS')) {
// iOS
include "layout_apple.php";
exit;
}
if ($detect->isTablet()) {
// Tablet
include "layout_tablet.php";
exit;
}
// Any other mobile device.
include "layout_mobile.php";
exit;
}
$sqlNoFrame = "SELECT * FROM homecontrol_noframe WHERE ip = '" . $_SERVER['REMOTE_ADDR'] . "'";
//$_SERVER['HTTP_X_FORWARDED_FOR']
示例14: getServerEquipmentInfo
/**
* get server equipment info by SERVER.
* @param array $server $_SERVER
* @return array
*/
public static function getServerEquipmentInfo($server)
{
$base_path = dirname(__FILE__);
require_once $base_path . DIRECTORY_SEPARATOR . 'Mobile_Detect.php';
$result = array();
$detect = new Mobile_Detect($server);
$isMobile = $detect->isMobile();
if ($isMobile) {
$mobileDetectRules = $detect->getMobileDetectionRules();
$tmpArr = array();
foreach ($mobileDetectRules as $k => $v) {
if ($detect->is($k)) {
$tmpArr[] = $k;
}
}
$result['equipment_type'] = 'tablet';
$result['equipment'] = $tmpArr[0];
$result['equipment_os'] = $tmpArr[1];
$result['equipment_browser'] = $tmpArr[2];
} else {
require_once $base_path . DIRECTORY_SEPARATOR . 'PC_User_Agent.php';
$pcUserAgent = new PC_User_Agent($server);
$result['equipment_type'] = 'pc';
$browserRules = $pcUserAgent->getBrowsers();
foreach ($browserRules as $k => $v) {
if ($pcUserAgent->is($k)) {
$browser = $k;
break;
}
}
$result['equipment_browser'] = $browser ? $browser : '';
$systemsRules = $pcUserAgent->getOperatingSystems();
foreach ($systemsRules as $k => $v) {
if ($pcUserAgent->is($k)) {
$system = $k;
break;
}
}
$result['equipment_os'] = $system ? $system : '';
$result['equipment'] = '';
}
return $result;
}
示例15: getBrowserInfo
/**
* Return information about user browser
*
* Returns array with the following format:
* array(
* 'browsername' => Browser name (firefox|chrome|iceweasel|epiphany|safari|opera|ie|unknown)
* 'browserversion' => Browser version. Empty if unknown
* 'browseros' => Set with mobile OS (android|blackberry|ios|palm|symbian|webos|maemo|windows|unknown)
* 'layout' => (tablet|phone|classic)
* 'phone' => empty if not mobile, (android|blackberry|ios|palm|unknown) if mobile
* 'tablet' => true/false
* )
*
* @param string $user_agent Content of $_SERVER["HTTP_USER_AGENT"] variable
* @return array Check function documentation
*/
function getBrowserInfo($user_agent)
{
include_once DOL_DOCUMENT_ROOT . '/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
$name = 'unknown';
$version = '';
$os = 'unknown';
$phone = '';
$detectmobile = new Mobile_Detect(null, $user_agent);
$tablet = $detectmobile->isTablet();
if ($detectmobile->isMobile()) {
$phone = 'unknown';
// If phone/smartphone, we set phone os name.
if ($detectmobile->is('AndroidOS')) {
$os = $phone = 'android';
} elseif ($detectmobile->is('BlackBerryOS')) {
$os = $phone = 'blackberry';
} elseif ($detectmobile->is('iOS')) {
$os = 'ios';
$phone = 'iphone';
} elseif ($detectmobile->is('PalmOS')) {
$os = $phone = 'palm';
} elseif ($detectmobile->is('SymbianOS')) {
$os = 'symbian';
} elseif ($detectmobile->is('webOS')) {
$os = 'webos';
} elseif ($detectmobile->is('MaemoOS')) {
$os = 'maemo';
} elseif ($detectmobile->is('WindowsMobileOS') || $detectmobile->is('WindowsPhoneOS')) {
$os = 'windows';
}
}
// OS
if (preg_match('/linux/i', $user_agent)) {
$os = 'linux';
} elseif (preg_match('/macintosh/i', $user_agent)) {
$os = 'macintosh';
}
// Name
if (preg_match('/firefox(\\/|\\s)([\\d\\.]*)/i', $user_agent, $reg)) {
$name = 'firefox';
$version = $reg[2];
} elseif (preg_match('/chrome(\\/|\\s)([\\d\\.]+)/i', $user_agent, $reg)) {
$name = 'chrome';
$version = $reg[2];
} elseif (preg_match('/chrome/i', $user_agent, $reg)) {
$name = 'chrome';
} elseif (preg_match('/iceweasel/i', $user_agent)) {
$name = 'iceweasel';
$version = $reg[2];
} elseif (preg_match('/epiphany/i', $user_agent)) {
$name = 'epiphany';
$version = $reg[2];
} elseif (preg_match('/safari(\\/|\\s)([\\d\\.]*)/i', $user_agent, $reg)) {
$name = 'safari';
$version = $reg[2];
} elseif (preg_match('/opera(\\/|\\s)([\\d\\.]*)/i', $user_agent, $reg)) {
$name = 'opera';
$version = $reg[2];
} elseif (preg_match('/(MSIE\\s([0-9]+\\.[0-9]))|.*(Trident\\/[0-9]+.[0-9];\\srv:([0-9]+\\.[0-9]+))/i', $user_agent, $reg)) {
$name = 'ie';
$version = end($reg);
}
// MS products at end
if ($tablet) {
$layout = 'tablet';
} elseif ($phone) {
$layout = 'phone';
} else {
$layout = 'classic';
}
return array('browsername' => $name, 'browserversion' => $version, 'browseros' => $os, 'layout' => $layout, 'phone' => $phone, 'tablet' => $tablet);
}