|
1 <?php |
|
2 /*********************************************************************** |
|
3 |
|
4 Copyright (C) 2002-2008 PunBB.org |
|
5 |
|
6 This file is part of PunBB. |
|
7 |
|
8 PunBB is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published |
|
10 by the Free Software Foundation; either version 2 of the License, |
|
11 or (at your option) any later version. |
|
12 |
|
13 PunBB is distributed in the hope that it will be useful, but |
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 GNU General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with this program; if not, write to the Free Software |
|
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|
21 MA 02111-1307 USA |
|
22 |
|
23 ************************************************************************/ |
|
24 |
|
25 |
|
26 if (isset($_GET['action'])) |
|
27 define('PUN_QUIET_VISIT', 1); |
|
28 |
|
29 // if (!defined('PUN_ROOT')) |
|
30 // define('PUN_ROOT', './'); |
|
31 // require PUN_ROOT.'include/common.php'; |
|
32 |
|
33 // import globals (I really hope this isn't dangerous) |
|
34 foreach ( $GLOBALS as $key => $_ ) |
|
35 { |
|
36 $$key =& $GLOBALS[$key]; |
|
37 } |
|
38 |
|
39 ($hook = get_hook('mi_start')) ? eval($hook) : null; |
|
40 |
|
41 // Load the misc.php language file |
|
42 require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php'; |
|
43 |
|
44 |
|
45 $action = isset($_GET['action']) ? $_GET['action'] : null; |
|
46 |
|
47 |
|
48 // Show the forum rules? |
|
49 if ($action == 'rules') |
|
50 { |
|
51 if ($pun_config['o_rules'] == '0') |
|
52 message($lang_common['Bad request']); |
|
53 |
|
54 // Setup breadcrumbs |
|
55 $pun_page['crumbs'] = array( |
|
56 array($pun_config['o_board_title'], pun_link($pun_url['index'])), |
|
57 $lang_common['Rules'] |
|
58 ); |
|
59 |
|
60 ($hook = get_hook('mi_rules_pre_header_load')) ? eval($hook) : null; |
|
61 |
|
62 define('PUN_PAGE', 'rules'); |
|
63 require PUN_ROOT.'header.php'; |
|
64 |
|
65 ?> |
|
66 <div id="pun-main" class="main"> |
|
67 |
|
68 <h1><span><?php echo end($pun_page['crumbs']) ?></span></h1> |
|
69 |
|
70 <div class="main-head"> |
|
71 <h2><span><?php echo $lang_common['Forum rules'] ?></span></h2> |
|
72 </div> |
|
73 |
|
74 <div class="main-content frm"> |
|
75 <div class="userbox"> |
|
76 <?php echo $pun_config['o_rules_message']."\n" ?> |
|
77 </div> |
|
78 </div> |
|
79 |
|
80 </div> |
|
81 <?php |
|
82 |
|
83 require PUN_ROOT.'footer.php'; |
|
84 } |
|
85 |
|
86 |
|
87 // Mark all topics/posts as read? |
|
88 else if ($action == 'markread') |
|
89 { |
|
90 if ($pun_user['is_guest']) |
|
91 message($lang_common['No permission']); |
|
92 |
|
93 ($hook = get_hook('mi_markread_selected')) ? eval($hook) : null; |
|
94 |
|
95 $query = array( |
|
96 'UPDATE' => 'users', |
|
97 'SET' => 'last_visit='.$pun_user['logged'], |
|
98 'WHERE' => 'id='.$pun_user['id'] |
|
99 ); |
|
100 |
|
101 ($hook = get_hook('mi_qr_update_last_visit')) ? eval($hook) : null; |
|
102 $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
103 |
|
104 // Reset tracked topics |
|
105 set_tracked_topics(null); |
|
106 |
|
107 pun_redirect($pun_user['prev_url'], $lang_misc['Mark read redirect']); |
|
108 } |
|
109 |
|
110 |
|
111 // Mark the topics/posts in a forum as read? |
|
112 else if ($action == 'markforumread') |
|
113 { |
|
114 if ($pun_user['is_guest']) |
|
115 message($lang_common['No permission']); |
|
116 |
|
117 ($hook = get_hook('mi_markforumread_selected')) ? eval($hook) : null; |
|
118 |
|
119 $tracked_topics = get_tracked_topics(); |
|
120 $tracked_topics['forums'][intval($_GET['fid'])] = time(); |
|
121 set_tracked_topics($tracked_topics); |
|
122 |
|
123 pun_redirect($pun_user['prev_url'], $lang_misc['Mark forum read redirect']); |
|
124 } |
|
125 |
|
126 |
|
127 // Send form e-mail? |
|
128 else if (isset($_GET['email'])) |
|
129 { |
|
130 if ($pun_user['is_guest']) |
|
131 message($lang_common['No permission']); |
|
132 |
|
133 ($hook = get_hook('mi_email_selected')) ? eval($hook) : null; |
|
134 |
|
135 // User pressed the cancel button |
|
136 if (isset($_POST['cancel'])) |
|
137 pun_redirect(htmlspecialchars($_POST['redirect_url']), $lang_common['Cancel']); |
|
138 |
|
139 $recipient_id = intval($_GET['email']); |
|
140 if ($recipient_id < 2) |
|
141 message($lang_common['Bad request']); |
|
142 |
|
143 $query = array( |
|
144 'SELECT' => 'u.username, u.email, u.email_setting', |
|
145 'FROM' => 'users AS u', |
|
146 'WHERE' => 'u.id='.$recipient_id |
|
147 ); |
|
148 |
|
149 ($hook = get_hook('mi_qr_get_form_email_data')) ? eval($hook) : null; |
|
150 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
151 if (!$pun_db->num_rows($result)) |
|
152 message($lang_common['Bad request']); |
|
153 |
|
154 list($recipient, $recipient_email, $email_setting) = $pun_db->fetch_row($result); |
|
155 |
|
156 if ($email_setting == 2 && !$pun_user['is_admmod']) |
|
157 message($lang_misc['Form e-mail disabled']); |
|
158 |
|
159 |
|
160 if (isset($_POST['form_sent'])) |
|
161 { |
|
162 ($hook = get_hook('mi_email_form_submitted')) ? eval($hook) : null; |
|
163 |
|
164 // Clean up message and subject from POST |
|
165 $subject = trim($_POST['req_subject']); |
|
166 $message = trim($_POST['req_message']); |
|
167 |
|
168 if ($subject == '') |
|
169 message($lang_misc['No e-mail subject']); |
|
170 else if ($message == '') |
|
171 message($lang_misc['No e-mail message']); |
|
172 else if (strlen($message) > 65535) |
|
173 message($lang_misc['Too long e-mail message']); |
|
174 |
|
175 // Load the "form e-mail" template |
|
176 $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/form_email.tpl')); |
|
177 |
|
178 // The first row contains the subject |
|
179 $first_crlf = strpos($mail_tpl, "\n"); |
|
180 $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8)); |
|
181 $mail_message = trim(substr($mail_tpl, $first_crlf)); |
|
182 |
|
183 $mail_subject = str_replace('<mail_subject>', $subject, $mail_subject); |
|
184 $mail_message = str_replace('<sender>', $pun_user['username'], $mail_message); |
|
185 $mail_message = str_replace('<board_title>', $pun_config['o_board_title'], $mail_message); |
|
186 $mail_message = str_replace('<mail_message>', $message, $mail_message); |
|
187 $mail_message = str_replace('<board_mailer>', sprintf($lang_common['Forum mailer'], $pun_config['o_board_title']), $mail_message); |
|
188 |
|
189 require_once PUN_ROOT.'include/email.php'; |
|
190 |
|
191 pun_mail($recipient_email, $mail_subject, $mail_message, '"'.str_replace('"', '', $pun_user['username']).'" <'.$pun_user['email'].'>'); |
|
192 |
|
193 pun_redirect(htmlspecialchars($_POST['redirect_url']), $lang_misc['E-mail sent redirect']); |
|
194 } |
|
195 |
|
196 // Setup form |
|
197 $pun_page['set_count'] = $pun_page['fld_count'] = 0; |
|
198 $pun_page['form_action'] = pun_link($pun_url['email'], $recipient_id); |
|
199 |
|
200 $pun_page['hidden_fields'] = array( |
|
201 '<input type="hidden" name="form_sent" value="1" />', |
|
202 '<input type="hidden" name="redirect_url" value="'.htmlspecialchars($pun_user['prev_url']).'" />' |
|
203 ); |
|
204 if ($pun_user['is_admmod']) |
|
205 $pun_page['hidden_fields'][] = '<input type="hidden" name="csrf_token" value="'.generate_form_token($pun_page['form_action']).'" />'; |
|
206 |
|
207 // Setup main heading |
|
208 $pun_page['main_head'] = sprintf($lang_misc['Send forum e-mail'], htmlspecialchars($recipient)); |
|
209 |
|
210 // Setup breadcrumbs |
|
211 $pun_page['crumbs'] = array( |
|
212 array($pun_config['o_board_title'], pun_link($pun_url['index'])), |
|
213 $lang_common['Send forum e-mail'] |
|
214 ); |
|
215 |
|
216 ($hook = get_hook('mi_email_pre_header_load')) ? eval($hook) : null; |
|
217 |
|
218 define('PUN_PAGE', 'formemail'); |
|
219 require PUN_ROOT.'header.php'; |
|
220 |
|
221 ?> |
|
222 <div id="pun-main" class="main"> |
|
223 |
|
224 <h1><span><?php echo end($pun_page['crumbs']) ?></span></h1> |
|
225 |
|
226 <div class="main-head"> |
|
227 <h2><span><?php echo $pun_page['main_head'] ?></span></h2> |
|
228 </div> |
|
229 |
|
230 <div class="main-content frm"> |
|
231 <div class="frm-info"> |
|
232 <p class="important"><?php echo $lang_misc['E-mail disclosure note'] ?></p> |
|
233 </div> |
|
234 <div id="req-msg" class="frm-warn"> |
|
235 <p class="important"><?php printf($lang_common['Required warn'], '<em class="req-text">'.$lang_common['Required'].'</em>') ?></p> |
|
236 </div> |
|
237 <form id="afocus" class="frm-form" method="post" accept-charset="utf-8" action="<?php echo $pun_page['form_action'] ?>"> |
|
238 <div class="hidden"> |
|
239 <?php echo implode("\n\t\t\t\t", $pun_page['hidden_fields'])."\n" ?> |
|
240 </div> |
|
241 <?php ($hook = get_hook('mi_email_pre_fieldset')) ? eval($hook) : null; ?> |
|
242 <fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>"> |
|
243 <legend class="frm-legend"><strong><?php echo $lang_misc['Write e-mail'] ?></strong></legend> |
|
244 <div class="frm-fld text required longtext"> |
|
245 <label for="fld<?php echo ++$pun_page['fld_count'] ?>"> |
|
246 <span class="fld-label"><?php echo $lang_misc['E-mail subject'] ?></span><br /> |
|
247 <span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="req_subject" size="75" maxlength="70" /></span> |
|
248 <em class="req-text"><?php echo $lang_common['Required'] ?></em> |
|
249 </label> |
|
250 </div> |
|
251 <?php ($hook = get_hook('mi_email_pre_message_contents')) ? eval($hook) : null; ?> |
|
252 <div class="frm-fld text textarea required"> |
|
253 <label for="fld<?php echo ++$pun_page['fld_count'] ?>"> |
|
254 <span class="fld-label"><?php echo $lang_misc['E-mail message'] ?></span><br /> |
|
255 <span class="fld-input"><textarea id="fld<?php echo $pun_page['fld_count'] ?>" name="req_message" rows="10" cols="95"></textarea></span> |
|
256 <em class="req-text"><?php echo $lang_common['Required'] ?></em> |
|
257 </label> |
|
258 </div> |
|
259 </fieldset> |
|
260 <?php ($hook = get_hook('mi_email_post_fieldset')) ? eval($hook) : null; ?> |
|
261 <div class="frm-buttons"> |
|
262 <span class="submit"><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" title="<?php echo $lang_common['Submit title'] ?>" /></span> |
|
263 <span class="cancel"><input type="submit" name="cancel" value="<?php echo $lang_common['Cancel'] ?>" /></span> |
|
264 </div> |
|
265 </form> |
|
266 </div> |
|
267 |
|
268 </div> |
|
269 <?php |
|
270 |
|
271 require PUN_ROOT.'footer.php'; |
|
272 } |
|
273 |
|
274 |
|
275 // Report a post? |
|
276 else if (isset($_GET['report'])) |
|
277 { |
|
278 if ($pun_user['is_guest']) |
|
279 message($lang_common['No permission']); |
|
280 |
|
281 ($hook = get_hook('mi_report_selected')) ? eval($hook) : null; |
|
282 |
|
283 $post_id = intval($_GET['report']); |
|
284 if ($post_id < 1) |
|
285 message($lang_common['Bad request']); |
|
286 |
|
287 // User pressed the cancel button |
|
288 if (isset($_POST['cancel'])) |
|
289 pun_redirect(pun_link($pun_url['post'], $post_id), $lang_common['Cancel redirect']); |
|
290 |
|
291 |
|
292 if (isset($_POST['form_sent'])) |
|
293 { |
|
294 ($hook = get_hook('mi_report_form_submitted')) ? eval($hook) : null; |
|
295 |
|
296 // Clean up reason from POST |
|
297 $reason = pun_linebreaks(trim($_POST['req_reason'])); |
|
298 if ($reason == '') |
|
299 message($lang_misc['No reason']); |
|
300 |
|
301 // Get some info about the topic we're reporting |
|
302 $query = array( |
|
303 'SELECT' => 't.id, t.subject, t.forum_id', |
|
304 'FROM' => 'posts AS p', |
|
305 'JOINS' => array( |
|
306 array( |
|
307 'INNER JOIN' => 'topics AS t', |
|
308 'ON' => 't.id=p.topic_id' |
|
309 ) |
|
310 ), |
|
311 'WHERE' => 'p.id='.$post_id |
|
312 ); |
|
313 |
|
314 ($hook = get_hook('mi_qr_get_report_topic_data')) ? eval($hook) : null; |
|
315 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
316 if (!$pun_db->num_rows($result)) |
|
317 message($lang_common['Bad request']); |
|
318 |
|
319 list($topic_id, $subject, $forum_id) = $pun_db->fetch_row($result); |
|
320 |
|
321 ($hook = get_hook('mi_report_pre_reports_sent')) ? eval($hook) : null; |
|
322 |
|
323 // Should we use the internal report handling? |
|
324 if ($pun_config['o_report_method'] == 0 || $pun_config['o_report_method'] == 2) |
|
325 { |
|
326 $query = array( |
|
327 'INSERT' => 'post_id, topic_id, forum_id, reported_by, created, message', |
|
328 'INTO' => 'reports', |
|
329 'VALUES' => $post_id.', '.$topic_id.', '.$forum_id.', '.$pun_user['id'].', '.time().', \''.$pun_db->escape($reason).'\'' |
|
330 ); |
|
331 |
|
332 ($hook = get_hook('mi_add_report')) ? eval($hook) : null; |
|
333 $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
334 } |
|
335 |
|
336 // Should we e-mail the report? |
|
337 if ($pun_config['o_report_method'] == 1 || $pun_config['o_report_method'] == 2) |
|
338 { |
|
339 // We send it to the complete mailing-list in one swoop |
|
340 if ($pun_config['o_mailing_list'] != '') |
|
341 { |
|
342 $mail_subject = 'Report('.$forum_id.') - \''.$subject.'\''; |
|
343 $mail_message = 'User \''.$pun_user['username'].'\' has reported the following message:'."\n".pun_link($pun_url['post'], $post_id)."\n\n".'Reason:'."\n".$reason; |
|
344 |
|
345 require PUN_ROOT.'include/email.php'; |
|
346 |
|
347 pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message); |
|
348 } |
|
349 } |
|
350 |
|
351 pun_redirect(pun_link($pun_url['post'], $post_id), $lang_misc['Report redirect']); |
|
352 } |
|
353 |
|
354 // Setup form |
|
355 $pun_page['set_count'] = $pun_page['fld_count'] = 0; |
|
356 $pun_page['form_action'] = pun_link($pun_url['report'], $post_id); |
|
357 |
|
358 $pun_page['hidden_fields'][] = '<input type="hidden" name="form_sent" value="1" />'; |
|
359 if ($pun_user['is_admmod']) |
|
360 $pun_page['hidden_fields'][] = '<input type="hidden" name="csrf_token" value="'.generate_form_token($pun_page['form_action']).'" />'; |
|
361 |
|
362 // Setup breadcrumbs |
|
363 $pun_page['crumbs'] = array( |
|
364 array($pun_config['o_board_title'], pun_link($pun_url['index'])), |
|
365 $lang_misc['Report post'] |
|
366 ); |
|
367 |
|
368 ($hook = get_hook('mi_report_pre_header_load')) ? eval($hook) : null; |
|
369 |
|
370 define('PUN_PAGE', 'report'); |
|
371 require PUN_ROOT.'header.php'; |
|
372 |
|
373 ?> |
|
374 <div id="pun-main" class="main"> |
|
375 |
|
376 <h1><span><?php echo end($pun_page['crumbs']) ?></span></h1> |
|
377 |
|
378 <div class="main-head"> |
|
379 <h2><span><?php echo $lang_misc['Send report'] ?></span></h2> |
|
380 </div> |
|
381 |
|
382 <div class="main-content frm"> |
|
383 <div id="req-msg" class="frm-warn"> |
|
384 <p class="important"><?php printf($lang_common['Required warn'], '<em class="req-text">'.$lang_common['Required'].'</em>') ?></p> |
|
385 </div> |
|
386 <form id="afocus" class="frm-form" method="post" accept-charset="utf-8" action="<?php echo $pun_page['form_action'] ?>"> |
|
387 <div class="hidden"> |
|
388 <?php echo implode("\n\t\t\t\t", $pun_page['hidden_fields'])."\n" ?> |
|
389 </div> |
|
390 <?php ($hook = get_hook('mi_report_pre_fieldset')) ? eval($hook) : null; ?> |
|
391 <fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>"> |
|
392 <legend class="frm-legend"><strong><?php echo $lang_common['Required information'] ?></strong></legend> |
|
393 <div class="frm-fld text textarea required"> |
|
394 <label for="fld<?php echo ++$pun_page['fld_count'] ?>"> |
|
395 <span class="fld-label"><?php echo $lang_misc['Reason'] ?></span><br /> |
|
396 <span class="fld-input"><textarea id="fld<?php echo $pun_page['fld_count'] ?>" name="req_reason" rows="5" cols="60"></textarea></span><br /> |
|
397 <em class="req-text"><?php echo $lang_common['Required'] ?></em> |
|
398 <span class="fld-help"><?php echo $lang_misc['Reason help'] ?></span> |
|
399 </label> |
|
400 </div> |
|
401 </fieldset> |
|
402 <?php ($hook = get_hook('mi_report_post_fieldset')) ? eval($hook) : null; ?> |
|
403 <div class="frm-buttons"> |
|
404 <span class="submit"><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" title="<?php echo $lang_common['Submit title'] ?>" /></span> |
|
405 <span class="cancel"><input type="submit" name="cancel" value="<?php echo $lang_common['Cancel'] ?>" /></span> |
|
406 </div> |
|
407 </form> |
|
408 </div> |
|
409 |
|
410 </div> |
|
411 <?php |
|
412 |
|
413 require PUN_ROOT.'footer.php'; |
|
414 } |
|
415 |
|
416 |
|
417 // Subscribe to a topic? |
|
418 else if (isset($_GET['subscribe'])) |
|
419 { |
|
420 if ($pun_user['is_guest'] || $pun_config['o_subscriptions'] != '1') |
|
421 message($lang_common['No permission']); |
|
422 |
|
423 ($hook = get_hook('mi_subscribe_selected')) ? eval($hook) : null; |
|
424 |
|
425 $topic_id = intval($_GET['subscribe']); |
|
426 if ($topic_id < 1) |
|
427 message($lang_common['Bad request']); |
|
428 |
|
429 $query = array( |
|
430 'SELECT' => '1', |
|
431 'FROM' => 'subscriptions AS s', |
|
432 'WHERE' => 'user_id='.$pun_user['id'].' AND topic_id='.$topic_id |
|
433 ); |
|
434 |
|
435 ($hook = get_hook('mi_qr_check_subscribed')) ? eval($hook) : null; |
|
436 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
437 if ($pun_db->num_rows($result)) |
|
438 message($lang_misc['Already subscribed']); |
|
439 |
|
440 $query = array( |
|
441 'INSERT' => 'user_id, topic_id', |
|
442 'INTO' => 'subscriptions', |
|
443 'VALUES' => $pun_user['id'].' ,'.$topic_id |
|
444 ); |
|
445 |
|
446 ($hook = get_hook('mi_add_subscription')) ? eval($hook) : null; |
|
447 $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
448 |
|
449 pun_redirect(pun_link($pun_url['topic'], $topic_id), $lang_misc['Subscribe redirect']); |
|
450 } |
|
451 |
|
452 |
|
453 // Unsubscribe from a topic? |
|
454 else if (isset($_GET['unsubscribe'])) |
|
455 { |
|
456 if ($pun_user['is_guest'] || $pun_config['o_subscriptions'] != '1') |
|
457 message($lang_common['No permission']); |
|
458 |
|
459 ($hook = get_hook('mi_unsubscribe_selected')) ? eval($hook) : null; |
|
460 |
|
461 $topic_id = intval($_GET['unsubscribe']); |
|
462 if ($topic_id < 1) |
|
463 message($lang_common['Bad request']); |
|
464 |
|
465 $query = array( |
|
466 'SELECT' => '1', |
|
467 'FROM' => 'subscriptions AS s', |
|
468 'WHERE' => 'user_id='.$pun_user['id'].' AND topic_id='.$topic_id |
|
469 ); |
|
470 |
|
471 ($hook = get_hook('mi_qr_check_subscribed2')) ? eval($hook) : null; |
|
472 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
473 if (!$pun_db->num_rows($result)) |
|
474 message($lang_misc['Not subscribed']); |
|
475 |
|
476 $query = array( |
|
477 'DELETE' => 'subscriptions', |
|
478 'WHERE' => 'user_id='.$pun_user['id'].' AND topic_id='.$topic_id |
|
479 ); |
|
480 |
|
481 ($hook = get_hook('mi_qr_delete_subscription')) ? eval($hook) : null; |
|
482 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
483 |
|
484 pun_redirect(pun_link($pun_url['topic'], $topic_id), $lang_misc['Unsubscribe redirect']); |
|
485 } |
|
486 |
|
487 |
|
488 ($hook = get_hook('mi_new_action')) ? eval($hook) : null; |
|
489 |
|
490 message($lang_common['Bad request']); |