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


PHP Request::is方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->is('install') && !$request->is('install/*') && !Storage::exists('public/install.lock')) {
         return redirect('/install');
     }
     return $next($request);
 }
开发者ID:koyeo,项目名称:bichon,代码行数:14,代码来源:InstallCheck.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $loggingIn = $request->is('api/v1/login') || $request->is('api/v1/register') || $request->is('api/v1/oauth_login');
     $headers = Utils::getApiHeaders();
     $hasApiSecret = false;
     if ($secret = env(API_SECRET)) {
         $requestSecret = Request::header('X-Ninja-Secret') ?: ($request->api_secret ?: '');
         $hasApiSecret = hash_equals($requestSecret, $secret);
     }
     if ($loggingIn) {
         // check API secret
         if (!$hasApiSecret) {
             sleep(ERROR_DELAY);
             return Response::json('Invalid value for API_SECRET', 403, $headers);
         }
     } else {
         // check for a valid token
         $token = AccountToken::where('token', '=', Request::header('X-Ninja-Token'))->first(['id', 'user_id']);
         // check if user is archived
         if ($token && $token->user) {
             Auth::onceUsingId($token->user_id);
             Session::set('token_id', $token->id);
         } else {
             sleep(ERROR_DELAY);
             return Response::json('Invalid token', 403, $headers);
         }
     }
     if (!Utils::isNinja() && !$loggingIn) {
         return $next($request);
     }
     if (!Utils::hasFeature(FEATURE_API) && !$hasApiSecret) {
         return Response::json('API requires pro plan', 403, $headers);
     } else {
         $key = Auth::check() ? Auth::user()->account->id : $request->getClientIp();
         // http://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users
         $hour = 60 * 60;
         $hour_limit = 100;
         # users are limited to 100 requests/hour
         $hour_throttle = Cache::get("hour_throttle:{$key}", null);
         $last_api_request = Cache::get("last_api_request:{$key}", 0);
         $last_api_diff = time() - $last_api_request;
         if (is_null($hour_throttle)) {
             $new_hour_throttle = 0;
         } else {
             $new_hour_throttle = $hour_throttle - $last_api_diff;
             $new_hour_throttle = $new_hour_throttle < 0 ? 0 : $new_hour_throttle;
             $new_hour_throttle += $hour / $hour_limit;
             $hour_hits_remaining = floor(($hour - $new_hour_throttle) * $hour_limit / $hour);
             $hour_hits_remaining = $hour_hits_remaining >= 0 ? $hour_hits_remaining : 0;
         }
         if ($new_hour_throttle > $hour) {
             $wait = ceil($new_hour_throttle - $hour);
             sleep(1);
             return Response::json("Please wait {$wait} second(s)", 403, $headers);
         }
         Cache::put("hour_throttle:{$key}", $new_hour_throttle, 10);
         Cache::put("last_api_request:{$key}", time(), 10);
     }
     return $next($request);
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:67,代码来源:ApiCheck.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->isMethod('get') && !$request->has('PageSpeed') && !$request->is(config('site.admin_path') . '*') && !$request->is('avatar/*') && !$request->is('my/*') && !$request->is('*/login') && !$request->is('*/authorize') && !in_array($request->path(), ['sitemap.xml', 'logout', 'login'])) {
         $aSiteMap = Cache::get('sitemap', []);
         $changefreq = 'always';
         if (!empty($aSiteMap[$request->fullUrl()]['added'])) {
             $aDateDiff = Carbon::createFromTimestamp($aSiteMap[$request->fullUrl()]['added'])->diff(Carbon::now());
             if ($aDateDiff->y > 0) {
                 $changefreq = 'yearly';
             } else {
                 if ($aDateDiff->m > 0) {
                     $changefreq = 'monthly';
                 } else {
                     if ($aDateDiff->d > 6) {
                         $changefreq = 'weekly';
                     } else {
                         if ($aDateDiff->d > 0 && $aDateDiff->d < 7) {
                             $changefreq = 'daily';
                         } else {
                             if ($aDateDiff->h > 0) {
                                 $changefreq = 'hourly';
                             } else {
                                 $changefreq = 'always';
                             }
                         }
                     }
                 }
             }
         }
         $aSiteMap[$request->fullUrl()] = ['added' => time(), 'lastmod' => Carbon::now()->format('Y-m-d\\TH:i:sP'), 'priority' => 1 - substr_count($request->getPathInfo(), '/') / 10, 'changefreq' => $changefreq];
         Cache::forever('sitemap', $aSiteMap);
     }
     return $next($request);
 }
