/** * Public class constructor * @access public * @throws Exception when user has already been registered */ public function __construct() { if (isset($_SESSION['visitor']) && $_SESSION['visitor'] == "accessed") { throw new Exception("User already registered", 1); } else { $this->dateTime = Carbon::now(); $this->browser = BrowserDetect::browserFamily(); $this->OS = BrowserDetect::osName(); if (BrowserDetect::isMobile()) { $this->deviceType = "mobile"; } elseif (Browser::isTablet()) { $this->deviceType = "tablet"; } elseif (Browser::isDesktop()) { $this->deviceType = "desktop"; } elseif (Browser::isBot()) { $this->deviceType = "bot"; } else { $this->deviceType = "unknown"; } $this->deviceFamily = Broswer::deviceFamily(); $this->deviceModel = Browser::deviceModel(); $this->broadcastAddress = $_SERVER["REMOTE_ADDR"]; $this->model = new AccessModel($this); } }
/** * Returns the stream URL for the media. A direct link will be returned if * the user is on a mobile device or if the "singleFilePlaylist" setting * is enabled, otherwise the media playlist URL will be returned * @return string the stream URL */ protected function getStreamUrl() { if (count($this->_links) === 1 && (Setting::getBoolean('singleFilePlaylist') || (Browser::isMobile() || Browser::isTablet()))) { return $this->_links[0]->url; } else { return $this->getPlayListAction(); } }
/** * Returns whether the given user agent is of a tablet device. * * @param string $userAgent * @return boolean */ public static function isTablet($userAgent = '') { require_once CMS_DIR . 'lib/util/Browser.php'; $browser = new \Browser($userAgent); return $browser->isTablet(); }
<?php // start Theme class $theme = \Theme::instance(); // set page class $page_class = 'page_' . str_replace(['\\', '/'], '-', \Uri::string()); // check for mobile, tablet, pc device // get browser class for use instead of fuelphp agent which is does not work. include_once APPPATH . 'vendor' . DS . 'browser' . DS . 'lib' . DS . 'Browser.php'; $browser = new Browser(); $pc_class = ''; if (!$browser->isMobile() && !$browser->isTablet()) { $pc_class .= ' pc_device'; } elseif ($browser->isMobile()) { $pc_class .= ' mobile_device'; } elseif ($browser->isTablet()) { $pc_class .= ' tablet_device'; } unset($browser); // get admin cookie. if (!isset($cookie_admin) || !isset($cookie_admin['account_display_name'])) { $model_account = new \Model_Accounts(); $cookie_admin = $model_account->getAccountCookie('admin'); if ($cookie_admin == null) { $cookie_admin = $model_account->getAccountCookie(); } unset($model_account); if (is_array($cookie_admin) && array_key_exists('account_id', $cookie_admin)) { $account_id = $cookie_admin['account_id']; } }
foreach ($query->rows as $setting) { $config->set($setting['key'], $setting['value']); } } else { $config = unserialize($session->get('ntConfig_' . (int) STORE_ID)); } $config->set('config_store_id', STORE_ID); $loader->library('browser'); $browser = new Browser(); if ($browser->isMobile()) { if ($config->get('config_redirect_when_mobile')) { location($config->get('config_mobile_url')); } else { $config->set('config_template', $config->get('config_mobile_template')); } } elseif ($browser->isTablet()) { if ($config->get('config_redirect_when_tablet')) { location($config->get('config_tablet_url')); } else { $config->set('config_template', $config->get('config_tablet_template')); } } elseif ($browser->isFacebook()) { if ($config->get('config_redirect_when_facebbok')) { location($config->get('config_facebook_url')); } else { $config->set('config_template', $config->get('config_facebook_theme')); } } $response->addHeader('Content-Type: text/html; charset=utf-8'); // Language Detection $languages = array();
// xac dinh co phai User_Agent cua NukeViet hay khong if (NV_USER_AGENT == 'NUKEVIET CMS ' . $global_config['version'] . '. Developed by VINADES. Url: http://nukeviet.vn. Code: ' . md5($global_config['sitekey'])) { define('NV_IS_MY_USER_AGENT', true); } // Xac dinh borwser cua client $browser = new Browser(NV_USER_AGENT); $client_info['browser'] = array(); $client_info['browser']['key'] = $browser->getBrowserKey(); $client_info['browser']['name'] = $browser->getBrowser(); if (preg_match('/^([0-9]+)\\.(.*)$/', $browser->getVersion(), $matches)) { $client_info['browser']['version'] = (int) $matches[1]; } else { $client_info['browser']['version'] = 0; } $client_info['is_mobile'] = $browser->isMobile(); $client_info['is_tablet'] = $browser->isTablet(); $client_info['is_bot'] = $browser->isRobot(); $client_info['client_os'] = array('key' => $browser->getPlatformKey(), 'name' => $browser->getPlatform()); $is_mobile_tablet = $client_info['is_mobile'] . '-' . $client_info['is_tablet']; if ($is_mobile_tablet != $nv_Request->get_string('is_mobile_tablet', 'session')) { $nv_Request->set_Session('is_mobile_tablet', $is_mobile_tablet); $nv_Request->unset_request('nv' . NV_LANG_DATA . 'themever', 'cookie'); } // Ket noi voi class chong flood if ($global_config['is_flood_blocker'] and !$nv_Request->isset_request('admin', 'session') and (!$nv_Request->isset_request('second', 'get') or $nv_Request->isset_request('second', 'get') and $client_info['is_myreferer'] != 1)) { require NV_ROOTDIR . '/includes/core/flood_blocker.php'; } // Captcha if ($nv_Request->isset_request('scaptcha', 'get')) { require NV_ROOTDIR . '/includes/core/captcha.php'; }