#!/usr/local/bin/perl
$mail_prog = '/usr/sbin/sendmail' ;
&GetFormInput;
$login = $field{'login'} ;	
$s = $field {'s'} ;
$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;
}

tie %hashd, "NDBM_File", "/web/012/wmclicks/public_html/members/logs/$login", O_RDWR, 0644;
$pass=$hashd{pass};
$csumm=$hashd{csumm};
untie %hashd;


if ($pass eq $ps and $csumm>0.1 and $s=$csumm)
{
$refile = "/web/012/wmclicks/public_html/members/logs/$login.pag";
$refiles = "/web/012/wmclicks/public_html/members/logs/$login.dir";

use Fcntl;
use NDBM_File;


tie %hashd, "NDBM_File", "/web/012/wmclicks/public_html/members/logs/$login", O_RDWR, 0644;
$pass=$hashd{pass};
$nick=$hashd{nick};
$mail=$hashd{mail};
$z=$hashd{z};
$csumm=$hashd{csumm};
$psumm=$hashd{psumm};
$refnum=$hashd{refnum};
$rf=$hashd{referer};
untie %hashd;

$csumm=$csumm-$s;
$psumm=$psumm+$s;

unlink ($refile);
unlink ($refiles);

tie %hashr, "NDBM_File", "/web/012/wmclicks/public_html/members/logs/$login", O_RDWR|O_CREAT|O_EXCL, 0644;
$hashr{pass} = $pass;
$hashr{nick} = $nick;
$hashr{mail} = $mail;
$hashr{csumm} = $csumm;
$hashr{psumm} = $psumm;
$hashr{refnum} = $refnum;
$hashr{z} = $z;
$hashr{referer} = $rf;
untie %hashr;



open (FILE,">>/web/012/wmclicks/public_html/admin/orderlist.dat");
print FILE "$login $s $z\n";
close (FILE);

open (FILE,"/web/012/wmclicks/public_html/members/topay/$login.dat");
@m = <FILE>;
close (FILE);

chomp ($m[0]);
$zakaz= $m[0]+$s;

open (FILE,">/web/012/wmclicks/public_html/members/topay/$login.dat");
print FILE "$zakaz\n";
close (FILE);





print "Location: http://www.wmclicks.com/cgi-bin/ballance.pl?login=$login&pass=$pass\nURI: http://www.wmclicks.com/cgi-bin/ballance.pl?login=$login&pass=$pass\n\n";


}










