misc_buyinvitecode.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: misc_buyinvitecode.php 31572 2012-09-10 08:59:03Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(submitcheck('buysubmit')) {
  12. if($_G['setting']['ec_tenpay_bargainor'] || $_G['setting']['ec_tenpay_opentrans_chnid'] || $_G['setting']['ec_account']) {
  13. $language = lang('forum/misc');
  14. $amount = intval($_GET['amount']);
  15. $email = dhtmlspecialchars($_GET['email']);
  16. if(empty($amount)) {
  17. showmessage('buyinvitecode_no_count');
  18. }
  19. if(strlen($email) < 6 || !preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email)) {
  20. showmessage('buyinvitecode_email_error');
  21. }
  22. $price = round($amount * $_G['setting']['inviteconfig']['invitecodeprice'], 2);
  23. $orderid = '';
  24. $apitype = is_numeric($_GET['bank_type']) ? 'tenpay' : $_GET['bank_type'];
  25. if(empty($apitype)) {
  26. showmessage('parameters_error');
  27. }
  28. require_once libfile('function/trade');
  29. $requesturl = invite_payurl($amount, $price, $orderid, $_GET['bank_type']);
  30. if(C::t('forum_order')->fetch($orderid)) {
  31. showmessage('credits_addfunds_order_invalid');
  32. }
  33. C::t('forum_order')->insert(array(
  34. 'orderid' => $orderid,
  35. 'status' => '1',
  36. 'uid' => 0,
  37. 'amount' => $amount,
  38. 'price' => $price,
  39. 'submitdate' => $_G['timestamp'],
  40. 'email' => $email,
  41. 'ip' => $_G['clientip'],
  42. ));
  43. include template('common/header_ajax');
  44. echo '<form id="payform" action="'.$requesturl.'" method="post"></form><script type="text/javascript" reload="1">$(\'payform\').submit();</script>';
  45. include template('common/footer_ajax');
  46. dexit();
  47. } else {
  48. showmessage('action_closed', NULL);
  49. }
  50. }
  51. if($_GET['action'] == 'paysucceed' && $_GET['orderid']) {
  52. $orderid = $_GET['orderid'];
  53. $order = C::t('forum_order')->fetch($orderid);
  54. if(!$order) {
  55. showmessage('parameters_error');
  56. }
  57. $codes = array();
  58. foreach(C::t('common_invite')->fetch_all_orderid($orderid) as $code) {
  59. $codes[] = $code['code'];
  60. }
  61. if(empty($codes)) {
  62. showmessage('buyinvitecode_no_id');
  63. }
  64. $codetext = implode("\r\n", $codes);
  65. }
  66. if($_G['group']['maxinviteday']) {
  67. $maxinviteday = time() + 86400 * $_G['group']['maxinviteday'];
  68. } else {
  69. $maxinviteday = time() + 86400 * 10;
  70. }
  71. $maxinviteday = dgmdate($maxinviteday, 'Y-m-d H:i');
  72. $_G['setting']['inviteconfig']['invitecodeprompt'] = nl2br($_G['setting']['inviteconfig']['invitecodeprompt']);
  73. include template('common/buyinvitecode');
  74. ?>