當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Input::user_agent方法代碼示例

本文整理匯總了PHP中Input::user_agent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Input::user_agent方法的具體用法?PHP Input::user_agent怎麽用?PHP Input::user_agent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Input的用法示例。


在下文中一共展示了Input::user_agent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: read

 /**
  * read the session
  *
  * @access public
  * @param
  *        	boolean, set to true if we want to force a new session to be created
  * @return Fuel\Core\Session_Driver
  */
 public function read($force = false)
 {
     // initialize the session
     $this->data = array();
     $this->keys = array();
     $this->flash = array();
     // get the session cookie
     $payload = $this->_get_cookie();
     // validate it
     if ($payload === false or $force) {
         // not a valid cookie, or a forced session reset
     } elseif (!isset($payload[0]) or !is_array($payload[0])) {
         // not a valid cookie payload
     } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) {
         // session has expired
     } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) {
         // IP address doesn't match
     } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) {
         // user agent doesn't match
     } else {
         // session is valid, retrieve the payload
         if (isset($payload[0]) and is_array($payload[0])) {
             $this->keys = $payload[0];
         }
         if (isset($payload[1]) and is_array($payload[1])) {
             $this->data = $payload[1];
         }
         if (isset($payload[2]) and is_array($payload[2])) {
             $this->flash = $payload[2];
         }
     }
     return parent::read();
 }
開發者ID:vienbk91,項目名稱:fuelphp17,代碼行數:41,代碼來源:cookie.php

示例2: read

 /**
  * read the session
  *
  * @access	public
  * @param	boolean, set to true if we want to force a new session to be created
  * @return	Fuel\Core\Session_Driver
  */
 public function read($force = false)
 {
     // initialize the session
     $this->data = array();
     $this->keys = array();
     $this->flash = array();
     // get the session cookie
     $payload = $this->_get_cookie();
     // validate it
     if ($force) {
         // a forced session reset
     } elseif ($payload === false) {
         // no cookie found
     } elseif (!isset($payload[0]) or !is_array($payload[0])) {
         logger('DEBUG', 'Error: not a valid cookie payload!');
     } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) {
         logger('DEBUG', 'Error: session id has expired!');
     } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) {
         logger('DEBUG', 'Error: IP address in the session doesn\'t match this requests source IP!');
     } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) {
         logger('DEBUG', 'Error: User agent in the session doesn\'t match the browsers user agent string!');
     } else {
         // session is valid, retrieve the payload
         if (isset($payload[0]) and is_array($payload[0])) {
             $this->keys = $payload[0];
         }
         if (isset($payload[1]) and is_array($payload[1])) {
             $this->data = $payload[1];
         }
         if (isset($payload[2]) and is_array($payload[2])) {
             $this->flash = $payload[2];
         }
     }
     return parent::read();
 }
開發者ID:SainsburysTests,項目名稱:sainsburys,代碼行數:42,代碼來源:cookie.php

示例3: check_legacy_ie

 public static function check_legacy_ie($criteria_version = 8)
 {
     if (!$criteria_version) {
         return false;
     }
     if (!preg_match('/MSIE\\s([\\d.]+)/i', \Input::user_agent(), $matches)) {
         return false;
     }
     $version = floor($matches[1]);
     return $version <= $criteria_version;
 }
開發者ID:uzura8,項目名稱:flockbird,代碼行數:11,代碼來源:agent.php

