当前位置: 首页>>代码示例>>PHP>>正文


PHP request::user_agent方法代码示例

本文整理汇总了PHP中request::user_agent方法的典型用法代码示例。如果您正苦于以下问题:PHP request::user_agent方法的具体用法?PHP request::user_agent怎么用?PHP request::user_agent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在request的用法示例。


在下文中一共展示了request::user_agent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setup

 public function setup()
 {
     $this->_ip_address = Input::instance()->ip_address;
     $this->_user_agent = request::user_agent();
     $this->_save = $_SERVER;
     $_SERVER["HTTP_ACCEPT"] = "HTTP_ACCEPT";
     $_SERVER["HTTP_ACCEPT_CHARSET"] = "HTTP_ACCEPT_CHARSET";
     $_SERVER["HTTP_ACCEPT_ENCODING"] = "HTTP_ACCEPT_ENCODING";
     $_SERVER["HTTP_ACCEPT_LANGUAGE"] = "HTTP_ACCEPT_LANGUAGE";
     $_SERVER["HTTP_CONNECTION"] = "HTTP_CONNECTION";
     $_SERVER["HTTP_HOST"] = "HTTP_HOST";
     $_SERVER["HTTP_REFERER"] = "HTTP_REFERER";
     $_SERVER["QUERY_STRING"] = "QUERY_STRING";
     $_SERVER["REMOTE_ADDR"] = "REMOTE_ADDR";
     $_SERVER["REMOTE_HOST"] = "REMOTE_HOST";
     $_SERVER["REMOTE_PORT"] = "REMOTE_PORT";
     request::set_user_agent("HTTP_USER_AGENT");
 }
开发者ID:andyst,项目名称:gallery3,代码行数:18,代码来源:Comment_Helper_Test.php

示例2: sendHeaders

 /**
  * See system/helpers/download.php
  */
 private function sendHeaders($filename, $filesize = null)
 {
     if (!is_null($filesize)) {
         header('Content-Length: ' . $filesize);
     }
     // Retrieve MIME type by extension
     $mime = Kohana::config('mimes.' . strtolower(substr(strrchr($filename, '.'), 1)));
     $mime = empty($mime) ? 'application/octet-stream' : $mime[0];
     header("Content-Type: {$mime}");
     header('Content-Transfer-Encoding: binary');
     // Send headers necessary to invoke a "Save As" dialog
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     // Prevent caching
     header('Expires: Thu, 01 Jan 1970 00:00:00 GMT');
     $pragma = 'no-cache';
     $cachecontrol = 'no-cache, max-age=0';
     // request::user_agent('browser') seems bugged
     if (request::user_agent('browser') === 'Internet Explorer' || stripos(request::user_agent(), 'msie') !== false || stripos(request::user_agent(), 'internet explorer') !== false) {
         if (request::protocol() === 'https') {
             // See http://support.microsoft.com/kb/323308/en-us
             $pragma = 'cache';
             $cachecontrol = 'private';
         } else {
             if (request::user_agent('version') <= '6.0') {
                 $pragma = '';
                 $cachecontrol = 'must-revalidate, post-check=0, pre-check=0';
             }
         }
     }
     header('Pragma: ' . $pragma);
     header('Cache-Control: ' . $cachecontrol);
 }
开发者ID:Retroguy,项目名称:gallery3-contrib,代码行数:35,代码来源:downloadalbum.php

