<?require 'header.php'; ?>
<div class="menucenter">
<?
if(!(isset($_SESSION["username"]) && isset($_SESSION["password"]))){
	?>
<script type="text/javascript">location.replace("login.php");</script>
<noscript>	<meta http-equiv="refresh" content="0; url=login.php"></noscript>
<?exit();}?>

<?

$res=mysql_query("select purse, valutaname from tb_site where id='1'");
$res=mysql_fetch_assoc($res);$p=$res["purse"];$vn=$res["valutaname"];

?>
<?if(isset($_POST["amount"])){
	if( strtolower($_POST['code'])!= strtolower($_SESSION['logcaptcha']) OR !isset($_SESSION["logcaptcha"]))
	{
		echo "<div class='error'>&nbsp;Неверно введен код с картинки...</div>";
		require 'footer.php';
		exit();
	}
	unset($_SESSION['logcaptcha']);
	$user=text($_SESSION["username"]);
	if($user!=='')	{		$amount=round(floatval($_POST["amount"]),2);

if($amount>0)
{			require('config.php');
			echo "<div class=good>&nbsp;Заявка на пополнение баланса принята и будет выполнена после оплаты.</div>";

if($duser["system"]==0){
echo "<form method=\"POST\" action=\"https://merchant.webmoney.ru/lmi/payment.asp\">
		<input type=\"hidden\" name=\"LMI_PAYMENT_AMOUNT\" value=\"".$amount."\">
		<input type=\"hidden\" name=\"LMI_PAYMENT_DESC\" value=\"Пополнение баланса на сумму ".$amount." для пользователя ".$user.".\">
		<input type=\"hidden\" name=\"LMI_PAYEE_PURSE\" value=\"".$p."\">
		<input type=\"hidden\" name=\"service\" value=\"mta\">
		<input type=\"hidden\" name=\"id\" value=\"".$duser["id"],"\">
		<input type=\"submit\" value=\"Оплатить ".$amount." ".$vn." WebMoney\">
	</form></center></fieldset>";
}elseif($duser["system"]==1){
$liq=mysql_query("select * from tb_liqpay where id='1'");$ld=mysql_fetch_assoc($liq);

$order = "mta_".$id; $resurl = $ld['urlok']; $serurl = $ld['urldop']; $merchant_id = $ld['merchid']; $vval = $ld['valuta'];
    $descript = "popolnenie balansa dla user:".$user." summa:".$amount; $urlzap = "https://www.liqpay.com/?do=clickNbuy";

	$xml="<request>
      <version>1.2</version>
      <result_url>$resurl</result_url>
      <server_url>$serurl</server_url>
      <merchant_id>$merchant_id</merchant_id>
      <order_id>$order</order_id>
      <amount>$amount</amount>
      <currency>$vval</currency>
      <description>$descript</description>
      <default_phone></default_phone>
      <pay_way></pay_way>
</request>";

    $signature = $ld['podp'];
	$xml_encoded = base64_encode($xml);
	$lqsignature = base64_encode(sha1($signature.$xml.$signature,1));

echo "<form action=\"".$urlzap."\" method=POST accept-charset=utf-8>
<input type=\"hidden\" name=\"operation_xml\" value=\"".$xml_encoded."\">
<input type=\"hidden\" name=\"signature\" value=\"".$lqsignature."\">
<input type=submit value=\"Оплатить ".$amount." ".$ld['valuta']." LiqPay\">
</form></center></fieldset>
";
}
require 'footer.php';
			exit();
		}else{

echo "<div class='error'>Неверно введена сумма пополнения баланса!</div>";
}}}?>


<center><form method="post" action="moneytoacc.php" name="frm">
<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0'>
<thead><tr>
<th align="center">Cумма</th>
<th align="center"></th>
<th align="center"></th>
</tr></thead>
<tr><td>
<input type="text" size="7" value="0.1" maxlength="10" name="amount"> руб.</td><td>
<font color="#dd0000"><b>Введите код: <img src="logincap.php" align="absmiddle"></b></font>
<input type='text' size='3' maxlength='4' name='code' autocomplete="off" onChange="getZakaz(this.form)" value="">
</td><td>
<input type="submit" class="ok_wm" value="Пополнить" class="submit"></td></tr></table></form></center>
<? require 'footer.php'; ?>