<?php 
/**
 * @version        $Id: check_card.php 1 8:38 2010年7月9日Z tianya $
 * @package        DedeCMS.Member
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once(dirname(__FILE__)."/config.php");
$svali = GetCkVdValue();

if(strtolower($vdcode)!=$svali || $svali=="")
{
    ShowMsg("驗證碼錯誤！","-1");
    exit();
}

$cardid = preg_replace("#[^0-9A-Za-z-]#", "", $cardid);
if(empty($cardid))
{
    ShowMsg("卡號為空！","-1");
    exit();
}

$row = $dsql->GetOne("SELECT * FROM #@__moneycard_record WHERE cardid='$cardid' ");

if(!is_array($row))
{
    ShowMsg("卡號錯誤：不存在此卡號！","-1");
    exit();
}

if($row['isexp']==-1)
{
    ShowMsg("此卡號已經失效，不能再次使用！","-1");
    exit();
}

$hasMoney = $row['num'];
$dsql->ExecuteNoneQuery("UPDATE #@__moneycard_record SET uid='".$cfg_ml->M_ID."',isexp='-1',utime='".time()."' WHERE cardid='$cardid' ");
$dsql->ExecuteNoneQuery("UPDATE #@__member SET money=money+$hasMoney WHERE mid='".$cfg_ml->M_ID."'");

ShowMsg("充值成功，你本次增加的金幣為：{$hasMoney} 個！",-1);
exit();