Esempio n. 1
1
 /**
  * This middleware forces the entire application to use SSL. We like that, because it's secure.
  *
  * Shamelessly copied from: http://stackoverflow.com/questions/28402726/laravel-5-redirect-to-https
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $force = env('FORCE_DOMAIN', null);
     if ($force != null && $request->getHttpHost() != $force) {
         return redirect()->to(env('APP_URL') . '/' . ($request->path() == '/' ? '' : $request->path()));
     }
     return $next($request);
 }
Esempio n. 2
1
 /**
  * Guess the HREF for the views.
  *
  * @param TableBuilder $builder
  */
 public function guess(TableBuilder $builder)
 {
     $views = $builder->getViews();
     foreach ($views as &$view) {
         // Only automate it if not set.
         if (!isset($view['attributes']['href'])) {
             $view['attributes']['href'] = $this->url->to($this->request->path() . '?' . array_get($view, 'prefix') . 'view=' . $view['slug']);
         }
     }
     $builder->setViews($views);
 }
Esempio n. 3
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param integer $key
  * @return mixed
  */
 public function handle($request, Closure $next, $key)
 {
     if (Cache::has($request->path() . '-' . $key)) {
         return Cache::get($request->path() . '-' . $key);
     }
     return $next($request);
 }
 /**
  * Disable sessions for requests to the acs endpoint
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (strpos($request->path(), 'access-control/') === 0 || $request->path() === 'acs' || $request->path() === 'acs/spark') {
         $this->app['config']->set('session.driver', 'array');
     }
     return $next($request);
 }
 /**
  * Handle the event.
  */
 public function handle()
 {
     if (!$this->config->get('app.debug') && !$this->session->get(__CLASS__ . 'warned') && $this->request->path() == 'admin/dashboard' && $this->modules->get('anomaly.module.installer')) {
         $this->session->set(__CLASS__ . 'warned', true);
         $this->messages->error('streams::message.delete_installer');
     }
 }
Esempio n. 6
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check() && \Hash::check($this->auth->user()->getNumber(), $this->auth->user()->getPassword()) && $request->path() != 'my/password' && $request->path() != 'logout') {
         return redirect()->route('front.my.password')->with('danger-message', trans('site.You have to change your password'));
     }
     return $next($request);
 }
Esempio n. 7
0
 public function getEdit(Request $request)
 {
     $id = intval(substr($request->path(), strrpos($request->path(), '/') + 1));
     $sample = $this->sample->getById($id);
     $producers = $this->producer->getAll();
     return view('website.user.samples.edit')->with(['browserTitle' => str_replace('{wildcard}', $sample->generated_number, trans('sample.edit_sample_wildcard')), 'mainArea' => 'samples', 'subArea' => 'edit', 'sample' => $sample, 'producers' => $producers]);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //Don't add the header to acs requests
     if (strpos($request->path(), 'access-control/') === 0 || $request->path() === 'acs' || $request->path() === 'acs/spark') {
         return $next($request);
     }
     return $next($request)->header('Built-By', 'arthurguy.co.uk');
 }
Esempio n. 9
0
 /**
  * Make the page breadcrumbs.
  *
  * @param PageInterface $page
  */
 public function make(PageInterface $page)
 {
     $breadcrumbs = [$page->getTitle() => $this->request->path()];
     $this->loadParent($page, $breadcrumbs);
     foreach (array_reverse($breadcrumbs) as $key => $url) {
         $this->breadcrumbs->add($key, $url);
     }
 }
Esempio n. 10
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Illuminate\Routing\Route $route
  * @param  \Illuminate\Http\Request $request
  *
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     $regex = $route->getCompiled()->getRegex();
     if (str_contains($request->getRequestUri(), '/wp-admin')) {
         return preg_match(str_replace('$#s', '(?:&.+)?$#s', $regex), rawurldecode($request->getRequestUri()));
     }
     $path = $request->path() == '/' ? '/' : '/' . $request->path();
     return preg_match($regex, rawurldecode($path));
 }
 /**
  * Handle the event.
  */
 public function handle()
 {
     if ($this->request->path() == 'admin/login') {
         $this->breadcrumbs->add('streams::breadcrumb.login', '#');
     }
     if ($this->request->path() == 'installer/install') {
         $this->breadcrumbs->add('streams::breadcrumb.install', '#');
     }
 }
