#!/usr/local/bin/perl
$mail_prog = '/usr/lib/sendmail' ;
&GetFormInput;
$login = $field{'login'} ;	
$ps = $field{'pass'} ;

	 sub GetFormInput {

	(*fval) = @_ if @_ ;

	local ($buf);
	if ($ENV{'REQUEST_METHOD'} eq 'POST') {
		read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
	}
	else {
		$buf=$ENV{'QUERY_STRING'};
	}
	if ($buf eq "") {
			return 0 ;
		}
	else {
 		@fval=split(/&/,$buf);
		foreach $i (0 .. $#fval){
			($name,$val)=split (/=/,$fval[$i],2);
			$val=~tr/+/ /;
			$val=~ s/%(..)/pack("c",hex($1))/ge;
			$name=~tr/+/ /;
			$name=~ s/%(..)/pack("c",hex($1))/ge;

			if (!defined($field{$name})) {
				$field{$name}=$val;
			}
			else {
				$field{$name} .= ",$val";
				
			}


		   }
		}
return 1;
}

use Fcntl;
use NDBM_File;

tie %hash, "NDBM_File", "/web/012/wmclicks/public_html/members/logs/$login", O_RDWR, 0644;


$nick = $hash{nick};
$pass = $hash{pass};
$csumm = $hash{csumm};
$psumm = $hash{psumm};
$refnum=$hash{refnum};
untie %hash;

if ($pass eq $ps)
{

if ($login ne "")
{

opendir (KAT,"/web/012/wmclicks/public_html/members/logs/");
@list=readdir (KAT);
closedir (KAT);

$k=0;
$i=1;
foreach (@list)
{
$k=$k+1;
}

print "Content-Type: text/html\n\n";
print "<html><head><title>Ваши рефералы</title></head><body background=http://wmclicks.com/bg.gif>";

print "<center>";
print "<!-- Russian LinkExchange code START (468x60)-->\n";
print "  <iframe src=http://www.linkexchange.ru/cgi-bin/erle.cgi?28805?44 \n";
print "  frameborder=0 vspace=0 hspace=0 width=468 height=60 \n";
print "  marginwidth=0 marginheight=0 scrolling=no>\n";
print "  <a href=http://www.linkexchange.ru/users/028805/goto.map target=_top> \n";
print "  <img src=http://www.linkexchange.ru/cgi-bin/rle.cgi?28805?44 \n";
print "  alt=\"RLE Banner Network\" border=0 height=60 width=468></a> \n";
print "  </iframe> \n";
print "<!-- Russian LinkExchange code END --> \n";
print "</center>";


print "<p align=center><b>Список рефералов:</b>";
print "<table border=1>";
print "<tr><td>Логин</td><td>Заработано</td><td>Всего заработано</td><td>E-mail</td></tr>";
use Fcntl;
use NDBM_File;

foreach (@list)
{
@member = split (/\./,$list[$i]);
chomp ($member[0]);
tie %hasht, "NDBM_File", "/web/012/wmclicks/public_html/members/logs/$member[0]", O_RDWR, 0644;
$referer = $hasht{referer};
$csumm = $hasht{csumm};
$psumm = $hasht{psumm};
$mail = $hasht{mail};
untie %hasht;


if ($referer eq $login)
{
$all=$csumm+$psumm;
print "<tr><td>$member[0]</td><td>$csumm</td><td>$all</td><td><a href=\"mailto: $mail\">$mail</td></tr>";
}

$i=$i+2;
}


print "</table>";


print "</body></html>";

}
	
}