示例3: create

 /**
  * Create a new session.
  *
  * @param   array  variables to set after creation
  * @param   string Force a specific session_id
  * @return  void
  */
 public function create($vars = NULL, $session_id = NULL)
 {
     // Destroy any current sessions
     $this->destroy();
     if (Session::$config['driver'] !== 'native') {
         // Set driver name
         $driver = 'Session_' . ucfirst(Session::$config['driver']) . '_Driver';
         // Load the driver
         if (!Kohana::auto_load($driver)) {
             throw new Kohana_Exception('The :driver: driver for the :library: library could not be found', array(':driver:' => Session::$config['driver'], ':library:' => get_class($this)));
         }
         // Initialize the driver
         Session::$driver = new $driver();
         // Validate the driver
         if (!Session::$driver instanceof Session_Driver) {
             throw new Kohana_Exception('The :driver: driver for the :library: library must implement the :interface: interface', array(':driver:' => Session::$config['driver'], ':library:' => get_class($this), ':interface:' => 'Session_Driver'));
         }
         // Register non-native driver as the session handler
         session_set_save_handler(array(Session::$driver, 'open'), array(Session::$driver, 'close'), array(Session::$driver, 'read'), array(Session::$driver, 'write'), array(Session::$driver, 'destroy'), array(Session::$driver, 'gc'));
     }
     // Validate the session name
     if (!preg_match('~^(?=.*[a-z])[a-z0-9_]++$~iD', Session::$config['name'])) {
         throw new Kohana_Exception('The session_name, :session:, is invalid. It must contain only alphanumeric characters and underscores. Also at least one letter must be present.', array(':session:' => Session::$config['name']));
     }
     // Name the session, this will also be the name of the cookie
     session_name(Session::$config['name']);
     // Set the session cookie parameters
     session_set_cookie_params(Session::$config['expiration'], Kohana::config('cookie.path'), Kohana::config('cookie.domain'), Kohana::config('cookie.secure'), Kohana::config('cookie.httponly'));
     $cookie = cookie::get(Session::$config['name']);
     if ($session_id === NULL) {
         // Reopen session from signed cookie value.
         $session_id = $cookie;
     }
     // Reopen an existing session if supplied
     if (!is_null($session_id)) {
         session_id($session_id);
     }
     // Start the session!
     session_start();
     // Put session_id in the session variable
     $_SESSION['session_id'] = session_id();
     // Set defaults
     if (!isset($_SESSION['_kf_flash_'])) {
         $_SESSION['total_hits'] = 0;
         $_SESSION['_kf_flash_'] = array();
         $_SESSION['user_agent'] = request::user_agent();
         $_SESSION['ip_address'] = $this->input->ip_address();
     }
     // Set up flash variables
     Session::$flash =& $_SESSION['_kf_flash_'];
     // Increase total hits
     $_SESSION['total_hits'] += 1;
     // Validate data only on hits after one
     if ($_SESSION['total_hits'] > 1) {
         // Validate the session
         foreach (Session::$config['validate'] as $valid) {
             switch ($valid) {
                 // Check user agent for consistency
                 case 'user_agent':
                     if ($_SESSION[$valid] !== request::user_agent()) {
                         return $this->create();
                     }
                     break;
                     // Check ip address for consistency
                 // Check ip address for consistency
                 case 'ip_address':
                     if ($_SESSION[$valid] !== $this->input->{$valid}()) {
                         return $this->create();
                     }
                     break;
                     // Check expiration time to prevent users from manually modifying it
                 // Check expiration time to prevent users from manually modifying it
                 case 'expiration':
                     if (time() - $_SESSION['last_activity'] > ini_get('session.gc_maxlifetime')) {
                         return $this->create();
                     }
                     break;
             }
         }
     }
     // Expire flash keys
     $this->expire_flash();
     // Update last activity
     $_SESSION['last_activity'] = time();
     // Set the new data
     Session::set($vars);
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:94,代码来源:Session.php

示例4: get_display_context

 /**
  * Call the display context callback for the given item
  */
 static function get_display_context($item)
 {
     if (!request::user_agent("robot")) {
         $args = Cache::instance()->get("display_context_" . ($sid = Session::instance()->id()));
         $callback = $args[0];
         $args[0] = $item;
     }
     if (empty($callback)) {
         $callback = "Albums_Controller::get_display_context";
         $args = array($item);
     }
     return call_user_func_array($callback, $args);
 }
开发者ID:qboy1987,项目名称:mooiyou,代码行数:16,代码来源:item.php

示例5: reset

 public static function reset()
 {
     request::$accept_charsets = NULL;
     request::$accept_encodings = NULL;
     request::$accept_languages = NULL;
     request::$accept_types = NULL;
     request::$user_agent = NULL;
 }
开发者ID:swk,项目名称:bluebox,代码行数:8,代码来源:Helper_Request_Test.php

示例6:

 static function set_user_agent($value)
 {
     self::$user_agent = null;
     $_SERVER["HTTP_USER_AGENT"] = $value;
 }
开发者ID:andyst,项目名称:gallery3,代码行数:5,代码来源:MY_request.php

示例7: ready

 /**
  * This function is called when the Gallery is fully initialized.  We relay it to modules as the
  * "gallery_ready" event.  Any module that wants to perform an action at the start of every
  * request should implement the <module>_event::gallery_ready() handler.
  */
 static function ready()
 {
     // Don't keep a session for robots; it's a waste of database space.
     if (request::user_agent("robot")) {
         Session::instance()->abort_save();
     }
     module::event("gallery_ready");
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:13,代码来源:gallery.php

示例8: user_agent

 /**
  * Retrieves current user agent information
  * keys:  browser, version, platform, mobile, robot
  *
  * @param   string  key
  * @return  mixed   NULL or the parsed value
  */
 public static function user_agent($key = 'agent')
 {
     // Retrieve raw user agent without parsing
     if ($key === 'agent') {
         if (request::$user_agent === NULL) {
             return request::$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : '';
         }
         if (is_array(request::$user_agent)) {
             return request::$user_agent['agent'];
         }
         return request::$user_agent;
     }
     if (!is_array(request::$user_agent)) {
         request::$user_agent = array();
         request::$user_agent['agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : '';
         // Parse the user agent and extract basic information
         foreach (Kohana::config('user_agents') as $type => $data) {
             foreach ($data as $fragment => $name) {
                 if (stripos(request::$user_agent['agent'], $fragment) !== FALSE) {
                     if ($type === 'browser' and preg_match('|' . preg_quote($fragment) . '[^0-9.]*+([0-9.][0-9.a-z]*)|i', request::$user_agent['agent'], $match)) {
                         // Set the browser version
                         request::$user_agent['version'] = $match[1];
                     }
                     // Set the agent name
                     request::$user_agent[$type] = $name;
                     break;
                 }
             }
         }
     }
     return isset(request::$user_agent[$key]) ? request::$user_agent[$key] : NULL;
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:39,代码来源:request.php

示例9: force

 /**
  * Force the download of a file by the user's browser by preventing any
  * caching. Contains a workaround for Internet Explorer.
  *
  * @link http://support.microsoft.com/kb/316431
  * @link http://support.microsoft.com/kb/812935
  *
  * @uses download::dialog()
  * @uses download::send()
  *
  * @param   string  a file path or file name
  * @param   mixed   data to be sent if the filename does not exist
  * @param   string  suggested filename to display in the download
  * @return  void
  */
 public static function force($filename = NULL, $data = NULL, $nicename = NULL)
 {
     download::dialog(empty($nicename) ? $filename : $nicename);
     // Prevent caching
     header('Expires: Thu, 01 Jan 1970 00:00:00 GMT');
     if (request::user_agent('browser') === 'Internet Explorer' and request::user_agent('version') <= '6.0') {
         // HTTP 1.0
         header('Pragma:');
         // HTTP 1.1 with IE extensions
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     } else {
         // HTTP 1.0
         header('Pragma: no-cache');
         // HTTP 1.1
         header('Cache-Control: no-cache, max-age=0');
     }
     if (is_file($filename)) {
         download::send($filename);
     } else {
         download::send($filename, $data);
     }
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:37,代码来源:download.php


注:本文中的request::user_agent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。