<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	exit;
}
?><!--<?php
$Dvbbs_Server_Url = DVBBS_SERVER_URL;
if( $action === 'alipay_return' ){
	AliPay_Return();
	footer();
} elseif( $action === 'Re_inmoney' ){
	Re_inmoney();
	footer();
}
print <<<EOT
-->
<table  width="100%" cellpadding="0" cellspacing="0" align="center" class="mainbox">
	<tr>
		<td width="180" valign=top>
			<table  cellpadding="0" cellspacing="0" align="center" class="mainbox tableborder">
				<tr>
				<th align="center">{$lang['tpl.str1']}</th>
				</tr>
				<tr>
					<td align="left" class="tablebody5">
					<table border="0" cellpadding="0" cellspacing="0" align="center" style="width:100%;">
						<tr>
							<td class="tablebody2 table_noright">{$lang['tpl.str2']}<b><font color="{$_DCACHE['stylecss'][19]}">{$userinfo['usermoney']}</font></b> {$lang['tpl.str79']}</td>
						</tr>
						<tr>
							<td class="tablebody1 table_noright">{$lang['tpl.str3']}<b><font color="{$_DCACHE['stylecss'][19]}">{$userinfo['userticket']}</font></b> {$lang['tpl.str4']}</td>
						</tr>
						<tr>
							<td class="tablebody1 table_noright">{$lang['tpl.str5']}{$userinfo['userwealth']}</td>
						</tr>
						<tr>
							<td class="tablebody2 table_noright">{$lang['tpl.str6']}{$userinfo['userpost']}</td>
						</tr>
						<tr>
							<td class="tablebody1 table_noright">{$lang['tpl.str7']}{$userinfo['userep']}</td>
						</tr>
						<tr>
							<td class="tablebody2 table_noright">{$lang['tpl.str8']}{$userinfo['usercp']}</td>
						</tr>
						<tr>
							<td class="tablebody1 table_noright">{$lang['tpl.str9']}{$userinfo['userpower']}</td>
						</tr>
						<tr>
							<td class="tablebody2 table_noright"></td>
						</tr>
					</table>
				</td>
				</tr>
			</table>
		</td>
		<td width="*" valign=top>
<!--
EOT;
	switch($_GET['action']){
		case 'dsms':
			Get_ChallengeWord();
			if( !is_numeric($money) || ( $money != 2 && $money != 4 && $money != 6 ) ){
				//print '--'.'>';
				showmsg($lang['Error.strings1']);
				exit;
			}
			$arrDSms =& getDSms();
			if( $arrDSms['user_exists'] === false ){
				//print '--'.'>';
				showmsg($lang['Error.strings2']);
				exit;
			}
			if( $arrDSms['is_challenge'] === false ){
				//print '--'.'>';
				showmsg($lang['Error.strings3']);
				exit;
			}
			if( $arrDSms['challenge_info'] === false ){
				//print '--'.'>';
				showmsg($lang['Error.strings4']);
				exit;
			}
			$scriptNameUrl = getScriptUrl();
			print <<<EOT
-->		
		{$lang['tpl.str10']}
		<form name="redir" action="{$Dvbbs_Server_Url}ray.asp?Action=ToolsPay" method="post">
		<input type="hidden" name="mobile" value="{$arrDSms['user_mobile']}">
		<input type="hidden" name="mouseid" value="{$arrDSms['challenge_info']['d_username']}">
		<input type="hidden" name="forumid" value="{$arrDSms['challenge_info']['d_forumid']}">
		<input type="hidden" name="backurl" value="{$scriptNameUrl}userpay.php?action=Re_Sms">
		<input type="hidden" name="money" value="{$money}">
		<input type="hidden" name="seqno" value="{$_SESSION['challenge_word']}">
		</form>
		<script LANGUAGE=javascript>
		<!--
		redir.submit();
		//-->
		</script>
<!--
EOT;
			break;
		case 'Re_Sms':
			Re_Sms();
			break;
		case 'inmoney':
			inmoney();
			break;
		case 'alipay':
			AliPay();
			break;
		case 'alipay_1':
			AliPay_1();
			break;
		case 'alipay_return':
			AliPay_Return();
			break;
		case 'UserCenter':
			UserCenter();
			break;
		case 'UserToolsLog_List':
			UserToolsLog_List();
			break;
		case 'PayList':
			PayList();
			break;
		default:
			SmsPayMain();
			break;
	}
print <<<EOT
-->
		</td>
	</tr>
</table>
<!--
EOT;