示例4: create

 /**
  * create a new session
  *
  * @access	public
  * @return	Fuel\Core\Session_Cookie
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['ip_hash'] = md5(\Input::ip() . \Input::real_ip());
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     $this->keys['payload'] = '';
     return $this;
 }
開發者ID:highestgoodlikewater,項目名稱:webspider-1,代碼行數:17,代碼來源:cookie.php

示例5: create

 /**
  * create a new session
  *
  * @access	public
  * @return	Fuel\Core\Session_Memcached
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['previous_id'] = $this->keys['session_id'];
     // prevents errors if previous_id has a unique index
     $this->keys['ip_hash'] = md5(\Input::ip() . \Input::real_ip());
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     return $this;
 }
開發者ID:highestgoodlikewater,項目名稱:webspider-1,代碼行數:18,代碼來源:memcached.php

示例6: create

 /**
  * create a new session
  *
  * @access	public
  * @return	void
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['ip_address'] = \Input::real_ip();
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     $this->keys['payload'] = '';
     // and set the session cookie
     $this->_set_cookie();
 }
開發者ID:bryanheo,項目名稱:FuelPHP-Auth-AJAX,代碼行數:18,代碼來源:cookie.php

示例7: action_send

 public function action_send()
 {
     // CSRF対策
     if (!Security::check_token()) {
         throw new HttpInvalidInputException('ページ遷移が正しくありません');
     }
     $form = $this->forge_form();
     $val = $form->validation()->add_callable('MyValidationRules');
     if (!$val->run()) {
         $form->repopulate();
         $this->template->title = 'コンタクトフォーム: エラー';
         $this->template->content = View::forge('form/index');
         $this->template->content->set_safe('html_error', $val->show_errors());
         $this->template->content->set_safe('html_form', $form->build('form/confirm'));
         return;
     }
     $post = $val->validated();
     $post['ip_address'] = Input::ip();
     $post['user_agent'] = Input::user_agent();
     unset($post['submit']);
     // データベースへ保存
     $model_form = Model_Form::forge($post);
     $ret = $model_form->save();
     if (!$ret) {
         Log::error('データベース保存エラー', __METHOD__);
         $form->repopulate();
         $this->template->title = 'コンタクトフォーム: サーバエラー';
         $this->template->content = View::forge('form/index');
         $html_error = '<p>サーバでエラーが発生しました。</p>';
         $this->template->content->set_safe('html_error', $html_error);
         $this->template->content->set_safe('html_form', $form->build('form/confirm'));
         return;
     }
     // メールの送信
     try {
         $mail = new Model_Mail();
         $mail->send($post);
         $this->template->title = 'コンタクトフォーム: 送信完了';
         $this->template->content = View::forge('form/send');
         return;
     } catch (EmailValidationFailedException $e) {
         Log::error('メール検証エラー: ' . $e->getMessage(), __METHOD__);
         $html_error = '<p>メールアドレスに誤りがあります。</p>';
     } catch (EmailSendingFailedException $e) {
         Log::error('メール送信エラー: ' . $e->getMessage(), __METHOD__);
         $html_error = '<p>メールを送信できませんでした。</p>';
     }
     $form->repopulate();
     $this->template->title = 'コンタクトフォーム: 送信エラー';
     $this->template->content = View::forge('form/index');
     $this->template->content->set_safe('html_error', $html_error);
     $this->template->content->set_safe('html_form', $form->build('form/confirm'));
 }
開發者ID:sato5603,項目名稱:fuelphp1st-2nd,代碼行數:53,代碼來源:form.php

示例8: response

 public function response()
 {
     $error_code = $this->getMessage();
     $error_list = Lang::load('error/user', $error_code);
     if (!isset($error_list[$error_code])) {
         $error_code = \Model_Error::ER00001;
     }
     $error_message = $error_list[$error_code];
     $params = array('error_code' => $error_code, 'error_message' => $error_message, 'line' => $this->getLine(), 'file' => $this->getFile(), 'url' => Uri::main(), 'input' => print_r(Input::all(), true), 'real_ip' => Input::real_ip(), 'user_agent' => Input::user_agent(), 'user_id' => Auth::get_user_id(), 'occurred_at' => date('Y/m/d H:i:s'));
     $email = new Model_Email();
     $email->sendMailByParams('error', $params);
     $response = \Request::forge('errors/index', false)->execute($params)->response();
     return $response;
 }
開發者ID:eva-tuantran,項目名稱:use-knife-solo-instead-chef-solo-day13,代碼行數:14,代碼來源:systemexception.php

示例9: end

 public static function end()
 {
     // cookie details
     $name = Config::get('session.name', 'anchorcms');
     $expire = time() + Config::get('session.expire', 86400);
     $path = Config::get('session.path', '/');
     $domain = Config::get('session.domain', '');
     // update db session
     Db::update('sessions', array('date' => date(DATE_ISO8601), 'ip' => Input::ip_address(), 'ua' => Input::user_agent(), 'data' => serialize(static::$data)), array('id' => static::$id));
     // create cookie with ID
     if (!Cookie::write($name, static::$id, $expire, $path, $domain)) {
         Log::error('Could not write session cookie: ' . static::$id);
     }
 }
開發者ID:nathggns,項目名稱:anchor-cms,代碼行數:14,代碼來源:session.php

示例10: create

 /**
  * create a new session
  *
  * @access	public
  * @return	void
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['previous_id'] = $this->keys['session_id'];
     // prevents errors if previous_id has a unique index
     $this->keys['ip_hash'] = md5(\Input::ip() . \Input::real_ip());
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     // create the session record
     $this->_write_redis($this->keys['session_id'], serialize(array()));
     // and set the session cookie
     $this->_set_cookie();
 }
開發者ID:469306621,項目名稱:Languages,代碼行數:21,代碼來源:redis.php

示例11: create

 /**
  * create a new session
  *
  * @access	public
  * @return	void
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['previous_id'] = $this->keys['session_id'];
     // prevents errors if previous_id has a unique index
     $this->keys['ip_hash'] = md5(\Input::ip() . \Input::real_ip());
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     $this->keys['payload'] = '';
     // create the session record
     $result = \DB::insert($this->config['table'], array_keys($this->keys))->values($this->keys)->execute($this->config['database']);
     // and set the session cookie
     $this->_set_cookie();
 }
開發者ID:469306621,項目名稱:Languages,代碼行數:22,代碼來源:db.php

示例12: before

 public function before()
 {
     parent::before();
     $client_type = false;
     $ua = \Input::user_agent();
     if (preg_match('/MicroMessenger/i', $ua)) {
         //加載微信公眾號信息
         $this->load_wx_account();
         //加載微信粉絲OPENID信息
         $this->load_wechat();
         $client_type = 'wechat';
     }
     $this->load_seller();
     $this->getToken();
     \View::set_global(['client_type' => $client_type]);
 }
開發者ID:wxl2012,項目名稱:wx,代碼行數:16,代碼來源:basecontroller.php

示例13: build_mail

    public function build_mail($post)
    {
        $data['from'] = $post['email'];
        $data['from_name'] = $post['name'];
        $data['to'] = 'info@example.jp';
        $data['to_name'] = '管理者';
        $data['subject'] = 'コンタクトフォーム';
        $ip = Input::ip();
        $agent = Input::user_agent();
        $data['body'] = <<<END
------------------------------------------------------------
          名前: {$post['name']}
メールアドレス: {$post['email']}
    IPアドレス: {$ip}
      ブラウザ: {$agent}
------------------------------------------------------------
コメント:
{$post['comment']}
------------------------------------------------------------
END;
        return $data;
    }
開發者ID:sato5603,項目名稱:fuelphp1st-2nd,代碼行數:22,代碼來源:form.php

示例14: build_mail

    protected function build_mail($post)
    {
        Config::load('contact_form', true);
        $data['from'] = $post['email'];
        $data['from_name'] = $post['name'];
        $data['to'] = Config::get('contact_form.admin_email');
        $data['to_name'] = Config::get('contact_form.admin_name');
        $data['subject'] = Config::get('contact_form.subject');
        $ip = Input::ip();
        $agent = Input::user_agent();
        $data['body'] = <<<END
------------------------------------------------------------
          名前: {$post['name']}
メールアドレス: {$post['email']}
    IPアドレス: {$ip}
      ブラウザ: {$agent}
------------------------------------------------------------
コメント:
{$post['comment']}
------------------------------------------------------------
END;
        return $data;
    }
開發者ID:sato5603,項目名稱:fuelphp1st-2nd,代碼行數:23,代碼來源:mail.php

示例15: _get_context

 /**
  * Generate the default data for the context object.
  * 
  * @param bool $js	Set this to generate the context for JS
  *  
  * @return array The array to use for the "context" object
  */
 private function _get_context($js = true)
 {
     $context_data = array('context' => array('locale' => $this->_get_locale(), 'timezone' => date('e')));
     if ($js !== true) {
         $php_context = array('ip' => \Input::real_ip(), 'userAgent' => \Input::user_agent());
         $context_data['context'] = \Arr::merge($context_data['context'], $php_context);
         // Don't use \Arr::set() since that will always add the keys.
         $context['campaign'] = $this->_add_element('name', \Input::get('utm_campaign'), array());
         $context['campaign'] = $this->_add_element('source', \Input::get('utm_source'), $context['campaign']);
         $context['campaign'] = $this->_add_element('medium', \Input::get('utm_medium'), $context['campaign']);
         $context['campaign'] = $this->_add_element('term', \Input::get('utm_term'), $context['campaign']);
         $context['campaign'] = $this->_add_element('content', \Input::get('utm_content'), $context['campaign']);
         if (!empty($context['campaign'])) {
             $context_data['context'] = \Arr::merge($context_data['context'], $context);
         }
         // If we're using Google Analytics, we add it's ID.
         if (!empty($this->_ga_cookie_id)) {
             \Arr::set($context_data, 'integrations.Google Analytics.clientId', $this->_ga_cookie_id);
         }
     }
     return $context_data;
 }
開發者ID:bitapihub,項目名稱:fuelphp-segment-io,代碼行數:29,代碼來源:analytics.php


注:本文中的Input::user_agent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。