<?php
if ( ($PHP_AUTH_USER != "demo") || ($PHP_AUTH_PW != "demo")) {
Header("WWW-Authenticate: Basic realm=\"Для админов\"");
Header("HTTP/1.0 401 Unauthorized");
echo("<HTML>\n<HEAD>\n<TITLE>В доступе отказано!</TITLE>\n</HEAD>\n\n<BODY>\n\n<center><font size = 20 color=red><b>Access denied!</b></font></center><br><br><br>\n\n\n\n\n\n</BODY>\n</HTML>");
}
else {

if($date){
unlink("../temp/cash/". $date);
}

$count_all = 0;
$count_alls = 0;
$count_010 = 0;
$count_050 = 0;
$count_1 = 0;
$count_3 = 0;
$count_5 = 0;
$count_010s = 0;
$count_050s = 0;
$count_1s = 0;
$count_3s = 0;
$count_5s = 0;


$pay = "<form action=index.phtml method=get><input type=hidden name=date value=";
$pay2 = "><INPUT ID=button TYPE=submit VALUE=Оплачен>
</form>";
include("../data/header.dat");
if(!$cat) {


if ($dir = opendir("../temp/played/")) {
  while (($file = readdir($dir)) !== false) {
if($file !== "." and $file !== ".." and $file !== ".htaccess"){
$fp = fopen("../temp/played/". $file, "r");
$dat = fgets($fp, filesize("../temp/played/". $file) + 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("^", $dat);
if($PAYMENT_AMOUNT == "0.10") {$count_010 = $count_010 + 1;  $count_all = $count_all + 1;}
if($PAYMENT_AMOUNT == "0.50" and substr($file,17,1) !== "s") {$count_050 = $count_050 + 1; $summa = $summa + $PAYMENT_AMOUNT; $count_all = $count_all + 1;}
if($PAYMENT_AMOUNT == "1") {$count_1 = $count_1 + 1; $count_all = $count_all + 1;}
if($PAYMENT_AMOUNT == "3") {$count_3 = $count_3 + 1;  $count_all = $count_all + 1;}
if($PAYMENT_AMOUNT == "5") {$count_5 = $count_5 + 1; $count_all = $count_all + 1;}
if($PAYMENT_AMOUNT == "0.05") {$count_010s = $count_010s + 1;  $count_alls = $count_alls + 1;}
if($PAYMENT_AMOUNT == "0.25") {$count_050s = $count_050s + 1;  $count_alls = $count_alls + 1;}
if($PAYMENT_AMOUNT == "0.50" and substr($file,17,1) == "s") {$count_1s = $count_1s + 1; $count_alls = $count_alls + 1;}
if($PAYMENT_AMOUNT == "1.5") {$count_3s = $count_3s + 1;  $count_alls = $count_alls + 1;}
if($PAYMENT_AMOUNT == "2.5") {$count_5s = $count_5s + 1;  $count_alls = $count_alls + 1;}
}
}
  closedir($dir);






  echo "Всего куплено билетов&nbsp". $count_all."<br>";
  echo "Всего куплено статистики&nbsp". $count_alls."<br>";
  echo "Всего куплено билетов лотереи/статистики 010&nbsp". $count_010. "/". $count_010s. "<br>";
  echo "Всего куплено билетов лотереи/статистики 050&nbsp". $count_050. "/". $count_050s. "<br>";
  echo "Всего куплено билетов лотереи/статистики 1&nbsp". $count_1. "/". $count_1s. "<br>";
  echo "Всего куплено билетов лотереи/статистики 3&nbsp". $count_3. "/". $count_3s. "<br>";
  echo "Всего куплено билетов лотереи/статистики 5&nbsp". $count_5. "/". $count_5s. "<br>";



  }

  }

  echo "<br><br>Выигрыши<br>";
  echo '<TABLE   BORDER="1"><TR><TD>Лотерея</TD><TD><center>Кошелёк</center></TD><TD><center>Время</center></TD><TD>Выигрышь</TD><TD><center>Оплата</center></TD></TR>';
   if ($dir = opendir("../temp/cash/")) {
  while (($file = readdir($dir)) !== false) {
  if($file !== "." and $file !== ".." and $file !== ".htaccess"){
  $fp = fopen("../temp/cash/". $file, "r");
  $dat = fgets($fp, 100);
  $fp = fclose($fp);
  list($lot,$PAYER_PURSE,$SYS_TRANS_DATE,$sum) = explode("^", $dat);
  $SYS_TRANS_DATE2 = str_replace(" ", "_", $SYS_TRANS_DATE);
  $SYS_TRANS_DATE2 = str_replace(":", "+", $SYS_TRANS_DATE2);
  echo "<TR><TD><center>". $lot. "</center></TD><TD><center>". $PAYER_PURSE. "</center></TD><TD>".   $SYS_TRANS_DATE. "</TD><TD><center>". $sum ."&nbspWM</center></TD><TD><center><br>". $pay.$SYS_TRANS_DATE2.$pay2 ."</center></TD></TR>";
  }
  }
  }
  closedir($dir);
  echo "</TABLE>";

echo "<HR><br><br><br><br><br><br><br><br><center><font class=copy>Copyright &copy Loto</font></body></html>";
}
?>