#!/usr/bin/perl use DBI(); use CGI::Cookie; use CGI qw(:standard); $prog = $ARGV[0]; #$authl = param("authl"); #$authp = param("authp"); $authl = $ARGV[1]; $authp = $ARGV[2]; $rip = $ENV{'REMOTE_ADDR'}; my $cooke = cookie('mail.miranet'); if ($cooke ne "") {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 " Почтовый сервер MiraNet - Авторизация

Управление почтовым сервером - авторизация


Имя пользователя
Пароль
"; exit(2); } $database="mail"; $hostname="127.0.0.1"; $port="3306"; $dbuser="root"; $dbpasswd="zopa25703"; if ($authl ne "") { $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port"; $dbh = DBI->connect_cached($dsn, $dbuser, $dbpasswd) || die; $sth = $dbh->prepare("SELECT * FROM manage WHERE login='$authl'"); $sth->execute(); my ($dblogin, $dbpasswd, $dbaccess, $dbenabled) = $sth->fetchrow_array(); if ($authl eq $dblogin and $authp eq $dbpasswd) {$ok = $dbenabled; $level = $dbaccess;} $sth->finish(); } #if ($authl eq "mar" and $authp eq "zopazopa") {$ok = "1"; $level = "1";} #if ($authl eq "yalagina" and $authp eq "yalag123") {$ok = "1"; $level = "yalagina.ru";} #if ($authl eq "miranet" and $authp eq "mira322") {$ok = "1"; $level = "miranet.ru";} if ($ok eq "1") { $auth=sprintf("%s", $level); my $cook = cookie( -name => 'mail.miranet', -value => $auth, -expires => '0', -domain => 'mng.miranet.ru', -path => '/', ); $cook = sprintf header(-cookie=>$cook); ($cook) = split("charset=", $cook); $cook = sprintf ("%s charset=KOI8-R\n\n", $cook); print "$cook"; exit(1); } if ($ok eq "2") { print "Content-type: text/html\n\n
Доступ запрещён!"; system ("echo \"Authentication error\nLogin: $authl\nPassword: $authp\nIP Address: $rip\n\" >> ../../mail_manage.log"); exit(2); } if ($ok eq "0") { print "Content-type: text/html\n\n

Access denyed


"; }