-
Notifications
You must be signed in to change notification settings - Fork 20
/
privmsg.php
2338 lines (2048 loc) · 80.5 KB
/
privmsg.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
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*
* @Icy Phoenix is based on phpBB
* @copyright (c) 2008 phpBB Group
*
*/
define('IN_PM', true);
// MG Cash MOD For IP - BEGIN
define('IN_CASHMOD', true);
// MG Cash MOD For IP - END
// Added to optimize memory for attachments
define('ATTACH_DISPLAY', true);
define('ATTACH_PM', true);
define('IN_ICYPHOENIX', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(IP_ROOT_PATH . 'common.' . PHP_EXT);
include_once(IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
include_once(IP_ROOT_PATH . 'includes/functions_post.' . PHP_EXT);
include_once(IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT);
include_once(IP_ROOT_PATH . 'includes/functions_zebra.' . PHP_EXT);
// Adding CPL_NAV only if needed
define('PARSE_CPL_NAV', true);
// Is PM disabled?
if (!empty($config['privmsg_disable']))
{
message_die(GENERAL_MESSAGE, 'PM_disabled');
}
$html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#', '#"#');
$html_entities_replace = array('&', '<', '>', '"');
// Parameters
$privmsg_id = request_var(POST_POST_URL, 0);
$mode = request_var('mode', '');
$start = request_var('start', 0);
$start = ($start < 0) ? 0 : $start;
$sid = request_post_var('sid', '');
$submit = (isset($_POST['post'])) ? true : false;
$submit_search = (isset($_POST['usersubmit'])) ? true : false;
$submit_msgdays = (isset($_POST['submit_msgdays'])) ? true : false;
$cancel = (isset($_POST['cancel'])) ? true : false;
$preview = (isset($_POST['preview'])) ? true : false;
$confirm = (isset($_POST['confirm'])) ? true : false;
$delete = (isset($_POST['delete'])) ? true : false;
$delete_all = (isset($_POST['deleteall'])) ? true : false;
$download = (isset($_POST['download'])) ? true : false;
$save = (isset($_POST['save'])) ? true : false;
$draft = request_var('draft', '');
$draft_mode = request_var('draft_mode', '');
$draft_confirm = !empty($_POST['draft_confirm']) ? true : false;
$draft = (!empty($draft) || $draft_confirm) ? true : false;
$draft_id = request_var('d', 0);
if (($config['allow_drafts'] == true) && ($draft_mode == 'draft_load') && ($draft_id > 0))
{
$sql = "SELECT d.*
FROM " . DRAFTS_TABLE . " d
WHERE d.draft_id = '" . $draft_id . "'
AND d.user_id = '" . $user->data['user_id'] . "'
LIMIT 1";
$result = $db->sql_query($sql);
if ($draft_row = $db->sql_fetchrow($result))
{
$db->sql_freeresult($result);
$draft_subject = $draft_row['draft_subject'];
$draft_message = htmlspecialchars_decode($draft_row['draft_message'], ENT_COMPAT);
$preview = true;
}
}
$search_type = request_var('searchvar', '');
$search_value = request_var('searchvalue', '');
$search_value_tmp = request_var('searchvalue2', '');
$search_value = (!empty($search_value) && !empty($search_value_tmp)) ? $search_value_tmp : $search_value;
$refresh = $preview || $submit_search || ($draft && !$draft_confirm);
$mark_list = request_var('mark', array(0));
$folders_array = array('inbox', 'outbox', 'sentbox', 'savebox');
$folder = request_var('folder', 'inbox');
$folder = check_var_value($folder, $folders_array);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management
// Cancel
if ($cancel)
{
redirect(append_sid(CMS_PAGE_PRIVMSG . '?folder=' . $folder, true));
}
// Check search fields
$search_list = array(
'author' => 'author is',
'subject' => 'subject contains',
);
if(empty($search_value) || empty($search_type) || intval($search_type) || !isset($search_list[$search_type]))
{
$search_type = '';
}
if(empty($search_type))
{
$search_value = '';
}
$template->vars['SEARCH_TYPES'] = '';
foreach($search_list as $var => $value)
{
$template->vars['SEARCH_TYPES'] .= '<option value="' . $var . '"' . ($search_type === $var ? ' selected="selected"' : '') . '>' . $value . '</option>';
}
$template->vars['SEARCH_VALUE'] = htmlspecialchars($search_value);
$error = false;
// Define the box image links
$inbox_img = ($folder != 'inbox' || $mode != '') ? '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=inbox') . '"><img src="' . $images['pm_inbox'] . '" alt="' . $lang['Inbox'] . '" title="' . $lang['Inbox'] . '" /></a>' : '<img src="' . $images['pm_inbox'] . '" alt="' . $lang['Inbox'] . '" title="' . $lang['Inbox'] . '" />';
$inbox_url = ($folder != 'inbox' || $mode != '') ? '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=inbox') . '">' . $lang['Inbox'] . '</a>' : $lang['Inbox'];
$outbox_img = ($folder != 'outbox' || $mode != '') ? '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=outbox') . '"><img src="' . $images['pm_outbox'] . '" alt="' . $lang['Outbox'] . '" title="' . $lang['Outbox'] . '" /></a>' : '<img src="' . $images['pm_outbox'] . '" alt="' . $lang['Outbox'] . '" title="' . $lang['Outbox'] . '" />';
$outbox_url = ($folder != 'outbox' || $mode != '') ? '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=outbox') . '">' . $lang['Outbox'] . '</a>' : $lang['Outbox'];
$sentbox_img = ($folder != 'sentbox' || $mode != '') ? '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=sentbox') . '"><img src="' . $images['pm_sentbox'] . '" alt="' . $lang['Sentbox'] . '" title="' . $lang['Sentbox'] . '" /></a>' : '<img src="' . $images['pm_sentbox'] . '" alt="' . $lang['Sentbox'] . '" title="' . $lang['Sentbox'] . '" />';
$sentbox_url = ($folder != 'sentbox' || $mode != '') ? '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=sentbox') . '">' . $lang['Sentbox'] . '</a>' : $lang['Sentbox'];
$savebox_img = ($folder != 'savebox' || $mode != '') ? '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=savebox') . '"><img src="' . $images['pm_savebox'] . '" alt="' . $lang['Savebox'] . '" title="' . $lang['Savebox'] . '" /></a>' : '<img src="' . $images['pm_savebox'] . '" alt="' . $lang['Savebox'] . '" title="' . $lang['Savebox'] . '" />';
$savebox_url = ($folder != 'savebox' || $mode != '') ? '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=savebox') . '">' . $lang['Savebox'] . '</a>' : $lang['Savebox'];
execute_privmsgs_attachment_handling($mode);
// Start main
if ($mode == 'newpm')
{
$link_name = '';
if ($mode == 'post')
{
$link_name = $lang['Send_a_new_message'];
}
elseif ($mode == 'reply')
{
$link_name = $lang['Send_a_reply'];
}
elseif ($mode == 'edit')
{
$link_name = $lang['Edit_message'];
}
$nav_server_url = create_server_url();
$breadcrumbs['address'] = $lang['Nav_Separator'] . '<a href="' . $nav_server_url . append_sid(CMS_PAGE_PRIVMSG . '?folder=inbox') . '"' . (!empty($link_name) ? '' : ' class="nav-current"') . '>' . $lang['Private_Messaging'] . '</a>' . (!empty($link_name) ? ($lang['Nav_Separator'] . '<a class="nav-current" href="#">' . $link_name . '</a>') : '');
include_once(IP_ROOT_PATH . 'includes/users_zebra_block.' . PHP_EXT);
if ($user->data['session_logged_in'])
{
if ($user->data['user_new_privmsg'])
{
$l_new_message = ($user->data['user_new_privmsg'] == 1) ? $lang['You_new_pm'] : $lang['You_new_pms'];
}
else
{
$l_new_message = $lang['You_no_new_pm'];
}
$l_new_message .= '<br /><br />' . sprintf($lang['Click_view_privmsg'], '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=inbox') . '" onclick="jump_to_inbox();return false;" target="_new">', '</a>');
}
else
{
$l_new_message = $lang['Login_check_pm'];
}
$template->assign_vars(array(
'L_CLOSE_WINDOW' => $lang['Close_window'],
'L_MESSAGE' => $l_new_message
)
);
$gen_simple_header = true;
full_page_generation('privmsgs_popup.tpl', $lang['Private_Messaging'], '', '');
}
elseif ($mode == 'read')
{
if (!empty($_GET[POST_POST_URL]))
{
$privmsgs_id = intval($_GET[POST_POST_URL]);
}
else
{
message_die(GENERAL_ERROR, $lang['No_post_id']);
}
if (!$user->data['session_logged_in'])
{
redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=privmsg.' . PHP_EXT . '&folder=' . $folder . '&mode=' . $mode . '&' . POST_POST_URL . '=' . $privmsgs_id, true));
}
$ranks_array = $cache->obtain_ranks(false);
// SQL to pull appropriate message, prevents nosey people
// reading other peoples messages ... hopefully!
switch($folder)
{
case 'inbox':
$l_box_name = $lang['Inbox'];
$pm_sql_user = "AND pm.privmsgs_to_userid = " . $user->data['user_id'] . "
AND (pm.privmsgs_type = " . PRIVMSGS_READ_MAIL . "
OR pm.privmsgs_type = " . PRIVMSGS_NEW_MAIL . "
OR pm.privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . ")";
break;
case 'outbox':
$l_box_name = $lang['Outbox'];
$pm_sql_user = "AND pm.privmsgs_from_userid = " . $user->data['user_id'] . "
AND (pm.privmsgs_type = " . PRIVMSGS_NEW_MAIL . "
OR pm.privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . ") ";
break;
case 'sentbox':
$l_box_name = $lang['Sentbox'];
$pm_sql_user = "AND pm.privmsgs_from_userid = " . $user->data['user_id'] . "
AND pm.privmsgs_type = " . PRIVMSGS_SENT_MAIL;
break;
case 'savebox':
$l_box_name = $lang['Savebox'];
$pm_sql_user = "AND ((pm.privmsgs_to_userid = " . $user->data['user_id'] . "
AND pm.privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . ")
OR (pm.privmsgs_from_userid = " . $user->data['user_id'] . "
AND pm.privmsgs_type = " . PRIVMSGS_SAVED_OUT_MAIL . ")
)";
break;
default:
message_die(GENERAL_ERROR, $lang['No_such_folder']);
break;
}
// BEGIN PM Navigation MOD
if(($_GET['view'] == 'next') || ($_GET['view'] == 'prev'))
{
$sql_condition = ($_GET['view'] == 'next') ? '>' : '<';
$sql_ordering = ($_GET['view'] == 'next') ? 'ASC' : 'DESC';
$sql_nav = "SELECT pm.privmsgs_id FROM ". PRIVMSGS_TABLE ." pm, ". PRIVMSGS_TABLE ." p2
WHERE p2.privmsgs_id = $privmsgs_id
$pm_sql_user
AND pm.privmsgs_date $sql_condition p2.privmsgs_date
ORDER BY pm.privmsgs_date $sql_ordering LIMIT 1" ;
$result_nav = $db->sql_query($sql_nav);
if ($row = $db->sql_fetchrow($result_nav))
{
$privmsgs_id = intval($row['privmsgs_id']);
}
else
{
$output_message = (($_GET['view'] == 'next') ? $lang['No_newer_pm'] : $lang['No_older_pm']) . '<br /><br />' . sprintf($lang['Click_return_inbox'], '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=inbox') . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(CMS_PAGE_FORUM) . '">', '</a>');
message_die(GENERAL_MESSAGE, $output_message);
}
}
// END PM Navigation MOD
// Major query obtains the message ...
$sql = "SELECT u.username AS username_1, u.user_id AS user_id_1, u.user_active AS user_active_1, u.user_color AS user_color_1, u2.username AS username_2, u2.user_id AS user_id_2, u2.user_active AS user_active_2, u2.user_color AS user_color_2, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_skype, u.user_regdate, u.user_msnm, u.user_allow_viewemail, u.user_rank, u.user_sig, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allow_viewonline, u.user_session_time, u.user_from, u.user_gender, pm.*
FROM " . PRIVMSGS_TABLE . " pm, " . USERS_TABLE . " u, " . USERS_TABLE . " u2
WHERE pm.privmsgs_id = $privmsgs_id
$pm_sql_user
AND u.user_id = pm.privmsgs_from_userid
AND u2.user_id = pm.privmsgs_to_userid";
$result = $db->sql_query($sql);
// Did the query return any data?
if (!($privmsg = $db->sql_fetchrow($result)))
{
redirect(append_sid(CMS_PAGE_PRIVMSG . '?folder=' . $folder, true));
}
$privmsg_id = $privmsg['privmsgs_id'];
// Is this a new message in the inbox? If it is then save a copy in the posters sent box
if ((($privmsg['privmsgs_type'] == PRIVMSGS_NEW_MAIL) || ($privmsg['privmsgs_type'] == PRIVMSGS_UNREAD_MAIL)) && ($folder == 'inbox'))
{
// Update appropriate counter
switch ($privmsg['privmsgs_type'])
{
case PRIVMSGS_NEW_MAIL:
$sql = "user_new_privmsg = user_new_privmsg - 1";
break;
case PRIVMSGS_UNREAD_MAIL:
$sql = "user_unread_privmsg = user_unread_privmsg - 1";
break;
}
$sql = "UPDATE " . USERS_TABLE . "
SET $sql
WHERE user_id = " . $user->data['user_id'];
$result = $db->sql_query($sql);
$sql = "UPDATE " . PRIVMSGS_TABLE . "
SET privmsgs_type = " . PRIVMSGS_READ_MAIL . "
WHERE privmsgs_id = " . $privmsg['privmsgs_id'];
$result = $db->sql_query($sql);
// Check to see if the poster has a 'full' sent box
$sql = "SELECT COUNT(privmsgs_id) AS sent_items, MIN(privmsgs_date) AS oldest_post_time
FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_type = " . PRIVMSGS_SENT_MAIL . "
AND privmsgs_from_userid = " . $privmsg['privmsgs_from_userid'];
$result = $db->sql_query($sql);
if ($sent_info = $db->sql_fetchrow($result))
{
if ($config['max_sentbox_privmsgs'] && ($sent_info['sent_items'] >= $config['max_sentbox_privmsgs']))
{
$sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_type = " . PRIVMSGS_SENT_MAIL . "
AND privmsgs_date = " . $sent_info['oldest_post_time'] . "
AND privmsgs_from_userid = " . $privmsg['privmsgs_from_userid'];
$result = $db->sql_query($sql);
$old_privmsgs_id = $db->sql_fetchrow($result);
$old_privmsgs_id = $old_privmsgs_id['privmsgs_id'];
if (!empty($old_privmsgs_id))
{
$sql = "DELETE FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_id = " . $old_privmsgs_id;
$result = $db->sql_query($sql);
}
}
}
//
// This makes a copy of the post and stores it as a SENT message from the sender. Perhaps
// not the most DB friendly way but a lot easier to manage, besides the admin will be able to
// set limits on numbers of storable posts for users... hopefully!
//
$sql = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_text, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_enable_autolinks_acronyms, privmsgs_attach_sig)
VALUES (" . PRIVMSGS_SENT_MAIL . ", '" . $db->sql_escape($privmsg['privmsgs_subject']) . "', '" . $db->sql_escape($privmsg['privmsgs_text']) . "', " . $privmsg['privmsgs_from_userid'] . ", " . $privmsg['privmsgs_to_userid'] . ", " . $privmsg['privmsgs_date'] . ", '" . $privmsg['privmsgs_ip'] . "', " . $privmsg['privmsgs_enable_html'] . ", " . $privmsg['privmsgs_enable_bbcode'] . ", " . $privmsg['privmsgs_enable_smilies'] . ", " . $privmsg['privmsgs_enable_autolinks_acronyms'] . ", " . $privmsg['privmsgs_attach_sig'] . ")";
$result = $db->sql_query($sql);
$privmsg_sent_id = $db->sql_nextid();
}
$attachment_mod['pm']->duplicate_attachment_pm($privmsg['privmsgs_attachment'], $privmsg['privmsgs_id'], $privmsg_sent_id);
// Pick a folder, any folder, so long as it's one below ...
$post_urls = array(
'post' => append_sid(CMS_PAGE_PRIVMSG . '?mode=post'),
'reply' => append_sid(CMS_PAGE_PRIVMSG . '?mode=reply&' . POST_POST_URL . '=' . $privmsg_id),
'quote' => append_sid(CMS_PAGE_PRIVMSG . '?mode=quote&' . POST_POST_URL . '=' . $privmsg_id),
'edit' => append_sid(CMS_PAGE_PRIVMSG . '?mode=edit&' . POST_POST_URL . '=' . $privmsg_id)
);
$post_icons = array(
'post_img' => '<a href="' . $post_urls['post'] . '"><img src="' . $images['pm_postmsg'] . '" alt="' . $lang['Post_new_pm'] . '" /></a>',
'post' => '<a href="' . $post_urls['post'] . '">' . $lang['Post_new_pm'] . '</a>',
'reply_img' => '<a href="' . $post_urls['reply'] . '"><img src="' . $images['pm_replymsg'] . '" alt="' . $lang['Post_reply_pm'] . '" /></a>',
'reply' => '<a href="' . $post_urls['reply'] . '">' . $lang['Post_reply_pm'] . '</a>',
'quote_img' => '<a href="' . $post_urls['quote'] . '"><img src="' . $images['pm_quotemsg'] . '" alt="' . $lang['Post_quote_pm'] . '" /></a>',
'quote' => '<a href="' . $post_urls['quote'] . '">' . $lang['Post_quote_pm'] . '</a>',
'edit_img' => '<a href="' . $post_urls['edit'] . '"><img src="' . $images['pm_editmsg'] . '" alt="' . $lang['Edit_pm'] . '" /></a>',
'edit' => '<a href="' . $post_urls['edit'] . '">' . $lang['Edit_pm'] . '</a>'
);
if ($folder == 'inbox')
{
$post_img = $post_icons['post_img'];
$reply_img = $post_icons['reply_img'];
$quote_img = $post_icons['quote_img'];
$edit_img = '';
$post = $post_icons['post'];
$reply = $post_icons['reply'];
$quote = $post_icons['quote'];
$edit = '';
$post_url = $post_urls['post'];
$reply_url = $post_urls['reply'];
$quote_url = $post_urls['quote'];
$edit_url = '';
$l_box_name = $lang['Inbox'];
}
elseif ($folder == 'outbox')
{
$post_img = $post_icons['post_img'];
$reply_img = '';
$quote_img = '';
$edit_img = $post_icons['edit_img'];
$post = $post_icons['post'];
$reply = '';
$quote = '';
$edit = $post_icons['edit'];
$post_url = $post_urls['post'];
$reply_url = '';
$quote_url = '';
$edit_url = $post_urls['edit'];
$l_box_name = $lang['Outbox'];
}
elseif ($folder == 'savebox')
{
if ($privmsg['privmsgs_type'] == PRIVMSGS_SAVED_IN_MAIL)
{
$post_img = $post_icons['post_img'];
$reply_img = $post_icons['reply_img'];
$quote_img = $post_icons['quote_img'];
$edit_img = '';
$post = $post_icons['post'];
$reply = $post_icons['reply'];
$quote = $post_icons['quote'];
$edit = '';
$post_url = $post_urls['post'];
$reply_url = $post_urls['reply'];
$quote_url = $post_urls['quote'];
$edit_url = '';
}
else
{
$post_img = $post_icons['post_img'];
$reply_img = '';
$quote_img = '';
$edit_img = '';
$post = $post_icons['post'];
$reply = '';
$quote = '';
$edit = '';
$post_url = $post_urls['post'];
$reply_url = '';
$quote_url = '';
$edit_url = '';
}
$l_box_name = $lang['Saved'];
}
elseif ($folder == 'sentbox')
{
$post_img = $post_icons['post_img'];
$reply_img = '';
$quote_img = '';
$edit_img = '';
$post = $post_icons['post'];
$reply = '';
$quote = '';
$edit = '';
$post_url = $post_urls['post'];
$reply_url = '';
$quote_url = '';
$edit_url = '';
$l_box_name = '';
}
$s_hidden_fields = '<input type="hidden" name="mark[]" value="' . $privmsgs_id . '" />';
$nav_server_url = create_server_url();
$breadcrumbs['address'] = $lang['Nav_Separator'] . '<a href="' . $nav_server_url . append_sid(CMS_PAGE_PRIVMSG . '?folder=inbox') . '">' . $lang['Private_Messaging'] . '</a>' . $lang['Nav_Separator'] . '<a class="nav-current" href="#">' . $privmsg['privmsgs_subject'] . '</a>';
$breadcrumbs['bottom_right_links'] = '<a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=' . $folder . '&mode=' . $mode . '&' . POST_POST_URL . '=' . $privmsgs_id . '&view=prev', true) . '">' . $lang['Previous_privmsg'] . '</a> • <a href="' . append_sid(CMS_PAGE_PRIVMSG . '?folder=' . $folder . '&mode=' . $mode . '&' . POST_POST_URL . '=' . $privmsgs_id . '&view=next', true) . '">' . $lang['Next_privmsg'] . '</a>';
$skip_nav_cat = true;
include_once(IP_ROOT_PATH . 'includes/users_zebra_block.' . PHP_EXT);
make_jumpbox(CMS_PAGE_VIEWFORUM);
$template->assign_vars(array(
'INBOX_IMG' => $inbox_img,
'SENTBOX_IMG' => $sentbox_img,
'OUTBOX_IMG' => $outbox_img,
'SAVEBOX_IMG' => $savebox_img,
'INBOX' => $inbox_url,
'SENTBOX' => $sentbox_url,
'OUTBOX' => $outbox_url,
'SAVEBOX' => $savebox_url,
'BOX_NAME' => $l_box_name,
'L_QUICK_REPLY' => $lang['Quick_Reply'],
'L_EDIT_PM' => $lang['Edit_pm'],
'L_QUOTE_PM' => $lang['Post_quote_pm'],
'L_POST_PM' => $lang['Post_new_pm'],
'L_REPLY_PM' => $lang['Post_reply_pm'],
'EDIT_PM_URL' => $edit_url,
'POST_PM_URL' => $post_url,
'QUOTE_PM_URL' => $quote_url,
'REPLY_PM_URL' => $reply_url,
'POST_PM_IMG' => $post_img,
'REPLY_PM_IMG' => $reply_img,
'EDIT_PM_IMG' => $edit_img,
'QUOTE_PM_IMG' => $quote_img,
'POST_PM' => $post,
'REPLY_PM' => $reply,
'EDIT_PM' => $edit,
'QUOTE_PM' => $quote,
'IMG_QUICK_QUOTE' => $images['icon_quick_quote'],
'IMG_OFFTOPIC' => $images['icon_offtopic'],
'L_MESSAGE' => $lang['Message'],
'L_INBOX' => $lang['Inbox'],
'L_OUTBOX' => $lang['Outbox'],
'L_SENTBOX' => $lang['Sent'],
'L_SAVEBOX' => $lang['Saved'],
'L_FLAG' => $lang['Flag'],
'L_SUBJECT' => $lang['Subject'],
'L_QUICK_QUOTE' => $lang['QuickQuote'],
'L_OFFTOPIC' => $lang['OffTopic'],
'L_POSTED' => $lang['Posted'],
'L_DATE' => $lang['Date'],
'L_FROM' => $lang['From'],
'L_TO' => $lang['To'],
'L_SAVE_MSG' => $lang['Save_message'],
'L_DELETE_MSG' => $lang['Delete_message'],
'L_PM' => $lang['Private_Message'],
'L_EMAIL' => $lang['Email'],
'L_POSTS' => $lang['Posts'],
'L_CONTACTS' => $lang['User_Contacts'],
'L_WEBSITE' => $lang['Website'],
'L_FROM' => $lang['Location'],
'L_ONLINE_STATUS' => $lang['Online_status'],
'L_USER_WWW' => $lang['Website'],
'L_USER_EMAIL' => $lang['Send_Email'],
'L_USER_PROFILE' => $lang['Profile'],
// BEGIN PM Navigation MOD
'L_PRIVMSG_NEXT' => $lang['Next_privmsg'],
'L_PRIVMSG_PREVIOUS' => $lang['Previous_privmsg'],
'U_PRIVMSG_NEXT' => append_sid(CMS_PAGE_PRIVMSG . '?folder=' . $folder . '&mode=' . $mode . '&' . POST_POST_URL . '=' . $privmsgs_id . '&view=next', true),
'U_PRIVMSG_PREVIOUS' => append_sid(CMS_PAGE_PRIVMSG . '?folder=' . $folder . '&mode=' . $mode . '&' . POST_POST_URL . '=' . $privmsgs_id . '&view=prev', true),
// END PM Navigation MOD
'S_PRIVMSGS_ACTION' => append_sid(CMS_PAGE_PRIVMSG . '?folder=' . $folder),
'S_HIDDEN_FIELDS' => $s_hidden_fields
)
);
$username_from = colorize_username($privmsg['user_id_1'], $privmsg['username_1'], $privmsg['user_color_1'], $privmsg['user_active_1']);
$user_id_from = $privmsg['user_id_1'];
$username_to = colorize_username($privmsg['user_id_2'], $privmsg['username_2'], $privmsg['user_color_2'], $privmsg['user_active_2']);
$user_id_to = $privmsg['user_id_2'];
// Needed for attachments... do not remove!
$template_to_parse = 'privmsgs_read_body.tpl';
$template->set_filenames(array('body' => $template_to_parse));
init_display_pm_attachments($privmsg['privmsgs_attachment']);
$post_date = create_date_ip($config['default_dateformat'], $privmsg['privmsgs_date'], $config['board_timezone']);
$privmsg['user_id'] = $privmsg['user_id_1'];
$privmsg['username'] = $privmsg['username_1'];
$privmsg['user_color'] = $privmsg['user_color_1'];
$privmsg['user_active'] = $privmsg['user_active_1'];
$user_info = array();
$user_info = generate_user_info($privmsg);
foreach ($user_info as $k => $v)
{
${$k} = $v;
}
$poster_avatar = $user_info['avatar'];
$poster_posts = ($privmsg['user_id'] != ANONYMOUS) ? $lang['Posts'] . ': ' . $privmsg['user_posts'] : '';
$poster_from = ($privmsg['user_from']) ? $lang['Location'] . ': ' . $privmsg['user_from'] : '';
$poster_joined = ($privmsg['user_id'] != ANONYMOUS) ? $lang['Joined'] . ': ' . create_date($lang['JOINED_DATE_FORMAT'], $privmsg['user_regdate'], $config['board_timezone']) : '';
// Mighty Gorgon - Quick Quote - BEGIN
$look_up_array = array(
'\"',
'"',
"<",
">",
"\n",
chr(13),
);
$replacement_array = array(
'&q_mg;',
'\"',
"<_mg;",
">_mg;",
"\\n",
"",
);
$plain_message = $privmsg['privmsgs_text'];
$plain_message = strtr($plain_message, array_flip(get_html_translation_table(HTML_ENTITIES)));
$plain_message = censor_text($plain_message);
$plain_message = str_replace($look_up_array, $replacement_array, $plain_message);
// Mighty Gorgon - Quick Quote - END
// Processing of post
$post_subject = $privmsg['privmsgs_subject'];
$private_message = $privmsg['privmsgs_text'];
if ($config['allow_sig'])
{
$user_sig = ($privmsg['privmsgs_from_userid'] == $user->data['user_id']) ? $user->data['user_sig'] : $privmsg['user_sig'];
}
else
{
$user_sig = '';
}
// If the board has HTML off but the post has HTML on then we process it, else leave it alone
if (!$config['allow_html'])
{
if ($user_sig != '' && $privmsg['privmsgs_enable_sig'] && $user->data['user_allowhtml'])
{
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig);
}
if ($privmsg['privmsgs_enable_html'])
{
$private_message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $private_message);
}
}
if (($user_sig != '') && $privmsg['privmsgs_attach_sig'])
{
$bbcode->allow_html = $config['allow_html'];
$bbcode->allow_bbcode = $config['allow_bbcode'] ? true : false;
$bbcode->allow_smilies = $config['allow_smilies'];
$bbcode->is_sig = true;
$user_sig = $bbcode->parse($user_sig);
$bbcode->is_sig = false;
}
$bbcode->allow_html = (($config['allow_html'] && $user->data['user_allowhtml']) || $config['allow_html_only_for_admins']) && $privmsg['privmsgs_enable_html'];
$bbcode->allow_bbcode = $config['allow_bbcode'] ? true : false;
$bbcode->allow_smilies = $config['allow_smilies'] && $privmsg['privmsgs_enable_smilies'];
$private_message = $bbcode->parse($private_message);
if ($privmsg['privmsgs_attach_sig'] && $user_sig != '')
{
$signature = '<br />' . $config['sig_line'] . '<br />' . $user_sig;
}
$post_subject = censor_text($post_subject);
$private_message = censor_text($private_message);
//Acronyms, AutoLinks - BEGIN
if ($privmsg['privmsgs_enable_autolinks_acronyms'])
{
$private_message = $bbcode->acronym_pass($private_message);
$private_message = $bbcode->autolink_text($private_message, '999999');
}
//Acronyms, AutoLinks -END
// Mighty Gorgon - Multiple Ranks - BEGIN
$user_ranks = generate_ranks($privmsg, $ranks_array);
if (($user_ranks['rank_01_html'] == '') && ($user_ranks['rank_01_img_html'] == '') && ($user_ranks['rank_02_html'] == '') && ($user_ranks['rank_02_img_html'] == '') && ($user_ranks['rank_03_html'] == '') && ($user_ranks['rank_03_img_html'] == '') && ($user_ranks['rank_04_html'] == '') && ($user_ranks['rank_04_img_html'] == '') && ($user_ranks['rank_05_html'] == '') && ($user_ranks['rank_05_img_html'] == ''))
{
$user_ranks['rank_01_html'] = ' ';
}
// Mighty Gorgon - Multiple Ranks - END
$poster_rank = $user_ranks['rank_01_html'];
$rank_image = $user_ranks['rank_01_img_html'];
// Dump it to the templating engine
$template->assign_vars(array(
'MESSAGE_TO' => $username_to,
'RECIPIENT_QQ' => $privmsg['username_1'],
'PM_ID' => $privmsgs_id,
'MESSAGE_FROM' => $username_from,
'RANK_IMAGE' => $rank_image,
'POSTER_JOINED' => $poster_joined,
'POSTER_POSTS' => $poster_posts,
'POSTER_FROM' => $poster_from,
'POSTER_AVATAR' => $poster_avatar,
'POST_SUBJECT' => $post_subject,
'POST_DATE' => $post_date,
'MESSAGE' => $private_message,
'PLAIN_MESSAGE' => $plain_message,
'SIGNATURE' => $signature,
'POSTER_RANK' => $poster_rank,
'RANK_IMAGE' => $rank_image,
'POSTER_GENDER' => $user_info['gender'],
'PROFILE_URL' => $user_info['profile_url'],
'PROFILE_IMG' => $user_info['profile_img'],
'PROFILE' => $user_info['profile'],
'PM_URL' => $user_info['pm_url'],
'PM_IMG' => $user_info['pm_img'],
'PM' => $user_info['pm'],
'SEARCH_URL' => $user_info['search_url'],
'SEARCH_IMG' => $user_info['search_img'],
'SEARCH' => $user_info['search'],
'IP_URL' => $user_info['ip_url'],
'IP_IMG' => $user_info['ip_img'],
'IP' => $user_info['ip'],
'EMAIL_URL' => $user_info['email_url'],
'EMAIL_IMG' => $user_info['email_img'],
'EMAIL' => $user_info['email'],
'WWW_URL' => $user_info['www_url'],
'WWW_IMG' => $user_info['www_img'],
'WWW' => $user_info['www'],
'AIM_URL' => $user_info['aim_url'],
'AIM_IMG' => $user_info['aim_img'],
'AIM' => $user_info['aim'],
'ICQ_STATUS_IMG' => $user_info['icq_status_img'],
'ICQ_URL' => $user_info['icq_url'],
'ICQ_IMG' => $user_info['icq_img'],
'ICQ' => $user_info['icq'],
'MSN_URL' => $user_info['msn_url'],
'MSN_IMG' => $user_info['msn_img'],
'MSN' => $user_info['msn'],
'SKYPE_URL' => $user_info['skype_url'],
'SKYPE_IMG' => $user_info['skype_img'],
'SKYPE' => $user_info['skype'],
'YIM_URL' => $user_info['yahoo_url'],
'YIM_IMG' => $user_info['yahoo_img'],
'YIM' => $user_info['yahoo'],
'ONLINE_STATUS_URL' => $user_info['online_status_url'],
'ONLINE_STATUS_CLASS' => $user_info['online_status_class'],
'ONLINE_STATUS_IMG' => $user_info['online_status_img'],
'ONLINE_STATUS' => $user_info['online_status'],
'L_ONLINE_STATUS' => $user_info['online_status_lang'],
'L_READ_MESSAGE' => $lang['Read_pm'],
)
);
if (!function_exists('generate_smilies_row'))
{
include_once(IP_ROOT_PATH . 'includes/functions_bbcode.' . PHP_EXT);
}
generate_smilies_row();
$template->assign_vars(array(
'L_SMILEYS_MORE' => $lang['More_emoticons'],
'U_SMILEYS_MORE' => append_sid('posting.' . PHP_EXT . '?mode=smilies'),
)
);
full_page_generation($template_to_parse, $lang['Read_pm'], '', '');
}
elseif (($delete && $mark_list) || $delete_all)
{
if (!$user->data['session_logged_in'])
{
redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=privmsg.' . PHP_EXT . '&folder=inbox', true));
}
if (isset($mark_list) && !is_array($mark_list))
{
// Set to empty array instead of '0' if nothing is selected.
$mark_list = array();
}
if (!$confirm)
{
$s_hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" />';
$s_hidden_fields .= (isset($_POST['delete'])) ? '<input type="hidden" name="delete" value="true" />' : '<input type="hidden" name="deleteall" value="true" />';
$s_hidden_fields .= '<input type="hidden" name="sid" value="' . $user->data['session_id'] . '" />';
for($i = 0; $i < sizeof($mark_list); $i++)
{
$s_hidden_fields .= '<input type="hidden" name="mark[]" value="' . intval($mark_list[$i]) . '" />';
}
// Output confirmation page
$nav_server_url = create_server_url();
$breadcrumbs['address'] = $lang['Nav_Separator'] . '<a href="' . $nav_server_url . append_sid(CMS_PAGE_PRIVMSG . '?folder=inbox') . '" class="nav-current">' . $lang['Private_Messaging'] . '</a>';
$template->assign_vars(array(
'MESSAGE_TITLE' => $lang['Information'],
'MESSAGE_TEXT' => (sizeof($mark_list) == 1) ? $lang['Confirm_delete_pm'] : $lang['Confirm_delete_pms'],
'L_YES' => $lang['Yes'],
'L_NO' => $lang['No'],
'S_CONFIRM_ACTION' => append_sid(CMS_PAGE_PRIVMSG . '?folder=' . $folder),
'S_HIDDEN_FIELDS' => $s_hidden_fields
)
);
full_page_generation('confirm_body.tpl', $lang['Confirm'], '', '');
}
elseif ($confirm && $sid === $user->data['session_id'])
{
if ($delete_all)
{
switch($folder)
{
case 'inbox':
$delete_type = "privmsgs_to_userid = " . $user->data['user_id'] . " AND (
privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . ")";
break;
case 'outbox':
$delete_type = "privmsgs_from_userid = " . $user->data['user_id'] . " AND (privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . ")";
break;
case 'sentbox':
$delete_type = "privmsgs_from_userid = " . $user->data['user_id'] . " AND privmsgs_type = " . PRIVMSGS_SENT_MAIL;
break;
case 'savebox':
$delete_type = "((privmsgs_from_userid = " . $user->data['user_id'] . "
AND privmsgs_type = " . PRIVMSGS_SAVED_OUT_MAIL . ")
OR (privmsgs_to_userid = " . $user->data['user_id'] . "
AND privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . "))";
break;
}
$sql = "SELECT privmsgs_id
FROM " . PRIVMSGS_TABLE . "
WHERE $delete_type";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$mark_list[] = $row['privmsgs_id'];
}
unset($delete_type);
}
$attachment_mod['pm']->delete_all_pm_attachments($mark_list);
if (sizeof($mark_list))
{
$delete_sql_id = '';
for ($i = 0; $i < sizeof($mark_list); $i++)
{
$delete_sql_id .= (($delete_sql_id != '') ? ', ' : '') . intval($mark_list[$i]);
}
if ($folder == 'inbox' || $folder == 'outbox')
{
switch ($folder)
{
case 'inbox':
$sql = "privmsgs_to_userid = " . $user->data['user_id'];
break;
case 'outbox':
$sql = "privmsgs_from_userid = " . $user->data['user_id'];
break;
}
// Get information relevant to new or unread mail
// so we can adjust users counters appropriately
$sql = "SELECT privmsgs_to_userid, privmsgs_type
FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_id IN ($delete_sql_id)
AND $sql
AND privmsgs_type IN (" . PRIVMSGS_NEW_MAIL . ", " . PRIVMSGS_UNREAD_MAIL . ")";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$update_users = $update_list = array();
do
{
switch ($row['privmsgs_type'])
{
case PRIVMSGS_NEW_MAIL:
$update_users['new'][$row['privmsgs_to_userid']]++;
break;
case PRIVMSGS_UNREAD_MAIL:
$update_users['unread'][$row['privmsgs_to_userid']]++;
break;
}
}
while ($row = $db->sql_fetchrow($result));
if (sizeof($update_users))
{
//while (list($type, $users) = each($update_users))
foreach ($update_users as $type => $users)
{
//while (list($user_id, $dec) = each($users))
foreach ($users as $user_id => $dec)
{
$update_list[$type][$dec][] = $user_id;
}
}
unset($update_users);
//while (list($type, $dec_ary) = each($update_list))
foreach ($update_list as $type => $dec_ary)
{
switch ($type)
{
case 'new':
$type = "user_new_privmsg";
break;
case 'unread':
$type = "user_unread_privmsg";
break;
}
//while (list($dec, $user_ary) = each($dec_ary))
foreach ($dec_ary as $dec => $user_ary)
{
$user_ids = implode(', ', $user_ary);
$sql = "UPDATE " . USERS_TABLE . "
SET $type = $type - $dec
WHERE user_id IN ($user_ids)";
$db->sql_query($sql);
}
}
unset($update_list);
}
}
$db->sql_freeresult($result);
}
// Delete the messages
$delete_sql = "DELETE FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_id IN ($delete_sql_id)
AND ";
switch($folder)
{
case 'inbox':
$delete_sql .= "privmsgs_to_userid = " . $user->data['user_id'] . " AND (
privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . ")";
break;
case 'outbox':
$delete_sql .= "privmsgs_from_userid = " . $user->data['user_id'] . " AND (
privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . ")";
break;
case 'sentbox':
$delete_sql .= "privmsgs_from_userid = " . $user->data['user_id'] . " AND privmsgs_type = " . PRIVMSGS_SENT_MAIL;
break;
case 'savebox':
$delete_sql .= "((privmsgs_from_userid = " . $user->data['user_id'] . "
AND privmsgs_type = " . PRIVMSGS_SAVED_OUT_MAIL . ")
OR (privmsgs_to_userid = " . $user->data['user_id'] . "
AND privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . "))";
break;
}
$db->sql_query($delete_sql);
}
}
}
elseif ($download && $mark_list)
{
if (!$user->data['session_logged_in'])
{
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
header($header_location . append_sid(CMS_PAGE_LOGIN .'?redirect=privmsg.' . PHP_EXT . '&folder=inbox', true));
exit;
}
switch($folder)
{
case 'inbox':
$disp_folder = $lang['Inbox'];
break;
case 'outbox':
$disp_folder = $lang['Outbox'];
break;
case 'sentbox':
$disp_folder = $lang['Sentbox'];
break;
case 'savebox':
$disp_folder = $lang['Savebox'];
break;
}
if (sizeof($mark_list))
{
$i = 0;
$crlf = "\r\n";
$pmtext = $lang['Private_Messaging'] . ' (' . $config['sitename'] . ')' . $crlf;
$user_dateformat = ($user->data['user_dateformat']) ? $user->data['user_dateformat'] : $config['default_dateformat'];
$pmtext .= $disp_folder . ' (' . gmdate($user_dateformat) . ')' . $crlf;
while($mark_list[$i] != '')
{
$sql = "SELECT pm.privmsgs_date, pm.privmsgs_subject, pm.privmsgs_text, us.username, us.user_id
FROM " . PRIVMSGS_TABLE . " pm, " . USERS_TABLE . " us
WHERE pm.privmsgs_id = " . $mark_list[$i] . "
AND us.user_id = pm.privmsgs_from_userid";
$db->sql_return_on_error(true);
$result = $db->sql_query($sql);
$db->sql_return_on_error(false);
if ($result)
{
$db_row = $db->sql_fetchrow($result);
$tmpmsg = wordwrap(htmlspecialchars_decode($db_row['privmsgs_text'], ENT_COMPAT), 78, $crlf);
$from = (($folder == 'inbox') || ($folder == 'savebox')) ? $lang['From'] : $lang['To'];
$pmtext .= '------------------------------------------------------------------------------' . $crlf;
$pmtext .= $lang['Mailbox'] . ': ' . $user->data['username'] . $crlf;
$pmtext .= $from . ': ' . $db_row['username'] . $crlf;
$pmtext .= $lang['Posted'] . ': ' . gmdate($user_dateformat, $db_row['privmsgs_date']) . $crlf;
$pmtext .= $lang['Subject'] . ': ' . htmlspecialchars_decode($db_row['privmsgs_subject'], ENT_COMPAT) . $crlf . $crlf;
$pmtext .= $tmpmsg . $crlf;
}
else
{
print $sql . '<p>';
message_die(GENERAL_ERROR, 'Could not read private message info', '', __LINE__, __FILE__, $sql);
}