<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
header("Pragma: no-cache");                          // HTTP/1.0

error_reporting(7);

if (!isset($umgesetzt)) {
	$umgesetzt = true;

	if (is_array($_GET)) {
		foreach($_GET as $key => $val) {
			if (!is_array($val)) {
				if (get_magic_quotes_gpc) $val = StripSlashes($val);
				$val = AddSlashes(StripSlashes($val));
			}
			$$key = $val;
		}
	} elseif (is_array($HTTP_GET_VARS)) {
		foreach($HTTP_GET_VARS as $key => $val) {
			if (!is_array($val)) {
				if (get_magic_quotes_gpc) $val = StripSlashes($val);
				$val = AddSlashes(StripSlashes($val));
			}
			$$key = $val;
		}
	}

	if (is_array($_POST)) {
		foreach($_POST as $key => $val) {
			if (!is_array($val)) {
				if (get_magic_quotes_gpc) $val = StripSlashes($val);
				$val = AddSlashes(StripSlashes($val));
			}
			$$key = $val;
		}
	} elseif (is_array($HTTP_POST_VARS)) {
		foreach($HTTP_POST_VARS as $key => $val) {
			if (!is_array($val)) {
				if (get_magic_quotes_gpc) $val = StripSlashes($val);
				$val = AddSlashes(StripSlashes($val));
			}
			$$key = $val;
		}
	}

	if (is_array($_SERVER)) {
		foreach($_SERVER as $key => $val) {
			$$key = $val;
		}
	} elseif (is_array($HTTP_SERVER_VARS)) {
		foreach($HTTP_SERVER_VARS as $key => $val) {
			$$key = $val;
		}
	}

	unset($key, $val);
}

if (isset($PHP_AUTH_USER)) $PHP_AUTH_USER = strtolower(trim($PHP_AUTH_USER));
if (isset($kunde)) $kunde = strtolower(trim($kunde));

if ((!isset($PHP_AUTH_USER)) || ($olduser == $PHP_AUTH_USER))
	{
	 header('WWW-Authenticate: Basic realm="Reseller Login"');
	 header('HTTP/1.0 401 Unauthorized');
	 include("../settings.inc.php");
	 include("../noaccess.inc.php");
	 exit();
	} else
	{
	 include("../settings.inc.php");
	 include("../functions.inc.php");
	 db_connect($db_host, $db_user, $db_pass);

	 ## anbieterpasswort
	 $id = db_query("select longpw, gesperrt from anbieter where anbieter = '$PHP_AUTH_USER'");

	 if (db_num_rows($id) < 1)
		{
		 header('WWW-Authenticate: Basic realm="Reseller Login"');
		 header('HTTP/1.0 401 Unauthorized');
		 include("../noaccess.inc.php");
		 db_close();
		 exit();
		}

	 $werte = db_fetch_array($id);
	 $dbanbieterpw = $werte["longpw"];
	 $gesperrt = $werte["gesperrt"];
	 $authanbieterpw = crypt($PHP_AUTH_PW, $dbanbieterpw);
	 ## /anbieterpasswort

	 ## adminpasswort
	 $id = db_query("select longpw from admin");
	 $werte = db_fetch_array($id);
	 $dbadminpw = $werte["longpw"];
	 $authadminpw = crypt($PHP_AUTH_PW, $dbadminpw);
	 ## /adminpasswort

	 if (($dbadminpw != $authadminpw) && (($dbanbieterpw != $authanbieterpw) || ($gesperrt == "1")))
		{
		 header('WWW-Authenticate: Basic realm="Reseller Login"');
		 header('HTTP/1.0 401 Unauthorized');
		 include("../noaccess.inc.php");
		 db_close();
		 exit();
		}
	}

db_close();
?>
