<?php
include(dirname(__FILE__)."/require.php");
include(dirname(dirname(__FILE__))."/api/alipay/alipay.config.php");
if($ppurview[40]!=1)
  jump("jump.php?id=25&jump=main.php");
if(isset($_GET['action']) and $_GET['action'] == "submit")
{
  $str = "<?php\n";
  $str.= "\$alipay_config['partner']='".$_POST['partner']."';\n";
  $str.= "\$alipay_config['key']='".$_POST['key']."';\n";
  $str.= "\$payment_type = '1';\n";
  $str.= "\$notify_url='".$core_url."api/alipay/notify_url.php';\n";
  $str.= "\$return_url='".$core_url."api/alipay/return_url.php';\n";
  $str.= "\$seller_email='".$_POST['seller_email']."';\n";
  $str.= "\$alipay_config['sign_type'] = strtoupper('MD5');\n";
  $str.= "\$alipay_config['input_charset'] = strtolower('gbk');\n";
  $str.= "\$alipay_config['cacert'] = getcwd().'/cacert.pem';\n";
  $str.= "\$alipay_config['transport'] = 'http';\n";
  $str.= "?>";
  $filename='../api/alipay/alipay.config.php';
  @chmod($filename,0777);
  if (is_writable($filename)) 
  {
    if (!$handle=fopen($filename,'w') or fwrite($handle, $str) === FALSE)
      Header("Location: jump.php?id=error&jump=pay_config.php");
	else
	  Header("Location: jump.php?id=24&jump=pay_config.php");
	fclose($handle);
  }
  else
    jump("jump.php?id=13&jump=pay_config.php");
  exit();
}
$phpcolor->table="style";
$phpcolor->field="*";
$phpcolor->where="type=1";
$style=$phpcolor->assignment();
$tpl -> assign("alipay_config", $alipay_config);
$tpl -> assign("seller_email", $seller_email);
$tpl -> display("pay_config.htm");
?>