require_once dirname(__FILE__).'/include/classes/user/CWebUser.php';
CWebUser::disableSessionCookie();
require_once dirname(__FILE__).'/include/config.inc.php';
$config = select_config();
$redirect_to = (new CUrl('index.php'))->setArgument('form', 'default');
$request = getRequest('request', '');
preg_match('/^\/?(?<filename>[a-z0-9\_\.]+\.php)(\?.*)?$/i', $request, $test_request);
if (!array_key_exists('filename', $test_request) || !file_exists('./'.$test_request['filename'])
|| $test_request['filename'] == basename(__FILE__)) {
$redirect_to->setArgument('request', $request);
if ($config['http_auth_enabled'] != ZBX_AUTH_HTTP_ENABLED) {
redirect($redirect_to->toString());
foreach (['PHP_AUTH_USER', 'REMOTE_USER', 'AUTH_USER'] as $key) {
if (array_key_exists($key, $_SERVER) && $_SERVER[$key] !== '') {
$http_user = $_SERVER[$key];
$parser = new CADNameAttributeParser(['strict' => true]);
if ($parser->parse($http_user) === CParser::PARSE_SUCCESS) {
$strip_domain = explode(',', $config['http_strip_domains']);
$strip_domain = array_map('trim', $strip_domain);
if ($strip_domain && in_array($parser->getDomainName(), $strip_domain)) {