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