Exemplo n.º 1
0
 /**
  * A reference accessor the static singleton instantiation of the adapter
  * for the user agent, constructing the adapter with the user agent string
  * if the adapter has not already been instantiated.
  *
  * @return User_Agent_Adapter_Interface
  */
 public static function &adapter()
 {
     if (self::$_adapter === null) {
         if (($ua = User_Agent::get()) !== false) {
             require_once strtolower(Config::get('user_agent', 'adapter')) . '.class.php';
             $adapter_class = Config::get('user_agent', 'adapter');
             self::$_adapter = new $adapter_class($ua);
         } else {
             require_once 'user_agent_empty_adapter.class.php';
             self::$_adapter = new User_Agent_Empty_Adapter();
         }
     }
     return self::$_adapter;
 }
Exemplo n.º 2
0
Arquivo: js.php Projeto: ruucla/mwf
 * @uses User_Agent
 */
/** Set the header type and a cache of zero because this is very dynamic. */
header('Content-Type: text/javascript');
header("Cache-Control: max-age=0");
/** User_Agent is required to determine visitor device type. */
@(require_once '../lib/user_agent.class.php');
@(include_once dirname(dirname(__FILE__)) . '/config.php');
/**
 * Script does nothing if class can't load, user isn't mobile, or the GET 'm'
 * parameter isn't set (meaning the script wouldn't know where to redirect).
 * This also does nothing if the User_Agent fetch fails. This is a safety
 * fallback to leave the behavior on other sites as though they're already
 * on the other site.
 */
if (!class_exists('User_Agent') || User_Agent::get() === false || !User_Agent::is_mobile(false) || !isset($_GET['m'])) {
    die;
}
/** The page to redirect to is GET 'm' */
$mobile_page = $_GET['m'];
/**
 * The domain specifies a suffix that is optionally appended to the cookie name
 * to create an override setting for only particular pages.
 */
$domain_key = isset($_GET['d']) ? '_' . substr(md5($_GET['d']), 0, 8) : '';
/** Check to see if an override cookie exists. */
$cookie_override = isset($_COOKIE[Config::get('global', 'cookie_prefix') . 'ovrrdr' . $domain_key]) && $_COOKIE[Config::get('global', 'cookie_prefix') . 'ovrrdr' . $domain_key] == 1 ? 1 : 0;
/** The referrer is the page including this script - it may include GET 'ovrrdr'. */
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$referer_uri = strpos($referer, '?') !== false ? substr($referer, strpos($referer, '?') + 1, strlen($referer) - strpos($referer, '?') - 1) : '';
/** Find GET 'ovrrdr' if it exists in the referrer's URI. */