function MainReadMe($str){
	global $lang,$fsetting;
		$lang['tpl.str18']=str_replace('{$fsetting["chansetting"][14]}',forum_ticket(),$lang['tpl.str18']);
	print <<<EOT
-->
<table border="0" cellpadding="0" cellspacing="0" align="center" class="mainbox tableborder">
	<tr>
		<th height="23">{$lang['tpl.str11']}</th>
	</tr>
	<tr>
		<td height="24" class="tablebody5" align="center">
			<a href="?action=PayList">{$lang['tpl.str12']}</a> | <a href="?action=PayList&Suc=1">{$lang['tpl.str13']}</a> | <a href="?action=PayList&Suc=2">{$lang['tpl.str14']}</a> | <a href="?action=UserToolsLog_List">{$lang['tpl.str15']}</a> | <a href="?action=UserCenter"><font color="red">{$lang['tpl.str16']}</font></a> | <a href="userpay.php"><font color="red">{$lang['tpl.str17']}</font></a>
		</td>
	</tr>
	<tr>
		<td height="23" class="tablebody5" style="line-height: 22px">{$lang['tpl.str18']}
		</td>
	</tr>
<!--
EOT;
	if( $str == 1 ){
		print '--'.'></table><!--';
	}
}

function SmsPayMain(){
	global $lang,$fsetting;
	MainReadMe(0);
	$Dvbbs_Server_Url = DVBBS_SERVER_URL;
	$lang['tpl.str21']=str_replace('{$Num}',$Num,$lang['tpl.str21']);
	if( $fsetting['chansetting'][3] == 0 ){
		$Num = php_cCur(forum_ticket())*1;
		print <<<EOT
-->
		<tr>
			<td height=23 class="tablebody2 table_noright">
				<B>{$lang['tpl.str19']}
			</td>
		</tr>
		<form target="_blank" method="post" action="?action=alipay">
		<tr>
			<td height="23" class="tablebody1 table_noright">
				{$lang['tpl.str20']}
				<input type=text size=5 name="paymoney" value="1" onkeyup="ShowChange(this.value,this,'PAY_M',1)">
				{$lang['tpl.str21']}
				<button type="submit" name="submit" onMousemove="button_move(this)" onMouseout="button_out(this)">{$lang['tpl.str22']}</button>
			</td>
		</tr>
		</FORM>
		<tr>
			<td height="24" class="tablebody1 table_noright">
				<b>{$lang['tpl.str23']}</b>
			</td>
		</tr>
		<tr>
			<td height="24" class="tablebody1 table_noright">
				<iframe src="{$Dvbbs_Server_Url}dvbbs/dvdefaulttextad_1.asp" height="23" width="100%" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
			</td>
		</tr>
<!--
EOT;
	}
	if( $fsetting['chansetting'][13] == 1 && $fsetting['chansetting'][0] == 1 ){
		$Num = forum_ticket()*2;
		print <<<EOT
-->
		<tr>
			<td height="24" class="tablebody2 table_noright">{$lang['tpl.str24']}</td>
		</tr>
		<form target="_blank" method="post" action="?action=dsms">
		<tr>
			<td height="23" class="tablebody1 table_noright">
				{$lang['tpl.str25']}
				{$lang['tpl.str26']} <b><font color="red" id="pay" style="color:red;">{$Num}</font></b> {$lang['tpl.str27']}
				<input type="submit" class="button" name="submit" value="{$lang['tpl.str28']}">
			</td>
		</tr>
		</form>
		<form method="post" action="?action=inmoney">
		<tr>
			<td height="23" class="tablebody1 table_noright" style="line-height: 18px">
				{$lang['tpl.str29']}
				<input type="text" size="30" name="SmsCode">
				<input type="submit" class="button" name="submit" value="{$lang['tpl.str30']}"><BR>
				{$lang['tpl.str31']}
			</td>
		</tr>
		</form>
<!--
EOT;
	}
	print <<<EOT
-->
		<tr>
			<td height=23 class="tablebody2 table_noright" style="line-height: 18px">{$lang['tpl.str32']}
			</td>
		</tr>
	</table>
	<SCRIPT LANGUAGE="JavaScript">
	<!--
	var ProductMoney = '{$GLOBALS['ticket']}';
	function getinfo(v){
		v=parseFloat(v);
		var pag=document.getElementById('pay');
		pag.innerHTML=ProductMoney*v;
	}

	function ShowChange(Ivalue,Iname,ShowID,Min){
			if(isNaN(Ivalue)){
				Iname.value = Min;
				alert('{$lang['tpl.str33']}');
			}
			else{
				Ivalue = parseFloat(Ivalue);
				Min = parseFloat(Min);
				if (Ivalue<Min){
					Iname.value = Min;
					document.getElementById(ShowID).innerHTML = Min;
					alert('{$lang['tpl.str34']}');
				}
				else{
					document.getElementById(ShowID).innerHTML = (Ivalue * ProductMoney).toFixed(1);
				}
			}
		}
	//-->
	</SCRIPT>
<!--
EOT;
}

