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

require("rmb.inc.php");

if($fromurl){	//支付成功之后返回到某个频道
	setcookie('_fromurl',$fromurl);
}

if(in_array($banktype,array('alipay','tenpay','chinabank','yeepay','paypal','wxpay'))){
	
	if($banktype=='wxpay'){	//微信支付只能生成链接在手机上操作
		$url = "$webdb[www_url]/do/waprmb_add.php?banktype=wxpay&atc_moeny=$atc_moeny&uid=$lfjuid";
	}

	include(ROOT_PATH."inc/olpay/{$banktype}.php");
}elseif($banktype){
	showerr("支付类型有误!");	
}elseif(!$lfjuid){
	showerr('请先登录!');
}

//$lfjdb[money]=get_money($lfjuid);

require(ROOT_PATH."inc/head.php");
require(html("rmb_add"));
require(ROOT_PATH."inc/foot.php");


function olpay_send(){
	global $db,$pre,$webdb,$banktype,$atc_moeny,$timestamp,$lfjuid,$lfjid,$numcode;
	
	$atc_moeny = number_format($atc_moeny,2);
	if($atc_moeny<0.01){
		showerr("你输入的充值金额不能小于0.01元");
	}



	$array[money]=$atc_moeny;
	$array[return_url]="$webdb[www_url]/do/rmb_add.php?banktype=$banktype&";
	$array[title]="为{$lfjid}在线充值";
	$array[content]="为帐号:$lfjid,在线充值";
	$array[numcode]=$numcode?filtrate($numcode):strtolower(rands(10));

	switch($banktype){
		case 'alipay':
			$_banktype = '支付宝';
			$bank1 = $webdb['alipay_id'];
			break;
		case 'tenpay':
			$_banktype = '财付通';
			$bank1 = $webdb['tenpay_id'];
			break;
		case 'yeepay':
			$_banktype = '易宝支付';
			$bank1 = $webdb['yeepay_id'];
			break;
	}

	$db->query("INSERT INTO `{$pre}rmb_infull` (`numcode` ,`money` ,  `posttime` , `uid` , `username` , `banktype` , `bank1` ) VALUES ( '$array[numcode]', '$array[money]', '$timestamp', '$lfjuid', '$lfjid', '$_banktype', '$bank1')");

	return $array;
}

/*
function olpay_end($numcode){
	global $db,$pre,$webdb,$banktype;

	$rt = $db->get_one("SELECT * FROM {$pre}rmb_infull WHERE numcode='$numcode'");
	if(!$rt){
		showerr('系统中没有您的充值订单，无法完成充值！');
	}
	if($rt['ifpay'] == 1){
		showerr('该订单已经充值成功！');
	}
	$db->query("UPDATE {$pre}rmb_infull SET ifpay='1' WHERE id='$rt[id]'");

	
	add_rmb($rt['uid'],$rt['money'],0,date('m月d日H:i ').'在线充值');

	$fromurl = $_COOKIE['_fromurl'] ? $_COOKIE['_fromurl'] : "$webdb[www_url]/member/rmb.php?job=list";

	refreshto($fromurl,"恭喜你支付成功",1);
}
*/

?>