开发者ID:vnsource,项目名称:core,代码行数:42,代码来源:Sitemap.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $rota = Request::segment(1);
     if ($rota == 'auth' && Auth::guest()) {
         return redirect('/auth/login');
     }
     print time();
     dd('rrr');
     //dd($rota);
     if ($request->is('auth')) {
         dd('ddd');
         return redirect('/auth/login');
     }
     if (!$request->is('/auth/login') && Auth::guest()) {
         //    dd('oi');
         return redirect('/auth/login');
     }
     print $rota;
     if (($rota == null || $rota == 'auth' || $rota == 'home' || $request->is('permissao/negada')) && Auth::guest()) {
         return $next($request);
     }
     //dd( $request->is('Auth/logout') );
     $url = Request::url();
     print_r($url);
     //dd();
     if (!Infra_Permissao::tem_permissao()) {
         //die( 'NÂO tem permssao - redirecionar para uma view sem permissao');
         print time();
         //dd();
         return redirect('permissao/negada');
     }
     return $next($request);
 }
开发者ID:alipusman,项目名称:laravel5,代码行数:40,代码来源:PermissaoMiddleware.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     /**
      * check for ban by ip
      */
     $remote_ip = $request->ip();
     $cache_key = '_ban_ip_' . $remote_ip;
     $ban_info = Cache::rememberForever($cache_key, function () use($remote_ip) {
         return AdBanIp::where('ban_ip', $remote_ip)->first();
     });
     if (!empty($ban_info) && !$request->is('ban')) {
         return redirect('ban');
     }
     /**
      * check if user is banned my email
      */
     if (Auth()->check()) {
         $user_mail = Auth()->user()->email;
         $cache_key = '_ban_email_' . $user_mail;
         $ban_info = Cache::rememberForever($cache_key, function () use($user_mail) {
             return AdBanEmail::where('ban_email', $user_mail)->first();
         });
         if (!empty($ban_info) && !$request->is('ban')) {
             return redirect('ban');
         }
     }
     return $next($request);
 }
开发者ID:gdinko,项目名称:dclassifieds.laravel,代码行数:35,代码来源:BanMiddleware.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->is('administrator/*') || $request->is('administrator')) {
         config()->set('auth.defaults.guard', 'administrator');
     }
     return $next($request);
 }
开发者ID:yajra,项目名称:cms-core,代码行数:14,代码来源:AdministratorUserResolver.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->is('auth/*') && !$request->is('api/*') && $this->auth->guest()) {
         return redirect()->guest('auth/login');
     }
     return $next($request);
 }
开发者ID:nathan-lochala,项目名称:SF,代码行数:14,代码来源:AuthenticateAllPages.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             //                return redirect()->guest('auth/login');
             return redirect()->guest('dangnhap');
         }
     }
     if ($request->is('giangvien/*')) {
         if (\Auth::user()->quyen != 'gv') {
             return redirect()->guest('dangnhap');
         }
     }
     if ($request->is('quantri/*')) {
         if (\Auth::user()->quyen != 'qt') {
             return redirect()->guest('dangnhap');
         }
     }
     if ($request->is('sinhvien/*')) {
         if (\Auth::user()->quyen != 'sv') {
             return redirect()->guest('dangnhap');
         }
     }
     /* $action = $request->route()->getActionName();
        echo $action; */
     return $next($request);
 }
开发者ID:HaNguyen1410,项目名称:laravProject1,代码行数:36,代码来源:Authenticate.php

