/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed * * @throws \Symfony\Component\HttpKernel\Exception\HttpException */ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance() && $this->app->environment() != 'testing') { throw new HttpException(503, 'Server is currently undergoing maintenance. We should be ' . 'back up shortly.'); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed * * @throws \Symfony\Component\HttpKernel\Exception\HttpException */ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance()) { throw new HttpException(503, null, null, ['Retry-After' => 900]); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance()) { throw new HttpException(503); } return $next($request); }
/** * 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); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance()) { return new Response($this->view->make('maintenance')->render(), 503); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance()) { return new Response('Be right back!', 503); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return void|mixed */ public function handle(Request $request, Closure $next) { if (!$this->app->isDownForMaintenance()) { return $next($request); } if ($request->segment(1) == 'admin') { return $next($request); } if (in_array($request->getClientIp(), $this->config->get('streams::maintenance.ip_whitelist', []))) { return $next($request); } /* @var UserInterface $user */ $user = $this->guard->user(); if ($user && $user->isAdmin()) { return $next($request); } if ($user && $this->authorizer->authorize('streams::maintenance.access')) { return $next($request); } if (!$user && $this->config->get('streams::maintenance.auth')) { /* @var Response|null $response */ $response = $this->guard->onceBasic(); if (!$response) { return $next($request); } $response->setContent(view('streams::errors.401')); return $response; } abort(503); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance() && !in_array($request->getClientIp(), ['127.0.0.1'])) { throw new HttpException(503); } return $next($request); }
/** * 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) { if ($this->application->isDownForMaintenance()) { $data = json_decode(file_get_contents($this->application->storagePath() . '/bootstraps/down'), true); throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed * * @throws \Symfony\Component\HttpKernel\Exception\HttpException */ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance()) { if (site('adminIgnoresMaintenance') == '1' && ($user = $request->user()) && $user->isAdmin()) { return $next($request); } throw new HttpException(503); } return $next($request); }
/** * Handle the command. * * @param SettingsWereSaved $event */ public function handle(SettingsWereSaved $event) { $builder = $event->getBuilder(); if (!($namespace = $builder->getEntry()) == 'streams') { return; } $maintenance = $builder->getFormValue('maintenance'); if ($maintenance && !$this->application->isDownForMaintenance()) { touch(storage_path('framework/down')); } if (!$maintenance && $this->application->isDownForMaintenance()) { unlink(storage_path('framework/down')); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed * * @throws \Symfony\Component\HttpKernel\Exception\HttpException */ public function handle($request, Closure $next) { if ($this->app->isDownForMaintenance()) { $response = $next($request); $route = $request->route(); if ($route instanceof Route) { if (in_array($route->getName(), $this->excludedRoutes)) { return $response; } } throw new HttpException(503); } return $next($request); }
/** * Determine if the given event should run based on the Cron expression. * * @param \Illuminate\Contracts\Foundation\Application $app * @return bool */ public function isDue($app) { if (!$this->runsInMaintenanceMode() && $app->isDownForMaintenance()) { return false; } return $this->expressionPasses() && $this->runsInEnvironment($app->environment()); }
/** * Handle the request * * @param \Illuminate\Http\Request $request * @param callable $next * @return Response * @throws ExemptionDoesNotExist * @throws InvalidExemption */ public function handle($request, Closure $next) { // Grab our configs $injectGlobally = $this->app['config']->get('maintenancemode.inject.globally', true); $prefix = $this->app['config']->get('maintenancemode.inject.prefix', 'MaintenanceMode'); $lang = $this->app['config']->get('maintenancemode.language-path', 'maintenancemode::defaults'); // Setup value array $info = [$prefix . 'Enabled' => false, $prefix . 'Timestamp' => Carbon::now(), $prefix . 'Message' => $this->app['translator']->get($lang . '.message')]; // Are we down? if ($this->app->isDownForMaintenance()) { // Yes. :( $info[$prefix . 'Enabled'] = true; $path = storage_path() . '/framework/down'; if ($this->app['files']->exists($path)) { // Grab the stored information $fileContents = $this->app['files']->get($path); if (preg_match('~([0-9]+)\\|(.*)~', $fileContents, $matches)) { // And put it into our array, if it exists $info[$prefix . 'Timestamp'] = Carbon::createFromTimeStamp($matches[1]); if (isset($matches[2]) && $matches[2] != '') { $info[$prefix . 'Message'] = $matches[2]; } } } if ($injectGlobally) { // Inject the information globally foreach ($info as $key => $value) { $this->app['view']->share($key, $value); } } // Check to see if the user is exempt or not $isExempt = false; // Grab all of the exemption classes to create/execute against $exemptions = $this->app['config']->get('maintenancemode.exemptions', []); foreach ($exemptions as $className) { if (class_exists($className)) { $exemption = new $className($this->app); if ($exemption instanceof MaintenanceModeExemption) { // Run the exemption check if ($exemption->isExempt()) { $isExempt = true; break; } } else { // Class doesn't match what we're looking for throw new InvalidExemption($this->app['translator']->get($lang . '.exceptions.invalid', ['class' => $className])); } } else { // Where's Waldo? throw new ExemptionDoesNotExist($this->app['translator']->get($lang . '.exceptions.missing', ['class' => $className])); } } if (!$isExempt) { // Since the session isn't started... it'll throw an error $this->app['session']->start(); // The user isn't exempt, let's show them the maintenance page! $view = $this->app['config']->get('maintenancemode.view-page', 'maintenancemode::app-down'); // $view = 'errors.503'; return new Response(view($view, $info), 503); } } else { if ($injectGlobally) { // Inject the information globally (to prevent the need of isset) foreach ($info as $key => $value) { $this->app['view']->share($key, $value); } } } return $next($request); }
/** * Run the request filter. * * @return mixed */ public function filter() { if ($this->app->isDownForMaintenance()) { return new Response('Be right back!', 503); } }