<?php
require("global.php");

if(!$lfjid){
	showerr("你還沒登錄");
}

$lfjdb[money]=get_money($lfjuid);
$webdb[MoneyRatio]=intval($webdb[MoneyRatio]);



if($action=='money2card')
{
	if(!is_numeric($atc_moneycard))
	{
		showerr("請輸入一個正整數");
	}

	$atc_moneycard=intval($atc_moneycard);

	if($atc_moneycard<1)
	{
		showerr("你輸入的數字必須大于0");
	}
	elseif($atc_moneycard>$lfjdb[moneycard])
	{
		showerr("你輸入的數值不能大于你本身的金幣數");
	}
	$db->query("UPDATE {$pre}memberdata SET moneycard=moneycard-'$atc_moneycard' WHERE uid='$lfjuid'");
	add_user($lfjuid,$atc_moneycard*$webdb[MoneyRatio]);
	refreshto("$FROMURL","恭喜你,兌換succeed",1);
}
elseif($action=='card2money')
{
	if(!$webdb[Money2card])
	{
		showerr("管理員關閉了{$webdb[MoneyName]}兌換金幣*-*能");
	}
	$lfjdb[money]=get_money($lfjuid);
	if(!is_numeric($atc_money))
	{
		showerr("請輸入一個正整數");
	}

	$atc_money=intval($atc_money);

	if($atc_money<1)
	{
		showerr("你輸入的數字必須大于0");
	}
	elseif($atc_money>$lfjdb[money])
	{
		showerr("你輸入的數值不能大于你本身的{$webdb[MoneyName]}");
	}
	$moneycard=floor($atc_money/$webdb[MoneyRatio]);
	$db->query("UPDATE {$pre}memberdata SET moneycard=moneycard+'$moneycard' WHERE uid='$lfjuid'");
	add_user($lfjuid,-$atc_money);
	refreshto("$FROMURL","恭喜你,兌換succeed",1);
}

if($action=="del_record"){
	$db->query("DELETE FROM {$pre}olpay WHERE uid='$lfjuid' AND id='$id'");
}
if($job=="record")
{
	if($page<1){
		$page=1;
	}
	$rows=20;
	$min=($page-1)*$rows;
	unset($listdb);
	$showpage=getpage("{$pre}olpay","WHERE uid='$lfjuid'","?job=$job",$rows);
	$query = $db->query("SELECT * FROM {$pre}olpay WHERE uid='$lfjuid' ORDER BY id DESC LIMIT $min,$rows");
	while($rs = $db->fetch_array($query)){
		$rs[ifpay]=$rs[ifpay]?"<font color=red>支付succeed</font>":"支付失敗";
		$rs[posttime]=date("Y-m-d H:i:s",$rs[posttime]);
		if($rs[banktype]=='tenpay'){
			$rs[banktype]="財付通";
		}elseif($rs[banktype]=='alipay'){
			$rs[banktype]="支付寶";
		}elseif($rs[banktype]=='99pay'){
			$rs[banktype]="快錢";
		}elseif($rs[banktype]=='yeepay'){
			$rs[banktype]="易寶支付";
		}else{
			$rs[banktype]="其它方式";
		}
		$listdb[]=$rs;
	}
}

require(dirname(__FILE__)."/"."head.php");
require(dirname(__FILE__)."/"."template/money.htm");
require(dirname(__FILE__)."/"."foot.php");

?>