forked from Bigjoos/U-232-V4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdonatecheck.php
236 lines (236 loc) · 17.5 KB
/
donatecheck.php
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?php
/**
|--------------------------------------------------------------------------|
| https://github.com/Bigjoos/ |
|--------------------------------------------------------------------------|
| Licence Info: GPL |
|--------------------------------------------------------------------------|
| Copyright (C) 2010 U-232 V4 |
|--------------------------------------------------------------------------|
| A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. |
|--------------------------------------------------------------------------|
| Project Leaders: Mindless,putyn. |
|--------------------------------------------------------------------------|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
*/
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'bittorrent.php');
require_once (CACHE_DIR . 'paypal_settings.php');
dbconn();
//$payment_status = "Completed";//Only uncomment if using sandbox mode
$donate_goods = array(
$INSTALLER09['paypal_config']['gb_donated_1'] => array(
'to_add' => array(
'uploaded' => $INSTALLER09['paypal_config']['up_amt_1'] * 1073741824,
'invites' => $INSTALLER09['paypal_config']['inv_amt_1'],
'seedbonus' => $INSTALLER09['paypal_config']['kp_amt_1'],
'total_donated' => $INSTALLER09['paypal_config']['gb_donated_1'],
) ,
'to_update' => array(
'donated' => $INSTALLER09['paypal_config']['gb_donated_1'],
'warned' => 0,
'downloadpos' => 1,
'uploadpos' => 1,
'leechwarn' => 0,
'hit_and_run_total' => 0,
'hnrwarn' => '\'no\'',
'enabled' => '\'yes\'',
'class' => 'IF(class < ' . UC_VIP . ', ' . UC_VIP . ', class), vipclass_before = IF(class < ' . UC_VIP . ', class, 0)',
'donoruntil' => sprintf('IF(donoruntil > 0,donoruntil + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['duntil_dur_1'], $INSTALLER09['paypal_config']['duntil_dur_1']) ,
'vip_until' => sprintf('IF(vip_until > 0,vip_until + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['vip_dur_1'], $INSTALLER09['paypal_config']['vip_dur_1']) ,
'free_switch' => sprintf('IF(free_switch > 0,free_switch + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['free_dur_1'], $INSTALLER09['paypal_config']['free_dur_1']) ,
'immunity' => sprintf('IF(immunity > 0,immunity + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['imm_dur_1'], $INSTALLER09['paypal_config']['imm_dur_1']) ,
'donor' => '\'yes\'',
'modcomment' => "CONCAT('" . get_date(TIME_NOW, 'DATE', 1) . " - User donated ".$INSTALLER09['paypal_config']['gb_donated_1']." " . $INSTALLER09['paypal_config']['currency'] . "\n',modcomment)"
)
) ,
$INSTALLER09['paypal_config']['gb_donated_2'] => array(
'to_add' => array(
'uploaded' => $INSTALLER09['paypal_config']['up_amt_2'] * 1073741824,
'invites' => $INSTALLER09['paypal_config']['inv_amt_2'],
'seedbonus' => $INSTALLER09['paypal_config']['kp_amt_2'],
'total_donated' => $INSTALLER09['paypal_config']['gb_donated_2'],
) ,
'to_update' => array(
'donated' => $INSTALLER09['paypal_config']['gb_donated_2'],
'warned' => 0,
'downloadpos' => 1,
'uploadpos' => 1,
'leechwarn' => 0,
'hit_and_run_total' => 0,
'hnrwarn' => '\'no\'',
'enabled' => '\'yes\'',
'class' => 'IF(class < ' . UC_VIP . ', ' . UC_VIP . ', class), vipclass_before = IF(class < ' . UC_VIP . ', class, 0)',
'donoruntil' => sprintf('IF(donoruntil > 0,donoruntil + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['duntil_dur_2'], $INSTALLER09['paypal_config']['duntil_dur_2']) ,
'vip_until' => sprintf('IF(vip_until > 0,vip_until + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['vip_dur_2'], $INSTALLER09['paypal_config']['vip_dur_2']) ,
'free_switch' => sprintf('IF(free_switch > 0,free_switch + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['free_dur_2'], $INSTALLER09['paypal_config']['free_dur_2']) ,
'immunity' => sprintf('IF(immunity > 0,immunity + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['imm_dur_2'], $INSTALLER09['paypal_config']['imm_dur_2']) ,
'donor' => '\'yes\'',
'modcomment' => "CONCAT('" . get_date(TIME_NOW, 'DATE', 1) . " - User donated ".$INSTALLER09['paypal_config']['gb_donated_2']." " . $INSTALLER09['paypal_config']['currency'] . "\n',modcomment)"
)
) ,
$INSTALLER09['paypal_config']['gb_donated_3'] => array(
'to_add' => array(
'uploaded' => $INSTALLER09['paypal_config']['up_amt_3'] * 1073741824,
'invites' => $INSTALLER09['paypal_config']['inv_amt_3'],
'seedbonus' => $INSTALLER09['paypal_config']['kp_amt_3'],
'total_donated' => $INSTALLER09['paypal_config']['gb_donated_3'],
) ,
'to_update' => array(
'donated' => $INSTALLER09['paypal_config']['gb_donated_3'],
'warned' => 0,
'downloadpos' => 1,
'uploadpos' => 1,
'leechwarn' => 0,
'hit_and_run_total' => 0,
'hnrwarn' => '\'no\'',
'enabled' => '\'yes\'',
'class' => 'IF(class < ' . UC_VIP . ', ' . UC_VIP . ', class), vipclass_before = IF(class < ' . UC_VIP . ', class, 0)',
'donoruntil' => sprintf('IF(donoruntil > 0,donoruntil + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['duntil_dur_3'], $INSTALLER09['paypal_config']['duntil_dur_3']) ,
'vip_until' => sprintf('IF(vip_until > 0,vip_until + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['vip_dur_3'], $INSTALLER09['paypal_config']['vip_dur_3']) ,
'free_switch' => sprintf('IF(free_switch > 0,free_switch + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['free_dur_3'], $INSTALLER09['paypal_config']['free_dur_3']) ,
'immunity' => sprintf('IF(immunity > 0,immunity + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['imm_dur_3'], $INSTALLER09['paypal_config']['imm_dur_3']) ,
'donor' => '\'yes\'',
'modcomment' => "CONCAT('" . get_date(TIME_NOW, 'DATE', 1) . " - User donated ".$INSTALLER09['paypal_config']['gb_donated_3']." " . $INSTALLER09['paypal_config']['currency'] . "\n',modcomment)"
)
) ,
$INSTALLER09['paypal_config']['gb_donated_4'] => array(
'to_add' => array(
'uploaded' => $INSTALLER09['paypal_config']['up_amt_4'] * 1073741824,
'invites' => $INSTALLER09['paypal_config']['inv_amt_4'],
'seedbonus' => $INSTALLER09['paypal_config']['kp_amt_4'],
'total_donated' => $INSTALLER09['paypal_config']['gb_donated_4'],
) ,
'to_update' => array(
'donated' => $INSTALLER09['paypal_config']['gb_donated_4'],
'warned' => 0,
'downloadpos' => 1,
'uploadpos' => 1,
'leechwarn' => 0,
'hit_and_run_total' => 0,
'hnrwarn' => '\'no\'',
'enabled' => '\'yes\'',
'class' => 'IF(class < ' . UC_VIP . ', ' . UC_VIP . ', class), vipclass_before = IF(class < ' . UC_VIP . ', class, 0)',
'donoruntil' => sprintf('IF(donoruntil > 0,donoruntil + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['duntil_dur_4'], $INSTALLER09['paypal_config']['duntil_dur_4']) ,
'vip_until' => sprintf('IF(vip_until > 0,vip_until + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['vip_dur_4'], $INSTALLER09['paypal_config']['vip_dur_4']) ,
'free_switch' => sprintf('IF(free_switch > 0,free_switch + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['free_dur_4'], $INSTALLER09['paypal_config']['free_dur_4']) ,
'immunity' => sprintf('IF(immunity > 0,immunity + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['imm_dur_4'], $INSTALLER09['paypal_config']['imm_dur_4']) ,
'donor' => '\'yes\'',
'modcomment' => "CONCAT('" . get_date(TIME_NOW, 'DATE', 1) . " - User donated ".$INSTALLER09['paypal_config']['gb_donated_4']." " . $INSTALLER09['paypal_config']['currency'] . "\n',modcomment)"
)
) ,
$INSTALLER09['paypal_config']['gb_donated_5'] => array(
'to_add' => array(
'uploaded' => $INSTALLER09['paypal_config']['up_amt_5'] * 1073741824,
'invites' => $INSTALLER09['paypal_config']['inv_amt_5'],
'seedbonus' => $INSTALLER09['paypal_config']['kp_amt_5'],
'total_donated' => $INSTALLER09['paypal_config']['gb_donated_5'],
) ,
'to_update' => array(
'donated' => $INSTALLER09['paypal_config']['gb_donated_5'],
'warned' => 0,
'downloadpos' => 1,
'uploadpos' => 1,
'leechwarn' => 0,
'hit_and_run_total' => 0,
'hnrwarn' => '\'no\'',
'enabled' => '\'yes\'',
'class' => 'IF(class < ' . UC_VIP . ', ' . UC_VIP . ', class), vipclass_before = IF(class < ' . UC_VIP . ', class, 0)',
'donoruntil' => sprintf('IF(donoruntil > 0,donoruntil + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['duntil_dur_5'], $INSTALLER09['paypal_config']['duntil_dur_5']) ,
'vip_until' => sprintf('IF(vip_until > 0,vip_until + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['vip_dur_5'], $INSTALLER09['paypal_config']['vip_dur_5']) ,
'free_switch' => sprintf('IF(free_switch > 0,free_switch + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['free_dur_5'], $INSTALLER09['paypal_config']['free_dur_5']) ,
'immunity' => sprintf('IF(immunity > 0,immunity + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['imm_dur_5'], $INSTALLER09['paypal_config']['imm_dur_5']) ,
'donor' => '\'yes\'',
'modcomment' => "CONCAT('" . get_date(TIME_NOW, 'DATE', 1) . " - User donated ".$INSTALLER09['paypal_config']['gb_donated_5']." " . $INSTALLER09['paypal_config']['currency'] . "\n',modcomment)"
)
) ,
$INSTALLER09['paypal_config']['gb_donated_6'] => array(
'to_add' => array(
'uploaded' => $INSTALLER09['paypal_config']['up_amt_6'] * 1073741824,
'invites' => $INSTALLER09['paypal_config']['inv_amt_6'],
'seedbonus' => $INSTALLER09['paypal_config']['kp_amt_6'],
'total_donated' => $INSTALLER09['paypal_config']['gb_donated_6'],
) ,
'to_update' => array(
'donated' => $INSTALLER09['paypal_config']['gb_donated_6'],
'warned' => 0,
'downloadpos' => 1,
'uploadpos' => 1,
'leechwarn' => 0,
'hit_and_run_total' => 0,
'hnrwarn' => '\'no\'',
'enabled' => '\'yes\'',
'class' => 'IF(class < ' . UC_VIP . ', ' . UC_VIP . ', class), vipclass_before = IF(class < ' . UC_VIP . ', class, 0)',
'donoruntil' => sprintf('IF(donoruntil > 0,donoruntil + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['duntil_dur_6'], $INSTALLER09['paypal_config']['duntil_dur_6']) ,
'vip_until' => sprintf('IF(vip_until > 0,vip_until + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['vip_dur_6'], $INSTALLER09['paypal_config']['vip_dur_6']) ,
'free_switch' => sprintf('IF(free_switch > 0,free_switch + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['free_dur_6'], $INSTALLER09['paypal_config']['free_dur_6']) ,
'immunity' => sprintf('IF(immunity > 0,immunity + (%d * 604800), ' . TIME_NOW . ' + (%d * 604800))', $INSTALLER09['paypal_config']['imm_dur_6'], $INSTALLER09['paypal_config']['imm_dur_6']) ,
'donor' => '\'yes\'',
'modcomment' => "CONCAT('" . get_date(TIME_NOW, 'DATE', 1) . " - User donated ".$INSTALLER09['paypal_config']['gb_donated_6']." " . $INSTALLER09['paypal_config']['currency'] . "\n',modcomment)"
)
) ,
);
function mk_update_query($amount, $user_id)
{
global $donate_goods;
$query = array();
foreach ($donate_goods[$amount]['to_add'] as $field => $value) $query[] = sprintf('%s = %s + %d', $field, $field, $value);
foreach ($donate_goods[$amount]['to_update'] as $field => $value) $query[] = sprintf('%s = %s', $field, $value);
return sprintf('update users set %s where id = %d', join(', ', $query) , $user_id);
}
function paypallog($txt)
{
file_put_contents(ROOT_DIR . '/logs/paypal.txt', "\n[" . date('h:m D-M-Y') . "]\n" . $txt, FILE_APPEND);
}
if (sizeof($_POST) == 0) paypallog('There is no _POST from paypal');
$request = 'cmd=_notify-validate';
foreach ($_POST as $p_key => $p_value) $request.= '&' . $p_key . '=' . urlencode(stripslashes($p_value));
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header.= "Host: www.paypal.com\r\n";
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
$header.= "Content-Length: " . strlen($request) . "\r\n\r\n";
if ($hand = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30)) {
fputs($hand, $header . $request);
$paypal_data = '';
while (!feof($hand)) $paypal_data.= fgets($hand, 128);
$vars['uid'] = isset($_POST['custom']) ? (int)$_POST['custom'] : 0;
$vars['amount'] = isset($_POST['mc_gross']) ? (int)$_POST['mc_gross'] : 0;
$vars['memo'] = isset($_POST['memo']) ? htmlsafechars($_POST['memo']) : '';
if (stripos($paypal_data, 'VERIFIED') !== false) {
$user_query = sql_query(sprintf('SELECT COUNT(id) FROM users WHERE id = %d', $vars['uid'])) or paypallog(mysqli_error($GLOBALS["___mysqli_ston"]));
if (mysqli_num_rows($user_query) == 1) {
//update the user and add the goodies
sql_query(mk_update_query($vars['amount'], $vars['uid'])) or paypallog(mysqli_error($GLOBALS["___mysqli_ston"]));
//instead of updating the cache delete it :P
$mc1->delete_value('MyUser_' . $vars['uid']);
$mc1->delete_value('user' . $vars['uid']);
$mc1->delete_value('userstats_' . $vars['uid']);
$mc1->delete_value('user_stats_' . $vars['uid']);
//update total funds
sql_query(sprintf('INSERT INTO funds(cash,user,added) VALUES (%d,%d,%d)', $vars['amount'], $vars['uid'], TIME_NOW)) or paypallog(mysqli_error($GLOBALS["___mysqli_ston"]));
//clear the cache for the funds
$mc1->delete_value('totalfunds_');
$msg[] = '(' . $vars['uid'] . ',0,' . sqlesc('Donation - processed') . ',' . sqlesc("Your donation was processed by paypal and our system\nWe remind you that you donated " . $vars['amount'] . $INSTALLER09['paypal_config']['currency'] . "\nIf you forgot what you'll get check the donation page again\nStaff from " . $INSTALLER09['site_name'] . " is grateful for your donation\nIf you have any question's feel free to contact someone from staff") . ',' . TIME_NOW . ')';
$msg[] = '(' . $INSTALLER09['paypal_config']['staff'] . ',0,' . sqlesc('Donation - made') . ',' . sqlesc("This [url=" . $INSTALLER09['baseurl'] . "/userdetails.php?id=" . (int)$vars['uid'] . "]user[/url] - donated " . $vars['amount'] . $INSTALLER09['paypal_config']['currency'] . (!empty($vars['memo']) ? "\nUser sent a message with his donation:\n[b]" . $vars['memo'] . "[/b]" : '')) . ',' . TIME_NOW . ')';
} else paypallog('Could not find user with id = ' . $vars['uid']);
} elseif (stripos($paypal_data, 'INVALID') !== false) {
//something went wrong log data
paypallog('Paypal didn\'t like the transaction and it rejected it. _POST = ' . print_r($_POST, 1));
//make some nice messages to let everyone know about the problem
$msg[] = '(' . $vars['uid'] . ',0,' . sqlesc('Donation - problem') . ',' . sqlesc("We are sorry to announce you that paypal rejected the donation please contact the staff\n" . $INSTALLER09['site_name'] . "'s staff") . ',' . TIME_NOW . ')';
$msg[] = '(' . $INSTALLER09['paypal_config']['staff'] . ',0,' . sqlesc('Donation - problem') . ',' . sqlesc("This [url=" . $INSTALLER09['baseurl'] . "/userdetails.php?id=" . (int)$vars['uid'] . "]user[/url] - donated but there was a problem with paypal. Check paypal log!") . ',' . TIME_NOW . ')';
}
sql_query('INSERT INTO messages(receiver,sender,subject,msg,added) VALUES ' . join(',', $msg)) or paypallog(mysqli_error($GLOBALS["___mysqli_ston"]));
//clear memcache for staff
$mc1->delete_value('inbox_new_' . $INSTALLER09['paypal_config']['staff']);
$mc1->delete_value('inbox_new_sb_' . $INSTALLER09['paypal_config']['staff']);
//and for the user that donated
$mc1->delete_value('inbox_new_' . $vars['uid']);
$mc1->delete_value('inbox_new_sb_' . $vars['uid']);
//and shoutbox (for new message inside shoutbox)
$mc1->delete_value('shoutbox_');
fclose($hand);
} else paypallog('Can\'t open hand');
?>