#!/usr/bin/perl
# EasyHost
# Built by CyberScript
# Website: http://www.cyberscript.net
# Email: rcampbell@cyberscript.net
# (C) Copyright 2001, All Rights Reserved.
#####################################################
# The following code may not be modified            #
# or redistributed by anyone other then CyberScript #
#####################################################

$pwd = ($0 =~ /^(.+)[\/\\]/)[0] || '.';
require ("$pwd/cs-lib.pl");

&login;

&cmd("admin");
print &ct("text/html").&display("admin");

exit(0);

sub login {
	if (!-f "$tokens{data_dir}/logins/admin/$ENV{REMOTE_ADDR}") {
		if ($ENV{REQUEST_METHOD} eq 'POST') {
			&error("The password field is required","password") if (!$tokens{password});
			&error("The password you entered was incorrect","password") if (crypt($tokens{password},'as') ne $tokens{site_password});

			if (!$tokens{error_message}) {
				&file_write("$tokens{data_dir}/logins/admin/$ENV{REMOTE_ADDR}",1);
			} else {
				print &ct("text/html").&file("$tokens{data_dir}/html/admin/login.html");
				exit;
			}
		} else {
			print &ct("text/html").&file("$tokens{data_dir}/html/admin/login.html");
			exit;
		}
	}
}