-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendmessage.php
656 lines (551 loc) · 19.7 KB
/
sendmessage.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 3.7.2 Patch Level 2 - Licence Number VBF2470E4F
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2000-2013 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/
// ######################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'sendmessage');
define('CSRF_PROTECTION', true);
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array('messaging');
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array(
'mailform',
'sendtofriend',
'contactus',
'contactus_option',
'newpost_errormessage',
);
// pre-cache templates used by specific actions
$actiontemplates = array(
'im' => array(
'im_send_aim',
'im_send_icq',
'im_send_yahoo',
'im_send_msn',
'im_send_skype',
'im_message'
),
'sendtofriend' => array(
'newpost_usernamecode',
'humanverify'
),
'contactus' => array(
'humanverify',
),
);
$actiontemplates['none'] =& $actiontemplates['contactus'];
$actiontemplates['docontactus'] =& $actiontemplates['contactus'];
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'contactus';
}
($hook = vBulletinHook::fetch_hook('sendmessage_start')) ? eval($hook) : false;
// ############################### start im message ###############################
if ($_REQUEST['do'] == 'im')
{
if (!($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canviewmembers']))
{
print_no_permission();
}
$vbulletin->input->clean_array_gpc('r', array(
'type' => TYPE_NOHTML,
'userid' => TYPE_UINT
));
// verify userid
$userinfo = verify_id('user', $vbulletin->GPC['userid'], 1, 1, 15);
$type = $vbulletin->GPC['type'];
switch ($type)
{
case 'aim':
case 'yahoo':
case 'skype':
$userinfo["{$type}_link"] = urlencode($userinfo["$type"]);
break;
case 'icq':
$userinfo['icq'] = trim(htmlspecialchars_uni($userinfo['icq']));
break;
default:
$type = 'msn';
break;
}
($hook = vBulletinHook::fetch_hook('sendmessage_im_start')) ? eval($hook) : false;
if (empty($userinfo["$type"]))
{
// user does not have this messaging medium defined
eval(standard_error(fetch_error('immethodnotdefined', $userinfo['username'])));
}
if ($type == 'icq')
{
// ICQ's API for paging doesn't seem to work right now, but they have a URL that does
$vbulletin->url = 'http://www.icq.com/people/webmsg.ph' . 'p?to=' . urlencode($userinfo['icq'])
. '&from=' . urlencode(unhtmlspecialchars($vbulletin->userinfo['username']))
. '&fromemail=' . urlencode($vbulletin->userinfo['email']);
exec_header_redirect($vbulletin->url);
exit;
}
// shouldn't be a problem hard-coding this text, as they are all commercial names
$typetext = array(
'msn' => 'MSN',
'icq' => 'ICQ',
'aim' => 'AIM',
'yahoo' => 'Yahoo!',
'skype' => 'Skype'
);
// add language suffix to SkypeWeb graphic if possible
$userinfo['skype_suffix'] = '';
if ($vbulletin->options['skypeweb_gfx'] == 2 AND $type == 'skype')
{
// list of available language codes from the SkypeWeb Partner Whitepaper
$skype_language_codes = array(
'en',
'de',
'fr',
'it',
'pl',
'ja',
'pt',
'pt-br',
'se',
'zh',
'cn',
'zh-cn',
'hk',
'tw',
'zh-tw',
);
// is the visiting user's language code available?
$search_result = array_search(strtolower(str_replace('/', '-', $vbulletin->userinfo['lang_code'])), $skype_language_codes);
if ($search_result > 0) // ignore 'en' as that's the default
{
$userinfo['skype_suffix'] = '.' . $skype_language_codes["$search_result"];
}
}
($hook = vBulletinHook::fetch_hook('sendmessage_im_complete')) ? eval($hook) : false;
$typetext = $typetext["$type"];
eval('$imtext = "' . fetch_template("im_send_$type") . '";');
eval('print_output("' . fetch_template('im_message') . '");');
}
// ##################################################################################
// ALL other actions from here onward require email permissions, so check that now...
// *** email permissions ***
if (!$vbulletin->options['enableemail'])
{
eval(standard_error(fetch_error('emaildisabled')));
}
$perform_floodcheck = (
!($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])
AND $vbulletin->options['emailfloodtime']
AND $vbulletin->userinfo['userid']
);
if ($perform_floodcheck AND ($timepassed = TIMENOW - $vbulletin->userinfo['emailstamp']) < $vbulletin->options['emailfloodtime'])
{
eval(standard_error(fetch_error('emailfloodcheck', $vbulletin->options['emailfloodtime'], ($vbulletin->options['emailfloodtime'] - $timepassed))));
}
// initialize errors array
$errors = array();
// ############################### do contact webmaster ###############################
if ($_POST['do'] == 'docontactus')
{
if (!$vbulletin->userinfo['userid'] AND !$vbulletin->options['contactustype'])
{
print_no_permission();
}
$vbulletin->input->clean_array_gpc('p', array(
'name' => TYPE_STR,
'email' => TYPE_STR,
'subject' => TYPE_STR,
'message' => TYPE_STR,
'other_subject' => TYPE_STR,
'humanverify' => TYPE_ARRAY,
));
($hook = vBulletinHook::fetch_hook('sendmessage_docontactus_start')) ? eval($hook) : false;
// Used in phrase(s)
$subject =& $vbulletin->GPC['subject'];
$name =& $vbulletin->GPC['name'];
$message =& $vbulletin->GPC['message'];
$email =& $vbulletin->GPC['email'];
// check we have a message and a subject
if ($message == '' OR $subject == '' OR ($vbulletin->options['contactusoptions'] AND $subject == 'other' AND $vbulletin->GPC['other_subject'] == ''))
{
$errors[] = fetch_error('nosubject');
}
// check for valid email address
if (!is_valid_email($vbulletin->GPC['email']))
{
$errors[] = fetch_error('bademail');
}
if (!$vbulletin->userinfo['userid'] AND $vbulletin->options['hvcheck_contactus'])
{
require_once(DIR . '/includes/class_humanverify.php');
$verify =& vB_HumanVerify::fetch_library($vbulletin);
if (!$verify->verify_token($vbulletin->GPC['humanverify']))
{
$errors[] = fetch_error($verify->fetch_error());
}
}
($hook = vBulletinHook::fetch_hook('sendmessage_docontactus_process')) ? eval($hook) : false;
// if it's all good... send the email
if (empty($errors))
{
$languageid = -1;
if ($vbulletin->options['contactusoptions'])
{
if ($subject == 'other')
{
$subject = $vbulletin->GPC['other_subject'];
}
else
{
$options = explode("\n", trim($vbulletin->options['contactusoptions']));
foreach($options AS $index => $title)
{
if ($index == $subject)
{
if (preg_match('#^{(.*)} (.*)$#siU', $title, $matches))
{
$title =& $matches[2];
if (is_numeric($matches[1]) AND intval($matches[1]) !== 0)
{
$userinfo = fetch_userinfo($matches[1]);
$alt_email =& $userinfo['email'];
$languageid =& $userinfo['languageid'];
}
else
{
$alt_email = $matches[1];
}
}
$subject = $title;
break;
}
}
}
}
if (!empty($alt_email))
{
if ($destemail == $vbulletin->options['webmasteremail'])
{
$ip = IPADDRESS;
}
else
{
$ip =& $vbphrase['n_a'];
}
$destemail =& $alt_email;
}
else
{
$ip = IPADDRESS;
$destemail =& $vbulletin->options['webmasteremail'];
}
($hook = vBulletinHook::fetch_hook('sendmessage_docontactus_complete')) ? eval($hook) : false;
$url =& $vbulletin->url;
eval(fetch_email_phrases('contactus', $languageid));
vbmail($destemail, $subject, $message, false, $vbulletin->GPC['email'], '', $name);
eval(print_standard_redirect('redirect_sentfeedback', true, true));
}
// there are errors!
else
{
$show['errors'] = true;
foreach ($errors AS $errormessage)
{
eval('$errormessages .= "' . fetch_template('newpost_errormessage') . '";');
}
$_REQUEST['do'] = 'contactus';
}
}
// ############################### start contact webmaster ###############################
if ($_REQUEST['do'] == 'contactus')
{
if (!$vbulletin->userinfo['userid'] AND !$vbulletin->options['contactustype'])
{
print_no_permission();
}
// These values may have already been cleaned in the previous action so we can not clean them again here (TYPE_NOHTML)
$vbulletin->input->clean_array_gpc('r', array(
'name' => TYPE_STR,
'email' => TYPE_STR,
'subject' => TYPE_STR,
'message' => TYPE_STR,
));
($hook = vBulletinHook::fetch_hook('sendmessage_contactus_start')) ? eval($hook) : false;
$name = htmlspecialchars_uni($vbulletin->GPC['name']);
$email = htmlspecialchars_uni($vbulletin->GPC['email']);
$subject = htmlspecialchars_uni($vbulletin->GPC['subject']);
$message = htmlspecialchars_uni($vbulletin->GPC['message']);
// enter $vbulletin->userinfo's name and email if necessary
if ($name == '' AND $vbulletin->userinfo['userid'] > 0)
{
$name = $vbulletin->userinfo['username'];
}
if ($email == '' AND $vbulletin->userinfo['userid'] > 0)
{
$email = $vbulletin->userinfo['email'];
}
if ($vbulletin->options['contactusoptions'])
{
$options = explode("\n", trim($vbulletin->options['contactusoptions']));
foreach($options AS $index => $title)
{
// Look for the {(int)} or {(email)} identifier at the start and strip it out
if (preg_match('#^({.*}) (.*)$#siU', $title, $matches))
{
$title =& $matches[2];
}
if ($subject == $index)
{
$checked = 'checked="checked"';
}
($hook = vBulletinHook::fetch_hook('sendmessage_contactus_option')) ? eval($hook) : false;
eval('$contactusoptions .= "' . fetch_template('contactus_option') . '";');
unset($checked);
}
}
if (!$vbulletin->userinfo['userid'] AND $vbulletin->options['hvcheck_contactus'])
{
require_once(DIR . '/includes/class_humanverify.php');
$verification =& vB_HumanVerify::fetch_library($vbulletin);
$human_verify = $verification->output_token();
}
else
{
$human_verify = '';
}
// generate navbar
if ($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview'])
{
$navbits = construct_navbits(array('' => $vbphrase['contact_us']));
eval('$navbar = "' . fetch_template('navbar') . '";');
}
else
{
$navbar = '';
}
($hook = vBulletinHook::fetch_hook('sendmessage_contactus_complete')) ? eval($hook) : false;
$url =& $vbulletin->url;
eval('print_output("' . fetch_template('contactus') . '");');
}
// ############################### start send to friend permissions ###############################
if ($_REQUEST['do'] == 'sendtofriend' OR $_POST['do'] == 'dosendtofriend')
{
$forumperms = fetch_permissions($threadinfo['forumid']);
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canemail']) OR (($threadinfo['postuserid'] != $vbulletin->userinfo['userid']) AND !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers'])))
{
print_no_permission();
}
// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($foruminfo['forumid'], $foruminfo['password']);
}
// ############################### start send to friend ###############################
if ($_REQUEST['do'] == 'sendtofriend')
{
($hook = vBulletinHook::fetch_hook('sendmessage_sendtofriend_start')) ? eval($hook) : false;
if ($vbulletin->options['wordwrap'] != 0)
{
$threadinfo['title'] = fetch_word_wrapped_string($threadinfo['title']);
}
eval('$usernamecode = "' . fetch_template('newpost_usernamecode') . '";');
// human verification
if (!$vbulletin->userinfo['userid'] AND $vbulletin->options['hvcheck_contactus'])
{
require_once(DIR . '/includes/class_humanverify.php');
$verification =& vB_HumanVerify::fetch_library($vbulletin);
$human_verify = $verification->output_token();
}
else
{
$human_verify = '';
}
// draw nav bar
$navbits = array();
$parentlist = array_reverse(explode(',', substr($foruminfo['parentlist'], 0, -3)));
foreach ($parentlist AS $forumID)
{
$forumTitle =& $vbulletin->forumcache["$forumID"]['title'];
$navbits['forumdisplay.php?' . $vbulletin->session->vars['sessionurl'] . "f=$forumID"] = $forumTitle;
}
$navbits['showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t=$threadid"] = $threadinfo['prefix_plain_html'] . ' ' . $threadinfo['title'];
$navbits[''] = $vbphrase['email_to_friend'];
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
($hook = vBulletinHook::fetch_hook('sendmessage_sendtofriend_complete')) ? eval($hook) : false;
$url =& $vbulletin->url;
eval('print_output("' . fetch_template('sendtofriend') . '");');
}
// ############################### start do send to friend ###############################
if ($_POST['do'] == 'dosendtofriend')
{
$vbulletin->input->clean_array_gpc('p', array(
'sendtoname' => TYPE_STR,
'sendtoemail' => TYPE_STR,
'emailsubject' => TYPE_STR,
'emailmessage' => TYPE_STR,
'username' => TYPE_STR,
'humanverify' => TYPE_ARRAY
));
// Values that are used in phrases or error messages
$sendtoname =& $vbulletin->GPC['sendtoname'];
$emailmessage =& $vbulletin->GPC['emailmessage'];
if ($sendtoname == '' OR !is_valid_email($vbulletin->GPC['sendtoemail']) OR $vbulletin->GPC['emailsubject'] == '' OR $emailmessage == '')
{
eval(standard_error(fetch_error('requiredfields')));
}
if ($perform_floodcheck)
{
require_once(DIR . '/includes/class_floodcheck.php');
$floodcheck =& new vB_FloodCheck($vbulletin, 'user', 'emailstamp');
$floodcheck->commit_key($vbulletin->userinfo['userid'], TIMENOW, TIMENOW - $vbulletin->options['emailfloodtime']);
if ($floodcheck->is_flooding())
{
eval(standard_error(fetch_error('emailfloodcheck', $vbulletin->options['emailfloodtime'], $floodcheck->flood_wait())));
}
}
if (!$vbulletin->userinfo['userid'] AND $vbulletin->options['hvcheck_contactus'])
{
require_once(DIR . '/includes/class_humanverify.php');
$verify =& vB_HumanVerify::fetch_library($vbulletin);
if (!$verify->verify_token($vbulletin->GPC['humanverify']))
{
standard_error(fetch_error($verify->fetch_error()));
}
}
($hook = vBulletinHook::fetch_hook('sendmessage_dosendtofriend_start')) ? eval($hook) : false;
if ($vbulletin->GPC['username'] != '')
{
if ($userinfo = $db->query_first_slave("
SELECT user.*, userfield.*
FROM " . TABLE_PREFIX . "user AS user," . TABLE_PREFIX . "userfield AS userfield
WHERE username='" . $db->escape_string(htmlspecialchars_uni($vbulletin->GPC['username'])) . "'
AND user.userid = userfield.userid"
))
{
eval(standard_error(fetch_error('usernametaken', $vbulletin->GPC['username'], $vbulletin->session->vars['sessionurl'])));
}
else
{
$postusername = htmlspecialchars_uni($vbulletin->GPC['username']);
}
}
else
{
$postusername = $vbulletin->userinfo['username'];
}
eval(fetch_email_phrases('sendtofriend'));
vbmail($vbulletin->GPC['sendtoemail'], $vbulletin->GPC['emailsubject'], $message);
($hook = vBulletinHook::fetch_hook('sendmessage_dosendtofriend_complete')) ? eval($hook) : false;
$sendtoname = htmlspecialchars_uni($sendtoname);
eval(print_standard_redirect('redirect_sentemail'));
}
// ############################### start mail member permissions ###############################
if ($_REQUEST['do'] == 'mailmember' OR $_POST['do'] == 'domailmember')
{
$vbulletin->input->clean_array_gpc('r', array(
'userid' => TYPE_UINT
));
if (!$vbulletin->userinfo['userid'] OR !($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canemailmember']))
{
print_no_permission();
}
$userinfo = verify_id('user', $vbulletin->GPC['userid'], 1, 1);
if ($userinfo['usergroupid'] == 3 OR $userinfo['usergroupid'] == 4)
{ // user hasn't confirmed email address yet or is COPPA
eval(standard_error(fetch_error('usernoemail', $vbulletin->options['contactuslink'])));
}
}
// ############################### start mail member ###############################
if ($_REQUEST['do'] == 'mailmember')
{
if (!$vbulletin->options['displayemails'])
{
eval(standard_error(fetch_error('emaildisabled')));
}
else if (!$userinfo['showemail'])
{
eval(standard_error(fetch_error('usernoemail', $vbulletin->options['contactuslink'])));
}
else
{
($hook = vBulletinHook::fetch_hook('sendmessage_mailmember')) ? eval($hook) : false;
$destusername = $userinfo['username'];
if ($vbulletin->options['secureemail']) // use secure email form or not?
{
// generate navbar
$navbits = construct_navbits(array('' => $vbphrase['email']));
eval('$navbar = "' . fetch_template('navbar') . '";');
$url =& $vbulletin->url;
$userid =& $userinfo['userid'];
eval('print_output("' . fetch_template('mailform') . '");');
}
else
{
// show the user's email address
eval(standard_error(fetch_error('showemail', $destusername, htmlspecialchars_uni($userinfo['email']))));
}
}
}
// ############################### start do mail member ###############################
if ($_POST['do'] == 'domailmember')
{
$vbulletin->input->clean_array_gpc('p', array(
'message' => TYPE_STR,
'emailsubject' => TYPE_STR,
));
$destuserid = $userinfo['userid'];
if (!$vbulletin->options['displayemails'])
{
eval(standard_error(fetch_error('emaildisabled')));
}
else if (!$userinfo['showemail'])
{
eval(standard_error(fetch_error('usernoemail', $vbulletin->options['contactuslink'])));
}
else
{
if ($vbulletin->GPC['message'] == '')
{
eval(standard_error(fetch_error('nomessage')));
}
if ($perform_floodcheck)
{
require_once(DIR . '/includes/class_floodcheck.php');
$floodcheck =& new vB_FloodCheck($vbulletin, 'user', 'emailstamp');
$floodcheck->commit_key($vbulletin->userinfo['userid'], TIMENOW, TIMENOW - $vbulletin->options['emailfloodtime']);
if ($floodcheck->is_flooding())
{
eval(standard_error(fetch_error('emailfloodcheck', $vbulletin->options['emailfloodtime'], $floodcheck->flood_wait())));
}
}
($hook = vBulletinHook::fetch_hook('sendmessage_domailmember')) ? eval($hook) : false;
$message = fetch_censored_text($vbulletin->GPC['message']);
eval(fetch_email_phrases('usermessage', $userinfo['languageid']));
vbmail($userinfo['email'], fetch_censored_text($vbulletin->GPC['emailsubject']), $message , false, $vbulletin->userinfo['email'], '', $vbulletin->userinfo['username']);
// parse this next line with eval:
$sendtoname = $userinfo['username'];
eval(print_standard_redirect('redirect_sentemail'));
}
}
/*======================================================================*\
|| ####################################################################
|| # Downloaded: 16:21, Sat Apr 6th 2013
|| # CVS: $RCSfile$ - $Revision: 26399 $
|| ####################################################################
\*======================================================================*/
?>