<?php if (!isset($_SESSION['app_devicetype'])) { require_once 'MobileDetect.php'; $detect = new MobileDetect(); if ($detect->isMobile() && !$detect->isTablet()) { $deviceType = 'phone'; } elseif ($detect->isTablet() && !$detect->isMobile()) { $deviceType = 'tablet'; } else { $deviceType = 'computer'; } $_SESSION['app_devicetype'] = $deviceType; } else { $deviceType = $_SESSION['app_devicetype']; } THCFrame\Events\Events::fire('plugin.mobiledetect.devicetype', array($deviceType));
set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), CORE_PATH))); set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), FCK_PATH))); set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), MOBILE_DETECT_PATH))); /** * Autoloader */ function sf_autoloader($class) { include $class . '.class.php'; } spl_autoload_register('sf_autoloader'); /** * detect mobile */ $detect = new MobileDetect(); $deviceType = $detect->isMobile() ? $detect->isTablet() ? TABLET : PHONE : COMPUTER; switch ($deviceType) { case TABLET: header("location:" . MOBILE_URL); break; case PHONE: header("location:" . MOBILE_URL); break; case COMPUTER: break; default: break; } /** * a new registry object */
public function test2Action() { $detect = new MobileDetect(); $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer'; $scriptVersion = $detect->getHttpHeaders(); $mobileGrade = $detect->mobileGrade(); var_dump($deviceType . "::" . $mobileGrade); var_dump($scriptVersion); die; }
/** * Detect device */ public function getPlatform() { $detect = new MobileDetect(); if ($detect->isMobile() || $detect->isTablet()) { return 'mobile'; } else { return 'pc'; } }
} foreach (glob(_MODULES . "/*.php") as $modules) { require_once $modules; } //======================================== Config $GLOBALS['CONFIG_DATABASE'] = array('host' => '192.168.75.140', 'user' => 'root', 'pwd' => 'admin888', 'dbname' => 'fxptpcn', 'port' => 3306, 'tb_prefix' => 'fx_'); //======================================= Smarty if (!defined('_SMARTY')) { define('_SMARTY', _LIBS . 'Smarty' . DS); } foreach (glob(_SMARTY . "/*.php") as $lib_smarty) { require_once $lib_smarty; } //====================================== Template $detect = new MobileDetect(); if ($detect->isMobile() || $detect->isTablet()) { header("Location: http://192.168.75.99:86/"); exit; } if ('192.168.75.99:86' == $_SERVER['HTTP_HOST']) { define('_DEVICE', 'mo' . DS); } else { define('_DEVICE', 'pc' . DS); } if (!defined('_SMARTY_TEMPLATE')) { define('_SMARTY_TEMPLATE', _SITE . 'template' . DS . _DEVICE); } if (!defined('_SMARTY_COMPILED')) { define('_SMARTY_COMPILED', _DATA . 'compileds' . DS . _DEVICE); } if (!defined('_SMARTY_CACHE')) {
/** * Return information about user browser * * @return array Array of information ('browsername'=>,'browseros'=>,'browserversion'=>,'layout'=>(classic|phone|tablet)) */ function getBrowserInfo() { $name = 'unknown'; $version = ''; $os = 'unknown'; $phone = ''; $tablet = ''; // If phone/smartphone, we set phone os name. if (preg_match('/android/i', $_SERVER["HTTP_USER_AGENT"])) { $os = $phone = 'android'; } elseif (preg_match('/blackberry/i', $_SERVER["HTTP_USER_AGENT"])) { $os = $phone = 'blackberry'; } elseif (preg_match('/iphone/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'ios'; $phone = 'iphone'; } elseif (preg_match('/ipod/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'ios'; $phone = 'iphone'; } elseif (preg_match('/palm/i', $_SERVER["HTTP_USER_AGENT"])) { $os = $phone = 'palm'; } elseif (preg_match('/symbian/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'symbian'; $phone = 'unknown'; } elseif (preg_match('/webos/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'webos'; $phone = 'unknown'; } elseif (preg_match('/maemo/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'maemo'; $phone = 'unknown'; } elseif (preg_match('/iemobile/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'windows'; $phone = 'unkown'; } elseif (preg_match('/windows ce/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'windows'; $phone = 'unkown'; } // OS if (preg_match('/android/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'android'; } elseif (preg_match('/linux/i', $_SERVER["HTTP_USER_AGENT"])) { $os = 'linux'; } // Name if (preg_match('/firefox(\\/|\\s)([\\d\\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'firefox'; $version = $reg[2]; } elseif (preg_match('/chrome(\\/|\\s)([\\d\\.]+)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'chrome'; $version = $reg[2]; } elseif (preg_match('/chrome/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'chrome'; } elseif (preg_match('/iceweasel/i', $_SERVER["HTTP_USER_AGENT"])) { $name = 'iceweasel'; $version = $reg[2]; } elseif (preg_match('/epiphany/i', $_SERVER["HTTP_USER_AGENT"])) { $name = 'epiphany'; $version = $reg[2]; } elseif ((empty($phone) || preg_match('/iphone/i', $_SERVER["HTTP_USER_AGENT"])) && preg_match('/safari(\\/|\\s)([\\d\\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'safari'; $version = $reg[2]; } elseif (preg_match('/opera(\\/|\\s)([\\d\\.]*)/i', $_SERVER["HTTP_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', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end // Other $firefox = 0; if (in_array($name, array('firefox', 'iceweasel'))) { $firefox = 1; } include_once DOL_DOCUMENT_ROOT . '/core/class/mobiledetect.class.php'; $detectmobile = new MobileDetect(); $phone = $detectmobile->isMobile(); $tablet = $detectmobile->isTablet(); unset($detectmobile); // free memory return array('browsername' => $name, 'browserversion' => $version, 'browseros' => $os, 'browserfirefox' => $firefox, 'layout' => $tablet ? 'tablet' : ($phone ? 'phone' : 'classic'), 'phone' => $phone, 'tablet' => $tablet); }
} foreach (glob(_MODULES . "/*.php") as $modules) { require_once $modules; } //======================================== Config $GLOBALS['CONFIG_DATABASE'] = array('host' => '192.168.75.140', 'user' => 'root', 'pwd' => 'admin888', 'dbname' => 'fxptpcn', 'port' => 3306, 'tb_prefix' => 'fx_'); //======================================= Smarty if (!defined('_SMARTY')) { define('_SMARTY', _LIBS . 'Smarty' . DS); } foreach (glob(_SMARTY . "/*.php") as $lib_smarty) { require_once $lib_smarty; } //====================================== Template $detect = new MobileDetect(); if ($detect->isMobile() || $detect->isTablet() && '192.168.75.99:86' == $_SERVER['HTTP_HOST']) { define('_DEVICE', 'mo' . DS); } else { define('_DEVICE', 'pc' . DS); } if (!defined('_SMARTY_TEMPLATE')) { define('_SMARTY_TEMPLATE', _SITE . 'template' . DS . _DEVICE); } if (!defined('_SMARTY_COMPILED')) { define('_SMARTY_COMPILED', _DATA . 'compileds' . DS . _DEVICE); } if (!defined('_SMARTY_CACHE')) { define('_SMARTY_CACHE', _DATA . 'caches' . DS . _DEVICE); } if (!defined('_UPLOAD')) { define('_UPLOAD', _SITE . 'upload' . DS);