<div class = "s-bk-lf">
<div class = "acc-title"> Purchase Order </ div>
</ div>
<div class = "silver-bk">
<BR />
<? PHP
$ _OPTIMIZATION ["title"] = "Account - Payment Order";
$ usid = $ _SESSION ["user_id"];
$ usname = $ _SESSION ["user"];
$ db-> Query ("SELECT * FROM db_users_b WHERE id = '$ usid' LIMIT 1");
$ user_data = $ db-> FetchArray ();
$ db-> Query ("SELECT * FROM db_config WHERE id = '1' LIMIT 1");
$ sonfig_site = $ db-> FetchArray ();
$ status_array = array (0 => "Checked", 1 => "Paid", 2 => "Canceled", 3 => "Paid");
# Minimal silver!
$ minPay = 50;
?>
<b> Payments are made automatically and only on the payment system <a href="
http://payeer.com/?partner=19879" target="_BLANK"> PAYEER! The percentage of output is 0% </ b> <BR /> <BR />
<b> From the Payeer payment system you can withdraw your funds automatically in all known payment systems and international banks. </ b> <BR /> <BR />
<b> Links to tutorials: </ b> <BR />
- <a href="
http://payeer.com/?partner=19879" target="_blank"> Creating a Payeer account </a> <BR />
- <a href="
http://payeeer.ru/outpay" target="_blank"> Withdrawing funds from payeer </a> <BR /> <BR />
<center> <b> Payment order: </ b> </ center> <BR />
<? PHP
function ViewPurse ($ purse) {
if (substr ($ purse, 0,1)! = "P") return false;
if (! ereg ("^ [0-9] {8} $", substr ($ purse, 1))) return false;
return $ purse;
}
# We pay the payment
if (isset ($ _ POST ["purse"])) {
$ purse = ViewPurse ($ _ POST ["purse"]);
$ sum = intval ($ _ POST ["sum"]);
$ val = "RUB";
if ($ purse! == false) {
if ($ sum> = $ minPay) {
if ($ sum <= $ user_data ["money_p"]) {
# Check for existing orders
$ db-> Query ("SELECT COUNT (*) FROM db_payment WHERE user_id = '$ usid' AND (status = '0' OR status = '1')");
if ($ db-> FetchRow () == 0) {
### Make payment ###
$ payeer = new rfs_payeer ($ config-> AccountNumber, $ config-> apiId, $ config-> apiKey);
if ($ payeer-> isAuth ())
{
$ arBalance = $ payeer-> getBalance ();
if ($ arBalance ["auth_error"] == 10000)
{
$ sum_pay = round (($ sum / $ sonfig_site ["ser_per_wmr"]), 2);
$ balance = $ arBalance ["balance"] ["RUB"] ["DOSTUPNO"];
if (($ balance)> = ($ sum_pay + 100)) {
$ arTransfer = $ payeer-> transfer (array (
'curIn' => 'RUB', // write-off account
'sum' => $ sum_pay, // the amount of the receipt
'curOut' => 'RUB', // the currency of receipt
'to' => $ purse, // the recipient (email)
// 'to' => '+71112223344', // the recipient (phone)
// 'to' => 'P1000000', // the recipient (account number)
'comment' => iconv ('windows-1251', 'utf-8', "Payment to the user {$ usname} from the WM-Farm project")
// 'anonim' => 'Y', // anonymous translation
// 'protect' => 'Y', // protection of the transaction
// 'protectPeriod' => '3', // protection period (from 1 to 30 days)
// 'protectCode' => '12345', // protection code
));
if (! empty ($ arTransfer ["historyId"]))
{
# Remove from user
$ db-> Query ("UPDATE db_users_b SET money_p = money_p - '$ sum' WHERE id = '$ usid'");
# Insert the entry in the payment
$ da = time ();
$ dd = $ da + 60 * 60 * 24 * 15;
$ ppid = $ arTransfer ["historyId"];
$ db-> Query ("INSERT INTO db_payment (user, user_id, purse, sum, valuta, serebro, payment_id, date_add, status)
VALUES ($ usname, $ usid, $ purse, $ sum_pay, RUB, $ sum, $ ppid, time.) ");
$ db-> Query ("UPDATE db_users_b SET payment_sum = payment_sum + '$ sum_pay' WHERE id = '$ usid'");
$ db-> Query ("UPDATE db_stats SET all_payments = all_payments + '$ sum_pay' WHERE id = '1'");
echo "<center> <font color = 'green'> <b> Paid! </ b> </ font> </ center> <BR />";
}
else
{
echo "<center> <font color = 'red'> <b> Internal error - report it to the administrator! </ b> </ font> </ center> <BR />";
}
} else echo "<center> <font color = 'red'> <b> Internal error - report it to the administrator! </ b> </ font> </ center> <BR />";
} else echo "<center> <font color = 'red'> <b> Failed to pay, please try again later </ b> </ font> </ center> <BR />";
} else echo "<center> <font color = 'red'> <b> Failed to pay, please try again later </ b> </ font> </ center> <BR />";
} else echo "<center> <font color = 'red'> <b> You have unprocessed requests, please wait for them to run. </ b> </ font> </ center> <BR />";
} else echo "<center> <font color = 'red'> <b> You specified more than there are in your account </ b> </ font> </ center> <BR />";
}else echo "<center><b><font color = 'red'>Минимальная сумма для выплаты составляет {$minPay} серебра!</font></b></center><BR />";
}else echo "<center><b><font color = 'red'>Кошелек Payeer указан неверно! Смотрите образец!</font></b></center><BR />";
}
?>
<?PHP
# Заглушка от халявщиков
if($user_data["insert_sum"] <= 9.99 OR $user_data["kredit"] >= 1){
?>
<center><font color="red"><b>Вы не можете заказать выплату!<p>Возможно у Вас не погашен кредит, либо сумма ваших пополнений не более 10 рублей!</center>
<div class="clr"></div>
</div>
<?PHP
return;
}
?>
<form action="" method="post">
<table width="99%" border="0" align="center">
<tr>
<td><font color="#000;">Введите кошелек Payeer [Пример: P1304289]</font>: </td>
<td><input type="text" name="purse" size="15"/></td>
</tr>
<tr>
<td><font color="#000;">Отдаете серебро для вывода</font> [Мин. <span id="res_min"></span>]<font color="#000;">:</font> </td>
<td><input type="text" name="sum" id="sum" value="<?=round($user_data["money_p"]); ?>" size="15" onkeyup="PaymentSum();" /></td>
</tr>
<tr>
<td><font color="#000;">Получаете <span id="res_val"></span></font><font color="#000;">:</font> </td>
<td>
<input type="text" name="res" id="res_sum" value="0" size="15" disabled="disabled"/>
<input type="hidden" name="per" id="RUB" value="<?=$sonfig_site["ser_per_wmr"]; ?>" disabled="disabled"/>
<input type="hidden" name="per" id="min_sum_RUB" value="0.5" disabled="disabled"/>
<input type="hidden" name="val_type" id="val_type" value="RUB" />
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="swap" value="Заказать выплату" style="height: 30px; margin-top:10px;" /></td>
</tr>
</table>
</form>
<script language="javascript">PaymentSum(); SetVal();</script>
<table cellpadding='3' cellspacing='0' border='0' bordercolor='#336633' align='center' width="99%">
<tr>
<td colspan="5" align="center"><h4>Последние 10 выплат</h4></td>
</tr>
<tr>
<td align="center" class="m-tb">Серебро</td>
<td align="center" class="m-tb">Получаете</td>
<td align="center" class="m-tb">Кошелек</td>
<td align="center" class="m-tb">Дата</td>
<td align="center" class="m-tb">Статус</td>
</tr>
<?PHP
$db->Query("SELECT * FROM db_payment WHERE user_id = '$usid' ORDER BY id DESC LIMIT 20");
if($db->NumRows() > 0){
while($ref = $db->FetchArray()){
?>
<tr class="htt">
<td align="center"><?=$ref["serebro"]; ?></td>
<td align="center"><?=sprintf("%.2f",$ref["sum"] - $ref["comission"]); ?> <?=$ref["valuta"]; ?></td>
<td align="center"><?=$ref["purse"]; ?></td>
<td align="center"><?=date("d.m.Y",$ref["date_add"]); ?></td>
<td align="center"><?=$status_array[$ref["status"]]; ?></td>
</tr>
<?PHP
}
}else echo '<tr><td align="center" colspan="5">Нет записей</td></tr>'
?>
</table><div class="clr"></div>
</div>