Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 545 lines (397 sloc) 19.01 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 /**
7c5edc2 @reines Updating copyright notices for 2012
reines authored
4 * Copyright (C) 2008-2012 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
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
17 $lang->load('misc');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
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'))
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
25 message($lang->t('Bad request'));
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
26
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
27 // Load the register.php language file
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
28 $lang->load('register');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
29
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
30 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang->t('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">
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
36 <div class="hd"><h2><span><?php echo $lang->t('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'])
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
52 message($lang->t('No permission'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
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
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
65 redirect('index.php', $lang->t('Mark read redirect'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
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'])
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
73 message($lang->t('No permission'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
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)
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
77 message($lang->t('Bad request'));
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
78
79 $tracked_topics = get_tracked_topics();
80 $tracked_topics['forums'][$fid] = time();
81 set_tracked_topics($tracked_topics);
82
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
83 redirect('viewforum.php?id='.$fid, $lang->t('Mark forum read redirect'));
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
84 }
85
86
87 else if (isset($_GET['email']))
88 {
89 if ($pun_user['is_guest'] || $pun_user['g_send_email'] == '0')
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
90 message($lang->t('No permission'));
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored
91
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
92 $recipient_id = intval($_GET['email']);
93 if ($recipient_id < 2)
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
94 message($lang->t('Bad request'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
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))
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
103 message($lang->t('Bad request'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
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'])
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
109 message($lang->t('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 == '')
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
119 message($lang->t('No email subject'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
120 else if ($message == '')
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
121 message($lang->t('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)
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
123 message($lang->t('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)
a5a577f @daris Use $lang->t() instead of sprintf/printf
daris authored
126 message($lang->t('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
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
154 redirect(htmlspecialchars($_POST['redirect_url']), $lang->t('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
e793d7e @Quy #598: Fixed undefined index: path in misc.php
Quy authored
166 // Make sure the path component exists
167 if (!isset($referrer['path']))
168 $referrer['path'] = '';
169
c7be20e @reines Replacing more references to o_base_url. This shouldnt have any effec…
reines authored
170 $valid = parse_url(get_base_url());
ce8b3a0 @reines Updating the referrer checks in login.php and misc.php to allow https…
reines authored
171 // Remove www subdomain if it exists
172 if (strpos($valid['host'], 'www.') === 0)
173 $valid['host'] = substr($valid['host'], 4);
174
e793d7e @Quy #598: Fixed undefined index: path in misc.php
Quy authored
175 // Make sure the path component exists
176 if (!isset($valid['path']))
177 $valid['path'] = '';
178
b1deb69 @reines Updating all the regular expressions to use % as a delimiter. Before …
reines authored
179 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
180 $redirect_url = $_SERVER['HTTP_REFERER'];
181 }
182
183 if (!isset($redirect_url))
184 $redirect_url = 'profile.php?id='.$recipient_id;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
185
586bc04 @franzliedke Merge branch 'fluxbb-2.0-db' into fluxbb-2.0
franzliedke authored
186 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang->t('Send email to').' '.pun_htmlspecialchars($recipient['username']));
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
187 $required_fields = array('req_subject' => $lang->t('Email subject'), 'req_message' => $lang->t('Email message'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
188 $focus_element = array('email', 'req_subject');
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored
189 define('PUN_ACTIVE_PAGE', 'index');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
190 require PUN_ROOT.'header.php';
191
192 ?>
1417352 Added some id's to scripts that generate more than one type of page. …
Paul Sullivan authored
193 <div id="emailform" class="blockform">
586bc04 @franzliedke Merge branch 'fluxbb-2.0-db' into fluxbb-2.0
franzliedke authored
194 <h2><span><?php echo $lang->t('Send email to') ?> <?php echo pun_htmlspecialchars($recipient['username']) ?></span></h2>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
195 <div class="box">
196 <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;}">
197 <div class="inform">
198 <fieldset>
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
199 <legend><?php echo $lang->t('Write email') ?></legend>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
200 <div class="infldset txtarea">
201 <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
202 <input type="hidden" name="redirect_url" value="<?php echo pun_htmlspecialchars($redirect_url) ?>" />
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
203 <label class="required"><strong><?php echo $lang->t('Email subject') ?> <span><?php echo $lang->t('Required') ?></span></strong><br />
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
204 <input class="longinput" type="text" name="req_subject" size="75" maxlength="70" tabindex="1" /><br /></label>
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
205 <label class="required"><strong><?php echo $lang->t('Email message') ?> <span><?php echo $lang->t('Required') ?></span></strong><br />
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
206 <textarea name="req_message" rows="10" cols="75" tabindex="2"></textarea><br /></label>
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
207 <p><?php echo $lang->t('Email disclosure note') ?></p>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
208 </div>
209 </fieldset>
210 </div>
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
211 <p class="buttons"><input type="submit" name="submit" value="<?php echo $lang->t('Submit') ?>" tabindex="3" accesskey="s" /> <a href="javascript:history.go(-1)"><?php echo $lang->t('Go back') ?></a></p>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
212 </form>
213 </div>
214 </div>
215 <?php
216
217 require PUN_ROOT.'footer.php';
218 }
219
220
221 else if (isset($_GET['report']))
222 {
223 if ($pun_user['is_guest'])
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
224 message($lang->t('No permission'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
225
226 $post_id = intval($_GET['report']);
227 if ($post_id < 1)
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
228 message($lang->t('Bad request'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
229
230 if (isset($_POST['form_sent']))
231 {
232 // Clean up reason from POST
233 $reason = pun_linebreaks(pun_trim($_POST['req_reason']));
234 if ($reason == '')
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
235 message($lang->t('No reason'));
9f259f2 @reines Adding a check to the max length of a reason when making a report. Re…
reines authored
236 else if (strlen($reason) > 65535) // TEXT field can only hold 65535 bytes
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
237 message($lang->t('Reason too long'));
56ab252 Updated copyright texts.
Frank Smit authored
238
bc60ad8 @franzliedke #465: Implement report flood protection.
franzliedke authored
239 if ($pun_user['last_report_sent'] != '' && (time() - $pun_user['last_report_sent']) < $pun_user['g_report_flood'] && (time() - $pun_user['last_report_sent']) >= 0)
a5a577f @daris Use $lang->t() instead of sprintf/printf
daris authored
240 message($lang->t('Report flood', $pun_user['g_report_flood']));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
241
242 // Get the topic ID
7c97871 @daris Updating to use new db layer
daris authored
243 $query = $db->select(array('topic_id' => 'p.topic_id'), 'posts AS p');
d1807fa @reines Converting some more queries
reines authored
244 $query->where = 'p.id = :post_id';
245
246 $params = array(':post_id' => $post_id);
247
7c97871 @daris Updating to use new db layer
daris authored
248 $result = $query->run($params);
d1807fa @reines Converting some more queries
reines authored
249 if (empty($result))
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
250 message($lang->t('Bad request'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
251
d1807fa @reines Converting some more queries
reines authored
252 $topic_id = $result[0]['topic_id'];
253 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
254
255 // Get the subject and forum ID
7c97871 @daris Updating to use new db layer
daris authored
256 $query = $db->select(array('subject' => 't.subject', 'forum_id' => 't.forum_id'), 'topics AS t');
d1807fa @reines Converting some more queries
reines authored
257 $query->where = 't.id = :topic_id';
258
259 $params = array(':topic_id' => $topic_id);
260
7c97871 @daris Updating to use new db layer
daris authored
261 $result = $query->run($params);
d1807fa @reines Converting some more queries
reines authored
262 if (empty($result))
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
263 message($lang->t('Bad request'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
264
0cfb58d @reines Updating some more queries
reines authored
265 $cur_post = $result[0];
d1807fa @reines Converting some more queries
reines authored
266 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
267
268 // Should we use the internal report handling?
ce8dd32 @Quy Made code consistent.
Quy authored
269 if ($pun_config['o_report_method'] == '0' || $pun_config['o_report_method'] == '2')
d1807fa @reines Converting some more queries
reines authored
270 {
7c97871 @daris Updating to use new db layer
daris authored
271 $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
272 $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
273
7c97871 @daris Updating to use new db layer
daris authored
274 $query->run($params);
d1807fa @reines Converting some more queries
reines authored
275 unset ($query, $params);
276 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
277
fde0054 @franzliedke Changed e-mail to email throughout the code. Be over with it!
franzliedke authored
278 // Should we email the report?
ce8dd32 @Quy Made code consistent.
Quy authored
279 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
280 {
281 // We send it to the complete mailing-list in one swoop
282 if ($pun_config['o_mailing_list'] != '')
56ab252 Updated copyright texts.
Frank Smit authored
283 {
c247d6c @franzliedke #422: Use templates for all emails. Thanks to Daris for the patch!
franzliedke authored
284 // Load the "new report" template
285 $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/new_report.tpl'));
286
287 // The first row contains the subject
288 $first_crlf = strpos($mail_tpl, "\n");
289 $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
290 $mail_message = trim(substr($mail_tpl, $first_crlf));
291
731999f @franzliedke Merge commit 'bf7116c9aa232c42dc38457906d6060e126a74fc' into fluxbb-2…
franzliedke authored
292 $mail_subject = str_replace('<forum_id>', $cur_post['forum_id'], $mail_subject);
293 $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
294 $mail_message = str_replace('<username>', $pun_user['username'], $mail_message);
295 $mail_message = str_replace('<post_url>', get_base_url().'/viewtopic.php?pid='.$post_id.'#p'.$post_id, $mail_message);
296 $mail_message = str_replace('<reason>', $reason, $mail_message);
9bb1cf1 @franzliedke #476: Make "forum mailer" properly translateable.
franzliedke authored
297 $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
298
299 require PUN_ROOT.'include/email.php';
300
301 pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
302 }
303 }
56ab252 Updated copyright texts.
Frank Smit authored
304
7c97871 @daris Updating to use new db layer
daris authored
305 $query = $db->update(array('last_report_sent' => ':now'), 'users');
d1807fa @reines Converting some more queries
reines authored
306 $query->where = 'id = :user_id';
307
308 $params = array(':now' => time(), ':user_id' => $pun_user['id']);
309
7c97871 @daris Updating to use new db layer
daris authored
310 $query->run($params);
d1807fa @reines Converting some more queries
reines authored
311 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
312
f466eef @reines Caching the number of unzapped reports.
reines authored
313 $cache->delete('num_reports');
314
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
315 redirect('viewtopic.php?pid='.$post_id.'#p'.$post_id, $lang->t('Report redirect'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
316 }
317
698e711 @reines Added breadcrumbs to the report page to be consistent with the delete…
reines authored
318 // Fetch some info about the post, the topic and the forum
7c97871 @daris Updating to use new db layer
daris authored
319 $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
320
861460d @daris PHP methods are not case sensitive, but replace InnerJoin and LeftJoi…
daris authored
321 $query->innerJoin('t', 'topics AS t', 't.id = p.topic_id');
d1807fa @reines Converting some more queries
reines authored
322
861460d @daris PHP methods are not case sensitive, but replace InnerJoin and LeftJoi…
daris authored
323 $query->innerJoin('f', 'forums AS f', 'f.id = t.forum_id');
d1807fa @reines Converting some more queries
reines authored
324
861460d @daris PHP methods are not case sensitive, but replace InnerJoin and LeftJoi…
daris authored
325 $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
326
327 $query->where = '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.id = :post_id';
328
b612470 @franzliedke Change query parameter name.
franzliedke authored
329 $params = array(':group_id' => $pun_user['g_id'], ':post_id' => $post_id);
d1807fa @reines Converting some more queries
reines authored
330
7c97871 @daris Updating to use new db layer
daris authored
331 $result = $query->run($params);
d1807fa @reines Converting some more queries
reines authored
332 if (empty($result))
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
333 message($lang->t('Bad request'));
698e711 @reines Added breadcrumbs to the report page to be consistent with the delete…
reines authored
334
d1807fa @reines Converting some more queries
reines authored
335 $cur_post = $result[0];
336 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
337
d2c7e7e @reines Censoring post subject on the report and delete pages
reines authored
338 if ($pun_config['o_censoring'] == '1')
339 $cur_post['subject'] = censor_words($cur_post['subject']);
340
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
341 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang->t('Report post'));
342 $required_fields = array('req_reason' => $lang->t('Reason'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
343 $focus_element = array('report', 'req_reason');
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored
344 define('PUN_ACTIVE_PAGE', 'index');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
345 require PUN_ROOT.'header.php';
346
347 ?>
698e711 @reines Added breadcrumbs to the report page to be consistent with the delete…
reines authored
348 <div class="linkst">
349 <div class="inbox">
350 <ul class="crumbs">
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
351 <li><a href="index.php"><?php echo $lang->t('Index') ?></a></li>
8d5b6c0 @reines Replacing some entities with their UTF-8 character equivalent.
reines authored
352 <li><span&#160;</span><a href="viewforum.php?id=<?php echo $cur_post['fid'] ?>"><?php echo pun_htmlspecialchars($cur_post['forum_name']) ?></a></li>
353 <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>
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
354 <li><span&#160;</span><strong><?php echo $lang->t('Report post') ?></strong></li>
698e711 @reines Added breadcrumbs to the report page to be consistent with the delete…
reines authored
355 </ul>
356 </div>
357 </div>
358
4a01224 Added id to the report form because it is now different from other pa…
Paul Sullivan authored
359 <div id="reportform" class="blockform">
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
360 <h2><span><?php echo $lang->t('Report post') ?></span></h2>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
361 <div class="box">
362 <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;}">
363 <div class="inform">
364 <fieldset>
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
365 <legend><?php echo $lang->t('Reason desc') ?></legend>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
366 <div class="infldset txtarea">
367 <input type="hidden" name="form_sent" value="1" />
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
368 <label class="required"><strong><?php echo $lang->t('Reason') ?> <span><?php echo $lang->t('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
369 </div>
370 </fieldset>
371 </div>
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
372 <p class="buttons"><input type="submit" name="submit" value="<?php echo $lang->t('Submit') ?>" accesskey="s" /> <a href="javascript:history.go(-1)"><?php echo $lang->t('Go back') ?></a></p>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
373 </form>
374 </div>
375 </div>
376 <?php
377
378 require PUN_ROOT.'footer.php';
379 }
380
381
68b3934 @reines Adding forum subscriptions, see #142
reines authored
382 else if ($action == 'subscribe')
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
383 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
384 if ($pun_user['is_guest'])
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
385 message($lang->t('No permission'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
386
68b3934 @reines Adding forum subscriptions, see #142
reines authored
387 $topic_id = isset($_GET['tid']) ? intval($_GET['tid']) : 0;
388 $forum_id = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
389 if ($topic_id < 1 && $forum_id < 1)
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
390 message($lang->t('Bad request'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
391
68b3934 @reines Adding forum subscriptions, see #142
reines authored
392 if ($topic_id)
393 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
394 if ($pun_config['o_topic_subscriptions'] != '1')
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
395 message($lang->t('No permission'));
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored
396
68b3934 @reines Adding forum subscriptions, see #142
reines authored
397 // Make sure the user can view the topic
7c97871 @daris Updating to use new db layer
daris authored
398 $query = $db->select(array('one' => '1'), 'topics AS t');
d23999f @reines Converting all queries in misc.php
reines authored
399
861460d @daris PHP methods are not case sensitive, but replace InnerJoin and LeftJoi…
daris authored
400 $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
401
402 $query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND t.id = :topic_id AND t.moved_to IS NULL';
403
404 $params = array(':group_id' => $pun_user['g_id'], ':topic_id' => $topic_id);
405
7c97871 @daris Updating to use new db layer
daris authored
406 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
407 if (empty($result))
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
408 message($lang->t('Bad request'));
68b3934 @reines Adding forum subscriptions, see #142
reines authored
409
d23999f @reines Converting all queries in misc.php
reines authored
410 unset ($result, $query, $params);
411
412 // Make sure the user isn't already subscribed
7c97871 @daris Updating to use new db layer
daris authored
413 $query = $db->select(array('one' => '1'), 'topic_subscriptions AS ts');
d23999f @reines Converting all queries in misc.php
reines authored
414 $query->where = 'ts.user_id = :user_id AND ts.topic_id = :topic_id';
415
416 $params = array(':user_id' => $pun_user['id'], ':topic_id' => $topic_id);
417
7c97871 @daris Updating to use new db layer
daris authored
418 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
419 if (!empty($result))
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
420 message($lang->t('Already subscribed topic'));
68b3934 @reines Adding forum subscriptions, see #142
reines authored
421
d23999f @reines Converting all queries in misc.php
reines authored
422 unset ($result, $query, $params);
423
7c97871 @daris Updating to use new db layer
daris authored
424 $query = $db->insert(array('user_id' => ':user_id', 'topic_id' => ':topic_id'), 'topic_subscriptions');
d23999f @reines Converting all queries in misc.php
reines authored
425 $params = array(':user_id' => $pun_user['id'], ':topic_id' => $topic_id);
426
7c97871 @daris Updating to use new db layer
daris authored
427 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
428 unset ($query, $params);
68b3934 @reines Adding forum subscriptions, see #142
reines authored
429
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
430 redirect('viewtopic.php?id='.$topic_id, $lang->t('Subscribe redirect'));
68b3934 @reines Adding forum subscriptions, see #142
reines authored
431 }
432
433 if ($forum_id)
434 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
435 if ($pun_config['o_forum_subscriptions'] != '1')
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
436 message($lang->t('No permission'));
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored
437
68b3934 @reines Adding forum subscriptions, see #142
reines authored
438 // Make sure the user can view the forum
7c97871 @daris Updating to use new db layer
daris authored
439 $query = $db->select(array('one' => '1'), 'forums AS f');
d23999f @reines Converting all queries in misc.php
reines authored
440
861460d @daris PHP methods are not case sensitive, but replace InnerJoin and LeftJoi…
daris authored
441 $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
442
443 $query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND f.id = :forum_id';
444
445 $params = array(':group_id' => $pun_user['g_id'], ':forum_id' => $forum_id);
446
7c97871 @daris Updating to use new db layer
daris authored
447 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
448 if (empty($result))
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
449 message($lang->t('Bad request'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
450
d23999f @reines Converting all queries in misc.php
reines authored
451 unset ($result, $query, $params);
452
453 // Make sure the user isn't already subscribed
7c97871 @daris Updating to use new db layer
daris authored
454 $query = $db->select(array('one' => '1'), 'forum_subscriptions AS fs');
d23999f @reines Converting all queries in misc.php
reines authored
455 $query->where = 'fs.user_id = :user_id AND fs.forum_id = :forum_id';
456
457 $params = array(':user_id' => $pun_user['id'], ':forum_id' => $forum_id);
458
7c97871 @daris Updating to use new db layer
daris authored
459 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
460 if (!empty($result))
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
461 message($lang->t('Already subscribed forum'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
462
d23999f @reines Converting all queries in misc.php
reines authored
463 unset ($result, $query, $params);
464
7c97871 @daris Updating to use new db layer
daris authored
465 $query = $db->insert(array('user_id' => ':user_id', 'forum_id' => ':forum_id'), 'forum_subscriptions');
d23999f @reines Converting all queries in misc.php
reines authored
466 $params = array(':user_id' => $pun_user['id'], ':forum_id' => $forum_id);
467
7c97871 @daris Updating to use new db layer
daris authored
468 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
469 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
470
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
471 redirect('viewforum.php?id='.$forum_id, $lang->t('Subscribe redirect'));
68b3934 @reines Adding forum subscriptions, see #142
reines authored
472 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
473 }
474
475
68b3934 @reines Adding forum subscriptions, see #142
reines authored
476 else if ($action == 'unsubscribe')
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
477 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
478 if ($pun_user['is_guest'])
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
479 message($lang->t('No permission'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
480
68b3934 @reines Adding forum subscriptions, see #142
reines authored
481 $topic_id = isset($_GET['tid']) ? intval($_GET['tid']) : 0;
482 $forum_id = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
483 if ($topic_id < 1 && $forum_id < 1)
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
484 message($lang->t('Bad request'));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
485
68b3934 @reines Adding forum subscriptions, see #142
reines authored
486 if ($topic_id)
487 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
488 if ($pun_config['o_topic_subscriptions'] != '1')
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
489 message($lang->t('No permission'));
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored
490
d23999f @reines Converting all queries in misc.php
reines authored
491 // Make sure the user is already subscribed
7c97871 @daris Updating to use new db layer
daris authored
492 $query = $db->select(array('one' => '1'), 'topic_subscriptions AS ts');
d23999f @reines Converting all queries in misc.php
reines authored
493 $query->where = 'ts.user_id = :user_id AND ts.topic_id = :topic_id';
494
495 $params = array(':user_id' => $pun_user['id'], ':topic_id' => $topic_id);
496
7c97871 @daris Updating to use new db layer
daris authored
497 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
498 if (empty($result))
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
499 message($lang->t('Not subscribed topic'));
68b3934 @reines Adding forum subscriptions, see #142
reines authored
500
d23999f @reines Converting all queries in misc.php
reines authored
501 unset ($result, $query, $params);
502
7c97871 @daris Updating to use new db layer
daris authored
503 $query = $db->delete('topic_subscriptions');
d23999f @reines Converting all queries in misc.php
reines authored
504 $query->where = 'user_id = :user_id AND topic_id = :topic_id';
505
506 $params = array(':user_id' => $pun_user['id'], ':topic_id' => $topic_id);
507
7c97871 @daris Updating to use new db layer
daris authored
508 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
509 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
510
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
511 redirect('viewtopic.php?id='.$topic_id, $lang->t('Unsubscribe redirect'));
68b3934 @reines Adding forum subscriptions, see #142
reines authored
512 }
513
514 if ($forum_id)
515 {
1016a03 @franzliedke Ticket #142: Add option for switching forum subscriptions on/off.
franzliedke authored
516 if ($pun_config['o_forum_subscriptions'] != '1')
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
517 message($lang->t('No permission'));
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored
518
7c97871 @daris Updating to use new db layer
daris authored
519 $query = $db->select(array('one' => '1'), 'forum_subscriptions AS fs');
d23999f @reines Converting all queries in misc.php
reines authored
520 $query->where = 'fs.user_id = :user_id AND fs.forum_id = :forum_id';
521
522 $params = array(':user_id' => $pun_user['id'], ':forum_id' => $forum_id);
523
7c97871 @daris Updating to use new db layer
daris authored
524 $result = $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
525 if (empty($result))
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
526 message($lang->t('Not subscribed forum'));
68b3934 @reines Adding forum subscriptions, see #142
reines authored
527
d23999f @reines Converting all queries in misc.php
reines authored
528 unset ($result, $query, $params);
529
7c97871 @daris Updating to use new db layer
daris authored
530 $query = $db->delete('forum_subscriptions');
d23999f @reines Converting all queries in misc.php
reines authored
531 $query->where = 'user_id = :user_id AND forum_id = :forum_id';
532
533 $params = array(':user_id' => $pun_user['id'], ':forum_id' => $forum_id);
534
7c97871 @daris Updating to use new db layer
daris authored
535 $query->run($params);
d23999f @reines Converting all queries in misc.php
reines authored
536 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
537
89d19d2 @franzliedke #498: Convert remaining front-end files to use the new language system.
franzliedke authored
538 redirect('viewforum.php?id='.$forum_id, $lang->t('Unsubscribe redirect'));
68b3934 @reines Adding forum subscriptions, see #142
reines authored
539 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored
540 }
541
542
543 else
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored
544 message($lang->t('Bad request'));
Something went wrong with that request. Please try again.