本文整理汇总了PHP中Input::ip方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::ip方法的具体用法?PHP Input::ip怎么用?PHP Input::ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::ip方法的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 ($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();
}
示例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 ($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();
}
示例3: action_send
public function action_send()
{
if (!\Security::check_token()) {
\Log::error('CSRF: ' . \Input::uri() . ' ' . \Input::ip() . ' "' . \Input::user_agent() . '"');
throw new HttpInvalidInputException('Invalid input data');
}
$val = $this->form()->validation();
$val->add_callable('myvalidation');
if ($val->run()) {
$post = $val->validated();
\Config::load('contact', true);
$data = array();
$data['email'] = $post['email'];
$data['name'] = $post['name'];
$data['to'] = \Config::get('contact.admin_email');
$data['to_name'] = \Config::get('contact.admin_name');
$data['subject'] = \Config::get('contact.mail_subject');
$data['ip'] = \Input::ip();
$data['ua'] = \Input::user_agent();
$langs = implode(' ', $post['lang']);
$data['body'] = <<<END
====================
名前: {$post['name']}
メールアドレス: {$post['email']}
IPアドレス: {$data['ip']}
ブラウザ: {$data['ua']}
====================
コメント:
{$post['comment']}
性別: {$post['gender']}
問い合わせの種類: {$post['kind']}
好きな鳥: {$langs}
====================
END;
try {
$this->sendmail($data);
$this->save($data);
$this->template->title = 'コンタクトフォーム: 送信完了';
$this->template->content = View::forge('contact/send');
} catch (EmailValidationFailedException $e) {
$this->template->title = 'コンタクトフォーム: 送信エラー';
$this->template->content = View::forge('contact/error');
\Log::error(__METHOD__ . ' email validation error: ' . $e->getMessage());
} catch (EmailSendingFailedException $e) {
$this->template->title = 'コンタクトフォーム: 送信エラー';
$this->template->content = View::forge('contact/error');
\Log::error(__METHOD__ . ' email sending error: ' . $e->getMessage());
} catch (EmailSavingFailedException $e) {
$this->template->title = 'コンタクトフォーム: 送信エラー';
$this->template->content = View::forge('contact/error');
\Log::error(__METHOD__ . ' email saving error: ' . $e->getMessage());
}
} else {
$this->template->title = 'コンタクトフォーム: エラー';
$this->template->content = View::forge('contact/index');
$this->template->content->set_safe('html_error', $val->show_errors());
}
}
示例4: write
function write($msg)
{
if ($msg == null) {
return;
}
$msg = $msg . ' IP:' . Input::ip();
// Log::write(Fuel::L_NOTICE ,$msg);
Log::write(Fuel::L_WARNING, $msg);
}
示例5: 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;
}
示例6: 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;
}
示例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: attempt_number
public function attempt_number($email)
{
$ip = \Input::ip();
//Check the number of log in attempts for this user and this ip
$lastGood = Model_Log_In_Attempt::query()->select('time')->where('status', Model_Log_In_Attempt::$ATTEMPT_GOOD)->and_where_open()->where('email', $email)->or_where('ip', $ip)->and_where_close()->order_by('time', 'DESC')->limit(1);
$attempts = Model_Log_In_Attempt::query()->where('time', '>', $lastGood->get_query(false))->and_where_open()->where('email', $email)->or_where('ip', $ip)->and_where_close()->order_by('time', 'DESC')->get();
if (count($attempts) == 0) {
//There was no good last login so get all of them instead
$attempts = Model_Log_In_Attempt::find('all', array('where' => array('or' => array(array('ip', $ip), array('email', $email))), 'order_by' => array(array('time', 'DESC'))));
}
return count($attempts);
}
示例9: 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();
}
示例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'];
$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();
}
示例11: action_create
public function action_create()
{
if (Input::method() == 'POST') {
$val = Model_Request::validate('create');
if ($val->run()) {
$request = Model_Request::forge(array('body' => Input::post('body'), 'ip' => Input::ip()));
if ($request and $request->save()) {
Session::set_flash('success', 'Added request #' . $request->id . '.');
Response::redirect('request');
} else {
Session::set_flash('error', 'Could not save request.');
}
} else {
Session::set_flash('error', $val->error());
}
}
$this->template->title = "Requests";
$this->template->content = View::forge('request/create');
}
示例12: 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;
}
示例13: 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;
}
示例14: action_login
public function action_login()
{
if (Input::method() == 'POST') {
if (!\Security::check_token()) {
\Log::info('CSRF detected from IP:' . \Input::ip() . ', Real IP:' . \Input::real_ip() . ', Ref:' . \Input::referrer() . ', Agent:' . \Input::user_agent());
throw new \HttpNotFoundException();
}
$val = \Validation::forge('users');
$val->add_field('username', 'Your username', 'required|min_length[3]|max_length[20]');
$val->add_field('password', 'Your password', 'required|min_length[3]|max_length[20]');
if ($val->run()) {
$valid_login = \Auth::instance()->login($val->validated('username'), $val->validated('password'));
if ($valid_login) {
$user = \Auth::instance()->get_user_info();
\Session::set('user_info', $user);
\Session::set_flash('success', 'Welcome, ' . $val->validated('username'));
$url = \Session::get('redirect_url', '/');
\Session::delete('redirect_url');
\Response::redirect($url);
} else {
$data['username'] = $val->validated('username');
\Session::set_flash('error', 'Wrong username/password. Try again');
}
} else {
\Session::set_flash('error', 'Please correct the error(s).');
$this->template->set_global('errors', $val->error());
}
}
$this->template->title = 'Login';
$this->template->page_title = 'Login';
$this->template->content = \View::forge('petro/login');
}
示例15: 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
$cookie = $this->_get_cookie();
// if a cookie was present, find the session record
if ($cookie and !$force and isset($cookie[0])) {
// read the session file
$payload = $this->_read_redis($cookie[0]);
if ($payload === false) {
// cookie present, but session record missing. force creation of a new session
return $this->read(true);
}
// unpack the payload
$payload = $this->_unserialize($payload);
// session referral?
if (isset($payload['rotated_session_id'])) {
$payload = $this->_read_redis($payload['rotated_session_id']);
if ($payload === false) {
// cookie present, but session record missing. force creation of a new session
return $this->read(true);
}
// unpack the payload
$payload = $this->_unserialize($payload);
}
if (!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 rest of 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();
}