-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprintthread.php
219 lines (183 loc) · 6.92 KB
/
printthread.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
<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 4.2.0 Patch Level 3 - Licence Number VBFBED0615
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2000-2012 vBulletin Solutions Inc. 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', 'printthread');
define('CSRF_PROTECTION', true);
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array('showthread', 'postbit');
// get special data templates from the datastore
$specialtemplates = array(
'smiliecache',
'bbcodecache'
);
// pre-cache templates used by all actions
$globaltemplates = array(
'printthread',
'printthreadbit',
'printthreadbit_ignore',
'bbcode_code_printable',
'bbcode_html_printable',
'bbcode_php_printable',
'bbcode_quote_printable',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/class_bbcode_alt.php');
require_once(DIR . '/includes/functions_bigthree.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
verify_forum_url();
$vbulletin->input->clean_array_gpc('r', array(
'perpage' => TYPE_UINT,
'pagenumber'=> TYPE_UINT
));
($hook = vBulletinHook::fetch_hook('printthread_start')) ? eval($hook) : false;
// oldest first or newest first
if ($vbulletin->userinfo['postorder'] == 0)
{
$postorder = '';
}
else
{
$postorder = 'DESC';
}
if ($vbulletin->options['wordwrap'])
{
$threadinfo['title'] = fetch_word_wrapped_string($threadinfo['title']);
}
if (!$threadinfo['threadid'] OR (!$threadinfo['visible'] AND !can_moderate($threadinfo['forumid'], 'canmoderateposts')) OR $threadinfo['isdeleted'] OR (in_coventry($threadinfo['postuserid']) AND !can_moderate($threadinfo['forumid'])))
{
eval(standard_error(fetch_error('invalidid', $vbphrase['thread'], $vbulletin->options['contactuslink'])));
}
$forumperms = fetch_permissions($threadinfo['forumid']);
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']))
{
print_no_permission();
}
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($threadinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0))
{
print_no_permission();
}
if ($threadinfo['open'] == 10)
{
//pollid is the real threadid for a redirect
exec_header_redirect(fetch_seo_url('threadprint', $threadinfo, array(), 'pollid'));
}
// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($foruminfo['forumid'], $foruminfo['password']);
// split thread over pages if necessary
$countposts = $db->query_first_slave("
SELECT COUNT(*) AS total
FROM " . TABLE_PREFIX . "post AS post
WHERE threadid=$threadinfo[threadid] AND visible=1
");
$totalposts = $countposts['total'];
$vbulletin->GPC['perpage'] = sanitize_maxposts($vbulletin->GPC['perpage']);
$maxperpage = sanitize_maxposts(-1);
if ($vbulletin->GPC['pagenumber'] < 1)
{
$vbulletin->GPC['pagenumber'] = 1;
}
$startat = ($vbulletin->GPC['pagenumber'] - 1) * $vbulletin->GPC['perpage'];
$pagenav = construct_page_nav(
$vbulletin->GPC['pagenumber'],
$vbulletin->GPC['perpage'],
$totalposts,
'',
'',
'',
'threadprint',
$threadinfo,
array('pp' => $vbulletin->GPC['perpage'])
);
// end page splitter
$bbcode_parser = new vB_BbCodeParser_PrintableThread($vbulletin, fetch_tag_list());
$ignore = array();
if (trim($vbulletin->userinfo['ignorelist']))
{
$ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY);
foreach ($ignorelist AS $ignoreuserid)
{
$ignore["$ignoreuserid"] = 1;
}
}
$posts = $db->query_read_slave("
SELECT post.*,post.username AS postusername,user.username
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)
WHERE post.threadid=$threadid AND post.visible=1
ORDER BY dateline $postorder
LIMIT $startat, " . $vbulletin->GPC['perpage'] . "
");
$postbits = '';
while ($post = $db->fetch_array($posts))
{
// hide users in Coventry from non-staff members
if ($tachyuser = in_coventry($post['userid']) AND !can_moderate($threadinfo['forumid']))
{
continue;
}
if ($tachyuser)
{
$show['adminignore'] = true;
$bit_template = 'printthreadbit_ignore';
}
else if ($ignore["$post[userid]"])
{
$show['adminignore'] = false;
$bit_template = 'printthreadbit_ignore';
}
else
{
$bit_template = 'printthreadbit';
}
$post['postdate'] = vbdate($vbulletin->options['dateformat'], $post['dateline']);
$post['posttime'] = vbdate($vbulletin->options['timeformat'], $post['dateline']);
if ($vbulletin->options['wordwrap'])
{
$post['title'] = fetch_word_wrapped_string($post['title']);
}
if (!$post['userid'])
{
$post['username'] = $post['postusername'];
}
$post['message'] = $bbcode_parser->parse($post['pagetext'], 'nonforum', false);
($hook = vBulletinHook::fetch_hook('printthread_post')) ? eval($hook) : false;
$templater = vB_Template::create($bit_template);
$templater->register('post', $post);
$templater->register('xhtml_id', ++$xhtml);
$postbits .= $templater->render();
}
($hook = vBulletinHook::fetch_hook('printthread_complete')) ? eval($hook) : false;
$templater = vB_Template::create('printthread');
$templater->register_page_templates();
$templater->register('foruminfo', $foruminfo);
$templater->register('maxperpage', $maxperpage);
$templater->register('pagenav', $pagenav);
$templater->register('postbits', $postbits);
$templater->register('threadid', $threadid);
$templater->register('threadinfo', $threadinfo);
$templater->register('perpage', $vbulletin->GPC['perpage']);
print_output($templater->render());
/*======================================================================*\
|| ####################################################################
|| # Downloaded: 16:29, Sun Dec 9th 2012
|| # CVS: $RCSfile$ - $Revision: 40911 $
|| ####################################################################
\*======================================================================*/
?>