//短信点播第一次提交接收信息部分
function Re_Sms(){
	global $_SESSION;
	if( $GLOBALS['errorcode'] == 1 ){
		$challengeWord_key = trim($_SESSION['challengeWord_key']);
		$retokerWord = trim($GLOBALS['token']);
		if( $challengeWord_key === $retokerWord ){
			print <<<EOT
-->	
	<!--论坛操作成功信息-->
	<br>
	<table cellpadding=5 cellspacing=0 align=center class="tableborder1" style="width:75%; border-top:none;">
	<tr align=center>
	<th width="100%">{$lang['tpl.str35']}
	</td>
	</tr>
	<tr>
	<td width="100%" class="tablebody5">
	{$lang['tpl.str36']}
	</td></tr>
	<tr align=center><td width="100%" class="tablebody5">
	<a href="userpay.php"> &lt;&lt; {$lang['tpl.str37']}</a> &nbsp;&nbsp;||&nbsp;&nbsp; <a href="javascript:void(0);" onclick="if( window.document.all ){window.opener=''}window.close();"> {$lang['tpl.str38']}>></a> 
	</td></tr>
	</table><br>
<!--
EOT;
		} else{
			showmsg($lang['Error.strings0']);
			exit;
		}
	} else{
		showmsg(str_replace('{$ErrorMsg}',$GLOBALS['errormsg'],$lang['Error.strings5']));
		exit;
	}
	Emp_ChallengeWord();
}

//短信点播第二次序列号提交部分
function inmoney(){
	global $dv,$db,$userid,$userinfo,$SmsCode;
	if( $SmsCode == '' ){
		showmsg($lang['Error.strings6']);
		exit;
	}
	if( empty($userinfo) ){
		showmsg($lang['Error.strings2']);
		exit;
	} elseif( $userinfo['ischallenge'] == 0 ){
		showmsg($lang['Error.strings7']);
		exit;
	} else{
		$UserMobile = $userinfo['usermobile'];
	}
	$challengeInfo =& getChallengeInfo();
	if( $challengeInfo === false ){
		showmsg($lang['Error.strings4']);
		exit;
	}
	Get_ChallengeWord();
	//进入论坛订单库
	$arrSmsCode = explode(',',$SmsCode);
	$PayMoney = count($arrSmsCode) * 2;
	addChanOrders($GLOBALS['membername'],$PayMoney,str_replace('dv','',$_SESSION['challengeWord']));
	$Dvbbs_Server_Url = DVBBS_SERVER_URL;
	$backurl = getScriptUrl();
	print <<<EOT
-->	
	{$lang['tpl.str39']}
	<form name="redir" action="{$Dvbbs_Server_Url}ray.asp?Action=ToolsInMoney" method="post">
	<input type="hidden" name="mobile" value="{$UserMobile}">
	<input type="hidden" name="forumid" value="{$challengeInfo['d_forumid']}">
	<input type="hidden" name="backurl" value="{$backurl}userpay.php?Action=Re_inmoney">
	<input type="hidden" name="seqno" value="{$_SESSION['challengeWord']}">
	<input type="hidden" name="linkid" value="{$SmsCode}">
	</form>
	<script LANGUAGE=javascript>
	<!--
	redir.submit();
	//-->
	</script>
<!--
EOT;
}

