<? 
////////////////////////////////////////////////////////
// auth.inc
// By: Isaac Force | gorgonous656@home.com
// Basic realm authentication for displaying of counter
// statistics.
///////////////////////////////////////////////////////
// The password is set in gcountinfo.php
//////////////////////////////////////////////////////

if ( !isset($PHP_AUTH_USER) ) {
	// If PHP_AUTH_USER isn't set, there has been no successful
	// login. Send the headers to request the username/password
	// from the user
	header('WWW-Authenticate: Basic realm="GCount Statistics"');
	header('HTTP/1.0 401 Unauthorized');
	//header("Status: 401 Unauthorized");
	echo 'Authorization Required.';
	// Terminate execution
	exit;
} 

else {
	if ( ($PHP_AUTH_USER != "$auth_user") || ($PHP_AUTH_PW != "$auth_passwd") ) {
		// If the username and password aren't correct, deny them and exit.
		// Otherwise everything must be ok.
		// header('HTTP/1.0 401 Unauthorized');
		header("Status: 401 Unauthorized"); 
		print "<H1>Authorization Required.</H1><BR>\n";
		print "Incorrect username or password.";
		exit;
	}
}

?>
