Added page to print sk-hasil-belajar freely
This commit is contained in:
35
app/Http/Middleware/IzinMasukPendopo.php
Normal file
35
app/Http/Middleware/IzinMasukPendopo.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class IzinMasukPendopo
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$AUTH_USER = 'tatausaha';
|
||||
$AUTH_PASS = substr(md5(Carbon::now()->toDateString().'ba'), 0, 6);
|
||||
header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
||||
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
|
||||
$is_not_authenticated = (
|
||||
!$has_supplied_credentials ||
|
||||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
|
||||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
|
||||
);
|
||||
if ($is_not_authenticated) {
|
||||
header('HTTP/1.1 401 Authorization Required');
|
||||
header('WWW-Authenticate: Basic realm="Access denied"');
|
||||
exit;
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user