本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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'));
}
示例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;
}
示例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);
}
}
示例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();
}
示例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();
}
示例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]);
}
示例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;
}
示例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;
}
示例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;
}