Facebook
From Beige Moth, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 249
  1. <?php
  2.  
  3. namespace App\Http\Middleware;
  4.  
  5. use Closure;
  6.  
  7. class AllowDomains
  8. {
  9.  
  10.     /**
  11.      * Handle an incoming request.
  12.      *
  13.      * @param  \Illuminate\Http\Request  $request
  14.      * @param  \Closure  $next
  15.      * @return mixed
  16.      */
  17.     public function handle($request, Closure $next)
  18.     {
  19.         $lp_domains = \App\Http\Controllers\LandingPageController::getCurrentDomains();
  20.  
  21.         if ($request->getHttpHost() != config('app.domain')) { // main domain dont match
  22.             if (! strstr($request->url(), '/link/')) { // not link
  23.                 if (substr($request->getHttpHost(), 0, 6) !== 'admin.') { // not admin page
  24.                     if (! in_array($request->getHttpHost(), $lp_domains)) { // not lp
  25.                         die();
  26.                     }
  27.                 }
  28.             }
  29.         }
  30.  
  31.         return $next($request);
  32.     }
  33. }
  34.