示例9: Response

 public function Response(Request $request, $id)
 {
     $uri = $request->path();
     $method = $request->method();
     if ($request->is('countries')) {
         if ($request->has('filter')) {
             $zones = CountryAdapter::zoneByName($request->filter);
         } else {
             $zones = CountryAdapter::zones();
         }
         return $this->apiOutput(function () use($zones) {
             $data = array();
             foreach ($zones as $i => $zone) {
                 $tmp_data[$i] = ['zone' => $zone->name, 'countries' => CountryAdapter::getByZone($zone)];
                 array_push($data, $tmp_data[$i]);
             }
             return $data;
         });
     } elseif ($request->is('countries/*')) {
         $country = CountryAdapter::getById($id);
         return $this->apiOutput(function () use($country) {
             $zone = CountryAdapter::zoneById($country->zone_id);
             $country_data = ['id' => intval($country->numeric_code), 'name' => $country->name, 'zone' => $zone->name, 'alpha2' => $country->alpha2, 'alpha3' => $country->alpha3];
             return $country_data;
         });
     } else {
         dd('error');
     }
 }
开发者ID:jnaxo,项目名称:country-codes,代码行数:29,代码来源:CountryStore.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Auth::check()) {
         if (!($request->is('auth/login') or $request->is('auth/register'))) {
             return redirect('/auth/login');
         }
     }
     return $next($request);
 }
开发者ID:michael-dean-haynie,项目名称:my-secret-santa,代码行数:16,代码来源:LoggedInMiddleware.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->session()->has('user') && (!$request->is('user/*') || $request->is('user/logout'))) {
         return redirect('user/login');
     } elseif ($request->session()->has('user') && ($request->is('user/*') && !$request->is('user/logout'))) {
         return redirect('/');
     }
     return $next($request);
 }
开发者ID:pratyush20,项目名称:lara_drupal,代码行数:16,代码来源:Custom.php

示例12: compose

 /**
  * compose.
  *
  * @param View $view 视图对象
  */
 public function compose(View $view)
 {
     $menus = $this->request->is('admin/account*') ? config('menu.account') : config('menu.func');
     $global = new Fluent();
     $global->user = Auth::user();
     $global->menus = $menus;
     $global->current_account = app('viease.current_account');
     $global->accounts = $this->accountRepository->lists(99);
     $view->with('global', $global);
 }
开发者ID:renyang9876,项目名称:viease,代码行数:15,代码来源:AdminComposer.php

示例13: handle

 /**
  * This middleware forces power users to use TFA before they can do anything else.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (App::environment('production') && Auth::check() && Auth::user()->hasRole(config('proto.tfaroles')) && (!Auth::user()->tfa_totp_key && !Auth::user()->tfa_yubikey_identity)) {
         if (!$request->is('user/dashboard') && !$request->is('auth/logout') && !$request->is('user/quit_impersonating') && !$request->is('user/*/2fa/*')) {
             $request->session()->flash('flash_message', 'Since you are able to access a lot of sensitive information, you are required to enable Two Factor Authentication on your account. Please do so now! :)');
             return Redirect::route('user::dashboard');
         }
     }
     return $next($request);
 }
开发者ID:saproto,项目名称:saproto,代码行数:17,代码来源:EnforceTFA.php

示例14: handle

 public function handle(Request $request, Closure $next)
 {
     if (!$request->is('account/verify') && !$request->is('account/reissue-code') && !$request->is('users/logout') && $this->requiresVerification($request)) {
         $verification = new UserVerification($this->auth->user(), $request);
         if (!$verification->isDone()) {
             return $verification->initiate();
         }
     }
     return $next($request);
 }
开发者ID:ppy,项目名称:osu-web,代码行数:10,代码来源:VerifyUser.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  *
  * @param string|null $context
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $context = null)
 {
     if (is_null($context)) {
         $context = ($request->is(backend_url_segment()) or $request->is(backend_url_segment() . '/*')) ? \KodiCMS\CMS\CMS::CONTEXT_BACKEND : \KodiCMS\CMS\CMS::CONTEXT_FRONTEND;
     }
     $contexts = explode('|', $context);
     foreach ($contexts as $context) {
         CMS::setContext($context);
     }
     return $next($request);
 }
开发者ID:KodiComponents,项目名称:module-core,代码行数:21,代码来源:Context.php


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