//短信点播第二次提交返回部分-充值到账号
function Re_inmoney(){
	global $db,$dv,$fsetting;
	if( $GLOBALS['errorcode'] != 1 ){
		showmsg(str_replace('{$ErrorMsg}',$GLOBALS['errormsg'],$lang['Error.strings5']));
		exit;
	}
	$UserInMoney = trim($GLOBALS['money']);
	if( !is_numeric($UserInMoney) ){
		showmsg(str_replace('{$UserInMoney}',$UserInMoney,$lang['Error.strings8']));
		exit;
	}
	if( $UserInMoney < 0 ){
		showmsg(str_replace('{$UserInMoney}',$UserInMoney,$lang['Error.strings8_1']));
		exit;
	}
	$retokerWord = trim($GLOBALS['retokerWord']);
	$PayCode = trim($GLOBALS['seqno']);
	if( $retokerWord === '' || $PayCode === '' ){
		eval('$errorMsg = "'.addslashes($lang['Error.strings8_2']).'";');
		showmsg($errorMsg);
		exit;
	}
	$PayCode = str_replace('dv','',$PayCode);
	$UserInMoney = number_format($UserInMoney,2);
	//验证订单信息
	$orderInfo =& getChanOrdersBy($PayCode);
	if( $orderInfo === false ){
		showmsg($lang['Error.strings9']);
		exit;
	}
	$challengePassword = getChallengePassword();
	//加密字符串验证
	//重新生成加密字符串对照返回加密字符串
	$PayCodeEnCode = md5("dv{$orderInfo['o_paycode']}:".trim($GLOBALS['errorcode']).':'.trim($GLOBALS['money']).':'.$challengePassword);
	if( $PayCodeEnCode != $retokerWord ){
		showmsg($lang['Error.strings10']);
		exit;
	}
	//更新数据库资料
	//更新用户资料
	$userinfo['userticket'] += forum_ticket()*$UserInMoney;
	UpdateUserInfoByName($userName,array('userticket'=>$userinfo['userticket']));
	$Num = forum_ticket()*$UserInMoney;
	//更新订单状态
	updateChanOrderState($UserInMoney,$orderInfo['o_id']);
	Emp_ChallengeWord();
	print <<<EOT
-->	
	<!--论坛操作成功信息-->
	<br>
	<table cellpadding=5 cellspacing=0 align=center class="tableborder1" style="width:75%; border-top:none;">
	<tr align=center>
	<th width="100%">{$lang['tpl.str40']}
	</td>
	</tr>
	<tr>
	<td width="100%" class="tablebody5">
	<b>{$lang['tpl.str41']}</b><br><br>
	<li>{$lang['tpl.str42']}<B><font color=red>{$Num}</font></B> {$lang['tpl.str27']}{$lang['tpl.str80']}
	</td></tr>
	<tr align=center><td width="100%"  class="tablebody5">
	<a href="usermanager.php"> &lt;&lt; {$lang['tpl.str43']}</a> &nbsp;&nbsp;||&nbsp;&nbsp; <a href="userpay.php?action=UserCenter"> {$lang['tpl.str44']}>></a> 
	</td></tr>
	</table><br>
<!--
EOT;
}

function AliPay(){
	global $fsetting,$lang;
	$PayMoney = trim($_POST['paymoney']);
	if(!is_numeric($PayMoney)){
		showmsg($lang['Error.strings11']);
		exit;
	}
	if( $PayMoney < 1 ){
		showmsg($lang['Error.strings11']);
		exit;
	}
	$PayMoney = number_format($PayMoney,2);
	mt_srand();
	$strRnd = mt_rand(0,999999);
	$strLen = strlen($strRnd);
	if( $strLen < 6 ){
		$strRnd = str_repeat('0',6-$strLen).$strRnd;
	}
	if( $fsetting['chansetting'][5] != 0 ){
		$PayCode = '01'.$fsetting['chansetting'][5].date('YmdHis').$strRnd;
	} else{
		$PayCode = date('YmdHis').$strRnd.substr(md5($fsetting['chansetting'][4].$fsetting['chansetting'][6]),0,8);
	}
	
	$Dvbbs_Payto_Url = DVBBS_PAYTO_URL;
	$strSeller = strtolower($fsetting['chansetting'][4]);
	addChanOrders($GLOBALS['membername'],$PayMoney,$PayCode);
	$backurl = getScriptUrl();
	$EnCodeStr="body=Forum points Certificates&out_trade_no={$PayCode}&partner=2088002048522272&payment_type=1&return_url={$Dvbbs_Payto_Url}top.asp&seller_email={$strSeller}&service=create_direct_pay_by_user&show_url={$backurl}&subject=Forum points Certificates&total_fee={$PayMoney}{$fsetting['chansetting'][6]}";
	$EnCodeStr = md5($EnCodeStr);
	
	//提交到动网官方主服务器
	if( $fsetting['chansetting'][5] != 0 ){
		$Dvbbs_Server_Url = DVBBS_SERVER_URL;
		print <<<EOT
-->	
	{$lang['tpl.str39']}
	<form name="redir" action="{$Dvbbs_Server_Url}alipay_t1.aspx?action=pay" method="post">
	<input type="hidden" name="username" value="{$GLOBALS['membername']}">
	<input type="hidden" name="paycode" value="{$PayCode}">
	<input type="hidden" name="returnurl" value="{$backurl}userpay.php?action=alipay_return">
	<input type="hidden" name="paymoney" value="{$PayMoney}">
	</form>
	
	<script LANGUAGE=javascript>
	<!--
	redir.submit();
	//-->
	</script>
<!--
EOT;
	} else{
		print <<<EOT
-->
	{$lang['tpl.str39']}
      <form name="redir" action="{$Dvbbs_Payto_Url}top.asp?action=pay" method="post">
         <input type="hidden" name="buyer" value="{$GLOBALS['membername']}">
         <input type=hidden name="returnurl" value="{$backurl}">
         <input type=hidden name="out_trade_no" value="{$PayCode}">
         <input type=hidden name="seller_email" value="{$strSeller}">
         <input type=hidden name="total_fee" value="{$PayMoney}">
         <input type=hidden name="sign" value="{$EnCodeStr}">
     </form>


	<script LANGUAGE=javascript>
	<!--
	redir.submit();
	//-->
	</script>
<!--
EOT;
	}
}

