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


PHP Request::ip方法代码示例

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


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

示例1: createBy

 static function createBy(User $user, array $info)
 {
     $fields = array('name', 'surname', 'address', 'phone', 'notes');
     $fields = userFields($fields, 'order');
     $order = with(new static())->fill_raw(array_intersect_key($info, array_flip($fields)))->fill_raw(array('password' => static::generatePassword(), 'user' => $user->id, 'manager' => \Vane\Current::config('general.new_order_manager'), 'sum' => Cart::subtotal(), 'ip' => Request::ip()));
     return Event::insertModel($order, 'order');
 }
开发者ID:SerdarSanri,项目名称:VaneMart,代码行数:7,代码来源:Order.php

示例2: post_create

 public function post_create()
 {
     $posts = Input::all();
     $title = $posts['thread_name'];
     $contentRaw = $posts['inputarea'];
     if ($title != '' && strlen($contentRaw) > 10) {
         $alias = Str::slug($title, '-');
         $exist = Thread::where('alias', '=', $alias)->first();
         if ($exist != null) {
             return Redirect::to($exist->id);
         }
         $threadData = array('title' => $posts['thread_name'], 'alias' => $alias, 'type' => 0, 'poster_ip' => Request::ip(), 'dateline' => date("Y-m-d H:i:s"), 'last_message_at' => date("Y-m-d H:i:s"));
         $thread = Thread::create($threadData);
         if ($thread != null) {
             $content = static::replace_at(BBCode2Html(strip_tags_attributes($contentRaw)), $thread->id);
             $postData = array('thread_id' => $thread->id, 'entry' => $content, 'userip' => Request::ip(), 'user_id' => Sentry::user()->id, 'datetime' => date("Y-m-d H:i:s"), 'count' => 1, 'type' => 0);
             $pst = Post::create($postData);
             if ($pst != null) {
                 return Redirect::to($thread->id);
             }
         }
     } else {
         return Redirect::to(URL::full());
     }
 }
开发者ID:TahsinGokalp,项目名称:L3-Sozluk,代码行数:25,代码来源:thread.php

