<?
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 {
$payy = "<form action=ad/cash2.phtml method=post>
<center><select name=summa>
<option value=3>1)&nbsp&nbsp3
<option value=6>2)&nbsp&nbsp6
<option value=12>3)&nbsp&nbsp12
<option value=24>4)&nbsp&nbsp24
<option value=48>5)&nbsp&nbsp48
<option value=96>6)&nbsp&nbsp96
<option value=192>7)&nbsp&nbsp192
<option value=384>8)&nbsp&nbsp384
<option value=768>9)&nbsp&nbsp768
<option value=1536>10)&nbsp&nbsp1536
</select></center>
<input type=hidden name=wmz value=";
$payy2 = "><INPUT ID=button TYPE=submit VALUE=Перевести>
</form>";
$mag = "<br><form action=ad/mb.phtml method=post>
<input type=hidden name=wmz value=";
$mag2 = "><INPUT ID=button TYPE=submit VALUE=";
$mag3 = "></form>";
$pay = "<form action=ad/cash.phtml method=post>
<center><select name=summa>
<option value=3>1)&nbsp&nbsp3
<option value=6>2)&nbsp&nbsp6
<option value=12>3)&nbsp&nbsp12
<option value=24>4)&nbsp&nbsp24
<option value=48>5)&nbsp&nbsp48
<option value=96>6)&nbsp&nbsp96
<option value=192>7)&nbsp&nbsp192
<option value=384>8)&nbsp&nbsp384
<option value=768>9)&nbsp&nbsp768
<option value=1536>10)&nbsp&nbsp1536
</select></center>
<input type=hidden name=wmz value=";
$pay2 = "><INPUT ID=button TYPE=submit VALUE=Перевести>
</form>";
$del = "<br><form action=ad/del.phtml method=post>
<input type=hidden name=wmz value=";
$del2 = "><INPUT ID=button TYPE=submit VALUE=Удалить>
</form>";
$opl = "<form action=ad/opl.phtml method=post>
<input type=hidden name=wmz value=";
$opl2 = "><INPUT ID=button TYPE=submit VALUE=Оплачен>
</form>";
include ("data/a_header.dat");
if(!$cat) {
$count_all = 0;
$count_p = 0;
$count_np = 0;
$count_y_p = 0;
$count_s = 0;
$count_s_y = 0;
if ($dir = opendir("users/") and $dir2 = opendir("temp/cash/")) {
  while (($file = readdir($dir)) !== false) {
$fp = @fopen("users/". $file, "r");
$dat = @fgets($fp, 100);
$fp = @fclose($fp);
//Ip >> Мыло >> Реф >> Номер п/п >> Счёт >> Кол-во раз оплаты >> Magic button >> Счёт 2
list($ip,$email,$id,$cash,$times,$magicb,$cash2,$paid)=split(">>", $dat);
$paid = substr($paid,0,4);
$count_all = $count_all + 1;
if($paid == "paid") {$count_p = $count_p + 1;}
if($paid == "forp") {$count_np = $count_np + 1;}
  }
  closedir($dir);

  while (($file = readdir($dir2)) !== false) {
if($file !== "." and $file !== ".." and $file !== ".htaccess") {
$fp = fopen("temp/cash/". $file, "r");
$dat = @fgets($fp, filesize("temp/cash/". $file) + 1);
$fp = @fclose($fp);
list($sum,$ref)=split(">>", $dat);
$count_s = $count_s + 1;
$count_s_s = $count_s_s + $sum;
}
}
  echo "<center>Оплаченных пользователей&nbsp&nbsp&nbsp". $count_p. "<br>";
  echo "Неоплаченных пользователей&nbsp&nbsp&nbsp". $count_np. "<br>";
  echo "Счетов&nbsp&nbsp&nbsp". $count_s. "&nbspна общую сумму&nbsp&nbsp&nbsp". $count_s_s. "&nbspWM<br></center>";
  }
}
if($cat == "paid") {
echo '<TABLE ALIGN="CENTER" BORDER="1" COLS="2" WIDTH="80">';
echo '
<TR>
 <TD>Ip</TD><TD><center>Кошелёк</center></TD><TD><center>Мыло</center></TD><TD><center>Внутренний номер</center></TD><TD><center>На счету</center></TD><TD><center>На 2 счету</center></TD><TD><center>Статус</center></TD><TD><center>Вкл./Выкл. оплату</center></TD><TD><center>Пополнить счёт</center></TD><TD><center>Пополнить 2 счёт</center></TD><TD><center>Удаление</center></TD>
</TR>';
if ($dir = opendir("users/")) {
  while (($file = readdir($dir)) !== false) {
$fp = @fopen("users/". $file, "r");
$dat = @fgets($fp, 100);
$fp = @fclose($fp);
//Ip >> Мыло >> Реф >> Номер п/п >> Счёт >> Кол-во раз оплаты >> Magic button >> Счёт 2
list($ip,$email,$id,$cash,$times,$magicb,$cash2,$paid)=split(">>", $dat);
$paid = substr($paid,0,4);
if($paid == "paid") {
if($magicb == 0) {$magic = "Включить";}
if($magicb == 1) {$magic = "Выключить";}
echo '
<TR>
 <TD><center>'. $ip .'</center></TD><TD><center>'. $file .'</center></TD><TD><center><a href=mailto:'. $email .'>'. $email .'</center></a></TD><TD><center>'. $id .'</center></TD><TD><center>'. $cash .'&nbspWM</center></TD><TD><center>'. $cash2 .'&nbspWM</center></TD><TD><center>'. $times .'</center></TD><TD><center>'. $mag.$file.$mag2.$magic.$mag3 .'</center></TD>
<TD>'. $pay.$file.$pay2 .'</TD><TD><center>'. $payy.$file.$payy2 .'</center></TD><TD>'. $del.$file.$del2 .'</TD></TR>';}
}
}
echo "</table>";
}
if($cat == "notpaid") {
echo '<TABLE ALIGN="CENTER" BORDER="1" COLS="2" WIDTH="80">';
echo '
<TR>
 <TD><center>Ip</center></TD><TD><center>Кошелёк</center></TD><TD><center>Мыло</center></TD><TD><center>Удаление</center></TD>
</TR>';
if ($dir = opendir("users/")) {
  while (($file = readdir($dir)) !== false) {
$fp = @fopen("users/". $file, "r");
$dat = @fgets($fp, 100);
$fp = @fclose($fp);
//Ip >> Мыло >> Реф >> Номер п/п >> Счёт >> Кол-во раз оплаты >> Magic button >> Счёт 2
list($ip,$email,$id,$cash,$times,$magicb,$cash2,$paid)=split(">>", $dat);
$paid = substr($paid,0,4);
if($paid == "forp") {
echo '
<TR>
 <TD><center>'. $ip .'</center></TD><TD><center>'. $file .'</center></TD><TD><center><a href=mailto:'. $email .'>'. $email .'</a></center></TD><TD>'. $del.$file.$del2 .'</TD></TR>';}
}
}
echo "</table>";
}

if($cat == "cash") {
echo '<TABLE ALIGN="CENTER" BORDER="1" COLS="2" WIDTH="80">';
echo '
<TR>
 <TD><center>Кошелёк<center></TD><TD><center>Сумма<center></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($cash,$ref) = split(">>", $dat);
echo '
<TR>
 <TD><center>'. $file .'</center></TD><TD><center>'. $cash .'&nbspWM</center></TD><TD>'. $opl.$file.$opl2 .'</TD></TR>';}
}
}
echo "</table>";
}
}
?>