function AliPay_Return_Old(){
	$PayCode = trim($GLOBALS['paycode']);
	$SignStr = trim($GLOBALS['sign']);
	$Success = trim($GLOBALS['success']);
	if( $PayCode === '' || $SignStr === '' || !is_numeric($Success) ){
		showmsg($lang['Error.strings13']);
		exit;
	}
	if( $Success == 0 ){
		showmsg($lang['Error.strings14']);
		exit;
	}
	$orderInfo =& getChanOrdersBy($PayCode);
	if( $orderInfo === false ){
		showmsg($lang['Error.strings9']);
		exit;
	}
	$PayCodeEnCode = md5("{$orderInfo['o_paycode']}:{$Success}:{$orderInfo['o_paymoney']}:{$fsetting['chansetting'][6]}");
	if( $PayCodeEnCode != $SignStr ){
		showmsg($lang['Error.strings15']);
		exit;
	}
	//更新数据库资料
	$UserInMoney = $orderInfo['o_paymoney'];
	$userinfo['userticket'] += forum_ticket()*$UserInMoney;
	UpdateUserInfoByName($userName,array('userticket'=>$userinfo['userticket']));
	//更新订单状态
	updateChanOrderState2($orderInfo['o_id']);
	$Num = forum_ticket()*$UserInMoney;
	print <<<EOT
-->
	<!--论坛操作成功信息-->
	<br>
	<table cellpadding=5 cellspacing=0 align=center class="tableborder1" style="width:75%; border-top:none;">
	<tr align=center>
	<th width="100%">{$lang['tpl.str40']}
	</td>
	</tr>
	<tr>
	<td width="100%" class="tablebody5">
	<b>{$lang['tpl.str41']}</b><br><br>
	<li>{$lang['tpl.str42']}<B><font color=red>{$Num}</font></B> {$lang['tpl.str27']}{$lang['tpl.str80']}
	</td></tr>
	<tr align=center><td width="100%" class="tablebody5">
	<a href="usermanager.asp"> &lt;&lt; {$lang['tpl.str43']}</a> &nbsp;&nbsp;||&nbsp;&nbsp; <a href="userpay.php?action=UserCenter"> {$lang['tpl.str44']}>></a> 
	</td></tr>
	</table><br>
<!--
EOT;
}