Esempio n. 12
0
 /**
  * Verify the incoming request is via an ssl connection unless its on an approved url
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->isSecure() && env('FORCE_SECURE', 'true')) {
         if (strpos($request->path(), 'access-control/') !== 0 && $request->path() !== 'acs' && $request->path() !== 'acs/spark') {
             return redirect()->secure($request->path());
         }
     }
     return $next($request);
 }
Esempio n. 13
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::user()) {
         Log::info('Admin user is in ID:' . Auth::user()->id . ', email:' . Auth::user()->email . ', Path:' . $request->path() . ', Env:' . env('HTTP_USER_AGENT', 'unrecognized') . ', Time:' . date('Y-m-d H:i:s', time()));
     } else {
         Log::info('Guest user is in ' . 'Path:' . $request->path() . ', Env:' . env('HTTP_USER_AGENT', 'unrecognized') . ', Time:' . date('Y-m-d H:i:s', time()));
     }
     return $next($request);
 }
Esempio n. 14
0
 /**
  * Return requested uri without locale.
  *
  * @return string
  */
 public function getUriWithoutLocale()
 {
     $current = $this->getUriLocale();
     $default = $this->getDefaultLocale();
     $path = $this->request->path();
     if ($current == $default) {
         return $path;
     }
     return preg_replace('/' . $current . '\\/?/', '', $path);
 }
 /**
  * Handle the event.
  */
 public function handle()
 {
     if (in_array($this->request->path(), ['admin/logout'])) {
         return;
     }
     if ($this->request->segment(1) !== 'admin') {
         return;
     }
     $this->template->put('cp', $this->controlPanel->build());
 }
Esempio n. 16
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  LaravelRoute   $route   illuminate route
  * @param  LaravelRequest $request illuminate request
  *
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     $path = $request->path() == '/' ? '/' : '/' . $request->path();
     $firstSegment = $request->segment(1);
     if ($firstSegment === null) {
         return true;
     } else {
         return preg_match($route->getCompiled()->getRegex(), rawurldecode($path));
     }
 }
Esempio n. 17
0
 /**
  * @return string
  */
 public function currentPath()
 {
     if ($this->currentPath == null) {
         $path = $this->request->path();
         if ($path == '/') {
             $path = '';
         }
         $this->currentPath = $path;
     }
     return $this->currentPath;
 }
Esempio n. 18
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $filters = ['files', 'favicon', '_debugbar', 'activities', 'debug'];
     $log = true;
     foreach ($filters as $filter) {
         $log = strpos($request->path(), $filter) === false ? $log : false;
     }
     if ($log && !$request->ajax() && Auth::user() && $request->path() != "/") {
         Activity::log();
     }
     return $next($request);
 }
Esempio n. 19
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->method() == 'POST') {
         if (preg_match('/uploader/', $request->path(), $res)) {
             exit;
         }
         if (preg_match('/update|store|destroy|action|activate|password/', $request->path(), $res)) {
             return back()->with(['message-warning' => '<b>' . trans('demo_mode.message') . '</b>
                 <p>' . trans('demo_mode.input') . ':<pre>' . print_r($request->all(), 1) . '</pre></p>']);
         }
     }
     return $next($request);
 }
Esempio n. 20
0
 /**
  * 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()) {
             $this->logger->error('Authentication failed: Ajax request?!', array('url' => $request->path()));
             return response('Unauthorized.', 401);
         } else {
             $request->session()->flash('intended_url', $request->path());
             return redirect('login');
         }
     }
     return $next($request);
 }
 /**
  * Guess the enabled property.
  *
  * @param ControlPanelBuilder $builder
  */
 public function guess(ControlPanelBuilder $builder)
 {
     $buttons = $builder->getButtons();
     foreach ($buttons as &$button) {
         if (!isset($button['enabled']) || is_bool($button['enabled'])) {
             continue;
         }
         if (is_string($button['enabled'])) {
             $button['enabled'] = str_is($button['enabled'], $this->request->path());
         }
     }
     $builder->setButtons($buttons);
 }
Esempio n. 22
0
	/**
	 * Handle an incoming request.
	 *
	 * @param  \Illuminate\Http\Request  $request
	 * @param  \Closure  $next
	 * @return mixed
	 */
	public function handle($request, Closure $next)
	{
    //edit by meroc chen 2015-10-14
    //
    if ($request->is('/order/paynotify') || $request->path() == 'order/wxpay' || $request->path() == 'order/payed') {

      return $next($request);

    }
     
    //original
		return parent::handle($request, $next);

	}
Esempio n. 23
0
 /**
  *
  */
 public function within(Request $request)
 {
     $start = microtime(true);
     if (str_contains($request->path(), 'mongo')) {
         $collection = $this->model->within($request->json('geometry.coordinates'));
         $elapsed = microtime(true) - $start;
     } else {
         $geometry = \geoPHP::load($request->input('geometry'), 'wkt');
         $collection = $this->model->within($geometry->asText('wkt'));
         $elapsed = microtime(true) - $start;
     }
     $logMessage = 'ms to get %s data: %f in %s';
     \Log::debug(sprintf($logMessage, str_contains($request->path(), 'mongo') ? 'Mongo' : 'PostGIS', $elapsed, 'within()'));
     return Response::json(['points' => $collection, 'area' => 0]);
 }
Esempio n. 24
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->credentials->check()) {
         $this->logger->info('User tried to access a page without being logged in', ['path' => $request->path()]);
         if ($request->ajax()) {
             throw new UnauthorizedHttpException('Action Requires Login');
         }
         return Redirect::guest(URL::route('account.login'))->with('error', 'You must be logged in to perform that action.');
     }
     if (!$this->credentials->hasAccess($level = $this->level())) {
         $this->logger->warning('User tried to access a page without permission', ['path' => $request->path(), 'permission' => $level]);
         throw new AccessDeniedHttpException(ucfirst($level) . ' Permissions Are Required');
     }
     return $next($request);
 }
 public function index(Request $request)
 {
     $parameters = $request->route()->parameters();
     $parser = new Parser($parameters);
     $generator = new Generator($request->path());
     if (!isset($parameters['version']) && !isset($parameters['resource']) && !isset($parameters['action'])) {
         $segments = ['index'];
     } else {
         $segments = $parameters;
     }
     $file = base_path('resources/' . config('apidocu.base') . '/' . implode('/', $segments) . '.md');
     if (file_exists($file)) {
         $content = file_get_contents($file);
         $status = 200;
     } else {
         $status = 404;
         switch (config('apidocu.404.type')) {
             case 'text':
                 $content = config('apidocu.404.value');
                 break;
             case 'view':
                 $content = view(config('apidocu.404.value'));
                 break;
             default:
                 $content = '**404 - page not found**';
                 break;
         }
     }
     $content = $parser->parse($content);
     return Response::make(view('apidocu::index')->with(['navigation' => $generator->navigation(), 'breadcrumb' => $generator->breadcrumb(), 'content' => $content]), $status);
 }
 /**
  * Get the failed validation message for the request.
  *
  * @param  \Illuminate\Http\Request $request
  * @return string|null
  */
 public function getFailedValidationMessage(Request $request)
 {
     $messages = method_exists($this, 'failedValidationMessages') ? $this->failedValidationMessages() : [];
     $method = strtoupper($request->method());
     $path = $request->path();
     return array_get($messages, "{$method}.{$path}", $this->fallbackValidationMessages($method));
 }
