<?php
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/adm_check.php';
include_once '../sys/inc/user.php';

/*
=============================
Автор: Shamsik
=============================
Модуль: Защита для админской части
=============================
*/
if (!isset($_SERVER['PHP_AUTH_USER']))

{
        Header ("WWW-Authenticate: Basic realm=\"Admin Page BleIK\"");
        Header ("HTTP/1.0 401 Unauthorized");
        exit();
}
else {
if (!get_magic_quotes_gpc()) {
$_SERVER['PHP_AUTH_USER'] = mysql_escape_string($_SERVER['PHP_AUTH_USER']);
$_SERVER['PHP_AUTH_PW'] = mysql_escape_string($_SERVER['PHP_AUTH_PW']);}
$query = "SELECT pass FROM adm_pass WHERE user='".$_SERVER['PHP_AUTH_USER']."'";
$lst = @mysql_query($query);
if (!$lst)
{Header ("WWW-Authenticate: Basic realm=\"Admin Page BleIK\"");
Header ("HTTP/1.0 401 Unauthorized");
exit();}
if (mysql_num_rows($lst) == 0)
{Header ("WWW-Authenticate: Basic realm=\"Admin Page BleIK\"");
Header ("HTTP/1.0 401 Unauthorized");
exit();}
$pass =  @mysql_fetch_array($lst);
if ($_SERVER['PHP_AUTH_PW']!= $pass['pass'])
{Header ("WWW-Authenticate: Basic realm=\"Admin Page BleIK\"");
Header ("HTTP/1.0 401 Unauthorized");exit();}}
?>