Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 537 lines (391 sloc) 19.112 kb
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
1 <?php
2
e5f7b2a @reines Updating copyright notices in all files
reines authored
3 /**
8637b8a @reines Updating the copyright notices to 2011.
reines authored
4 * Copyright (C) 2008-2011 FluxBB
e5f7b2a @reines Updating copyright notices in all files
reines authored
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
8
9 if (isset($_GET['action']))
10 define('PUN_QUIET_VISIT', 1);
11
f5ee836 @reines Changing PUN_ROOT to use absolute paths, this solves some issues with…
reines authored
12 define('PUN_ROOT', dirname(__FILE__).'/');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
13 require PUN_ROOT.'include/common.php';
14
15
16 // Load the misc.php language file
17 require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
18
19 $action = isset($_GET['action']) ? $_GET['action'] : null;
20
21
22 if ($action == 'rules')
23 {
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
24 if ($pun_config['o_rules'] == '0' || ($pun_user['is_guest'] && $pun_user['g_read_board'] == '0' && $pun_config['o_regs_allow'] == '0'))
25 message($lang_common['Bad request']);
26
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
27 // Load the register.php language file
28 require PUN_ROOT.'lang/'.$pun_user['language'].'/register.php';
29
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored
30 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_register['Forum rules']);
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored
31 define('PUN_ACTIVE_PAGE', 'rules');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
32 require PUN_ROOT.'header.php';
33
34 ?>
1417352 Added some id's to scripts that generate more than one type of page. …
Paul Sullivan authored
35 <div id="rules" class="block">
31a332a 1. Cutting down the very verbose and somewhat ugly label for style se…
Paul Sullivan authored
36 <div class="hd"><h2><span><?php echo $lang_register['Forum rules'] ?></span></h2></div>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
37 <div class="box">
b2a90a5 Added some styling for the rules page.
Frank Smit authored
38 <div id="rules-block" class="inbox">
cb7b187 1. Fixed various spacing and other issues with display of posts.
Paul Sullivan authored
39 <div class="usercontent"><?php echo $pun_config['o_rules_message'] ?></div>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
40 </div>
41 </div>
42 </div>
43 <?php
44
45 require PUN_ROOT.'footer.php';
46 }
47
48
49 else if ($action == 'markread')
50 {
51 if ($pun_user['is_guest'])
52 message($lang_common['No permission']);
53
7c97871 @daris Updating to use new db layer
daris authored
54 $query = $db->update(array('last_visit' => ':logged'), 'users');
d23999f @reines Converting all queries in misc.php
reines authored
55 $query->where = 'id = :user_id';
56
57 $params = array(':logged' => $pun_user['logged'], ':user_id' => $pun_user['id']);
58
7c97871 @daris Updating to use new db layer
daris authored
59 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
60 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
61
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
62 // Reset tracked topics
63 set_tracked_topics(null);
64
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
65 redirect('index.php', $lang_misc['Mark read redirect']);
66 }
67
68
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
69 // Mark the topics/posts in a forum as read?
70 else if ($action == 'markforumread')
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
71 {
72 if ($pun_user['is_guest'])
73 message($lang_common['No permission']);
74
6181e8f @Quy Added 'mark forum read' link.
Quy authored
75 $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
76 if ($fid < 1)
77 message($lang_common['Bad request']);
78
79 $tracked_topics = get_tracked_topics();
80 $tracked_topics['forums'][$fid] = time();
81 set_tracked_topics($tracked_topics);
82
83 redirect('viewforum.php?id='.$fid, $lang_misc['Mark forum read redirect']);
84 }
85
86
87 else if (isset($_GET['email']))
88 {
89 if ($pun_user['is_guest'] || $pun_user['g_send_email'] == '0')
90 message($lang_common['No permission']);
91
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
92 $recipient_id = intval($_GET['email']);
93 if ($recipient_id < 2)
94 message($lang_common['Bad request']);
95
7c97871 @daris Updating to use new db layer
daris authored
96 $query = $db->select(array('username' => 'u.username', 'email' => 'u.email', 'email_setting' => 'u.email_setting'), 'users AS u');
d23999f @reines Converting all queries in misc.php
reines authored
97 $query->where = 'u.id = :recipient_id';
98
99 $params = array(':recipient_id' => $recipient_id);
100
7c97871 @daris Updating to use new db layer
daris authored
101 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
102 if (empty($result))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
103 message($lang_common['Bad request']);
104
d23999f @reines Converting all queries in misc.php
reines authored
105 $recipient = $result[0];
106 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
107
d23999f @reines Converting all queries in misc.php
reines authored
108 if ($recipient['email_setting'] == 2 && !$pun_user['is_admmod'])
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
109 message($lang_misc['Form email disabled']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
110
111
112 if (isset($_POST['form_sent']))
113 {
114 // Clean up message and subject from POST
115 $subject = pun_trim($_POST['req_subject']);
116 $message = pun_trim($_POST['req_message']);
117
118 if ($subject == '')
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
119 message($lang_misc['No email subject']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
120 else if ($message == '')
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
121 message($lang_misc['No email message']);
8050cac @reines Replaced a few trims with pun_trim and strlen with pun_strlen
reines authored
122 else if (pun_strlen($message) > PUN_MAX_POSTSIZE)
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
123 message($lang_misc['Too long email message']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
124
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
125 if ($pun_user['last_email_sent'] != '' && (time() - $pun_user['last_email_sent']) < $pun_user['g_email_flood'] && (time() - $pun_user['last_email_sent']) >= 0)
edba592 @Quy Fixed email flood error message.
Quy authored
126 message(sprintf($lang_misc['Email flood'], $pun_user['g_email_flood']));
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
127
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
128 // Load the "form email" template
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
129 $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/form_email.tpl'));
130
131 // The first row contains the subject
132 $first_crlf = strpos($mail_tpl, "\n");
8050cac @reines Replaced a few trims with pun_trim and strlen with pun_strlen
reines authored
133 $mail_subject = pun_trim(substr($mail_tpl, 8, $first_crlf-8));
134 $mail_message = pun_trim(substr($mail_tpl, $first_crlf));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
135
136 $mail_subject = str_replace('<mail_subject>', $subject, $mail_subject);
137 $mail_message = str_replace('<sender>', $pun_user['username'], $mail_message);
138 $mail_message = str_replace('<board_title>', $pun_config['o_board_title'], $mail_message);
139 $mail_message = str_replace('<mail_message>', $message, $mail_message);
9bb1cf1 @franzliedke #476: Make "forum mailer" properly translateable.
franzliedke authored
140 $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
141
142 require_once PUN_ROOT.'include/email.php';
143
d23999f @reines Converting all queries in misc.php
reines authored
144 pun_mail($recipient['email'], $mail_subject, $mail_message, $pun_user['email'], $pun_user['username']);
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
145
7c97871 @daris Updating to use new db layer
daris authored
146 $query = $db->update(array('last_email_sent' => ':now'), 'users');
d23999f @reines Converting all queries in misc.php
reines authored
147 $query->where = 'id = :user_id';
148
149 $params = array(':now' => time(), ':user_id' => $pun_user['id']);
150
7c97871 @daris Updating to use new db layer
daris authored
151 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
152 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
153
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
154 redirect(htmlspecialchars($_POST['redirect_url']), $lang_misc['Email sent redirect']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
155 }
156
157
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
158 // Try to determine if the data in HTTP_REFERER is valid (if not, we redirect to the users profile after the email is sent)
ce8b3a0 @reines Updating the referrer checks in login.php and misc.php to allow https…
reines authored
159 if (!empty($_SERVER['HTTP_REFERER']))
160 {
161 $referrer = parse_url($_SERVER['HTTP_REFERER']);
162 // Remove www subdomain if it exists
163 if (strpos($referrer['host'], 'www.') === 0)
164 $referrer['host'] = substr($referrer['host'], 4);
165
c7be20e @reines Replacing more references to o_base_url. This shouldnt have any effec…
reines authored
166 $valid = parse_url(get_base_url());
ce8b3a0 @reines Updating the referrer checks in login.php and misc.php to allow https…
reines authored
167 // Remove www subdomain if it exists
168 if (strpos($valid['host'], 'www.') === 0)
169 $valid['host'] = substr($valid['host'], 4);
170
b1deb69 @reines Updating all the regular expressions to use % as a delimiter. Before …
reines authored
171 if ($referrer['host'] == $valid['host'] && preg_match('%^'.preg_quote($valid['path'], '%').'/(.*?)\.php%i', $referrer['path']))
ce8b3a0 @reines Updating the referrer checks in login.php and misc.php to allow https…
reines authored
172 $redirect_url = $_SERVER['HTTP_REFERER'];
173 }
174
175 if (!isset($redirect_url))
176 $redirect_url = 'profile.php?id='.$recipient_id;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
177
d23999f @reines Converting all queries in misc.php
reines authored
178 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Send email to'].' '.pun_htmlspecialchars($recipient['username']));
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
179 $required_fields = array('req_subject' => $lang_misc['Email subject'], 'req_message' => $lang_misc['Email message']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
180 $focus_element = array('email', 'req_subject');
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored
181 define('PUN_ACTIVE_PAGE', 'index');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
182 require PUN_ROOT.'header.php';
183
184 ?>
1417352 Added some id's to scripts that generate more than one type of page. …
Paul Sullivan authored
185 <div id="emailform" class="blockform">
d23999f @reines Converting all queries in misc.php
reines authored
186 <h2><span><?php echo $lang_misc['Send email to'] ?> <?php echo pun_htmlspecialchars($recipient['username']) ?></span></h2>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
187 <div class="box">
188 <form id="email" method="post" action="misc.php?email=<?php echo $recipient_id ?>" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">
189 <div class="inform">
190 <fieldset>
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
191 <legend><?php echo $lang_misc['Write email'] ?></legend>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
192 <div class="infldset txtarea">
193 <input type="hidden" name="form_sent" value="1" />
ce8b3a0 @reines Updating the referrer checks in login.php and misc.php to allow https…
reines authored
194 <input type="hidden" name="redirect_url" value="<?php echo pun_htmlspecialchars($redirect_url) ?>" />
ef91b66 Adding hidden required text to required fields with minimum alteratio…
Paul Sullivan authored
195 <label class="required"><strong><?php echo $lang_misc['Email subject'] ?> <span><?php echo $lang_common['Required'] ?></span></strong><br />
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
196 <input class="longinput" type="text" name="req_subject" size="75" maxlength="70" tabindex="1" /><br /></label>
ef91b66 Adding hidden required text to required fields with minimum alteratio…
Paul Sullivan authored
197 <label class="required"><strong><?php echo $lang_misc['Email message'] ?> <span><?php echo $lang_common['Required'] ?></span></strong><br />
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
198 <textarea name="req_message" rows="10" cols="75" tabindex="2"></textarea><br /></label>
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
199 <p><?php echo $lang_misc['Email disclosure note'] ?></p>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
200 </div>
201 </fieldset>
202 </div>
57eb86e Correcting an assortment of issues and inconsistencies discovered whi…
Paul Sullivan authored
203 <p class="buttons"><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" tabindex="3" accesskey="s" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
204 </form>
205 </div>
206 </div>
207 <?php
208
209 require PUN_ROOT.'footer.php';
210 }
211
212
213 else if (isset($_GET['report']))
214 {
215 if ($pun_user['is_guest'])
216 message($lang_common['No permission']);
217
218 $post_id = intval($_GET['report']);
219 if ($post_id < 1)
220 message($lang_common['Bad request']);
221
222 if (isset($_POST['form_sent']))
223 {
224 // Clean up reason from POST
225 $reason = pun_linebreaks(pun_trim($_POST['req_reason']));
226 if ($reason == '')
227 message($lang_misc['No reason']);
9f259f2 @reines Adding a check to the max length of a reason when making a report. Re…
reines authored
228 else if (strlen($reason) > 65535) // TEXT field can only hold 65535 bytes
229 message($lang_misc['Reason too long']);
56ab252 Updated copyright texts.
Frank Smit authored
230
bc60ad8 @franzliedke #465: Implement report flood protection.
franzliedke authored
231 if ($pun_user['last_report_sent'] != '' && (time() - $pun_user['last_report_sent']) < $pun_user['g_report_flood'] && (time() - $pun_user['last_report_sent']) >= 0)
232 message(sprintf($lang_misc['Report flood'], $pun_user['g_report_flood']));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
233
234 // Get the topic ID
7c97871 @daris Updating to use new db layer
daris authored
235 $query = $db->select(array('topic_id' => 'p.topic_id'), 'posts AS p');
d1807fa @reines Converting some more queries
reines authored
236 $query->where = 'p.id = :post_id';
237
238 $params = array(':post_id' => $post_id);
239
7c97871 @daris Updating to use new db layer
daris authored
240 $result = $query->run($params);
d1807fa @reines Converting some more queries
reines authored
241 if (empty($result))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
242 message($lang_common['Bad request']);
243
d1807fa @reines Converting some more queries
reines authored
244 $topic_id = $result[0]['topic_id'];
245 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
246
247 // Get the subject and forum ID
7c97871 @daris Updating to use new db layer
daris authored
248 $query = $db->select(array('subject' => 't.subject', 'forum_id' => 't.forum_id'), 'topics AS t');
d1807fa @reines Converting some more queries
reines authored
249 $query->where = 't.id = :topic_id';
250
251 $params = array(':topic_id' => $topic_id);
252
7c97871 @daris Updating to use new db layer
daris authored
253 $result = $query->run($params);
d1807fa @reines Converting some more queries
reines authored
254 if (empty($result))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
255 message($lang_common['Bad request']);
256
0cfb58d @reines Updating some more queries
reines authored
257 $cur_post = $result[0];
d1807fa @reines Converting some more queries
reines authored
258 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
259
260 // Should we use the internal report handling?
ce8dd32 @Quy Made code consistent.
Quy authored
261 if ($pun_config['o_report_method'] == '0' || $pun_config['o_report_method'] == '2')
d1807fa @reines Converting some more queries
reines authored
262 {
7c97871 @daris Updating to use new db layer
daris authored
263 $query = $db->insert(array('post_id' => ':post_id', 'topic_id' => ':topic_id', 'forum_id' => ':forum_id', 'reported_by' => ':user_id', 'created' => ':now', 'message' => ':reason'), 'reports');
0cfb58d @reines Updating some more queries
reines authored
264 $params = array(':post_id' => $post_id, ':topic_id' => $topic_id, ':forum_id' => $cur_post['forum_id'], ':user_id' => $pun_user['id'], ':now' => time(), ':reason' => $reason);
d1807fa @reines Converting some more queries
reines authored
265
7c97871 @daris Updating to use new db layer
daris authored
266 $query->run($params);
d1807fa @reines Converting some more queries
reines authored
267 unset ($query, $params);
268 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
269
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
270 // Should we email the report?
ce8dd32 @Quy Made code consistent.
Quy authored
271 if ($pun_config['o_report_method'] == '1' || $pun_config['o_report_method'] == '2')
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
272 {
273 // We send it to the complete mailing-list in one swoop
274 if ($pun_config['o_mailing_list'] != '')
56ab252 Updated copyright texts.
Frank Smit authored
275 {
c247d6c @franzliedke #422: Use templates for all emails. Thanks to Daris for the patch!
franzliedke authored
276 // Load the "new report" template
277 $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/new_report.tpl'));
278
279 // The first row contains the subject
280 $first_crlf = strpos($mail_tpl, "\n");
281 $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
282 $mail_message = trim(substr($mail_tpl, $first_crlf));
283
731999f @franzliedke Merge commit 'bf7116c9aa232c42dc38457906d6060e126a74fc' into fluxbb-2…
franzliedke authored
284 $mail_subject = str_replace('<forum_id>', $cur_post['forum_id'], $mail_subject);
285 $mail_subject = str_replace('<topic_subject>', $cur_post['subject'], $mail_subject);
c247d6c @franzliedke #422: Use templates for all emails. Thanks to Daris for the patch!
franzliedke authored
286 $mail_message = str_replace('<username>', $pun_user['username'], $mail_message);
287 $mail_message = str_replace('<post_url>', get_base_url().'/viewtopic.php?pid='.$post_id.'#p'.$post_id, $mail_message);
288 $mail_message = str_replace('<reason>', $reason, $mail_message);
9bb1cf1 @franzliedke #476: Make "forum mailer" properly translateable.
franzliedke authored
289 $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
290
291 require PUN_ROOT.'include/email.php';
292
293 pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
294 }
295 }
56ab252 Updated copyright texts.
Frank Smit authored
296
7c97871 @daris Updating to use new db layer
daris authored
297 $query = $db->update(array('last_report_sent' => ':now'), 'users');
d1807fa @reines Converting some more queries
reines authored
298 $query->where = 'id = :user_id';
299
300 $params = array(':now' => time(), ':user_id' => $pun_user['id']);
301
7c97871 @daris Updating to use new db layer
daris authored
302 $query->run($params);
d1807fa @reines Converting some more queries
reines authored
303 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
304
f466eef @reines Caching the number of unzapped reports.
reines authored
305 $cache->delete('num_reports');
306
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
307 redirect('viewtopic.php?pid='.$post_id.'#p'.$post_id, $lang_misc['Report redirect']);
308 }
309
698e711 @reines Added breadcrumbs to the report page to be consistent with the delete…
reines authored
310 // Fetch some info about the post, the topic and the forum
7c97871 @daris Updating to use new db layer
daris authored
311 $query = $db->select(array('fid' => 'f.id AS fid', 'forum_name' => 'f.forum_name', 'tid' => 't.id AS tid', 'subject' => 't.subject'), 'posts AS p');
d1807fa @reines Converting some more queries
reines authored
312
7c97871 @daris Updating to use new db layer
daris authored
313 $query->InnerJoin('t', 'topics AS t', 't.id = p.topic_id');
d1807fa @reines Converting some more queries
reines authored
314
7c97871 @daris Updating to use new db layer
daris authored
315 $query->InnerJoin('f', 'forums AS f', 'f.id = t.forum_id');
d1807fa @reines Converting some more queries
reines authored
316
7c97871 @daris Updating to use new db layer
daris authored
317 $query->LeftJoin('fp', 'forum_perms AS fp', 'fp.forum_id = f.id AND fp.group_id = :group_id');
d1807fa @reines Converting some more queries
reines authored
318
319 $query->where = '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.id = :post_id';
320
b612470 @franzliedke Change query parameter name.
franzliedke authored
321 $params = array(':group_id' => $pun_user['g_id'], ':post_id' => $post_id);
d1807fa @reines Converting some more queries
reines authored
322
7c97871 @daris Updating to use new db layer
daris authored
323 $result = $query->run($params);
d1807fa @reines Converting some more queries
reines authored
324 if (empty($result))
698e711 @reines Added breadcrumbs to the report page to be consistent with the delete…
reines authored
325 message($lang_common['Bad request']);
326
d1807fa @reines Converting some more queries
reines authored
327 $cur_post = $result[0];
328 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
329
d2c7e7e @reines Censoring post subject on the report and delete pages
reines authored
330 if ($pun_config['o_censoring'] == '1')
331 $cur_post['subject'] = censor_words($cur_post['subject']);
332
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored
333 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Report post']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
334 $required_fields = array('req_reason' => $lang_misc['Reason']);
335 $focus_element = array('report', 'req_reason');
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored
336 define('PUN_ACTIVE_PAGE', 'index');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
337 require PUN_ROOT.'header.php';
338
339 ?>
698e711 @reines Added breadcrumbs to the report page to be consistent with the delete…
reines authored
340 <div class="linkst">
341 <div class="inbox">
342 <ul class="crumbs">
343 <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li>
8d5b6c0 @reines Replacing some entities with their UTF-8 character equivalent.
reines authored
344 <li><span&#160;</span><a href="viewforum.php?id=<?php echo $cur_post['fid'] ?>"><?php echo pun_htmlspecialchars($cur_post['forum_name']) ?></a></li>
345 <li><span&#160;</span><a href="viewtopic.php?pid=<?php echo $post_id ?>#p<?php echo $post_id ?>"><?php echo pun_htmlspecialchars($cur_post['subject']) ?></a></li>
346 <li><span&#160;</span><strong><?php echo $lang_misc['Report post'] ?></strong></li>
698e711 @reines Added breadcrumbs to the report page to be consistent with the delete…
reines authored
347 </ul>
348 </div>
349 </div>
350
4a01224 Added id to the report form because it is now different from other pa…
Paul Sullivan authored
351 <div id="reportform" class="blockform">
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
352 <h2><span><?php echo $lang_misc['Report post'] ?></span></h2>
353 <div class="box">
354 <form id="report" method="post" action="misc.php?report=<?php echo $post_id ?>" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">
355 <div class="inform">
356 <fieldset>
357 <legend><?php echo $lang_misc['Reason desc'] ?></legend>
358 <div class="infldset txtarea">
359 <input type="hidden" name="form_sent" value="1" />
ef91b66 Adding hidden required text to required fields with minimum alteratio…
Paul Sullivan authored
360 <label class="required"><strong><?php echo $lang_misc['Reason'] ?> <span><?php echo $lang_common['Required'] ?></span></strong><br /><textarea name="req_reason" rows="5" cols="60"></textarea><br /></label>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
361 </div>
362 </fieldset>
363 </div>
57eb86e Correcting an assortment of issues and inconsistencies discovered whi…
Paul Sullivan authored
364 <p class="buttons"><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
365 </form>
366 </div>
367 </div>
368 <?php
369
370 require PUN_ROOT.'footer.php';
371 }
372
373
68b3934 @reines Adding forum subscriptions, see #142
reines authored
374 else if ($action == 'subscribe')
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
375 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
376 if ($pun_user['is_guest'])
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
377 message($lang_common['No permission']);
378
68b3934 @reines Adding forum subscriptions, see #142
reines authored
379 $topic_id = isset($_GET['tid']) ? intval($_GET['tid']) : 0;
380 $forum_id = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
381 if ($topic_id < 1 && $forum_id < 1)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
382 message($lang_common['Bad request']);
383
68b3934 @reines Adding forum subscriptions, see #142
reines authored
384 if ($topic_id)
385 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
386 if ($pun_config['o_topic_subscriptions'] != '1')
387 message($lang_common['No permission']);
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored
388
68b3934 @reines Adding forum subscriptions, see #142
reines authored
389 // Make sure the user can view the topic
7c97871 @daris Updating to use new db layer
daris authored
390 $query = $db->select(array('one' => '1'), 'topics AS t');
d23999f @reines Converting all queries in misc.php
reines authored
391
7c97871 @daris Updating to use new db layer
daris authored
392 $query->LeftJoin('fp', 'forum_perms AS fp', 'fp.forum_id = t.forum_id AND fp.group_id = :group_id');
d23999f @reines Converting all queries in misc.php
reines authored
393
394 $query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND t.id = :topic_id AND t.moved_to IS NULL';
395
396 $params = array(':group_id' => $pun_user['g_id'], ':topic_id' => $topic_id);
397
7c97871 @daris Updating to use new db layer
daris authored
398 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
399 if (empty($result))
68b3934 @reines Adding forum subscriptions, see #142
reines authored
400 message($lang_common['Bad request']);
401
d23999f @reines Converting all queries in misc.php
reines authored
402 unset ($result, $query, $params);
403
404 // Make sure the user isn't already subscribed
7c97871 @daris Updating to use new db layer
daris authored
405 $query = $db->select(array('one' => '1'), 'topic_subscriptions AS ts');
d23999f @reines Converting all queries in misc.php
reines authored
406 $query->where = 'ts.user_id = :user_id AND ts.topic_id = :topic_id';
407
408 $params = array(':user_id' => $pun_user['id'], ':topic_id' => $topic_id);
409
7c97871 @daris Updating to use new db layer
daris authored
410 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
411 if (!empty($result))
68b3934 @reines Adding forum subscriptions, see #142
reines authored
412 message($lang_misc['Already subscribed topic']);
413
d23999f @reines Converting all queries in misc.php
reines authored
414 unset ($result, $query, $params);
415
7c97871 @daris Updating to use new db layer
daris authored
416 $query = $db->insert(array('user_id' => ':user_id', 'topic_id' => ':topic_id'), 'topic_subscriptions');
d23999f @reines Converting all queries in misc.php
reines authored
417 $params = array(':user_id' => $pun_user['id'], ':topic_id' => $topic_id);
418
7c97871 @daris Updating to use new db layer
daris authored
419 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
420 unset ($query, $params);
68b3934 @reines Adding forum subscriptions, see #142
reines authored
421
422 redirect('viewtopic.php?id='.$topic_id, $lang_misc['Subscribe redirect']);
423 }
424
425 if ($forum_id)
426 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
427 if ($pun_config['o_forum_subscriptions'] != '1')
428 message($lang_common['No permission']);
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored
429
68b3934 @reines Adding forum subscriptions, see #142
reines authored
430 // Make sure the user can view the forum
7c97871 @daris Updating to use new db layer
daris authored
431 $query = $db->select(array('one' => '1'), 'forums AS f');
d23999f @reines Converting all queries in misc.php
reines authored
432
7c97871 @daris Updating to use new db layer
daris authored
433 $query->LeftJoin('fp', 'forum_perms AS fp', 'fp.forum_id = f.id AND fp.group_id = :group_id');
d23999f @reines Converting all queries in misc.php
reines authored
434
435 $query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND f.id = :forum_id';
436
437 $params = array(':group_id' => $pun_user['g_id'], ':forum_id' => $forum_id);
438
7c97871 @daris Updating to use new db layer
daris authored
439 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
440 if (empty($result))
68b3934 @reines Adding forum subscriptions, see #142
reines authored
441 message($lang_common['Bad request']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
442
d23999f @reines Converting all queries in misc.php
reines authored
443 unset ($result, $query, $params);
444
445 // Make sure the user isn't already subscribed
7c97871 @daris Updating to use new db layer
daris authored
446 $query = $db->select(array('one' => '1'), 'forum_subscriptions AS fs');
d23999f @reines Converting all queries in misc.php
reines authored
447 $query->where = 'fs.user_id = :user_id AND fs.forum_id = :forum_id';
448
449 $params = array(':user_id' => $pun_user['id'], ':forum_id' => $forum_id);
450
7c97871 @daris Updating to use new db layer
daris authored
451 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
452 if (!empty($result))
68b3934 @reines Adding forum subscriptions, see #142
reines authored
453 message($lang_misc['Already subscribed forum']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
454
d23999f @reines Converting all queries in misc.php
reines authored
455 unset ($result, $query, $params);
456
7c97871 @daris Updating to use new db layer
daris authored
457 $query = $db->insert(array('user_id' => ':user_id', 'forum_id' => ':forum_id'), 'forum_subscriptions');
d23999f @reines Converting all queries in misc.php
reines authored
458 $params = array(':user_id' => $pun_user['id'], ':forum_id' => $forum_id);
459
7c97871 @daris Updating to use new db layer
daris authored
460 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
461 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
462
68b3934 @reines Adding forum subscriptions, see #142
reines authored
463 redirect('viewforum.php?id='.$forum_id, $lang_misc['Subscribe redirect']);
464 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
465 }
466
467
68b3934 @reines Adding forum subscriptions, see #142
reines authored
468 else if ($action == 'unsubscribe')
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
469 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
470 if ($pun_user['is_guest'])
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
471 message($lang_common['No permission']);
472
68b3934 @reines Adding forum subscriptions, see #142
reines authored
473 $topic_id = isset($_GET['tid']) ? intval($_GET['tid']) : 0;
474 $forum_id = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
475 if ($topic_id < 1 && $forum_id < 1)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
476 message($lang_common['Bad request']);
477
68b3934 @reines Adding forum subscriptions, see #142
reines authored
478 if ($topic_id)
479 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
480 if ($pun_config['o_topic_subscriptions'] != '1')
481 message($lang_common['No permission']);
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored
482
d23999f @reines Converting all queries in misc.php
reines authored
483 // Make sure the user is already subscribed
7c97871 @daris Updating to use new db layer
daris authored
484 $query = $db->select(array('one' => '1'), 'topic_subscriptions AS ts');
d23999f @reines Converting all queries in misc.php
reines authored
485 $query->where = 'ts.user_id = :user_id AND ts.topic_id = :topic_id';
486
487 $params = array(':user_id' => $pun_user['id'], ':topic_id' => $topic_id);
488
7c97871 @daris Updating to use new db layer
daris authored
489 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
490 if (empty($result))
68b3934 @reines Adding forum subscriptions, see #142
reines authored
491 message($lang_misc['Not subscribed topic']);
492
d23999f @reines Converting all queries in misc.php
reines authored
493 unset ($result, $query, $params);
494
7c97871 @daris Updating to use new db layer
daris authored
495 $query = $db->delete('topic_subscriptions');
d23999f @reines Converting all queries in misc.php
reines authored
496 $query->where = 'user_id = :user_id AND topic_id = :topic_id';
497
498 $params = array(':user_id' => $pun_user['id'], ':topic_id' => $topic_id);
499
7c97871 @daris Updating to use new db layer
daris authored
500 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
501 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
502
68b3934 @reines Adding forum subscriptions, see #142
reines authored
503 redirect('viewtopic.php?id='.$topic_id, $lang_misc['Unsubscribe redirect']);
504 }
505
506 if ($forum_id)
507 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
508 if ($pun_config['o_forum_subscriptions'] != '1')
509 message($lang_common['No permission']);
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored
510
7c97871 @daris Updating to use new db layer
daris authored
511 $query = $db->select(array('one' => '1'), 'forum_subscriptions AS fs');
d23999f @reines Converting all queries in misc.php
reines authored
512 $query->where = 'fs.user_id = :user_id AND fs.forum_id = :forum_id';
513
514 $params = array(':user_id' => $pun_user['id'], ':forum_id' => $forum_id);
515
7c97871 @daris Updating to use new db layer
daris authored
516 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
517 if (empty($result))
68b3934 @reines Adding forum subscriptions, see #142
reines authored
518 message($lang_misc['Not subscribed forum']);
519
d23999f @reines Converting all queries in misc.php
reines authored
520 unset ($result, $query, $params);
521
7c97871 @daris Updating to use new db layer
daris authored
522 $query = $db->delete('forum_subscriptions');
d23999f @reines Converting all queries in misc.php
reines authored
523 $query->where = 'user_id = :user_id AND forum_id = :forum_id';
524
525 $params = array(':user_id' => $pun_user['id'], ':forum_id' => $forum_id);
526
7c97871 @daris Updating to use new db layer
daris authored
527 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
528 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
529
68b3934 @reines Adding forum subscriptions, see #142
reines authored
530 redirect('viewforum.php?id='.$forum_id, $lang_misc['Unsubscribe redirect']);
531 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
532 }
533
534
535 else
536 message($lang_common['Bad request']);
Something went wrong with that request. Please try again.