Exemplo n.º 1
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Nova\Routing\Route  $route
  * @param  \Nova\Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     if (is_null($route->getCompiled()->getHostRegex())) {
         return true;
     }
     return preg_match($route->getCompiled()->getHostRegex(), $request->getHost());
 }
Exemplo n.º 2
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Nova\Routing\Route  $route
  * @param  \Nova\Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     if ($route->httpOnly()) {
         return !$request->secure();
     } elseif ($route->secure()) {
         return $request->secure();
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * Get the base URL for the request.
  *
  * @param  string  $scheme
  * @param  string  $root
  * @return string
  */
 protected function getRootUrl($scheme, $root = null)
 {
     if (is_null($root)) {
         $root = $this->forcedRoot ?: $this->request->root();
     }
     $start = starts_with($root, 'http://') ? 'http://' : 'https://';
     return preg_replace('~' . $start . '~', $scheme, $root, 1);
 }
Exemplo n.º 4
0
 /**
  * Filter the incoming requests.
  */
 public function filterRequests(Route $route, Request $request)
 {
     // Store the Request instance for further processing.
     $this->request = $request;
     // Check the User Authorization.
     if (Auth::user()->hasRole('administrator')) {
         // The User is authorized; continue the Execution Flow.
         return null;
     }
     if ($request->ajax()) {
         // On an AJAX Request; just return Error 403 (Access denied)
         return Response::make('', 403);
     }
     // Redirect the User to his/hers Dashboard with a warning message.
     $status = __d('files', 'You are not authorized to access this resource.');
     return Redirect::to('admin/dashboard')->withStatus($status, 'warning');
 }
Exemplo n.º 5
0
 /**
  * Get a route (if necessary) that responds when other available methods are present.
  *
  * @param  \Nova\Http\Request  $request
  * @param  array  $others
  * @return \Nova\Routing\Route
  *
  * @throws \Symfony\Component\Routing\Exception\MethodNotAllowedHttpException
  */
 protected function getOtherMethodsRoute($request, array $others)
 {
     if ($request->method() == 'OPTIONS') {
         return (new Route('OPTIONS', $request->path(), function () use($others) {
             return new Response('', 200, array('Allow' => implode(',', $others)));
         }))->bind($request);
     }
     $this->methodNotAllowed($others);
 }
Exemplo n.º 6
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Nova\Routing\Route  $route
  * @param  \Nova\Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     $path = $request->path() == '/' ? '/' : '/' . $request->path();
     return preg_match($route->getCompiled()->getRegex(), rawurldecode($path));
 }
Exemplo n.º 7
0
 /**
  * Get the pattern filters for a given URI and method.
  *
  * @param  string  $uri
  * @param  string  $method
  * @return array
  */
 protected function getMethodPatterns($uri, $method)
 {
     return $this->router->findPatternFilters(Request::create($uri, $method));
 }
Exemplo n.º 8
0
 /**
  * Prepare the request by injecting any services.
  *
  * @param  \Nova\Http\Request  $request
  * @return \Nova\Http\Request
  */
 public function prepareRequest(Request $request)
 {
     if (!is_null($this['config']['session.driver']) && !$request->hasSession()) {
         $request->setSession($this['session']->driver());
     }
     return $request;
 }
Exemplo n.º 9
0
//--------------------------------------------------------------------------
$app->instance('config', $config = new ConfigRepository($app->getConfigLoader()));
//--------------------------------------------------------------------------
// Set The Default Timezone From Configuration
//--------------------------------------------------------------------------
$config = $app['config']['app'];
date_default_timezone_set($config['timezone']);
//--------------------------------------------------------------------------
// Register The Alias Loader
//--------------------------------------------------------------------------
$aliases = $config['aliases'];
AliasLoader::getInstance($aliases)->register();
//--------------------------------------------------------------------------
// Enable HTTP Method Override
//--------------------------------------------------------------------------
Request::enableHttpMethodParameterOverride();
//--------------------------------------------------------------------------
// Enable Trusting Of X-Sendfile Type Header
//--------------------------------------------------------------------------
BinaryFileResponse::trustXSendfileTypeHeader();
//--------------------------------------------------------------------------
// Register The Core Service Providers
//--------------------------------------------------------------------------
$providers = $config['providers'];
$app->getProviderRepository()->load($app, $providers);
//--------------------------------------------------------------------------
// Additional Middleware On Application
//--------------------------------------------------------------------------
App::middleware('Shared\\Http\\ContentGuard', array($app['config']['app.debug']));
//--------------------------------------------------------------------------
// Register Booted Start Files
Exemplo n.º 10
0
 /**
  * Determine if the filter fails the "on" constraint.
  *
  * @param  array  $filter
  * @param  \Nova\Http\Request  $request
  * @param  string  $method
  * @return bool
  */
 protected function filterFailsOn($filter, $request, $method)
 {
     $on = array_get($filter, 'options.on');
     if (is_null($on)) {
         return false;
     }
     // If the "on" is a string, we will explode it on the pipe so you can set any
     // amount of methods on the filter constraints and it will still work like
     // you specified an array. Then we will check if the method is in array.
     if (is_string($on)) {
         $on = explode('|', $on);
     }
     return !in_array(strtolower($request->getMethod()), $on);
 }
Exemplo n.º 11
0
 /**
  * Extract the parameter list from the host part of the request.
  *
  * @param  \Nova\Http\Request  $request
  * @param  array  $parameters
  * @return array
  */
 protected function bindHostParameters(Request $request, $parameters)
 {
     preg_match($this->compiled->getHostRegex(), $request->getHost(), $matches);
     return array_merge($this->matchToKeys(array_slice($matches, 1)), $parameters);
 }
Exemplo n.º 12
0
 /**
  * Flash an array of input to the session.
  *
  * @param  mixed  string
  * @return \Nova\Http\RedirectResponse
  */
 public function exceptInput()
 {
     return $this->withInput($this->request->except(func_get_args()));
 }
Exemplo n.º 13
0
 /**
  * Determine if the filter fails the "on" constraint.
  *
  * @param  array  $filter
  * @param  \Nova\Http\Request  $request
  * @param  string  $method
  * @return bool
  */
 protected function filterFailsOn($filter, $request, $method)
 {
     $on = array_get($filter, 'options.on');
     if (is_null($on)) {
         return false;
     }
     if (is_string($on)) {
         $on = explode('|', $on);
     }
     return !in_array(strtolower($request->getMethod()), $on);
 }
Exemplo n.º 14
0
 /**
  * Get the response for a given request.
  *
  * @param  \Symfony\Component\HttpFoundation\Request  $request
  * @param  int   $type
  * @param  bool  $catch
  * @return \Nova\Http\Response
  */
 public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     return $this->dispatch(Request::createFromBase($request));
 }
Exemplo n.º 15
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Nova\Routing\Route  $route
  * @param  \Nova\Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     return in_array($request->getMethod(), $route->methods());
 }