#!/usr/bin/perl
use CGI::Cookie;
use CGI qw(:standard);
############### CONFIG ###############
$cname = "cooke.site";
$csite = "192.168.200.13";
$dblogin = "user";
$dbpasswd = "password";
$title = "Заголовок авторизации";
$message = "Введите имя пользователя и пароль";
$link = "how-to-use.cgi";
$logfile = "file.log";
$secr = "secret";
######################################
$authl = $ARGV[0];
$authp = $ARGV[1];
$logout = param("logout");
if ($logout eq "1") {
my $cooke = cookie($cname);
if ($cooke eq "") {print "Content-type: text/html\n\n
Error
You are not logged on!"; exit (0);}
$auth="0";
my $cook = cookie(
-name => $cname,
-value => '0',
-expires => '1',
-domain => $csite,
-path => '/',
);
$cook = sprintf header(-cookie=>$cook);
($cook) = split("charset=", $cook);
$cook = sprintf ("%s charset=KOI8-R\n\n", $cook);
print "$cook";
print "";
exit (0);
}
$rip = $ENV{'REMOTE_ADDR'};
my $cooke = cookie($cname);
if ($cooke eq $secr) {print "Content-type: text/html\n\n"; exit(1);}
if ($authl ne "" or $authp ne "") {$ok = "2";}
if ($authl eq "" and $authp eq "")
{
$ok = "0";
print "Content-type: text/html\n\n";
print "
$title