<?php
$kosh = "Z205375731974";
$seckey = "secret_key";
sleep("7");
$SYS_TRANS_DATE = str_replace(" ", "_", $LMI_SYS_TRANS_DATE);
$SYS_TRANS_DATE = str_replace(":", "+", $SYS_TRANS_DATE);
$data_r = @file("temp/". $SYS_TRANS_DATE);
if($data_r){
list($PAYEE_PURSE,$PAYMENT_AMOUNT,$PAYMENT_NO,$MODE,$SYS_INVS_NO,$SYS_TRANS_NO,$SYS_TRANS_DATE,$PAYER_PURSE,$PAYER_WM,$HASH) = explode("^", $data_r[0]);
}else{sleep("10");
$data_r = @file("temp/". $SYS_TRANS_DATE);
list($PAYEE_PURSE,$PAYMENT_AMOUNT,$PAYMENT_NO,$MODE,$SYS_INVS_NO,$SYS_TRANS_NO,$SYS_TRANS_DATE,$PAYER_PURSE,$PAYER_WM,$HASH) = explode("^", $data_r[0]);
}
$hash_t = $PAYEE_PURSE.$PAYMENT_AMOUNT.$PAYMENT_NO.$MODE.$SYS_INVS_NO.$SYS_TRANS_NO.$SYS_TRANS_DATE.$seckey. $PAYER_PURSE.$PAYER_WM;
$hash = md5($hash_t);
$HASH = strtolower($HASH);
if($HASH == $hash) {

if($lot) {
include("data/header.dat");
$fp2 = fopen("temp/". $lot, "r");
$next = fgets($fp2, filesize("temp/". $lot) + 1);
$fp2 = fclose($fp2);
if($next == 5) {$next2 = 1;} else {$next2 = $next + 1;}
$SYS_TRANS_DATE2 = str_replace(" ", "_", $LMI_SYS_TRANS_DATE);
$SYS_TRANS_DATE2 = str_replace(":", "+", $SYS_TRANS_DATE2);
//if($next !== 5) {$next2 = $next + 1;}
$fp3 = fopen("temp/". $lot, "w");
fwrite($fp3, $next2);
$fp3 = fclose($fp3);
if ($next == 5) {
$fp = fopen("temp/". $SYS_TRANS_DATE2 , "r");
$f = fgets($fp, filesize("temp/". $SYS_TRANS_DATE2) + 1);
$fp = fclose($fp);
list($PAYEE_PURSE,$PAYMENT_AMOUNT,$PAYMENT_NO,$MODE,$SYS_INVS_NO,$SYS_TRANS_NO,$SYS_TRANS_DATE,$PAYER_PURSE,$PAYER_WM,$HASH) = explode("^", $f);
$sum = $PAYMENT_AMOUNT * 5 / 2;
$SYS_TRANS_DATE2 = str_replace(" ", "_", $SYS_TRANS_DATE);
$SYS_TRANS_DATE2 = str_replace(":", "+", $SYS_TRANS_DATE2);
$fp4 = fopen("temp/cash/". $SYS_TRANS_DATE2, "w");
fwrite($fp4, $lot. "^". $PAYER_PURSE. "^". $SYS_TRANS_DATE. "^". $sum);
$fp4 = fclose($fp4);
$dat = file("data/winlot.dat");
echo $dat[0];
echo $sum;
echo $dat[1];
}else{include("data/loselot.dat");
include("data/table.dat");
echo "<hr>";}
include("data/foot.dat");
}
if($stats) {
$fp2 = fopen("temp/". $stats, "r");
$next = fgets($fp2, filesize("temp/". $stats) + 1);
$fp2 = fclose($fp2);
include("data/header.dat");
echo "<font class=small_title>Статистика</font><HR>";
$q = 5 - $next;
if($stats == "010") {$namel = "0.10";}
if($stats == "050") {$namel = "0.50";}
if($stats == "1") {$namel = "1";}
if($stats == "3") {$namel = "3";}
if($stats == "5") {$namel = "5";}
if($q == 0){
echo "<h1>В лотереи на ". $namel ." WM следущий билет выиграет!!!</h1>";
include("data/table.dat");}
else{
if($q == 1){$q = $q. "&nbspпопытка";}else{$q = $q. "&nbspпопытки";}
echo "До выигрыша в лотереи на ". $namel ." WM осталось ". $q;
include("data/table.dat");
}
echo "<HR>";
include("data/foot.dat");
}
$SYS_TRANS_DATE = str_replace(" ", "_", $LMI_SYS_TRANS_DATE);
$SYS_TRANS_DATE = str_replace(":", "+", $SYS_TRANS_DATE);
if($lot){$SYS_TRANS_DATE2 = $SYS_TRANS_DATE;}
If($stats){$SYS_TRANS_DATE2 = $SYS_TRANS_DATE. "s";}
copy("temp/". $SYS_TRANS_DATE, "temp/played/". $SYS_TRANS_DATE2);
unlink("temp/". $SYS_TRANS_DATE);
}else{echo "<center><h1>Error!";}
?>
</SCRIPT>