//金币转换
function UserCenter(){
	global $lang,$userinfo,$fsetting,$_POST;
	if( $GLOBALS['react'] == 'Savechange' ){
		if( ChkPost() === false ){
			showmsg($lang['ChkPostError']);
			exit;
		}
		$userWealth = trim($_POST['userWealth']);
		$userep = trim($_POST['userep']);
		$usercp = trim($_POST['usercp']);
		$userticket = trim($_POST['userticket']);
		$UpUserMoney = 0;
		if( $userWealth < 0 || $userep < 0 || $usercp < 0 || $userticket < 0 ){
			showmsg($lang['Error.strings0']);
			exit;
		}
		if( $userWealth >= 1 && $userWealth <= php_cCur($userinfo['userwealth']) && php_cCur($fsetting['wealth_money']) != 0 ){
			if( $userWealth / php_cCur($fsetting['wealth_money']) > 0 ){
				$UpUserMoney += $userWealth / php_cCur($fsetting['wealth_money']);
				$userWealth = ($userWealth / php_cCur($fsetting['wealth_money'])) * php_cCur($fsetting['wealth_money']);
				$userinfo['userwealth'] = php_cCur($userinfo['userwealth']) - $userWealth;
			} else{
				$userWealth = 0;
			}
		} else{
			$userWealth = 0;
		}
		if( $userep >= 1 && $userep <= php_cCur($userinfo['userep']) && php_cCur($fsetting['userep_money']) != 0 ){
			if( $userep / php_cCur($fsetting['userep_money']) > 0 ){
				$UpUserMoney += $userep / php_cCur($fsetting['userep_money']);
				$userep = ($userep / php_cCur($fsetting['userep_money'])) * php_cCur($fsetting['userep_money']);
				$userinfo['userep'] = php_cCur($userinfo['userep']) - $userep;
			} else{
				$userep = 0;
			}
		} else{
			$userep = 0;
		}
		if( $usercp >= 1 && $usercp <= php_cCur($userinfo['usercp']) && php_cCur($fsetting['usercp_money']) != 0 ){
			if( $usercp / php_cCur($fsetting['usercp_money']) > 0 ){
				$UpUserMoney += $usercp / php_cCur($fsetting['usercp_money']);
				$usercp = ($usercp / php_cCur($fsetting['usercp_money'])) * php_cCur($fsetting['usercp_money']);
				$userinfo['usercp'] = php_cCur($userinfo['usercp']) - $usercp;
			} else{
				$usercp = 0;
			}
		} else{
			$usercp = 0;
		}
		if( $userticket >= 1 && $userticket <= php_cCur($userinfo['userticket']) && php_cCur($fsetting['ticket_money']) != 0 ){
			if( $usercp / php_cCur($fsetting['ticket_money']) > 0 ){
				$UpUserMoney += $userticket / php_cCur($fsetting['ticket_money']);
				$userticket = ($userticket / php_cCur($fsetting['ticket_money'])) * php_cCur($fsetting['ticket_money']);
				$userinfo['userticket'] = php_cCur($userinfo['userticket']) - $userticket;
			} else{
				$userticket = 0;
			}
		} else{
			$userticket = 0;
		}
		if( $UpUserMoney < 1 ){
			showmsg($lang['Error.strings16']);
			exit;
		} else{
			$userinfo['usermoney'] = php_cCur($userinfo['usermoney']) + $UpUserMoney;
			UpdateUserInfoById($GLOBALS['userid'],array('userwealth'=>$userinfo['userwealth'],'userep'=>$userinfo['userep'],'usercp'=>$userinfo['usercp'],'userticket'=>$userinfo['userticket'],'usermoney'=>$userinfo['usermoney']));
			eval('$logMsg = "'.addslashes($lang['template.strings2']).'";');
			showmsg($logMsg);
			exit;
		}
	} else{
		print <<<EOT
-->	
	<table cellpadding=0 cellspacing=0 class="mainbox tableborder">
	<tr><th height=20 colspan="5">{$lang['tpl.str46']}</th></tr>
	<tr><td height=20 colspan="5" class="tablebody5"><li>{$lang['tpl.str47']}</td></tr>
	</table>
	<table cellpadding=0 cellspacing=0 class="mainbox tableborder" align=center>
    <tr>
      <th width="30%" height="20">{$lang['tpl.str48']}</th>
      <th width="15%">{$lang['tpl.str49']}</th>
	  <th width="20%">{$lang['tpl.str50']}</th>
      <th width="15%">{$lang['tpl.str51']}</th>
	  <th width="20%">{$lang['tpl.str52']}</th>
    </tr>
	<form action="userpay.php?action=UserCenter&react=Savechange" method="post" name="CenterForm">
    <tr>
      <td rowspan="5">
		<table border="0" cellpadding=0 cellspacing=0 align=center class="mainbox">
			<tr><td class="tablebody1 table_noright">&nbsp;&nbsp;&nbsp;&nbsp;<a href="userpay.php"><font color=red>{$lang['tpl.str53']}</font></a></td></tr>
			<tr><td class="tablebody2 table_noright">&nbsp;&nbsp;&nbsp;&nbsp;<b><font class=redfont>1</font> {$lang['tpl.str2']} = <font class=redfont>{$fsetting['wealth_money']}</font> {$lang['tpl.str5']}</b></td></tr>
			<tr><td class="tablebody1 table_noright">&nbsp;&nbsp;&nbsp;&nbsp;<b><font class=redfont>1</font> {$lang['tpl.str2']} = <font class=redfont>{$fsetting['userep_money']}</font> {$lang['tpl.str7']}</b></td></tr>
			<tr><td class="tablebody2 table_noright">&nbsp;&nbsp;&nbsp;&nbsp;<b><font class=redfont>1</font> {$lang['tpl.str2']} = <font class=redfont>{$fsetting['usercp_money']}</font> {$lang['tpl.str8']}</b></td></tr>
			<tr><td class="tablebody1 table_noright">&nbsp;&nbsp;&nbsp;&nbsp;<b><font class=redfont>1</font> {$lang['tpl.str2']} = <font class=redfont>{$fsetting['ticket_money']}</font> {$lang['tpl.str3']}</b></td></tr>
			<tr><td class="tablebody2 table_noright"></td></tr>
		</table>
	  </td>
      <td align=center>{$lang['tpl.str54']}</td>
      <td><font class=redfont>{$userinfo['userwealth']}</font></td>
	  <td><input type="text" name="userWealth" value="0" onkeyup="ShowChange(this.value,this,'Show_Money','{$fsetting['wealth_money']}','{$userinfo['userwealth']}')"></td>
	  <td ID=Show_Money>0</td>
    </tr>
    <tr>
      <td align=center>{$lang['tpl.str55']}</td>
      <td><font class=redfont>{$userinfo['userep']}</font></td>
	  <td><input type="text" name="userep" value="0" onkeyup="ShowChange(this.value,this,'Show_EP','{$fsetting['userep_money']}','{$userinfo['userep']}')"></td>
	  <td ID=Show_EP>0</td>
    </tr>
    <tr>
      <td align=center>{$lang['tpl.str56']}</td>
      <td><font class=redfont>{$userinfo['usercp']}</font></td>
	  <td><input type="text" name="usercp" value="0" onkeyup="ShowChange(this.value,this,'Show_CP','{$fsetting['usercp_money']}','{$userinfo['usercp']}')"></td>
	  <td ID=Show_CP>0</td>
    </tr>
    <tr>
      <td align=center>{$lang['tpl.str57']}</td>
      <td><font class=redfont>{$userinfo['userticket']}</font></td>
	  <td><input type="text" name="userticket" value="0" onkeyup="ShowChange(this.value,this,'Show_Ticket','{$fsetting['ticket_money']}','{$userinfo['userticket']}')"></td>
	  <td ID=Show_Ticket>0</td>
    </tr>
	<tr>
      <td align=right colspan="4">
	  <button TYPE="submit" onMousemove="button_move(this)" onMouseout="button_out(this)">{$lang['tpl.str58']}</button>&nbsp;&nbsp;<button TYPE="reset"  onMousemove="button_move(this)" onMouseout="button_out(this)">{$lang['tpl.str59']}</button></td>
    </tr>
	</form>
	</table>
	<SCRIPT LANGUAGE="JavaScript">
	<!--
	function ShowChange(Ivalue,Iname,ShowID,Sys,User){
		if(isNaN(Ivalue)){
			Iname.value = 0;
			alert('{$lang['tpl.str33']}');
		}
		else{
			Ivalue = parseFloat(Ivalue);
			Sys = parseFloat(Sys);
			User = parseFloat(User);
			if (Ivalue>User||Ivalue<0){
				Iname.value = 0;
				document.getElementById(ShowID).innerHTML = 0;
				alert('{$lang['tpl.str60']}');
			}
			else{
				document.getElementById(ShowID).innerHTML = (Ivalue / Sys).toFixed(1);
			}
		}
	}
	//-->
	</SCRIPT>
<!--
EOT;
	}
}

