Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Middleware;
- use Closure;
- class blockIp
- {
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- $boleh = 0;
- $alamat_ip = gethostbyaddr($_SERVER['REMOTE_ADDR']);
- // dd($alamat_ip);
- $addr_ip = explode('.', $alamat_ip);
- $ip = $addr_ip[0];
- $ipdantoko = explode('-', $ip);
- $host_toko = $ipdantoko[0];
- $m_ip = \DB::table('ip')->get();
- foreach($m_ip as $mip)
- {
- $addr = $mip->addr;
- if($addr == $host_toko){
- $boleh = 1;
- }
- }
- if($boleh == 0){
- return \Response::make(view('errorr'), 404);
- }
- return $next($request);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement