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


PHP Request::setTrustedProxies方法代码示例

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


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

示例1: index

 /**
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
  */
 public function index()
 {
     if (Auth::Check()) {
         $user = Auth::user();
         $this->request->setTrustedProxies(array('192.0.0.1', '10.0.0.0/8'));
         $this->user->addIp($user, $this->request);
         if ($user->role == 'user') {
             return view('/code/index', compact('user'));
         } else {
             return redirect('/admin/home');
         }
     } else {
         return view('/errors/404');
     }
 }
开发者ID:kristofsw,项目名称:webdev.comp,代码行数:18,代码来源:CodeController.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $request->setTrustedProxies([$request->getClientIp()]);
     if (!$request->secure()) {
         return redirect()->secure($request->getRequestUri());
     }
     return $next($request);
 }
开发者ID:2n2n,项目名称:food4lunch,代码行数:15,代码来源:HttpsMiddleware.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->secure() && env('APP_ENV') === 'production') {
         $request->setTrustedProxies([$request->getClientIp()]);
         return redirect()->secure($request->getRequestUri());
     }
     return $next($request);
 }
开发者ID:johannesponader,项目名称:Onepager,代码行数:15,代码来源:HttpsProtocol.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Set trusted header names
     foreach ($this->getTrustedHeaders() as $headerKey => $headerName) {
         $request->setTrustedHeaderName($headerKey, $headerName);
     }
     $request->setTrustedProxies($this->getTrustedProxies($request->getClientIps()));
     return $next($request);
 }
开发者ID:phecho,项目名称:TrustedProxy,代码行数:19,代码来源:TrustProxies.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $proxyIps = Cache::remember('cloudFlareProxyIps', 1440, function () {
         $url = 'https://www.cloudflare.com/ips-v4';
         $ips = file_get_contents($url);
         return array_filter(explode("\n", $ips));
     });
     $request->setTrustedProxies($proxyIps);
     return $next($request);
 }
开发者ID:stickableapp,项目名称:stickable-api,代码行数:18,代码来源:CloudFlareProxies.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->app->environment() === 'production') {
         // for Proxies
         Request::setTrustedProxies([$request->getClientIp()]);
         if (!$request->isSecure()) {
             return redirect()->secure($request->getRequestUri());
         }
     }
     return $next($request);
 }
开发者ID:shin1x1,项目名称:laravel-force-https-url-scheme,代码行数:18,代码来源:ForceHttpsUrlScheme.php

示例7: postRegister

 public function postRegister(Request $request)
 {
     $request->setTrustedProxies(array('192.0.0.1', '10.0.0.0/8'));
     $data = array('name' => $request->input('name'), 'surname' => $request->input('surname'), 'email' => $request->input('email'), 'password' => $request->input('password'), 'password_confirmation' => $request->input('password_confirmation'), 'ip' => $request->getClientIp(), 'address' => $request->input('address'), 'residence' => $request->input('residence'), 'isAdmin' => false, 'is_facebook' => false);
     $validator = $this->validator($data);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors()->all())->withInput();
     } else {
         $user = $this->create($data);
         // $user->isAdmin = 0;
         Auth::login($user);
         return redirect()->back();
     }
 }
开发者ID:jeroenjvdb,项目名称:web-development-p1-wedstrijd-v2,代码行数:14,代码来源:AuthController.php

示例8: setTrustedProxies

 /**
  * Sets a list of trusted proxies.
  * 
  * You should only list the reverse proxies that you manage directly.
  *
  * @param array $proxies A list of trusted proxies
  * @static 
  */
 public static function setTrustedProxies($proxies)
 {
     //Method inherited from \Symfony\Component\HttpFoundation\Request
     return \Illuminate\Http\Request::setTrustedProxies($proxies);
 }
开发者ID:satriashp,项目名称:tour,代码行数:13,代码来源:_ide_helper.php

示例9: otherCompetitors

 public function otherCompetitors(Request $request)
 {
     $thisDate = Date::where('endDate', '>', Carbon::now())->where('startDate', '<=', Carbon::now())->first();
     $competitors = Competitor::where('created_at', '>', $thisDate->startDate)->orderby('created_at', 'DESC')->paginate(12);
     $request->setTrustedProxies(array('192.0.0.1', '10.0.0.0/8'));
     foreach ($competitors as $competitor) {
         $competitor->voted = false;
         foreach ($competitor->votes as $vote) {
             //check if you already have voted for this competitor
             if ($vote->ip == $request->getClientIp()) {
                 //give your object
                 $competitor->voted = true;
             }
         }
     }
     $data = ['competitors' => $competitors];
     return View('competition.otherCompetitors')->with($data);
 }
开发者ID:jeroenjvdb,项目名称:web-development-p1-wedstrijd-v2,代码行数:18,代码来源:MainController.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $request->setTrustedProxies([$request->getClientIp()]);
     return $next($request);
 }
开发者ID:JolitaGrazyte,项目名称:lockedornot,代码行数:12,代码来源:EB_SSL_Trust.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $request->setTrustedProxies(['10.134.162.216']);
     return $next($request);
 }
开发者ID:WhatDaFox-Examples,项目名称:ProjectFactory,代码行数:12,代码来源:TrustLoadBalancer.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $request->setTrustedProxies(['114.55.103.163', '223.197.27.204', $request->getClientIp()]);
     return $next($request);
 }
开发者ID:SkysoulDesign,项目名称:mirage.dev,代码行数:12,代码来源:ProxyMiddleware.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $request->setTrustedProxies(['199.27.128.0/21', '173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12']);
     return $next($request);
 }
开发者ID:WhatDaFox-Examples,项目名称:ProjectFactory,代码行数:12,代码来源:TrustCloudflare.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  Request $request
  * @param  Closure $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     // Set up trusted X-Forwarded-Proto proxies
     // TRUSTED_PROXIES accepts a comma delimited list of subnets
     // ie, TRUSTED_PROXIES='10.0.0.0/8,172.16.0.0/12,192.168.0.0/16'
     if (isset($_ENV['TRUSTED_PROXIES'])) {
         $request->setTrustedProxies(array_map('trim', explode(',', env('TRUSTED_PROXIES'))));
     }
     // Ensure all request are over HTTPS in production
     if (Utils::requireHTTPS() && !$request->secure()) {
         return Redirect::secure($request->path());
     }
     // If the database doens't yet exist we'll skip the rest
     if (!Utils::isNinja() && !Utils::isDatabaseSetup()) {
         return $next($request);
     }
     // Check if a new version was installed
     if (!Utils::isNinja()) {
         $file = storage_path() . '/version.txt';
         $version = @file_get_contents($file);
         if ($version != NINJA_VERSION) {
             if (version_compare(phpversion(), '5.5.9', '<')) {
                 dd('Please update PHP to >= 5.5.9');
             }
             $handle = fopen($file, 'w');
             fwrite($handle, NINJA_VERSION);
             fclose($handle);
             return Redirect::to('/update');
         }
     }
     // Check the application is up to date and for any news feed messages
     if (Auth::check()) {
         $count = Session::get(SESSION_COUNTER, 0);
         Session::put(SESSION_COUNTER, ++$count);
         if (isset($_SERVER['REQUEST_URI']) && !Utils::startsWith($_SERVER['REQUEST_URI'], '/news_feed') && !Session::has('news_feed_id')) {
             $data = false;
             if (Utils::isNinja()) {
                 $data = Utils::getNewsFeedResponse();
             } else {
                 $file = @CurlUtils::get(NINJA_APP_URL . '/news_feed/' . Utils::getUserType() . '/' . NINJA_VERSION);
                 $data = @json_decode($file);
             }
             if ($data) {
                 if (version_compare(NINJA_VERSION, $data->version, '<')) {
                     $params = ['user_version' => NINJA_VERSION, 'latest_version' => $data->version, 'releases_link' => link_to(RELEASES_URL, 'Invoice Ninja', ['target' => '_blank'])];
                     Session::put('news_feed_id', NEW_VERSION_AVAILABLE);
                     Session::flash('news_feed_message', trans('texts.new_version_available', $params));
                 } else {
                     Session::put('news_feed_id', $data->id);
                     if ($data->message && $data->id > Auth::user()->news_feed_id) {
                         Session::flash('news_feed_message', $data->message);
                     }
                 }
             } else {
                 Session::put('news_feed_id', true);
             }
         }
     }
     // Check if we're requesting to change the account's language
     if (Input::has('lang')) {
         $locale = Input::get('lang');
         App::setLocale($locale);
         Session::set(SESSION_LOCALE, $locale);
         if (Auth::check()) {
             if ($language = Language::whereLocale($locale)->first()) {
                 $account = Auth::user()->account;
                 $account->language_id = $language->id;
                 $account->save();
             }
         }
     } elseif (Auth::check()) {
         $locale = Auth::user()->account->language ? Auth::user()->account->language->locale : DEFAULT_LOCALE;
         App::setLocale($locale);
     } elseif (session(SESSION_LOCALE)) {
         App::setLocale(session(SESSION_LOCALE));
     }
     // Make sure the account/user localization settings are in the session
     if (Auth::check() && !Session::has(SESSION_TIMEZONE)) {
         Event::fire(new UserSettingsChanged());
     }
     // Check if the user is claiming a license (ie, additional invoices, white label, etc.)
     if (isset($_SERVER['REQUEST_URI'])) {
         $claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license');
         if (!$claimingLicense && Input::has('license_key') && Input::has('product_id')) {
             $licenseKey = Input::get('license_key');
             $productId = Input::get('product_id');
             $url = (Utils::isNinjaDev() ? SITE_URL : NINJA_APP_URL) . "/claim_license?license_key={$licenseKey}&product_id={$productId}&get_date=true";
             $data = trim(CurlUtils::get($url));
             if ($productId == PRODUCT_INVOICE_DESIGNS) {
                 if ($data = json_decode($data)) {
                     foreach ($data as $item) {
                         $design = new InvoiceDesign();
                         $design->id = $item->id;
//.........这里部分代码省略.........
开发者ID:rafaelsisweb,项目名称:invoice-ninja,代码行数:101,代码来源:StartupCheck.php

示例15: setTrustedProxiesForRequest

 /**
  * Set trusted proxies for the request.
  * @param \Illuminate\Http\Request $request
  */
 public function setTrustedProxiesForRequest(Request $request)
 {
     if (empty($request->getTrustedProxies())) {
         $request->setTrustedProxies($request->getClientIps());
     }
 }
开发者ID:vluzrmos,项目名称:lumen-cors,代码行数:10,代码来源:CorsMiddleware.php


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