<?php
require ('authentication_member.php');
?>
<?php

/* 在线充值 */  
/* 162100源码 - 162100.com */


if (POWER == 0) {
  err('请<a href="./login.php">登陆</a>。');
}
  
if (empty($_POST['WIDtotal_fee']) || !(is_numeric($_POST['WIDtotal_fee']) && $_POST['WIDtotal_fee'] > 0)) {
  err('金额必须是大于0的数字');
}


if ($_GET['act'] == 'class_c') {

  err('非商业版未开通此功能！请联系162100官方购买，谢谢支持');

}

//订单号
if ($trade_no = get_trade_no($session[0], $_POST['WIDtotal_fee'])) {
  err('正在提交……<form action="'.$web['path'].'pay/alipayapi.php" method="post" name="payform" id="payform" style="display:none">
<input name="WIDout_trade_no" type="hidden" value="'.$trade_no.'" />
<input name="WIDtotal_fee" type="hidden" value="'.$_POST['WIDtotal_fee'].'" />
<input name="WIDsubject" type="hidden" value="在线充值" />
<input name="WIDbody" type="hidden" value="" />
</form>
<script> document.getElementById("payform").submit(); </script>');

} else {
  err('获取订单号失败！请重试。');
}


function get_trade_no($username, $total_fee) {
  global $web, $session;
  require ('inc/function/write_file.php');
  $no = gmdate('YmdHis', time() + (floatval($web['time_pos']) * 3600));
  if (!file_exists('__temp__/order/'.$no.'.txt')) {
    if (write_file('__temp__/order/'.$no.'.txt', $_POST['WIDtotal_fee'].'|'.$session[0])) {
      return $no;
    }
  }
  return '';
}
?>

