File size: 2.77Kb
<?php
if (!isset($_POST['x_ok']))
{
$_POST['x_ok'] = 0;
}
if ($_POST['x_ok'] < 1)
{
echo '
<b>Ваш баланс: '.file_get_contents($cms.'user/'.$_SESSION['user_login'].'/balans.txt').' монет.</b>
<br />
Доступные статусы:
';
$dire = opendir ($cms.'flud/x_status/');
while ($filee = readdir ($dire))
{ if (( $filee != ".") && ($filee != ".."))
{
$status = explode('|',trim(file_get_contents($cms.'flud/x_status/'.$filee.'')));
echo '
<form class="mess2" name="" action="" method="post">
'.$status[0].' | '.$status[1].' монет |
<input name="x_file" type="hidden" value="'.$filee.'">
<input name="x_ok" type="hidden" value="1">
<input class="knopka" type="submit" value="Купить">
</form>
';
}
}
closedir ($dire);
}
elseif($_POST['x_ok'] == 1)
{
$x_file = trim($_POST['x_file']);
$status = explode('|',trim(file_get_contents($cms.'flud/x_status/'.$x_file.'')));
echo '
<br /><div class="mess2">Вы действительно хотите купить статус "'.$status[0].'" за '.$status[1].' монет?</div>
<table><tr><td>
<form name="" action="" method="post">
<input name="x_ok" type="hidden" value="0">
<input class="knopka" type="submit" value="Нет">
</form></td>
<td>
<form name="" action="" method="post">
<input name="x_ok" type="hidden" value="2">
<input name="x_file" type="hidden" value="'.$x_file.'">
<input class="knopka" type="submit" value="Да">
</form></td>
</tr></table>
';
}
elseif($_POST['x_ok'] == 2)
{
$x_file = trim(htmlspecialchars($_POST['x_file']));
$status = explode('|',trim(file_get_contents($cms.'flud/x_status/'.$x_file.'')));
if ($status[1] <= (int) file_get_contents($cms.'user/'.$_SESSION['user_login'].'/balans.txt'))
{
$bal = (int) $status[1];
include($cms.'user/bal_v.php');
$fp = fopen ($cms.'user/'.$_SESSION['user_login'].'/x_status.txt', "w+");
fwrite ($fp, $status[0]);
fclose ($fp);
$activ = ' Покупка x-status " '.$status[0].' " ';
include_once($cms.'moduls/act/act_add.php');
echo '
<div class="ramka">
Статус успешно установлен.
<form name="" action="" method="post">
<input name="x_ok" type="hidden" value="0">
<input class="knopka" type="submit" value="Выбрать другой статус"> | <a class="knopka" href="/">На главную</a>
</form>
</div>
';
}
else
{
echo '
<div class="error">
Недостаточно средств.
<form name="" action="" method="post">
<input name="x_ok" type="hidden" value="0">
<input class="knopka" type="submit" value="Выбрать другой статус"> | <a class="knopka" href="/">На главную</a>
</form>
</div>
';
}
}
?>