<?php
include_once "./config.php";
$version=$_POST['version'];
$customerid=$_POST['customerid'];
$sdorderno=$_POST['sdorderno'];
$total_fee=$_POST['total_fee'].'.00';
$paytype=$_POST['paytype']; 
$bankcode='';
$notifyurl=$_POST['notifyurl'];
$returnurl=$_POST['returnurl'];
$remark=$_POST['remark']; 
$remark=trim($remark," ");
$arrs=explode("-sp-",$remark);
$qu=$arrs[0];
$role_name=$arrs[1];
$get_code='00';  //此参数必须有，如没有可以为00
$recommend=$_POST['recommend'];

$conn = new mysqli($db_ip, $db_name, $db_psd, $server);
if ($conn->connect_error){
	die("连接失败: " . $conn->connect_error);
	exit("异常！");
}
$find=$role_name;
if(count($arrs)==3){
    $find=$arrs[2];
    $roleid=$arrs[1];
}else{
    $roleid=getRoleIDByName($quarr[$qu]['url'], $find);
}
if((!$roleid)||$roleid==0){
   exit("该角色不存在！");
}
/*
$userinfo = mysqli_query($conn,"SELECT * FROM user WHERE (uid='" . $find . "' or roleid='".$roleid."') and server='".$qu."' limit 1");
if($userinfo&&mysqli_num_rows($userinfo)>0) {
    mysqli_query($conn,"update user set roleid='".$roleid."',uid='" . $find . "'  WHERE (uid='" . $find . "' or roleid='".$roleid."')  and server='".$qu."' limit 1");
}else{
    header("Location: bind.php?rolename=".$find."&qu=".$arrs[0]);
	exit();
}*/

	$parameter = array(
	"pid" => $customerid,
	"type" => $paytype,
	"notify_url" => $notifyurl,
	"return_url" => $returnurl,
	"out_trade_no" => $sdorderno,
	"name" => $remark,
	"sitename" => $remark,
	"money"	=> $total_fee,
);
	$sign=buildRequestPara($parameter);
	//exit($sign);
?>
<!doctype html>
<html>
<head>
    <meta charset="utf8">
    <title>正在转到付款页</title>
</head>
<body  onLoad="document.pay.submit()">
	<form name="pay" action="<?php echo $paypath?>" method="post">
        <input type="hidden" name="pid" value="<?php echo $customerid?>">
        <input type="hidden" name="type" value="<?php echo $paytype?>">
        <input type="hidden" name="notify_url" value="<?php echo $notifyurl?>">
        <input type="hidden" name="return_url" value="<?php echo $returnurl?>">
        <input type="hidden" name="out_trade_no" value="<?php echo $sdorderno?>">
        <input type="hidden" name="name" value="<?php echo $remark?>">
		<input type="hidden" name="sitename" value="<?php echo $remark?>">
        <input type="hidden" name="money" value="<?php echo $total_fee?>">
        <input type="hidden" name="sign" value="<?php echo $sign?>">
        <input type="hidden" name="sign_type" value="MD5">
    </form>
	
</body>
</html>