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


PHP Request::getClientIp方法代码示例

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


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

示例1: addSubscribers

 /**
  * @param EventManager           $manager
  * @param EntityManagerInterface $em
  * @param Reader                 $reader
  */
 public function addSubscribers(EventManager $manager, EntityManagerInterface $em, Reader $reader)
 {
     $subscriber = new IpTraceableListener();
     $subscriber->setAnnotationReader($reader);
     $subscriber->setIpValue($this->request->getClientIp());
     $manager->addEventSubscriber($subscriber);
 }
开发者ID:rosstuck,项目名称:Laravel-Doctrine,代码行数:12,代码来源:IpTraceableExtension.php

示例2: get

 /**
  * @return string
  */
 public function get()
 {
     $ip = $this->request->getClientIp();
     if ($ip == '::1') {
         $ip = '127.0.0.1';
     }
     return $ip;
 }
开发者ID:weboap,项目名称:visitor,代码行数:11,代码来源:Ip.php

示例3: __call

 /**
  * Forward method calls to provider
  *
  * @param string $name
  * @param array $arguments
  *
  * @return mixed
  */
 public function __call($name, $arguments)
 {
     $ip = $this->request->getClientIp();
     if (!empty($arguments)) {
         $ip = array_shift($arguments);
     }
     if ($this->localhostProvider->isLocalhost($ip)) {
         return $this->localhostProvider->{$name}($ip);
     }
     return $this->provider->{$name}($ip);
 }
开发者ID:CsanadNovak,项目名称:laravel-geoip2,代码行数:19,代码来源:GeoIP2.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $rules = array('title' => 'required|max:255|min:5|string', 'body' => 'required|max:2000|min:5|string', 'browser' => 'min:1|max:20');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('create')->withErrors($validator);
     }
     $data = array('title' => Purifier::clean($request->input('title')), 'body' => Purifier::clean($request->input('body')), 'image' => Purifier::clean($request->input('image')), 'ip' => $request->getClientIp(), 'browser' => Purifier::clean($request->input('browser')), 'country' => UserClients::getCountry($request->getClientIp()), 'date' => time());
     Posts::create($data);
     return Redirect::to('/');
 }
开发者ID:sstetsurin,项目名称:testdesk,代码行数:17,代码来源:PostsController.php

示例5: ensureUser

 public function ensureUser($forceSession = false)
 {
     if (!Session::has(config('laravel-ab.cache_key')) || $forceSession) {
         $uid = md5(uniqid() . $this->request->getClientIp());
         $laravel_ab_id = $this->request->cookie(config('laravel-ab.cache_key'), $uid);
         Session::set(config('laravel-ab.cache_key'), $uid);
     }
     if (empty(self::$session)) {
         self::$session = Instance::firstOrCreate(['instance' => Session::get(config('laravel-ab.cache_key')), 'identifier' => $this->request->getClientIp(), 'metadata' => function_exists('laravel_ab_meta') ? call_user_func('laravel_ab_meta') : null]);
     }
 }
开发者ID:comocode,项目名称:laravel-ab,代码行数:11,代码来源:Ab.php

示例6: saveComment

 public function saveComment(Request $request)
 {
     $commentData = array('name' => $request->input('name'), 'email' => $request->input('email'), 'comment' => $request->input('comment'), 'slug' => ltrim($request->input('slug'), '/'), 'ip' => $request->getClientIp());
     $commentData['token'] = \Hash::make($commentData['comment'] . $commentData['email'] . $commentData['slug']);
     $comment = Comment::create($commentData);
     $commentData['created_at'] = $comment->created_at->toDateTimeString();
     $commentData['id'] = $comment->id;
     \Mail::send('new-comment', $commentData, function ($message) {
         $message->from('squabble@savaslabs.com', 'Squabble Comments');
         $message->to('info@savaslabs.com', 'Savas Labs')->subject('New comment posted to site');
     });
     \Log::info(sprintf('Saved new comment with ID %d from IP %s', $comment->id, $request->getClientIp()));
     return CommentHelpers::formatData(array($commentData));
 }
开发者ID:flowersw,项目名称:squabble,代码行数:14,代码来源:CommentController.php

示例7: getModel

 public function getModel()
 {
     if (\Auth::check()) {
         return \Auth::user();
     }
     if ($this->request->hasCookie('email_user')) {
         $user = Email::where('email', $this->request->cookie('email_user'));
     }
     if ($this->request->hasCookie('guest_user')) {
         $tracker = $this->request->cookie('guest_user');
     }
     $tracker = $this->request->getClientIp();
     $user = Guest::firstOrCreate(['identifier' => $tracker]);
     return $user;
 }
开发者ID:codeforpg,项目名称:PostIt,代码行数:15,代码来源:GetIdentity.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->getClientIp() != self::IP_BOT) {
         return response()->json('Invalid Request');
     }
     return $next($request);
 }
开发者ID:Kadexi,项目名称:CSGOVoid,代码行数:14,代码来源:SecretKey.php

