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

if(!$lfjuid){
	showerr("請先在前台登錄");
}

if($action=='get')
{
	if(!$atc_passwd){
		showerr("請輸入充值卡密碼");
	}
	$rsdb=$db->get_one("SELECT * FROM {$pre}moneycard WHERE passwd='$atc_passwd'");
	if(!$rsdb){
		showerr("充值卡密碼不對");
	}elseif($rsdb[ifsell]){
		showerr("本充值卡已使用過,請不要重復充值");
	}
	$db->query("UPDATE {$pre}moneycard SET ifsell='1',uid='$lfjuid',username='$lfjid',posttime='$timestamp' WHERE id='$rsdb[id]'");
	$db->query("UPDATE {$pre}memberdata SET moneycard=moneycard+'$rsdb[moneycard]' WHERE uid='$lfjuid'");
	refreshto("?","恭喜你,充值succeed",2);
}

require(PHP168_PATH."inc/head.php");
require(html("moneycard"));
require(PHP168_PATH."inc/foot.php");

?>