<?php if(!defined('ONGPHP'))exit('Error ONGSOFT');

$PAYID  = $PAYAC['payid']  ; //支付的id
$PAYKEY = $PAYAC['paykey'] ; //支付的key
$PAYZH  = $PAYAC['zhanghao'] ; //支付的帐号 需要用到的填写
$PAYHT  = '/codepay/codepay.php'; //支付通信地址
$TYID   = $PAYAC['beizhu']; //支付方式


$PAYYB  = WZHOST.'pay/yb'.anquanqu( $PAYAC ['payfile'] ).'.php'; //异步连接地址
$PAYTB  = WZHOST.'pay/tb'.anquanqu( $PAYAC ['payfile'] ).'.php'; //同步连接地址



if( $PLAYFS  == '1'){//充值处理

   $URL = $PAYHT.'?order_id='.$DINGID['orderid']."&type={$TYID}";
   Header("Location: ".$URL);
  
}else if($PLAYFS  == '2'){ //异步通信

require_once("../codepay/codepay_config.php"); //导入配置文件

ksort($_POST); //排序post参数
reset($_POST); //内部指针指向数组中的第一个元素
$sign = '';
foreach ($_POST AS $key => $val) {
    if ($val == '') continue;
    if ($key != 'sign') {
        $sign .= "$key=$val&"; //拼接为url参数形式
    }
}
if (!$_POST['pay_no']||md5(substr($sign, 0, -1) . $PAYKEY) != $_POST['sign']) { //不合法的数据 KEY密钥为你的密钥
   exit('fail');
}else{ //合法的数据
    //业务处理
  chongzhifan( $_POST['pay_no']  , $_POST['price']  , $_POST['param'] );
     exit('success');
}
  

}else if($PLAYFS  == '3'){ //同步返回

 
               //  if(  isset( $_GET['param']) && strlen( $_GET['param'] ) > 10  ){

                  //  $D= db('dingdan');

                  //  $huidiao = $D->setbiao('dingdan')->where(array('orderid'=>$_GET['param']))->find();
                  //  if($huidiao['mhash']!=''){
                    //  $jieguo = $D->setbiao('dingdan')->where(array('orderid'=>$huidiao['mhash']))->find();
						   // if($jieguo['cpid']>0){
							   //  msgbox('', WZHOST.'n-'.$jieguo['cpid'].'-hd.html');
							   //  exit();
						   // }
					 // } 
                  
				 // } 
		 msgbox('', WZHOST);
                
        


}
?>