示例9: login

 /**
  * 用户通过邮箱和密码进行登录操作
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function login(Request $request)
 {
     //获取当前访问的全部的地址
     $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
     //验证参数
     $validator = Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required']);
     //验证参数完整性
     if ($validator->fails()) {
         // var_dump($validator);
         $error = $validator->errors()->all();
         //写入日志
         Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
         //返回错误信息
         return Error::returnError($request_url, 1001);
     }
     $email = $request->get('email');
     $password = $request->get('password');
     //检查有没有
     $user_model = User::checkUserLogin($email, $password);
     if ($user_model == false) {
         return Error::returnError($request_url, 2001);
     }
     //更新token
     $token = User::updateToken($user_model);
     //返回对应的结果
     $json_arr = ['request' => $request_url, 'ret' => User::getUserInfo($user_model->id), 'token' => $token];
     return Common::returnResult($json_arr);
 }
开发者ID:diandianxiyu,项目名称:LaravelApi,代码行数:34,代码来源:UserController.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $authenticated = false;
     try {
         $user = $this->auth->user();
         if (!$user) {
             // redirect
             return redirect('/');
         }
         $authenticated = $user->hasPermission('platformAdmin');
     } catch (Exception $e) {
         // something else went wrong
         EventLog::logError('error.platformAuth.unexpected', $e);
         $error_message = 'An unexpected error occurred';
         $error_code = 500;
     }
     if (!$authenticated) {
         $error_code = isset($error_code) ? $error_code : 403;
         $error_message = isset($error_message) ? $error_message : "You do not have privileges to perform this operation";
         EventLog::logError('error.platformAuth.unauthenticated', ['remoteIp' => $request->getClientIp()]);
         return new Response($error_message, $error_code);
         $response = new JsonResponse(['message' => $error_message, 'errors' => [$error_message]], $error_code);
         return $response;
     }
     return $next($request);
 }
开发者ID:tokenly,项目名称:platform-admin,代码行数:33,代码来源:AuthenticatePlatformAdmin.php

示例11: validateCaptcha

 /**
  * Validate Captcha
  * @param $request
  * @return bool
  */
 private function validateCaptcha(Request $request)
 {
     // validate google captcha
     $recaptcha = new ReCaptcha(env('RECAPTCHA_PRIVATE_KEY'));
     $response = $recaptcha->verify(input('g-recaptcha-response'), $request->getClientIp());
     return $response;
 }
开发者ID:bpocallaghan,项目名称:titan,代码行数:12,代码来源:GoogleCaptcha.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!starts_with($request->getClientIp(), '192.168.0')) {
         $this->analysis();
     }
     return $next($request);
 }
开发者ID:picolit,项目名称:bbs,代码行数:14,代码来源:RequestAnalysis.php

示例13: create

 /**
  * post的方式添加一条记录
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
     //验证参数
     $validator = Validator::make($request->all(), ['name' => 'required|max:255']);
     //验证参数完整性
     if ($validator->fails()) {
         $error = $validator->errors()->all();
         //写入日志
         Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
         //返回错误信息
         return Error::returnError($request_url, 1001);
     }
     //验证token
     //        $user_id=Common::validateToken($request->get('token'));
     //
     //        if($user_id == false){
     //            return Error::returnError($request_url,2002);
     //        }
     $name = $request->get('name');
     //写入操作
     $add = Task::addTask($name);
     $info = Task::getTaskInfo($add);
     //返回对应的结果
     $json_arr = ['request' => $request_url, 'ret' => $info];
     return Common::returnResult($json_arr);
 }
开发者ID:diandianxiyu,项目名称:LaravelApi,代码行数:32,代码来源:TaskController.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  *
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 public function handle(Request $request, Closure $next)
 {
     if ($this->app->isDownForMaintenance() && !in_array($request->getClientIp(), config('maintenance.ips', [])) && (config('maintenance.bypass_with_cookie', false) === false || config('maintenance.cookie_name', '') === '' || !$request->hasCookie(config('maintenance.cookie_name')))) {
         throw new HttpException(503);
     }
     return $next($request);
 }
开发者ID:philcross,项目名称:laravel-maintenance-mode,代码行数:16,代码来源:CheckForMaintenanceMode.php

示例15: login

 public function login(Request $request)
 {
     //        dd(\Crypt::encrypt('jtmccombs@gmail.com'));
     try {
         $email = \Crypt::decrypt($request->get('token'));
     } catch (\Exception $e) {
         return abort('403', 'Forbidden');
     }
     $user = User::whereEmail($email)->first();
     if (!$user) {
         return abort('403', 'Forbidden');
     }
     if (!$user->account) {
         $b2bCompany = \DB::connection('mysql-b2b')->table('companies')->where('user_id', '=', $user->id)->first();
         //            $b2bCompany = false;
         $accountName = $b2bCompany ? $b2bCompany->company_name : $user->email;
         $account = new Account();
         $account->ip = $request->getClientIp();
         $account->name = $accountName;
         $account->account_key = str_random(RANDOM_KEY_LENGTH);
         $account->save();
         $user->account_id = $account->id;
         $user->registered = true;
         $user->save();
         $exists = \DB::connection('mysql')->table('users')->whereId($user->id)->count();
         if (!$exists) {
             \DB::connection('mysql')->table('users')->insert(['id' => $user->id, 'account_id' => $user->account_id, 'created_at' => $user->created_at, 'updated_at' => $user->updated_at, 'deleted_at' => $user->deleted_at, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'phone' => $user->phone, 'username' => $user->username, 'email' => $user->email, 'password' => $user->password, 'confirmation_code' => $user->confirmation_code, 'registered' => $user->registered, 'confirmed' => $user->confirmed, 'notify_sent' => $user->notify_sent, 'notify_viewed' => $user->notify_viewed, 'notify_paid' => $user->notify_paid, 'public_id' => $user->public_id, 'force_pdfjs' => false, 'remember_token' => $user->remember_token, 'news_feed_id' => $user->news_feed_id, 'notify_approved' => $user->notify_approved, 'failed_logins' => $user->failed_logins, 'dark_mode' => $user->dark_mode, 'referral_code' => $user->referral_code]);
         }
     }
     \Auth::loginUsingId($user->id);
     return redirect('/');
 }
开发者ID:sseshachala,项目名称:invoiceninja,代码行数:32,代码来源:AutoLoginController.php


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