//用户订单列表
function PayList(){
	global $lang;
	$Success = trim($GLOBALS['Suc']);
	if( is_numeric($Success) ){
		$Success = $Success;
	} else{
		$Success = 0;
	}
	MainReadMe(1);
	$SucMsg = str_replace('{MemberName}',$GLOBALS['membername'],$lang["SucMsg{$Success}"]);
	$orderInfo =& getChanOrdersByName($GLOBALS['membername'],$Success);
	print <<<EOT
-->
	
		</td>
	</tr>
	<tr>
		<td colspan=3>
			<table cellpadding=0 cellspacing=0 align=center width="100%" class="tableborder">
				<tr>
					<td height=23 colspan=6 style="line-height:18px;">{$SucMsg}</td>
				</tr>
				<tr align="center">
					<th height=23 width="15%">{$lang['tpl.str61']}</th>
					<th width="20%">{$lang['tpl.str62']}</th>
					<th width="15%">{$lang['tpl.str63']}</th>
					<th width="15%">{$lang['tpl.str64']}</th>
					<th width="15%">{$lang['tpl.str65']}</th>
					<!--<th width="15%">{$lang['tpl.str65']}</th>
					<th width="20%">{$lang['tpl.str66']}</th>-->
				</tr>
<!--
EOT;
	if( $orderInfo['RecordCount'] <= 0){
		print <<<EOT
-->
				<tr><td height=23 colspan=6>{$lang['tpl.str67']}</td></tr>
			</table>
<!--
EOT;
	} else{
		foreach( $orderInfo['result_set'] as $currOrder ){
			if( $currOrder['o_type'] == '1' ){
				$currType =$lang['tpl.str68'];
			} elseif( $currOrder['o_type'] == '2' ){
				$currType = $lang['tpl.str69'];
			} else{
				$currType = '<font color="gray">'.$lang['tpl.str70'].'</font>';
			}
			if( $currOrder['o_issuc'] == '0' ){
				$currState = '<font color="gray">'.$lang['tpl.str71'].'</font>';
			} elseif( $currOrder['o_type'] == '1' ){
				$currState = $lang['tpl.str72'];
			} else{
				$currState = '<font color="gray">'.$lang['tpl.str70'].'</font>';
			}
			$currOrdertime=gmdate('Y-m-d H:i:s',$currOrder['o_addtime']+getUserTimeZoneOffset());
			print <<<EOT
-->
				<tr align="center">
					<td height=23>{$currType}</td>
					<td height=23>{$currOrder['o_paycode']}</td>
					<td height=23>{$currOrder['o_paymoney']}</td>
					<td height=23>{$currState}</td>
					<td height=23 class="tablebody5">{$currOrdertime}</td>
					<!--<td height=23 class="tablebody1">&nbsp;</td>-->
				</tr>
<!--
EOT;
		}
		print <<<EOT
-->
			</table>
			<script language="JavaScript" src="templates/lang/{$GLOBALS['fsetting']['lang']}/js/pagination.js"></script>
			<script type="text/javascript" language="javascript">
			PageList({$orderInfo['AbsolutePage']},3,{$orderInfo['PageSize']},{$orderInfo['RecordCount']},"action=PayList&Suc={$Success}",1);
			</script>
<!--
EOT;
	}
	print <<<EOT
-->
<!--
EOT;
}

