Код: Выделить всё
if( !isset( $_SERVER[ 'PHP_AUTH_USER' ] ) ) :
header( 'WWW-Authenticate: Basic realm="My Realm"' );
header( 'HTTP/1.0 401 Unauthorized' );
LOG->error( 'Unauthorized access attempt to basic authentication report', ['reason' => 'Missing PHP_AUTH_USER', 'report' => $_SERVER['SCRIPT_FILENAME']] );
exit;
elseif( !isset( $_SERVER[ 'PHP_AUTH_PW' ] ) ) :
header( 'HTTP/1.0 401 Unauthorized' );
LOG->error( 'Unauthorized access attempt to basic authentication report', ['reason' => 'Missing PHP_AUTH_PW', 'report' => $_SERVER['SCRIPT_FILENAME']] );
exit;
else :
LOG->info( 'authorized request' );
/* do stuff */
endif;
Подробнее здесь: https://stackoverflow.com/questions/796 ... ower-query