Esempio n. 27
0
 /**
  * Enforces the secure attribute for a request
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->isSecure()) {
         return redirect()->secure($request->path());
     }
     return $next($request);
 }
 protected function download(Request $request, $prefix, $attachment = false)
 {
     $path = $request->path();
     // trim prefix
     if (starts_with($path, $prefix)) {
         $path = substr($path, strlen($prefix));
     }
     debug_log('File Download[File Path]', $path);
     // make absolute file path
     $path = wordpress_path($path);
     // ERROR: file not found
     if (!is_file($path)) {
         debug_log('File Download: [Abort]: not found');
         abort(404);
     }
     $extension = pathinfo($path, PATHINFO_EXTENSION);
     // ERROR: file extension is .php
     if ($extension == 'php') {
         debug_log('File Download: [Abort]: .php');
         abort(404);
     }
     debug_log('File Download[Content Type]', $this->getMimeType($path, $extension));
     $headers = ['Content-Type' => $this->getMimeType($path, $extension)];
     if ($attachment === false) {
         return response()->make(file_get_contents($path), 200, $headers);
     }
     return response()->download($path, 200, $headers);
 }
Esempio n. 29
0
 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');
     }
 }
Esempio n. 30
0
 /**
  * Handle an incoming request, check to see if we have a redirect in place for the requested URL
  * and then redirect if we do have a match
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Get the full URL that has been requested, minus the protocol
     $full_url = str_replace($request->getScheme() . "://", "", $request->url());
     // Check for any results matching the full domain request
     $results = Redirect::where("type", "domain")->where("from", $full_url)->where("status", "active");
     if ($results->exists()) {
         // Get the first result back
         $redirect = $results->first();
         // Grab the URL before we increment
         $url = $redirect->to;
         // Increment the hit count
         $redirect->increment('hits');
         // Redirect off to where we're going
         return RedirectFacade::to($url);
     }
     // Check for any results matching the path only
     $results = Redirect::where("type", "path")->where("from", "/" . $request->path())->where("status", "active");
     // If a redirect exists for this, process it and redirect
     if ($results->exists()) {
         // Get the first result back
         $redirect = $results->first();
         // Grab the URL before we increment
         $url = $redirect->to;
         // Increment the hit count
         $redirect->increment('hits');
         // Redirect off to where we're going
         return RedirectFacade::to($url, 301);
     }
     // By default, continue afterwards and bail out
     return $next($request);
 }