/** * Check if we are coming from a mobile browser and set * the $mobile_set variable for use by controllers. * @ignore */ function mobileInit() { if (!Controller::$mobile_set && isset($_GET['mobile'])) { $this->is_mobile = (bool) $_GET['mobile']; $mobile_device = isMobile($_SERVER['HTTP_USER_AGENT']); if (!$this->is_mobile && $mobile_device) { $cookie = 'o'; } else { if ($this->is_mobile) { $cookie = 'y'; } else { $cookie = 'n'; } } setcookie('m', $cookie, time() + 86400); $_COOKIE['m'] = $cookie; Controller::$mobile_set = true; } else { if (!isset($_COOKIE['m'])) { $this->is_mobile = isMobile($_SERVER['HTTP_USER_AGENT']); $cookie = $this->is_mobile ? 'y' : 'n'; setcookie('m', $cookie, time() + 31536000); $_COOKIE['m'] = $cookie; } else { $this->is_mobile = $_COOKIE['m'] == 'y' ? true : false; } } }