//重新获得交易状态
function AliPay_1(){
	global $lang;
	$id = trim($GLOBALS['id']);
	if( !is_numeric($id) ){
		showmsg($lang['Error.strings13']);
		exit;
	} else{
		$id = php_cCur($id);
	}
	$orderInfo =& getChanOrdersByIdName($id,$GLOBALS['membername']);
	if( $orderInfo === false ){
		showmsg($lang['Error.strings17']);
		exit;
	}
	//提交到动网官方主服务器
	$Dvbbs_Server_Url = DVBBS_SERVER_URL;
	$backUrl = getScriptUrl();
	$orderInfo[0]['o_paymoney'] = number_format($orderInfo[0]['o_paymoney'],2);
	print <<<EOT
-->
	{$lang['tpl.str39']}
	<form name="redir" action="{$Dvbbs_Server_Url}alipay_t1.aspx?action=pay_1" method="post">
	<INPUT type=hidden name="username" value="{$GLOBALS['membername']}">
	<INPUT type=hidden name="paycode" value="{$orderInfo[0]['o_paycode']}">
	<INPUT type=hidden name="returnurl" value="{$backUrl}userpay.php?action=alipay_return">
	<INPUT type=hidden name="paymoney" value="{$orderInfo[0]['o_paymoney']}">
	</form>
	<script LANGUAGE=javascript>
	<!--
	redir.submit();
	//-->
	</script>
<!--
EOT;
}

function UserToolsLog_List(){
	global $lang,$fsetting;
	$arrLogType = explode('|',$lang['LogType']);
	MainReadMe(1);
	$arrToolsNames = array('-88',$lang['ToolsNames']);
	$fsetting['plus_tools'] = 0;//禁用
	if( $fsetting['plus_tools'] == 1 ){
		$rsPlusTools =& getPlusTools();
		if( $rsPlusTools !== false ){
			foreach( $rsPlusTools as $val ){
				$arrToolsNames["{$val['id']}"] = $val['toolsname'];
			}
		}
	}
	$arrMoneyLog =& getMoneyLosgById();
	print <<<EOT
-->
	
			</td>
		</tr>
		<tr>
		<td colspan=3>
			<table cellpadding=0 cellspacing=0 align=center width="100%" class="tableborder">
				<tr align="center">
					<th height=23 width="15%">{$lang['tpl.str73']}</th>
					<th width="10%">{$lang['tpl.str66']}</th>
					<th width="*%">{$lang['tpl.str74']}</th>
					<th width="5%">{$lang['tpl.str2']}</th>
					<th width="5%">{$lang['tpl.str3']}</th>
					<th width="5%">{$lang['tpl.str75']}</th>
					<th width="13%">{$lang['tpl.str76']}</th>
					<th width="12%">{$lang['tpl.str77']}</th>
				</tr>
<!--
EOT;
	if( $arrMoneyLog['RecordCount'] <= 0 ){
		print <<<EOT
-->
				<tr><td colspan="8" align=center>{$lang['tpl.str78']}</td></tr>
			</table>
<!--
EOT;
	} else{
		foreach( $arrMoneyLog['result_set'] as $val ){
			if( $fsetting['plus_tools'] == 1 ){
				$toolsName = $arrToolsNames["{$val['toolsid']}"];
			} else{
				$toolsName = '<font color="gray">'.$lang['tpl.str39'].'</font>';
			}
			$logtime=gmdate('Y-m-d H:i:s',$val['log_time']+getUserTimeZoneOffset());
			print <<<EOT
-->
			<tr align="center" height="24">
				<td>{$toolsName}</td>
				<td>{$arrLogType["{$val['log_type']}"]}</td>
				<td>{$val['conect']}</td>
				<td>{$val['log_money']}</td>
				<td>{$val['log_ticket']}</td>
				<td>{$val['countnum']}</td>
				<td>{$val['log_ip']}</td>
				<td class="tablebody5">{$logtime}</td>
			</tr>
<!--
EOT;
		}
		print <<<EOT
-->
			</table>
			<script language="JavaScript" src="templates/lang/{$GLOBALS['fsetting']['lang']}/js/pagination.js"></script>
			<script type="text/javascript" language="javascript">
			PageList({$arrMoneyLog['AbsolutePage']},3,{$arrMoneyLog['PageSize']},{$arrMoneyLog['RecordCount']},"action=UserToolsLog_List",1);
			</script>
<!--
EOT;
	}
}

?>-->