示例3: check

 /**
  * Validate data
  *
  * @return  boolean  True if data is valid
  */
 public function check()
 {
     $this->offering_id = intval($this->offering_id);
     if (!$this->offering_id) {
         $this->setError(Lang::txt('COM_COURSES_LOGS_MUST_HAVE_OFFERING_ID'));
         return false;
     }
     $this->page_id = intval($this->page_id);
     if (!$this->page_id) {
         $this->setError(Lang::txt('COM_COURSES_LOGS_MUST_HAVE_PAGE_ID'));
         return false;
     }
     $this->ip = trim($this->ip);
     if (!$this->id) {
         $this->timestamp = Date::toSql();
         if (!$this->ip) {
             $this->ip = Request::ip();
         }
         if (!$this->user_id) {
             $this->user_id = User::get('id');
         }
     }
     $this->user_id = intval($this->user_id);
     if (!$this->user_id) {
         $this->setError(Lang::txt('COM_COURSES_LOGS_MUST_HAVE_USER_ID'));
         return false;
     }
     return true;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:34,代码来源:page.hit.php

示例4: __construct

 /**
  * Create the event handler.
  * @param UserProvider $userProvider
  * @param GroupProvider $groupProvider
  * @param ThrottleProvider $throttleProvider
  */
 public function __construct(UserProvider $userProvider, GroupProvider $groupProvider, ThrottleProvider $throttleProvider)
 {
     $this->userProvider = $userProvider;
     $this->groupProvider = $groupProvider;
     $this->throttleProvider = $throttleProvider;
     $this->ipAddress = \Request::ip();
 }
开发者ID:spetross,项目名称:ugvoice,代码行数:13,代码来源:Throttler.php

示例5: ip

 public static function ip()
 {
     $ip = Request::ip();
     if (in_array($ip, array('127.0.0.1', '0.0.0.0'))) {
         return Config::get('locate::options.fallback_ip');
     }
     return $ip;
 }
开发者ID:SerdarSanri,项目名称:locate,代码行数:8,代码来源:locate.php

示例6: onContentBeforeSave

 /**
  * Before save content method
  *
  * Article is passed by reference, but after the save, so no changes will be saved.
  * Method is called right after the content is saved
  *
  * @param   string   $context  The context of the content passed to the plugin (added in 1.6)
  * @param   object   $article  Model
  * @param   boolean  $isNew    If the content is just about to be created
  * @return  void
  * @since   2.5
  */
 public function onContentBeforeSave($context, $article, $isNew)
 {
     if (!App::isSite()) {
         return;
     }
     if ($article instanceof \Hubzero\Base\Object || $article instanceof \Hubzero\Database\Relational) {
         $key = $this->_key($context);
         $content = ltrim($article->get($key));
     } else {
         if (is_object($article) || is_array($article)) {
             return;
         } else {
             $content = $article;
         }
     }
     $content = preg_replace('/^<!-- \\{FORMAT:.*\\} -->/i', '', $content);
     $content = trim($content);
     if (!$content) {
         return;
     }
     // Get the detector manager
     $service = new \Hubzero\Spam\Checker();
     foreach (Event::trigger('antispam.onAntispamDetector') as $detector) {
         if (!$detector) {
             continue;
         }
         $service->registerDetector($detector);
     }
     // Check content
     $data = array('name' => User::get('name'), 'email' => User::get('email'), 'username' => User::get('username'), 'id' => User::get('id'), 'ip' => Request::ip(), 'user_agent' => Request::getVar('HTTP_USER_AGENT', null, 'server'), 'text' => $content);
     $result = $service->check($data);
     // Log errors any of the service providers may have thrown
     if ($service->getError() && App::has('log')) {
         App::get('log')->logger('debug')->info(implode(' ', $service->getErrors()));
     }
     // If the content was detected as spam...
     if ($result->isSpam()) {
         // Learn from it?
         if ($this->params->get('learn_spam', 1)) {
             Event::trigger('antispam.onAntispamTrain', array($content, true));
         }
         // If a message was set...
         if ($message = $this->params->get('message')) {
             Notify::error($message);
         }
         // Increment spam hits count...go to spam jail!
         \Hubzero\User\User::oneOrFail(User::get('id'))->reputation->incrementSpamCount();
         if ($this->params->get('log_spam')) {
             $this->log($result->isSpam(), $data);
         }
         return false;
     }
     // Content was not spam.
     // Learn from it?
     if ($this->params->get('learn_ham', 0)) {
         Event::trigger('antispam.onAntispamTrain', array($content, false));
     }
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:70,代码来源:antispam.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(UserRequest $request)
 {
     $newUser = new User($request->getValidInputs());
     $newUser->ip_when_created = \Request::ip();
     $newUser->password = \Hash::make($request->get('password'));
     $newUser->save();
     Email::sendAccountCreated($newUser);
     \Notifications::add('OK! Further instructions were sent to provided email.', 'success');
     return redirect()->route('user.index');
 }
开发者ID:Ravaelles,项目名称:Elder,代码行数:16,代码来源:UserController.php

示例8: __construct

 public function __construct(API $base, Request $request)
 {
     parent::__construct($base);
     // TODO: FastCGI, heavy refactoring
     session_start();
     $this->request = $request;
     if (!isset($_SESSION['IP'])) {
         $_SESSION['IP'] = (string) $request->ip(false);
     } else {
         if ($_SESSION['IP'] != (string) $request->ip(false)) {
             session_unset();
         }
     }
     $this->logged_in = false;
     $this->login_callback = array($this, 'loginDefault');
     if (@$_SESSION['SPINDASH_LOGGED_IN'] == 'yes') {
         $this->logged_in = true;
         $this->username = @$_SESSION['SPINDASH_USERNAME'];
     }
 }
开发者ID:wst,项目名称:spindash,代码行数:20,代码来源:session.inc.php

示例9: postCreateThread

 public function postCreateThread()
 {
     if (App::environment('production') && Auth::user()->hasCreatedAThreadRecently()) {
         return Redirect::action('ForumThreadsController@getCreateThread');
     }
     /** @var \Illuminate\Validation\Validator $validator */
     $validator = Validator::make(Input::only('g-recaptcha-response'), ['g-recaptcha-response' => 'required|recaptcha']);
     if ($validator->fails()) {
         return Redirect::action('ForumThreadsController@getCreateThread')->exceptInput('g-recaptcha-response')->withErrors($validator->errors());
     }
     return $this->threadCreator->create($this, ['subject' => Input::get('subject'), 'body' => Input::get('body'), 'author' => Auth::user(), 'laravel_version' => Input::get('laravel_version'), 'is_question' => Input::get('is_question'), 'tags' => $this->tags->getTagsByIds(Input::get('tags')), 'ip' => Request::ip()], new ThreadForm());
 }
开发者ID:ricoa,项目名称:laravel.io,代码行数:12,代码来源:ForumThreadsController.php

示例10: initialize

 /** обрабатываем входные параметры скрипта, определяем запрашиваемую страницу
  *
  */
 public static function initialize($deep = false)
 {
     if (!$deep && self::$initialized) {
         return;
     }
     $headers = @apache_request_headers();
     if (array_key_exists('X-Forwarded-For', $headers)) {
         $hostname = $headers['X-Forwarded-For'];
     } else {
         $hostname = $_SERVER["REMOTE_ADDR"];
     }
     self::$ip = $hostname;
     self::$path_history = '';
     self::$initialized = true;
     // принимаем uri
     $e = explode('?', $_SERVER['REQUEST_URI']);
     $_SERVER['REQUEST_URI'] = $e[0];
     if (isset($e[1])) {
         parse_str($e[1], $d);
     } else {
         $d = array();
     }
     $prepared_get = array();
     foreach ($d as $name => &$val) {
         $val = to_utf8($val);
         $prepared_get[$name] = stripslashes($val);
     }
     self::$get_normal = self::$get = $prepared_get;
     $path_array = explode('/', self::processRuri($_SERVER['REQUEST_URI']));
     // убиваем начальный слеш
     array_shift($path_array);
     // определяем, что из этого uri является страницей
     self::$structureFile = self::getPage($path_array, $deep);
     if (self::$real_path >= 0) {
         self::$structureFile = 'errors/p404.xml';
     }
     //die(self::$structureFile);
     // разбираем параметры
     self::parse_parameters($path_array);
     if (isset($_POST)) {
         foreach ($_POST as $f => $v) {
             if (!is_array($v)) {
                 self::$post[$f] = stripslashes($v);
             } else {
                 self::$post[$f] = $v;
             }
         }
     }
     unset($_POST);
     unset($_GET);
     self::afterAll();
 }
开发者ID:rasstroen,项目名称:sosedi,代码行数:55,代码来源:Request.php

示例11: createToken

 /**
  * 创建令牌
  */
 private function createToken()
 {
     if (C('app.token_on')) {
         //表单添加令牌
         if (preg_match_all('/<form.*?>(.*?)<\\/form>/is', $this->content, $matches, PREG_SET_ORDER)) {
             $token = md5(c('app.key') . Request::ip());
             foreach ($matches as $id => $m) {
                 $php = "<input type='hidden' name='" . C('app.token_name') . "' value='" . $token . "'/>";
                 $this->content = str_replace($m[1], $m[1] . $php, $this->content);
             }
         }
     }
 }
开发者ID:houdunwang,项目名称:hdcms,代码行数:16,代码来源:Compile.php

示例12: show

 public static function show()
 {
     if (Request::ip() != '127.0.0.1' && self::$enable) {
         return;
     }
     $time = microtime() - self::$start;
     $tmpl = '<script type="text/javascript">';
     $tmpl .= 'console.log("Executing time: ' . $time . ' s.");';
     $tmpl .= 'console.info("Queries count: ' . count(self::$data['query']) . '");';
     $tmpl .= 'console.log("Queries count: ' . count(self::$data['query']) . '");';
     $tmpl .= '</script>';
     echo $tmpl;
 }
开发者ID:Yogurt933,项目名称:Made-Easy,代码行数:13,代码来源:Debug.class.php

示例13: sendRedPack

 public function sendRedPack($data)
 {
     $data['mch_billno'] = time();
     $data['mch_id'] = c('weixin.mch_id');
     $data['wxappid'] = c('weixin.appid');
     $data['total_num'] = "1";
     //红包发放总人数
     $data['client_ip'] = Request::ip();
     $data['nonce_str'] = $this->getRandStr(16);
     $data['sign'] = $this->makeSign($data);
     $xml = Xml::toSimpleXml($data);
     $res = $this->curl_post_ssl("https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack", $xml);
     return Xml::toSimpleArray($res);
 }
开发者ID:houdunwang,项目名称:hdcms,代码行数:14,代码来源:Cash.php

示例14: post_login

 public function post_login()
 {
     $credentials = array('username' => Input::get('username'), 'password' => Input::get('password'));
     if (Auth::attempt($credentials)) {
         Log::write('info', Request::ip() . ' User : ' . Auth::user()->fullname . ' Event: Login', true);
         //set last login
         $user = Auth::user();
         $user->last_login = new \DateTime();
         $user->save();
         return Redirect::to('admin/dashboard');
     } else {
         return Redirect::to('admin/login');
     }
 }
开发者ID:acmadi,项目名称:diantaksi,代码行数:14,代码来源:dash.php

示例15: action_do_login

 public function action_do_login()
 {
     $email = Input::get('email');
     $password = Input::get('password');
     $remember = Input::get('remember');
     $credentials = array('username' => $email, 'password' => $password, 'remember' => !empty($remember) ? $remember : null);
     if (Auth::attempt($credentials)) {
         Auth::user()->last_ip = Request::ip();
         Auth::user()->save();
         return Redirect::to('dashboard/');
     } else {
         return Redirect::to('login')->with('login_failed', "Invalid Username/Password");
     }
 }
开发者ID:pustimeunutra,项目名称:TechnicSolder,代码行数:14,代码来源:base.php


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