Created
December 5, 2019 02:29
-
-
Save marcosrocha85/b83eaace8f7c79285321fcf388c21179 to your computer and use it in GitHub Desktop.
Laravel Robot Entertainer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected $middleware = [ | |
// ... | |
\App\Http\Middleware\RobotEntertainerMiddleware::class, | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Support\Arr; | |
class RobotEntertainerMiddleware | |
{ | |
const prohibitedRoutes = [ | |
'.well-known/assetlinks.json', | |
'blog/*', | |
"*/eval-stdin.php", | |
"*/Sms.php", | |
"*/update.php", | |
"*/wp-login.php", | |
"*/xmlrpc.php*", | |
"/.git/*", | |
"/xxxxxx.php", | |
"admin.php", | |
"admin/login.php", | |
"administrator", | |
"administrator/*", | |
"ajaxproxy/proxy.php", | |
"backup", | |
"bitrix/*", | |
"cms", | |
"demo", | |
"home", | |
"index.php", | |
"info.php", | |
"magmi/web/magmi.php", | |
"main", | |
"manager/*", | |
"new", | |
"news", | |
"old", | |
"site", | |
"temp", | |
"test", | |
"tmp", | |
"v1", | |
"v2", | |
"web", | |
"website", | |
"wordpress/*", | |
"wp-*/*", | |
"wp/*", | |
"xmlrpc.php*", | |
]; | |
const tenHoursOfFun = [ | |
"https://www.youtube.com/watch?v=wbby9coDRCk", | |
"https://www.youtube.com/watch?v=nb2evY0kmpQ", | |
"https://www.youtube.com/watch?v=eh7lp9umG2I", | |
"https://www.youtube.com/watch?v=z9Uz1icjwrM", | |
"https://www.youtube.com/watch?v=Sagg08DrO5U", | |
"https://www.youtube.com/watch?v=A3YmHZ9HMPs", | |
"https://www.youtube.com/watch?v=jI-kpVh6e1U", | |
"https://www.youtube.com/watch?v=jScuYd3_xdQ", | |
"https://www.youtube.com/watch?v=S5PvBzDlZGs", | |
"https://www.youtube.com/watch?v=9UZbGgXvCCA", | |
"https://www.youtube.com/watch?v=O-dNDXUt1fg", | |
"https://www.youtube.com/watch?v=MJ5JEhDy8nE", | |
"https://www.youtube.com/watch?v=VnnWp_akOrE", | |
"https://www.youtube.com/watch?v=jwGfwbsF4c4", | |
"https://www.youtube.com/watch?v=8ZcmTl_1ER8", | |
"https://www.youtube.com/watch?v=gLmcGkvJ-e0", | |
"https://www.youtube.com/watch?v=hGlyFc79BUE", | |
"https://www.youtube.com/watch?v=KMFOVSWn0mI", | |
"https://www.youtube.com/watch?v=clU0Sh9ngmY", | |
"https://www.youtube.com/watch?v=sCNrK-n68CM" | |
]; | |
private function isProhibited($request) { | |
foreach (self::prohibitedRoutes as $route) { | |
if ($request->is($route)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
if ($this->isProhibited($request)) | |
{ | |
return redirect()->away(Arr::random(self::tenHoursOfFun)); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment