<?php
error_reporting(0);
global $db, $CcTvAi_com_userid;
if(!eregi($_SERVER['SERVER_NAME'], $_SERVER['HTTP_REFERER'])) {
    exit();
}
close_browse();
$cd_id=SafeRequest("cd_id", "post"); //付款金额
$cd_points=SafeRequest("cd_points", "post"); //金币数量
$cd_type=SafeRequest("cd_type", "post"); //支付类型：1=>支付宝
if($CcTvAi_com_userid) {
    //产品信息
    $name="充值" . $cd_points . "金币";
    $cd_key=date("YmdHis") . rand(1000, 9999);

    switch($cd_type) { //支付方式
        case '1': //支付宝
            if(cd_xalipaya == "1") { //纯担保交易
                //创建订单
                $setarr=array(
                    'cd_key'=>$cd_key,
                    'cd_name'=>$name,
                    'cd_rmb'=>$cd_id,
                    'cd_mub'=>$cd_points,
                    'cd_type'=>'支付宝担保交易',
                    'cd_state'=>'等待付款',
                    'cd_uid'=>$CcTvAi_com_userid,
                    'cd_uname'=>$CcTvAi_com_username,
                    'cd_addtime'=>date('Y-m-d H:i:s'),
                    'cd_extime'=>date('Y-m-d H:i:s')
                );
                inserttable('pay', $setarr, 1);
                include "../plug/alipay/Gts_points.php";
            } elseif(cd_xalipaya == "2") { //即时到账
                //创建订单
                $setarr=array(
                    'cd_key'=>$cd_key,
                    'cd_name'=>$name,
                    'cd_rmb'=>$cd_id,
                    'cd_mub'=>$cd_points,
                    'cd_type'=>'支付宝即时到账',
                    'cd_state'=>'等待付款',
                    'cd_uid'=>$CcTvAi_com_userid,
                    'cd_uname'=>$CcTvAi_com_username,
                    'cd_addtime'=>date('Y-m-d H:i:s'),
                    'cd_extime'=>date('Y-m-d H:i:s')
                );
                inserttable('pay', $setarr, 1);
            } elseif(cd_xalipaya == "3") { //免签约
                //创建订单
                $setarr=array(
                    'cd_key'=>$cd_key,
                    'cd_name'=>$name,
                    'cd_rmb'=>$cd_id,
                    'cd_mub'=>$cd_points,
                    'cd_type'=>'支付宝免签约',
                    'cd_state'=>'等待付款',
                    'cd_uid'=>$CcTvAi_com_userid,
                    'cd_uname'=>$CcTvAi_com_username,
                    'cd_addtime'=>date('Y-m-d H:i:s'),
                    'cd_extime'=>date('Y-m-d H:i:s')
                );
                inserttable('pay', $setarr, 1);
                //执行
                echo '<html><head><title>页面加载中.....</title><meta http-equiv="content-type" content="text/html; charset=gb2312"></head><script language=javascript>setTimeout("document.form1.submit()",1)</script><body>页面加载中.....<form name="form1" method="post" action="https://shenghuo.alipay.com/send/payment/fill.htm"><input type="hidden" name="payAmount" value="' . $cd_id . '"><input type="hidden" name="optEmail" value="' . cd_xalipayuser . '"><input type="hidden" name="title" value="订单号：' . $cd_key . '"><input type="hidden" name="memo" value="' . $name . '"></form></body></html>';
            } elseif(cd_xalipaya == "4") { //双向交易
                //创建订单
                $setarr=array(
                    'cd_key'=>$cd_key,
                    'cd_name'=>$name,
                    'cd_rmb'=>$cd_id,
                    'cd_mub'=>$cd_points,
                    'cd_type'=>'支付宝双向接口',
                    'cd_state'=>'等待付款',
                    'cd_uid'=>$CcTvAi_com_userid,
                    'cd_uname'=>$CcTvAi_com_username,
                    'cd_addtime'=>date('Y-m-d H:i:s'),
                    'cd_extime'=>date('Y-m-d H:i:s')
                );
                inserttable('pay', $setarr, 1);
                include "../plug/alipay/points.php";
            }
            break;
    }



} else {
    echo '出错了，请先登录！';
}
?>