Chris@76
|
1 <?php
|
Chris@76
|
2
|
Chris@76
|
3 /**
|
Chris@76
|
4 * Simple Machines Forum (SMF)
|
Chris@76
|
5 *
|
Chris@76
|
6 * @package SMF
|
Chris@76
|
7 * @author Simple Machines http://www.simplemachines.org
|
Chris@76
|
8 * @copyright 2011 Simple Machines
|
Chris@76
|
9 * @license http://www.simplemachines.org/about/smf/license.php BSD
|
Chris@76
|
10 *
|
Chris@76
|
11 * @version 2.0
|
Chris@76
|
12 */
|
Chris@76
|
13
|
Chris@76
|
14 if (!defined('SMF'))
|
Chris@76
|
15 die('Hacking attempt...');
|
Chris@76
|
16
|
Chris@76
|
17 /* The job of this file is to handle everything related to posting replies,
|
Chris@76
|
18 new topics, quotes, and modifications to existing posts. It also handles
|
Chris@76
|
19 quoting posts by way of javascript.
|
Chris@76
|
20
|
Chris@76
|
21 void Post()
|
Chris@76
|
22 - handles showing the post screen, loading the post to be modified, and
|
Chris@76
|
23 loading any post quoted.
|
Chris@76
|
24 - additionally handles previews of posts.
|
Chris@76
|
25 - uses the Post template and language file, main sub template.
|
Chris@76
|
26 - allows wireless access using the protocol_post sub template.
|
Chris@76
|
27 - requires different permissions depending on the actions, but most
|
Chris@76
|
28 notably post_new, post_reply_own, and post_reply_any.
|
Chris@76
|
29 - shows options for the editing and posting of calendar events and
|
Chris@76
|
30 attachments, as well as the posting of polls.
|
Chris@76
|
31 - accessed from ?action=post.
|
Chris@76
|
32
|
Chris@76
|
33 void Post2()
|
Chris@76
|
34 - actually posts or saves the message composed with Post().
|
Chris@76
|
35 - requires various permissions depending on the action.
|
Chris@76
|
36 - handles attachment, post, and calendar saving.
|
Chris@76
|
37 - sends off notifications, and allows for announcements and moderation.
|
Chris@76
|
38 - accessed from ?action=post2.
|
Chris@76
|
39
|
Chris@76
|
40 void AnnounceTopic()
|
Chris@76
|
41 - handle the announce topic function (action=announce).
|
Chris@76
|
42 - checks the topic announcement permissions and loads the announcement
|
Chris@76
|
43 template.
|
Chris@76
|
44 - requires the announce_topic permission.
|
Chris@76
|
45 - uses the ManageMembers template and Post language file.
|
Chris@76
|
46 - call the right function based on the sub-action.
|
Chris@76
|
47
|
Chris@76
|
48 void AnnouncementSelectMembergroup()
|
Chris@76
|
49 - lets the user select the membergroups that will receive the topic
|
Chris@76
|
50 announcement.
|
Chris@76
|
51
|
Chris@76
|
52 void AnnouncementSend()
|
Chris@76
|
53 - splits the members to be sent a topic announcement into chunks.
|
Chris@76
|
54 - composes notification messages in all languages needed.
|
Chris@76
|
55 - does the actual sending of the topic announcements in chunks.
|
Chris@76
|
56 - calculates a rough estimate of the percentage items sent.
|
Chris@76
|
57
|
Chris@76
|
58 void notifyMembersBoard(notifyData)
|
Chris@76
|
59 - notifies members who have requested notification for new topics
|
Chris@76
|
60 posted on a board of said posts.
|
Chris@76
|
61 - receives data on the topics to send out notifications to by the passed in array.
|
Chris@76
|
62 - only sends notifications to those who can *currently* see the topic
|
Chris@76
|
63 (it doesn't matter if they could when they requested notification.)
|
Chris@76
|
64 - loads the Post language file multiple times for each language if the
|
Chris@76
|
65 userLanguage setting is set.
|
Chris@76
|
66
|
Chris@76
|
67 void getTopic()
|
Chris@76
|
68 - gets a summary of the most recent posts in a topic.
|
Chris@76
|
69 - depends on the topicSummaryPosts setting.
|
Chris@76
|
70 - if you are editing a post, only shows posts previous to that post.
|
Chris@76
|
71
|
Chris@76
|
72 void QuoteFast()
|
Chris@76
|
73 - loads a post an inserts it into the current editing text box.
|
Chris@76
|
74 - uses the Post language file.
|
Chris@76
|
75 - uses special (sadly browser dependent) javascript to parse entities
|
Chris@76
|
76 for internationalization reasons.
|
Chris@76
|
77 - accessed with ?action=quotefast.
|
Chris@76
|
78
|
Chris@76
|
79 void JavaScriptModify()
|
Chris@76
|
80 // !!!
|
Chris@76
|
81 */
|
Chris@76
|
82
|
Chris@76
|
83 function Post()
|
Chris@76
|
84 {
|
Chris@76
|
85 global $txt, $scripturl, $topic, $modSettings, $board;
|
Chris@76
|
86 global $user_info, $sc, $board_info, $context, $settings;
|
Chris@76
|
87 global $sourcedir, $options, $smcFunc, $language;
|
Chris@76
|
88
|
Chris@76
|
89 loadLanguage('Post');
|
Chris@76
|
90
|
Chris@76
|
91 // You can't reply with a poll... hacker.
|
Chris@76
|
92 if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg']))
|
Chris@76
|
93 unset($_REQUEST['poll']);
|
Chris@76
|
94
|
Chris@76
|
95 // Posting an event?
|
Chris@76
|
96 $context['make_event'] = isset($_REQUEST['calendar']);
|
Chris@76
|
97 $context['robot_no_index'] = true;
|
Chris@76
|
98
|
Chris@76
|
99 // You must be posting to *some* board.
|
Chris@76
|
100 if (empty($board) && !$context['make_event'])
|
Chris@76
|
101 fatal_lang_error('no_board', false);
|
Chris@76
|
102
|
Chris@76
|
103 require_once($sourcedir . '/Subs-Post.php');
|
Chris@76
|
104
|
Chris@76
|
105 if (isset($_REQUEST['xml']))
|
Chris@76
|
106 {
|
Chris@76
|
107 $context['sub_template'] = 'post';
|
Chris@76
|
108
|
Chris@76
|
109 // Just in case of an earlier error...
|
Chris@76
|
110 $context['preview_message'] = '';
|
Chris@76
|
111 $context['preview_subject'] = '';
|
Chris@76
|
112 }
|
Chris@76
|
113
|
Chris@76
|
114 // No message is complete without a topic.
|
Chris@76
|
115 if (empty($topic) && !empty($_REQUEST['msg']))
|
Chris@76
|
116 {
|
Chris@76
|
117 $request = $smcFunc['db_query']('', '
|
Chris@76
|
118 SELECT id_topic
|
Chris@76
|
119 FROM {db_prefix}messages
|
Chris@76
|
120 WHERE id_msg = {int:msg}',
|
Chris@76
|
121 array(
|
Chris@76
|
122 'msg' => (int) $_REQUEST['msg'],
|
Chris@76
|
123 ));
|
Chris@76
|
124 if ($smcFunc['db_num_rows']($request) != 1)
|
Chris@76
|
125 unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
|
Chris@76
|
126 else
|
Chris@76
|
127 list ($topic) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
128 $smcFunc['db_free_result']($request);
|
Chris@76
|
129 }
|
Chris@76
|
130
|
Chris@76
|
131 // Check if it's locked. It isn't locked if no topic is specified.
|
Chris@76
|
132 if (!empty($topic))
|
Chris@76
|
133 {
|
Chris@76
|
134 $request = $smcFunc['db_query']('', '
|
Chris@76
|
135 SELECT
|
Chris@76
|
136 t.locked, IFNULL(ln.id_topic, 0) AS notify, t.is_sticky, t.id_poll, t.id_last_msg, mf.id_member,
|
Chris@76
|
137 t.id_first_msg, mf.subject,
|
Chris@76
|
138 CASE WHEN ml.poster_time > ml.modified_time THEN ml.poster_time ELSE ml.modified_time END AS last_post_time
|
Chris@76
|
139 FROM {db_prefix}topics AS t
|
Chris@76
|
140 LEFT JOIN {db_prefix}log_notify AS ln ON (ln.id_topic = t.id_topic AND ln.id_member = {int:current_member})
|
Chris@76
|
141 LEFT JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
|
Chris@76
|
142 LEFT JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
|
Chris@76
|
143 WHERE t.id_topic = {int:current_topic}
|
Chris@76
|
144 LIMIT 1',
|
Chris@76
|
145 array(
|
Chris@76
|
146 'current_member' => $user_info['id'],
|
Chris@76
|
147 'current_topic' => $topic,
|
Chris@76
|
148 )
|
Chris@76
|
149 );
|
Chris@76
|
150 list ($locked, $context['notify'], $sticky, $pollID, $context['topic_last_message'], $id_member_poster, $id_first_msg, $first_subject, $lastPostTime) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
151 $smcFunc['db_free_result']($request);
|
Chris@76
|
152
|
Chris@76
|
153 // If this topic already has a poll, they sure can't add another.
|
Chris@76
|
154 if (isset($_REQUEST['poll']) && $pollID > 0)
|
Chris@76
|
155 unset($_REQUEST['poll']);
|
Chris@76
|
156
|
Chris@76
|
157 if (empty($_REQUEST['msg']))
|
Chris@76
|
158 {
|
Chris@76
|
159 if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any')))
|
Chris@76
|
160 is_not_guest();
|
Chris@76
|
161
|
Chris@76
|
162 // By default the reply will be approved...
|
Chris@76
|
163 $context['becomes_approved'] = true;
|
Chris@76
|
164 if ($id_member_poster != $user_info['id'])
|
Chris@76
|
165 {
|
Chris@76
|
166 if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
|
Chris@76
|
167 $context['becomes_approved'] = false;
|
Chris@76
|
168 else
|
Chris@76
|
169 isAllowedTo('post_reply_any');
|
Chris@76
|
170 }
|
Chris@76
|
171 elseif (!allowedTo('post_reply_any'))
|
Chris@76
|
172 {
|
Chris@76
|
173 if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own'))
|
Chris@76
|
174 $context['becomes_approved'] = false;
|
Chris@76
|
175 else
|
Chris@76
|
176 isAllowedTo('post_reply_own');
|
Chris@76
|
177 }
|
Chris@76
|
178 }
|
Chris@76
|
179 else
|
Chris@76
|
180 $context['becomes_approved'] = true;
|
Chris@76
|
181
|
Chris@76
|
182 $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own'));
|
Chris@76
|
183 $context['can_sticky'] = allowedTo('make_sticky') && !empty($modSettings['enableStickyTopics']);
|
Chris@76
|
184
|
Chris@76
|
185 $context['notify'] = !empty($context['notify']);
|
Chris@76
|
186 $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky;
|
Chris@76
|
187 }
|
Chris@76
|
188 else
|
Chris@76
|
189 {
|
Chris@76
|
190 $context['becomes_approved'] = true;
|
Chris@76
|
191 if ((!$context['make_event'] || !empty($board)))
|
Chris@76
|
192 {
|
Chris@76
|
193 if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
|
Chris@76
|
194 $context['becomes_approved'] = false;
|
Chris@76
|
195 else
|
Chris@76
|
196 isAllowedTo('post_new');
|
Chris@76
|
197 }
|
Chris@76
|
198
|
Chris@76
|
199 $locked = 0;
|
Chris@76
|
200 // !!! These won't work if you're making an event.
|
Chris@76
|
201 $context['can_lock'] = allowedTo(array('lock_any', 'lock_own'));
|
Chris@76
|
202 $context['can_sticky'] = allowedTo('make_sticky') && !empty($modSettings['enableStickyTopics']);
|
Chris@76
|
203
|
Chris@76
|
204 $context['notify'] = !empty($context['notify']);
|
Chris@76
|
205 $context['sticky'] = !empty($_REQUEST['sticky']);
|
Chris@76
|
206 }
|
Chris@76
|
207
|
Chris@76
|
208 // !!! These won't work if you're posting an event!
|
Chris@76
|
209 $context['can_notify'] = allowedTo('mark_any_notify');
|
Chris@76
|
210 $context['can_move'] = allowedTo('move_any');
|
Chris@76
|
211 $context['move'] = !empty($_REQUEST['move']);
|
Chris@76
|
212 $context['announce'] = !empty($_REQUEST['announce']);
|
Chris@76
|
213 // You can only announce topics that will get approved...
|
Chris@76
|
214 $context['can_announce'] = allowedTo('announce_topic') && $context['becomes_approved'];
|
Chris@76
|
215 $context['locked'] = !empty($locked) || !empty($_REQUEST['lock']);
|
Chris@76
|
216 $context['can_quote'] = empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC']));
|
Chris@76
|
217
|
Chris@76
|
218 // Generally don't show the approval box... (Assume we want things approved)
|
Chris@76
|
219 $context['show_approval'] = false;
|
Chris@76
|
220
|
Chris@76
|
221 // An array to hold all the attachments for this topic.
|
Chris@76
|
222 $context['current_attachments'] = array();
|
Chris@76
|
223
|
Chris@76
|
224 // Don't allow a post if it's locked and you aren't all powerful.
|
Chris@76
|
225 if ($locked && !allowedTo('moderate_board'))
|
Chris@76
|
226 fatal_lang_error('topic_locked', false);
|
Chris@76
|
227 // Check the users permissions - is the user allowed to add or post a poll?
|
Chris@76
|
228 if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
|
Chris@76
|
229 {
|
Chris@76
|
230 // New topic, new poll.
|
Chris@76
|
231 if (empty($topic))
|
Chris@76
|
232 isAllowedTo('poll_post');
|
Chris@76
|
233 // This is an old topic - but it is yours! Can you add to it?
|
Chris@76
|
234 elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any'))
|
Chris@76
|
235 isAllowedTo('poll_add_own');
|
Chris@76
|
236 // If you're not the owner, can you add to any poll?
|
Chris@76
|
237 else
|
Chris@76
|
238 isAllowedTo('poll_add_any');
|
Chris@76
|
239
|
Chris@76
|
240 require_once($sourcedir . '/Subs-Members.php');
|
Chris@76
|
241 $allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
|
Chris@76
|
242
|
Chris@76
|
243 // Set up the poll options.
|
Chris@76
|
244 $context['poll_options'] = array(
|
Chris@76
|
245 'max_votes' => empty($_POST['poll_max_votes']) ? '1' : max(1, $_POST['poll_max_votes']),
|
Chris@76
|
246 'hide' => empty($_POST['poll_hide']) ? 0 : $_POST['poll_hide'],
|
Chris@76
|
247 'expire' => !isset($_POST['poll_expire']) ? '' : $_POST['poll_expire'],
|
Chris@76
|
248 'change_vote' => isset($_POST['poll_change_vote']),
|
Chris@76
|
249 'guest_vote' => isset($_POST['poll_guest_vote']),
|
Chris@76
|
250 'guest_vote_enabled' => in_array(-1, $allowedVoteGroups['allowed']),
|
Chris@76
|
251 );
|
Chris@76
|
252
|
Chris@76
|
253 // Make all five poll choices empty.
|
Chris@76
|
254 $context['choices'] = array(
|
Chris@76
|
255 array('id' => 0, 'number' => 1, 'label' => '', 'is_last' => false),
|
Chris@76
|
256 array('id' => 1, 'number' => 2, 'label' => '', 'is_last' => false),
|
Chris@76
|
257 array('id' => 2, 'number' => 3, 'label' => '', 'is_last' => false),
|
Chris@76
|
258 array('id' => 3, 'number' => 4, 'label' => '', 'is_last' => false),
|
Chris@76
|
259 array('id' => 4, 'number' => 5, 'label' => '', 'is_last' => true)
|
Chris@76
|
260 );
|
Chris@76
|
261 }
|
Chris@76
|
262
|
Chris@76
|
263 if ($context['make_event'])
|
Chris@76
|
264 {
|
Chris@76
|
265 // They might want to pick a board.
|
Chris@76
|
266 if (!isset($context['current_board']))
|
Chris@76
|
267 $context['current_board'] = 0;
|
Chris@76
|
268
|
Chris@76
|
269 // Start loading up the event info.
|
Chris@76
|
270 $context['event'] = array();
|
Chris@76
|
271 $context['event']['title'] = isset($_REQUEST['evtitle']) ? htmlspecialchars(stripslashes($_REQUEST['evtitle'])) : '';
|
Chris@76
|
272
|
Chris@76
|
273 $context['event']['id'] = isset($_REQUEST['eventid']) ? (int) $_REQUEST['eventid'] : -1;
|
Chris@76
|
274 $context['event']['new'] = $context['event']['id'] == -1;
|
Chris@76
|
275
|
Chris@76
|
276 // Permissions check!
|
Chris@76
|
277 isAllowedTo('calendar_post');
|
Chris@76
|
278
|
Chris@76
|
279 // Editing an event? (but NOT previewing!?)
|
Chris@76
|
280 if (!$context['event']['new'] && !isset($_REQUEST['subject']))
|
Chris@76
|
281 {
|
Chris@76
|
282 // If the user doesn't have permission to edit the post in this topic, redirect them.
|
Chris@76
|
283 if ((empty($id_member_poster) || $id_member_poster != $user_info['id'] || !allowedTo('modify_own')) && !allowedTo('modify_any'))
|
Chris@76
|
284 {
|
Chris@76
|
285 require_once($sourcedir . '/Calendar.php');
|
Chris@76
|
286 return CalendarPost();
|
Chris@76
|
287 }
|
Chris@76
|
288
|
Chris@76
|
289 // Get the current event information.
|
Chris@76
|
290 $request = $smcFunc['db_query']('', '
|
Chris@76
|
291 SELECT
|
Chris@76
|
292 id_member, title, MONTH(start_date) AS month, DAYOFMONTH(start_date) AS day,
|
Chris@76
|
293 YEAR(start_date) AS year, (TO_DAYS(end_date) - TO_DAYS(start_date)) AS span
|
Chris@76
|
294 FROM {db_prefix}calendar
|
Chris@76
|
295 WHERE id_event = {int:id_event}
|
Chris@76
|
296 LIMIT 1',
|
Chris@76
|
297 array(
|
Chris@76
|
298 'id_event' => $context['event']['id'],
|
Chris@76
|
299 )
|
Chris@76
|
300 );
|
Chris@76
|
301 $row = $smcFunc['db_fetch_assoc']($request);
|
Chris@76
|
302 $smcFunc['db_free_result']($request);
|
Chris@76
|
303
|
Chris@76
|
304 // Make sure the user is allowed to edit this event.
|
Chris@76
|
305 if ($row['id_member'] != $user_info['id'])
|
Chris@76
|
306 isAllowedTo('calendar_edit_any');
|
Chris@76
|
307 elseif (!allowedTo('calendar_edit_any'))
|
Chris@76
|
308 isAllowedTo('calendar_edit_own');
|
Chris@76
|
309
|
Chris@76
|
310 $context['event']['month'] = $row['month'];
|
Chris@76
|
311 $context['event']['day'] = $row['day'];
|
Chris@76
|
312 $context['event']['year'] = $row['year'];
|
Chris@76
|
313 $context['event']['title'] = $row['title'];
|
Chris@76
|
314 $context['event']['span'] = $row['span'] + 1;
|
Chris@76
|
315 }
|
Chris@76
|
316 else
|
Chris@76
|
317 {
|
Chris@76
|
318 $today = getdate();
|
Chris@76
|
319
|
Chris@76
|
320 // You must have a month and year specified!
|
Chris@76
|
321 if (!isset($_REQUEST['month']))
|
Chris@76
|
322 $_REQUEST['month'] = $today['mon'];
|
Chris@76
|
323 if (!isset($_REQUEST['year']))
|
Chris@76
|
324 $_REQUEST['year'] = $today['year'];
|
Chris@76
|
325
|
Chris@76
|
326 $context['event']['month'] = (int) $_REQUEST['month'];
|
Chris@76
|
327 $context['event']['year'] = (int) $_REQUEST['year'];
|
Chris@76
|
328 $context['event']['day'] = isset($_REQUEST['day']) ? $_REQUEST['day'] : ($_REQUEST['month'] == $today['mon'] ? $today['mday'] : 0);
|
Chris@76
|
329 $context['event']['span'] = isset($_REQUEST['span']) ? $_REQUEST['span'] : 1;
|
Chris@76
|
330
|
Chris@76
|
331 // Make sure the year and month are in the valid range.
|
Chris@76
|
332 if ($context['event']['month'] < 1 || $context['event']['month'] > 12)
|
Chris@76
|
333 fatal_lang_error('invalid_month', false);
|
Chris@76
|
334 if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear'])
|
Chris@76
|
335 fatal_lang_error('invalid_year', false);
|
Chris@76
|
336
|
Chris@76
|
337 // Get a list of boards they can post in.
|
Chris@76
|
338 $boards = boardsAllowedTo('post_new');
|
Chris@76
|
339 if (empty($boards))
|
Chris@76
|
340 fatal_lang_error('cannot_post_new', 'user');
|
Chris@76
|
341
|
Chris@76
|
342 // Load a list of boards for this event in the context.
|
Chris@76
|
343 require_once($sourcedir . '/Subs-MessageIndex.php');
|
Chris@76
|
344 $boardListOptions = array(
|
Chris@76
|
345 'included_boards' => in_array(0, $boards) ? null : $boards,
|
Chris@76
|
346 'not_redirection' => true,
|
Chris@76
|
347 'use_permissions' => true,
|
Chris@76
|
348 'selected_board' => empty($context['current_board']) ? $modSettings['cal_defaultboard'] : $context['current_board'],
|
Chris@76
|
349 );
|
Chris@76
|
350 $context['event']['categories'] = getBoardList($boardListOptions);
|
Chris@76
|
351 }
|
Chris@76
|
352
|
Chris@76
|
353 // Find the last day of the month.
|
Chris@76
|
354 $context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year']));
|
Chris@76
|
355
|
Chris@76
|
356 $context['event']['board'] = !empty($board) ? $board : $modSettings['cal_defaultboard'];
|
Chris@76
|
357 }
|
Chris@76
|
358
|
Chris@76
|
359 if (empty($context['post_errors']))
|
Chris@76
|
360 $context['post_errors'] = array();
|
Chris@76
|
361
|
Chris@76
|
362 // See if any new replies have come along.
|
Chris@76
|
363 if (empty($_REQUEST['msg']) && !empty($topic))
|
Chris@76
|
364 {
|
Chris@76
|
365 if (empty($options['no_new_reply_warning']) && isset($_REQUEST['last_msg']) && $context['topic_last_message'] > $_REQUEST['last_msg'])
|
Chris@76
|
366 {
|
Chris@76
|
367 $request = $smcFunc['db_query']('', '
|
Chris@76
|
368 SELECT COUNT(*)
|
Chris@76
|
369 FROM {db_prefix}messages
|
Chris@76
|
370 WHERE id_topic = {int:current_topic}
|
Chris@76
|
371 AND id_msg > {int:last_msg}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
|
Chris@76
|
372 AND approved = {int:approved}') . '
|
Chris@76
|
373 LIMIT 1',
|
Chris@76
|
374 array(
|
Chris@76
|
375 'current_topic' => $topic,
|
Chris@76
|
376 'last_msg' => (int) $_REQUEST['last_msg'],
|
Chris@76
|
377 'approved' => 1,
|
Chris@76
|
378 )
|
Chris@76
|
379 );
|
Chris@76
|
380 list ($context['new_replies']) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
381 $smcFunc['db_free_result']($request);
|
Chris@76
|
382
|
Chris@76
|
383 if (!empty($context['new_replies']))
|
Chris@76
|
384 {
|
Chris@76
|
385 if ($context['new_replies'] == 1)
|
Chris@76
|
386 $txt['error_new_reply'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
|
Chris@76
|
387 else
|
Chris@76
|
388 $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']);
|
Chris@76
|
389
|
Chris@76
|
390 // If they've come from the display page then we treat the error differently....
|
Chris@76
|
391 if (isset($_GET['last_msg']))
|
Chris@76
|
392 $newRepliesError = $context['new_replies'];
|
Chris@76
|
393 else
|
Chris@76
|
394 $context['post_error'][$context['new_replies'] == 1 ? 'new_reply' : 'new_replies'] = true;
|
Chris@76
|
395
|
Chris@76
|
396 $modSettings['topicSummaryPosts'] = $context['new_replies'] > $modSettings['topicSummaryPosts'] ? max($modSettings['topicSummaryPosts'], 5) : $modSettings['topicSummaryPosts'];
|
Chris@76
|
397 }
|
Chris@76
|
398 }
|
Chris@76
|
399 // Check whether this is a really old post being bumped...
|
Chris@76
|
400 if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject']))
|
Chris@76
|
401 $oldTopicError = true;
|
Chris@76
|
402 }
|
Chris@76
|
403
|
Chris@76
|
404 // Get a response prefix (like 'Re:') in the default forum language.
|
Chris@76
|
405 if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
|
Chris@76
|
406 {
|
Chris@76
|
407 if ($language === $user_info['language'])
|
Chris@76
|
408 $context['response_prefix'] = $txt['response_prefix'];
|
Chris@76
|
409 else
|
Chris@76
|
410 {
|
Chris@76
|
411 loadLanguage('index', $language, false);
|
Chris@76
|
412 $context['response_prefix'] = $txt['response_prefix'];
|
Chris@76
|
413 loadLanguage('index');
|
Chris@76
|
414 }
|
Chris@76
|
415 cache_put_data('response_prefix', $context['response_prefix'], 600);
|
Chris@76
|
416 }
|
Chris@76
|
417
|
Chris@76
|
418 // Previewing, modifying, or posting?
|
Chris@76
|
419 if (isset($_REQUEST['message']) || !empty($context['post_error']))
|
Chris@76
|
420 {
|
Chris@76
|
421 // Validate inputs.
|
Chris@76
|
422 if (empty($context['post_error']))
|
Chris@76
|
423 {
|
Chris@76
|
424 if (htmltrim__recursive(htmlspecialchars__recursive($_REQUEST['subject'])) == '')
|
Chris@76
|
425 $context['post_error']['no_subject'] = true;
|
Chris@76
|
426 if (htmltrim__recursive(htmlspecialchars__recursive($_REQUEST['message'])) == '')
|
Chris@76
|
427 $context['post_error']['no_message'] = true;
|
Chris@76
|
428 if (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength'])
|
Chris@76
|
429 $context['post_error']['long_message'] = true;
|
Chris@76
|
430
|
Chris@76
|
431 // Are you... a guest?
|
Chris@76
|
432 if ($user_info['is_guest'])
|
Chris@76
|
433 {
|
Chris@76
|
434 $_REQUEST['guestname'] = !isset($_REQUEST['guestname']) ? '' : trim($_REQUEST['guestname']);
|
Chris@76
|
435 $_REQUEST['email'] = !isset($_REQUEST['email']) ? '' : trim($_REQUEST['email']);
|
Chris@76
|
436
|
Chris@76
|
437 // Validate the name and email.
|
Chris@76
|
438 if (!isset($_REQUEST['guestname']) || trim(strtr($_REQUEST['guestname'], '_', ' ')) == '')
|
Chris@76
|
439 $context['post_error']['no_name'] = true;
|
Chris@76
|
440 elseif ($smcFunc['strlen']($_REQUEST['guestname']) > 25)
|
Chris@76
|
441 $context['post_error']['long_name'] = true;
|
Chris@76
|
442 else
|
Chris@76
|
443 {
|
Chris@76
|
444 require_once($sourcedir . '/Subs-Members.php');
|
Chris@76
|
445 if (isReservedName(htmlspecialchars($_REQUEST['guestname']), 0, true, false))
|
Chris@76
|
446 $context['post_error']['bad_name'] = true;
|
Chris@76
|
447 }
|
Chris@76
|
448
|
Chris@76
|
449 if (empty($modSettings['guest_post_no_email']))
|
Chris@76
|
450 {
|
Chris@76
|
451 if (!isset($_REQUEST['email']) || $_REQUEST['email'] == '')
|
Chris@76
|
452 $context['post_error']['no_email'] = true;
|
Chris@76
|
453 elseif (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_REQUEST['email']) == 0)
|
Chris@76
|
454 $context['post_error']['bad_email'] = true;
|
Chris@76
|
455 }
|
Chris@76
|
456 }
|
Chris@76
|
457
|
Chris@76
|
458 // This is self explanatory - got any questions?
|
Chris@76
|
459 if (isset($_REQUEST['question']) && trim($_REQUEST['question']) == '')
|
Chris@76
|
460 $context['post_error']['no_question'] = true;
|
Chris@76
|
461
|
Chris@76
|
462 // This means they didn't click Post and get an error.
|
Chris@76
|
463 $really_previewing = true;
|
Chris@76
|
464 }
|
Chris@76
|
465 else
|
Chris@76
|
466 {
|
Chris@76
|
467 if (!isset($_REQUEST['subject']))
|
Chris@76
|
468 $_REQUEST['subject'] = '';
|
Chris@76
|
469 if (!isset($_REQUEST['message']))
|
Chris@76
|
470 $_REQUEST['message'] = '';
|
Chris@76
|
471 if (!isset($_REQUEST['icon']))
|
Chris@76
|
472 $_REQUEST['icon'] = 'xx';
|
Chris@76
|
473
|
Chris@76
|
474 // They are previewing if they asked to preview (i.e. came from quick reply).
|
Chris@76
|
475 $really_previewing = !empty($_POST['preview']);
|
Chris@76
|
476 }
|
Chris@76
|
477
|
Chris@76
|
478 // In order to keep the approval status flowing through, we have to pass it through the form...
|
Chris@76
|
479 $context['becomes_approved'] = empty($_REQUEST['not_approved']);
|
Chris@76
|
480 $context['show_approval'] = isset($_REQUEST['approve']) ? ($_REQUEST['approve'] ? 2 : 1) : 0;
|
Chris@76
|
481 $context['can_announce'] &= $context['becomes_approved'];
|
Chris@76
|
482
|
Chris@76
|
483 // Set up the inputs for the form.
|
Chris@76
|
484 $form_subject = strtr($smcFunc['htmlspecialchars']($_REQUEST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
|
Chris@76
|
485 $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES);
|
Chris@76
|
486
|
Chris@76
|
487 // Make sure the subject isn't too long - taking into account special characters.
|
Chris@76
|
488 if ($smcFunc['strlen']($form_subject) > 100)
|
Chris@76
|
489 $form_subject = $smcFunc['substr']($form_subject, 0, 100);
|
Chris@76
|
490
|
Chris@76
|
491 // Have we inadvertently trimmed off the subject of useful information?
|
Chris@76
|
492 if ($smcFunc['htmltrim']($form_subject) === '')
|
Chris@76
|
493 $context['post_error']['no_subject'] = true;
|
Chris@76
|
494
|
Chris@76
|
495 // Any errors occurred?
|
Chris@76
|
496 if (!empty($context['post_error']))
|
Chris@76
|
497 {
|
Chris@76
|
498 loadLanguage('Errors');
|
Chris@76
|
499
|
Chris@76
|
500 $context['error_type'] = 'minor';
|
Chris@76
|
501
|
Chris@76
|
502 $context['post_error']['messages'] = array();
|
Chris@76
|
503 foreach ($context['post_error'] as $post_error => $dummy)
|
Chris@76
|
504 {
|
Chris@76
|
505 if ($post_error == 'messages')
|
Chris@76
|
506 continue;
|
Chris@76
|
507
|
Chris@76
|
508 if ($post_error == 'long_message')
|
Chris@76
|
509 $txt['error_' . $post_error] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
|
Chris@76
|
510
|
Chris@76
|
511 $context['post_error']['messages'][] = $txt['error_' . $post_error];
|
Chris@76
|
512
|
Chris@76
|
513 // If it's not a minor error flag it as such.
|
Chris@76
|
514 if (!in_array($post_error, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification')))
|
Chris@76
|
515 $context['error_type'] = 'serious';
|
Chris@76
|
516 }
|
Chris@76
|
517 }
|
Chris@76
|
518
|
Chris@76
|
519 if (isset($_REQUEST['poll']))
|
Chris@76
|
520 {
|
Chris@76
|
521 $context['question'] = isset($_REQUEST['question']) ? $smcFunc['htmlspecialchars'](trim($_REQUEST['question'])) : '';
|
Chris@76
|
522
|
Chris@76
|
523 $context['choices'] = array();
|
Chris@76
|
524 $choice_id = 0;
|
Chris@76
|
525
|
Chris@76
|
526 $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']);
|
Chris@76
|
527 foreach ($_POST['options'] as $option)
|
Chris@76
|
528 {
|
Chris@76
|
529 if (trim($option) == '')
|
Chris@76
|
530 continue;
|
Chris@76
|
531
|
Chris@76
|
532 $context['choices'][] = array(
|
Chris@76
|
533 'id' => $choice_id++,
|
Chris@76
|
534 'number' => $choice_id,
|
Chris@76
|
535 'label' => $option,
|
Chris@76
|
536 'is_last' => false
|
Chris@76
|
537 );
|
Chris@76
|
538 }
|
Chris@76
|
539
|
Chris@76
|
540 if (count($context['choices']) < 2)
|
Chris@76
|
541 {
|
Chris@76
|
542 $context['choices'][] = array(
|
Chris@76
|
543 'id' => $choice_id++,
|
Chris@76
|
544 'number' => $choice_id,
|
Chris@76
|
545 'label' => '',
|
Chris@76
|
546 'is_last' => false
|
Chris@76
|
547 );
|
Chris@76
|
548 $context['choices'][] = array(
|
Chris@76
|
549 'id' => $choice_id++,
|
Chris@76
|
550 'number' => $choice_id,
|
Chris@76
|
551 'label' => '',
|
Chris@76
|
552 'is_last' => false
|
Chris@76
|
553 );
|
Chris@76
|
554 }
|
Chris@76
|
555 $context['choices'][count($context['choices']) - 1]['is_last'] = true;
|
Chris@76
|
556 }
|
Chris@76
|
557
|
Chris@76
|
558 // Are you... a guest?
|
Chris@76
|
559 if ($user_info['is_guest'])
|
Chris@76
|
560 {
|
Chris@76
|
561 $_REQUEST['guestname'] = !isset($_REQUEST['guestname']) ? '' : trim($_REQUEST['guestname']);
|
Chris@76
|
562 $_REQUEST['email'] = !isset($_REQUEST['email']) ? '' : trim($_REQUEST['email']);
|
Chris@76
|
563
|
Chris@76
|
564 $_REQUEST['guestname'] = htmlspecialchars($_REQUEST['guestname']);
|
Chris@76
|
565 $context['name'] = $_REQUEST['guestname'];
|
Chris@76
|
566 $_REQUEST['email'] = htmlspecialchars($_REQUEST['email']);
|
Chris@76
|
567 $context['email'] = $_REQUEST['email'];
|
Chris@76
|
568
|
Chris@76
|
569 $user_info['name'] = $_REQUEST['guestname'];
|
Chris@76
|
570 }
|
Chris@76
|
571
|
Chris@76
|
572 // Only show the preview stuff if they hit Preview.
|
Chris@76
|
573 if ($really_previewing == true || isset($_REQUEST['xml']))
|
Chris@76
|
574 {
|
Chris@76
|
575 // Set up the preview message and subject and censor them...
|
Chris@76
|
576 $context['preview_message'] = $form_message;
|
Chris@76
|
577 preparsecode($form_message, true);
|
Chris@76
|
578 preparsecode($context['preview_message']);
|
Chris@76
|
579
|
Chris@76
|
580 // Do all bulletin board code tags, with or without smileys.
|
Chris@76
|
581 $context['preview_message'] = parse_bbc($context['preview_message'], isset($_REQUEST['ns']) ? 0 : 1);
|
Chris@76
|
582
|
Chris@76
|
583 if ($form_subject != '')
|
Chris@76
|
584 {
|
Chris@76
|
585 $context['preview_subject'] = $form_subject;
|
Chris@76
|
586
|
Chris@76
|
587 censorText($context['preview_subject']);
|
Chris@76
|
588 censorText($context['preview_message']);
|
Chris@76
|
589 }
|
Chris@76
|
590 else
|
Chris@76
|
591 $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
|
Chris@76
|
592
|
Chris@76
|
593 // Protect any CDATA blocks.
|
Chris@76
|
594 if (isset($_REQUEST['xml']))
|
Chris@76
|
595 $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>'));
|
Chris@76
|
596 }
|
Chris@76
|
597
|
Chris@76
|
598 // Set up the checkboxes.
|
Chris@76
|
599 $context['notify'] = !empty($_REQUEST['notify']);
|
Chris@76
|
600 $context['use_smileys'] = !isset($_REQUEST['ns']);
|
Chris@76
|
601
|
Chris@76
|
602 $context['icon'] = isset($_REQUEST['icon']) ? preg_replace('~[\./\\\\*\':"<>]~', '', $_REQUEST['icon']) : 'xx';
|
Chris@76
|
603
|
Chris@76
|
604 // Set the destination action for submission.
|
Chris@76
|
605 $context['destination'] = 'post2;start=' . $_REQUEST['start'] . (isset($_REQUEST['msg']) ? ';msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id'] : '') . (isset($_REQUEST['poll']) ? ';poll' : '');
|
Chris@76
|
606 $context['submit_label'] = isset($_REQUEST['msg']) ? $txt['save'] : $txt['post'];
|
Chris@76
|
607
|
Chris@76
|
608 // Previewing an edit?
|
Chris@76
|
609 if (isset($_REQUEST['msg']) && !empty($topic))
|
Chris@76
|
610 {
|
Chris@76
|
611 // Get the existing message.
|
Chris@76
|
612 $request = $smcFunc['db_query']('', '
|
Chris@76
|
613 SELECT
|
Chris@76
|
614 m.id_member, m.modified_time, m.smileys_enabled, m.body,
|
Chris@76
|
615 m.poster_name, m.poster_email, m.subject, m.icon, m.approved,
|
Chris@76
|
616 IFNULL(a.size, -1) AS filesize, a.filename, a.id_attach,
|
Chris@76
|
617 a.approved AS attachment_approved, t.id_member_started AS id_member_poster,
|
Chris@76
|
618 m.poster_time
|
Chris@76
|
619 FROM {db_prefix}messages AS m
|
Chris@76
|
620 INNER JOIN {db_prefix}topics AS t ON (t.id_topic = {int:current_topic})
|
Chris@76
|
621 LEFT JOIN {db_prefix}attachments AS a ON (a.id_msg = m.id_msg AND a.attachment_type = {int:attachment_type})
|
Chris@76
|
622 WHERE m.id_msg = {int:id_msg}
|
Chris@76
|
623 AND m.id_topic = {int:current_topic}',
|
Chris@76
|
624 array(
|
Chris@76
|
625 'current_topic' => $topic,
|
Chris@76
|
626 'attachment_type' => 0,
|
Chris@76
|
627 'id_msg' => $_REQUEST['msg'],
|
Chris@76
|
628 )
|
Chris@76
|
629 );
|
Chris@76
|
630 // The message they were trying to edit was most likely deleted.
|
Chris@76
|
631 // !!! Change this error message?
|
Chris@76
|
632 if ($smcFunc['db_num_rows']($request) == 0)
|
Chris@76
|
633 fatal_lang_error('no_board', false);
|
Chris@76
|
634 $row = $smcFunc['db_fetch_assoc']($request);
|
Chris@76
|
635
|
Chris@76
|
636 $attachment_stuff = array($row);
|
Chris@76
|
637 while ($row2 = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
638 $attachment_stuff[] = $row2;
|
Chris@76
|
639 $smcFunc['db_free_result']($request);
|
Chris@76
|
640
|
Chris@76
|
641 if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
|
Chris@76
|
642 {
|
Chris@76
|
643 // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
|
Chris@76
|
644 if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
|
Chris@76
|
645 fatal_lang_error('modify_post_time_passed', false);
|
Chris@76
|
646 elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
|
Chris@76
|
647 isAllowedTo('modify_replies');
|
Chris@76
|
648 else
|
Chris@76
|
649 isAllowedTo('modify_own');
|
Chris@76
|
650 }
|
Chris@76
|
651 elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
|
Chris@76
|
652 isAllowedTo('modify_replies');
|
Chris@76
|
653 else
|
Chris@76
|
654 isAllowedTo('modify_any');
|
Chris@76
|
655
|
Chris@76
|
656 if (!empty($modSettings['attachmentEnable']))
|
Chris@76
|
657 {
|
Chris@76
|
658 $request = $smcFunc['db_query']('', '
|
Chris@76
|
659 SELECT IFNULL(size, -1) AS filesize, filename, id_attach, approved
|
Chris@76
|
660 FROM {db_prefix}attachments
|
Chris@76
|
661 WHERE id_msg = {int:id_msg}
|
Chris@76
|
662 AND attachment_type = {int:attachment_type}',
|
Chris@76
|
663 array(
|
Chris@76
|
664 'id_msg' => (int) $_REQUEST['msg'],
|
Chris@76
|
665 'attachment_type' => 0,
|
Chris@76
|
666 )
|
Chris@76
|
667 );
|
Chris@76
|
668 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
669 {
|
Chris@76
|
670 if ($row['filesize'] <= 0)
|
Chris@76
|
671 continue;
|
Chris@76
|
672 $context['current_attachments'][] = array(
|
Chris@76
|
673 'name' => htmlspecialchars($row['filename']),
|
Chris@76
|
674 'id' => $row['id_attach'],
|
Chris@76
|
675 'approved' => $row['approved'],
|
Chris@76
|
676 );
|
Chris@76
|
677 }
|
Chris@76
|
678 $smcFunc['db_free_result']($request);
|
Chris@76
|
679 }
|
Chris@76
|
680
|
Chris@76
|
681 // Allow moderators to change names....
|
Chris@76
|
682 if (allowedTo('moderate_forum') && !empty($topic))
|
Chris@76
|
683 {
|
Chris@76
|
684 $request = $smcFunc['db_query']('', '
|
Chris@76
|
685 SELECT id_member, poster_name, poster_email
|
Chris@76
|
686 FROM {db_prefix}messages
|
Chris@76
|
687 WHERE id_msg = {int:id_msg}
|
Chris@76
|
688 AND id_topic = {int:current_topic}
|
Chris@76
|
689 LIMIT 1',
|
Chris@76
|
690 array(
|
Chris@76
|
691 'current_topic' => $topic,
|
Chris@76
|
692 'id_msg' => (int) $_REQUEST['msg'],
|
Chris@76
|
693 )
|
Chris@76
|
694 );
|
Chris@76
|
695 $row = $smcFunc['db_fetch_assoc']($request);
|
Chris@76
|
696 $smcFunc['db_free_result']($request);
|
Chris@76
|
697
|
Chris@76
|
698 if (empty($row['id_member']))
|
Chris@76
|
699 {
|
Chris@76
|
700 $context['name'] = htmlspecialchars($row['poster_name']);
|
Chris@76
|
701 $context['email'] = htmlspecialchars($row['poster_email']);
|
Chris@76
|
702 }
|
Chris@76
|
703 }
|
Chris@76
|
704 }
|
Chris@76
|
705
|
Chris@76
|
706 // No check is needed, since nothing is really posted.
|
Chris@76
|
707 checkSubmitOnce('free');
|
Chris@76
|
708 }
|
Chris@76
|
709 // Editing a message...
|
Chris@76
|
710 elseif (isset($_REQUEST['msg']) && !empty($topic))
|
Chris@76
|
711 {
|
Chris@76
|
712 $_REQUEST['msg'] = (int) $_REQUEST['msg'];
|
Chris@76
|
713
|
Chris@76
|
714 // Get the existing message.
|
Chris@76
|
715 $request = $smcFunc['db_query']('', '
|
Chris@76
|
716 SELECT
|
Chris@76
|
717 m.id_member, m.modified_time, m.smileys_enabled, m.body,
|
Chris@76
|
718 m.poster_name, m.poster_email, m.subject, m.icon, m.approved,
|
Chris@76
|
719 IFNULL(a.size, -1) AS filesize, a.filename, a.id_attach,
|
Chris@76
|
720 a.approved AS attachment_approved, t.id_member_started AS id_member_poster,
|
Chris@76
|
721 m.poster_time
|
Chris@76
|
722 FROM {db_prefix}messages AS m
|
Chris@76
|
723 INNER JOIN {db_prefix}topics AS t ON (t.id_topic = {int:current_topic})
|
Chris@76
|
724 LEFT JOIN {db_prefix}attachments AS a ON (a.id_msg = m.id_msg AND a.attachment_type = {int:attachment_type})
|
Chris@76
|
725 WHERE m.id_msg = {int:id_msg}
|
Chris@76
|
726 AND m.id_topic = {int:current_topic}',
|
Chris@76
|
727 array(
|
Chris@76
|
728 'current_topic' => $topic,
|
Chris@76
|
729 'attachment_type' => 0,
|
Chris@76
|
730 'id_msg' => $_REQUEST['msg'],
|
Chris@76
|
731 )
|
Chris@76
|
732 );
|
Chris@76
|
733 // The message they were trying to edit was most likely deleted.
|
Chris@76
|
734 // !!! Change this error message?
|
Chris@76
|
735 if ($smcFunc['db_num_rows']($request) == 0)
|
Chris@76
|
736 fatal_lang_error('no_board', false);
|
Chris@76
|
737 $row = $smcFunc['db_fetch_assoc']($request);
|
Chris@76
|
738
|
Chris@76
|
739 $attachment_stuff = array($row);
|
Chris@76
|
740 while ($row2 = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
741 $attachment_stuff[] = $row2;
|
Chris@76
|
742 $smcFunc['db_free_result']($request);
|
Chris@76
|
743
|
Chris@76
|
744 if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
|
Chris@76
|
745 {
|
Chris@76
|
746 // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
|
Chris@76
|
747 if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
|
Chris@76
|
748 fatal_lang_error('modify_post_time_passed', false);
|
Chris@76
|
749 elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
|
Chris@76
|
750 isAllowedTo('modify_replies');
|
Chris@76
|
751 else
|
Chris@76
|
752 isAllowedTo('modify_own');
|
Chris@76
|
753 }
|
Chris@76
|
754 elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
|
Chris@76
|
755 isAllowedTo('modify_replies');
|
Chris@76
|
756 else
|
Chris@76
|
757 isAllowedTo('modify_any');
|
Chris@76
|
758
|
Chris@76
|
759 // When was it last modified?
|
Chris@76
|
760 if (!empty($row['modified_time']))
|
Chris@76
|
761 $context['last_modified'] = timeformat($row['modified_time']);
|
Chris@76
|
762
|
Chris@76
|
763 // Get the stuff ready for the form.
|
Chris@76
|
764 $form_subject = $row['subject'];
|
Chris@76
|
765 $form_message = un_preparsecode($row['body']);
|
Chris@76
|
766 censorText($form_message);
|
Chris@76
|
767 censorText($form_subject);
|
Chris@76
|
768
|
Chris@76
|
769 // Check the boxes that should be checked.
|
Chris@76
|
770 $context['use_smileys'] = !empty($row['smileys_enabled']);
|
Chris@76
|
771 $context['icon'] = $row['icon'];
|
Chris@76
|
772
|
Chris@76
|
773 // Show an "approve" box if the user can approve it, and the message isn't approved.
|
Chris@76
|
774 if (!$row['approved'] && !$context['show_approval'])
|
Chris@76
|
775 $context['show_approval'] = allowedTo('approve_posts');
|
Chris@76
|
776
|
Chris@76
|
777 // Load up 'em attachments!
|
Chris@76
|
778 foreach ($attachment_stuff as $attachment)
|
Chris@76
|
779 {
|
Chris@76
|
780 if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable']))
|
Chris@76
|
781 $context['current_attachments'][] = array(
|
Chris@76
|
782 'name' => htmlspecialchars($attachment['filename']),
|
Chris@76
|
783 'id' => $attachment['id_attach'],
|
Chris@76
|
784 'approved' => $attachment['attachment_approved'],
|
Chris@76
|
785 );
|
Chris@76
|
786 }
|
Chris@76
|
787
|
Chris@76
|
788 // Allow moderators to change names....
|
Chris@76
|
789 if (allowedTo('moderate_forum') && empty($row['id_member']))
|
Chris@76
|
790 {
|
Chris@76
|
791 $context['name'] = htmlspecialchars($row['poster_name']);
|
Chris@76
|
792 $context['email'] = htmlspecialchars($row['poster_email']);
|
Chris@76
|
793 }
|
Chris@76
|
794
|
Chris@76
|
795 // Set the destinaton.
|
Chris@76
|
796 $context['destination'] = 'post2;start=' . $_REQUEST['start'] . ';msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id'] . (isset($_REQUEST['poll']) ? ';poll' : '');
|
Chris@76
|
797 $context['submit_label'] = $txt['save'];
|
Chris@76
|
798 }
|
Chris@76
|
799 // Posting...
|
Chris@76
|
800 else
|
Chris@76
|
801 {
|
Chris@76
|
802 // By default....
|
Chris@76
|
803 $context['use_smileys'] = true;
|
Chris@76
|
804 $context['icon'] = 'xx';
|
Chris@76
|
805
|
Chris@76
|
806 if ($user_info['is_guest'])
|
Chris@76
|
807 {
|
Chris@76
|
808 $context['name'] = isset($_SESSION['guest_name']) ? $_SESSION['guest_name'] : '';
|
Chris@76
|
809 $context['email'] = isset($_SESSION['guest_email']) ? $_SESSION['guest_email'] : '';
|
Chris@76
|
810 }
|
Chris@76
|
811 $context['destination'] = 'post2;start=' . $_REQUEST['start'] . (isset($_REQUEST['poll']) ? ';poll' : '');
|
Chris@76
|
812
|
Chris@76
|
813 $context['submit_label'] = $txt['post'];
|
Chris@76
|
814
|
Chris@76
|
815 // Posting a quoted reply?
|
Chris@76
|
816 if (!empty($topic) && !empty($_REQUEST['quote']))
|
Chris@76
|
817 {
|
Chris@76
|
818 // Make sure they _can_ quote this post, and if so get it.
|
Chris@76
|
819 $request = $smcFunc['db_query']('', '
|
Chris@76
|
820 SELECT m.subject, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.body
|
Chris@76
|
821 FROM {db_prefix}messages AS m
|
Chris@76
|
822 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})
|
Chris@76
|
823 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
|
Chris@76
|
824 WHERE m.id_msg = {int:id_msg}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
|
Chris@76
|
825 AND m.approved = {int:is_approved}') . '
|
Chris@76
|
826 LIMIT 1',
|
Chris@76
|
827 array(
|
Chris@76
|
828 'id_msg' => (int) $_REQUEST['quote'],
|
Chris@76
|
829 'is_approved' => 1,
|
Chris@76
|
830 )
|
Chris@76
|
831 );
|
Chris@76
|
832 if ($smcFunc['db_num_rows']($request) == 0)
|
Chris@76
|
833 fatal_lang_error('quoted_post_deleted', false);
|
Chris@76
|
834 list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
835 $smcFunc['db_free_result']($request);
|
Chris@76
|
836
|
Chris@76
|
837 // Add 'Re: ' to the front of the quoted subject.
|
Chris@76
|
838 if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
|
Chris@76
|
839 $form_subject = $context['response_prefix'] . $form_subject;
|
Chris@76
|
840
|
Chris@76
|
841 // Censor the message and subject.
|
Chris@76
|
842 censorText($form_message);
|
Chris@76
|
843 censorText($form_subject);
|
Chris@76
|
844
|
Chris@76
|
845 // But if it's in HTML world, turn them into htmlspecialchar's so they can be edited!
|
Chris@76
|
846 if (strpos($form_message, '[html]') !== false)
|
Chris@76
|
847 {
|
Chris@76
|
848 $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $form_message, -1, PREG_SPLIT_DELIM_CAPTURE);
|
Chris@76
|
849 for ($i = 0, $n = count($parts); $i < $n; $i++)
|
Chris@76
|
850 {
|
Chris@76
|
851 // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
|
Chris@76
|
852 if ($i % 4 == 0)
|
Chris@76
|
853 $parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . preg_replace(\'~<br\s?/?' . '>~i\', \'<br /><br />\', \'$1\') . \'[/html]\'', $parts[$i]);
|
Chris@76
|
854 }
|
Chris@76
|
855 $form_message = implode('', $parts);
|
Chris@76
|
856 }
|
Chris@76
|
857
|
Chris@76
|
858 $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message);
|
Chris@76
|
859
|
Chris@76
|
860 // Remove any nested quotes, if necessary.
|
Chris@76
|
861 if (!empty($modSettings['removeNestedQuotes']))
|
Chris@76
|
862 $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
|
Chris@76
|
863
|
Chris@76
|
864 // Add a quote string on the front and end.
|
Chris@76
|
865 $form_message = '[quote author=' . $mname . ' link=topic=' . $topic . '.msg' . (int) $_REQUEST['quote'] . '#msg' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]';
|
Chris@76
|
866 }
|
Chris@76
|
867 // Posting a reply without a quote?
|
Chris@76
|
868 elseif (!empty($topic) && empty($_REQUEST['quote']))
|
Chris@76
|
869 {
|
Chris@76
|
870 // Get the first message's subject.
|
Chris@76
|
871 $form_subject = $first_subject;
|
Chris@76
|
872
|
Chris@76
|
873 // Add 'Re: ' to the front of the subject.
|
Chris@76
|
874 if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
|
Chris@76
|
875 $form_subject = $context['response_prefix'] . $form_subject;
|
Chris@76
|
876
|
Chris@76
|
877 // Censor the subject.
|
Chris@76
|
878 censorText($form_subject);
|
Chris@76
|
879
|
Chris@76
|
880 $form_message = '';
|
Chris@76
|
881 }
|
Chris@76
|
882 else
|
Chris@76
|
883 {
|
Chris@76
|
884 $form_subject = isset($_GET['subject']) ? $_GET['subject'] : '';
|
Chris@76
|
885 $form_message = '';
|
Chris@76
|
886 }
|
Chris@76
|
887 }
|
Chris@76
|
888
|
Chris@76
|
889 // !!! This won't work if you're posting an event.
|
Chris@76
|
890 if (allowedTo('post_attachment') || allowedTo('post_unapproved_attachments'))
|
Chris@76
|
891 {
|
Chris@76
|
892 if (empty($_SESSION['temp_attachments']))
|
Chris@76
|
893 $_SESSION['temp_attachments'] = array();
|
Chris@76
|
894
|
Chris@76
|
895 if (!empty($modSettings['currentAttachmentUploadDir']))
|
Chris@76
|
896 {
|
Chris@76
|
897 if (!is_array($modSettings['attachmentUploadDir']))
|
Chris@76
|
898 $modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
|
Chris@76
|
899
|
Chris@76
|
900 // Just use the current path for temp files.
|
Chris@76
|
901 $current_attach_dir = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
|
Chris@76
|
902 }
|
Chris@76
|
903 else
|
Chris@76
|
904 $current_attach_dir = $modSettings['attachmentUploadDir'];
|
Chris@76
|
905
|
Chris@76
|
906 // If this isn't a new post, check the current attachments.
|
Chris@76
|
907 if (isset($_REQUEST['msg']))
|
Chris@76
|
908 {
|
Chris@76
|
909 $request = $smcFunc['db_query']('', '
|
Chris@76
|
910 SELECT COUNT(*), SUM(size)
|
Chris@76
|
911 FROM {db_prefix}attachments
|
Chris@76
|
912 WHERE id_msg = {int:id_msg}
|
Chris@76
|
913 AND attachment_type = {int:attachment_type}',
|
Chris@76
|
914 array(
|
Chris@76
|
915 'id_msg' => (int) $_REQUEST['msg'],
|
Chris@76
|
916 'attachment_type' => 0,
|
Chris@76
|
917 )
|
Chris@76
|
918 );
|
Chris@76
|
919 list ($quantity, $total_size) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
920 $smcFunc['db_free_result']($request);
|
Chris@76
|
921 }
|
Chris@76
|
922 else
|
Chris@76
|
923 {
|
Chris@76
|
924 $quantity = 0;
|
Chris@76
|
925 $total_size = 0;
|
Chris@76
|
926 }
|
Chris@76
|
927
|
Chris@76
|
928 $temp_start = 0;
|
Chris@76
|
929
|
Chris@76
|
930 if (!empty($_SESSION['temp_attachments']))
|
Chris@76
|
931 {
|
Chris@76
|
932 if ($context['current_action'] != 'post2' || !empty($_POST['from_qr']))
|
Chris@76
|
933 {
|
Chris@76
|
934 $context['post_error']['messages'][] = $txt['error_temp_attachments'];
|
Chris@76
|
935 $context['error_type'] = 'minor';
|
Chris@76
|
936 }
|
Chris@76
|
937
|
Chris@76
|
938 foreach ($_SESSION['temp_attachments'] as $attachID => $name)
|
Chris@76
|
939 {
|
Chris@76
|
940 $temp_start++;
|
Chris@76
|
941
|
Chris@76
|
942 if (preg_match('~^post_tmp_' . $user_info['id'] . '_\d+$~', $attachID) == 0)
|
Chris@76
|
943 {
|
Chris@76
|
944 unset($_SESSION['temp_attachments'][$attachID]);
|
Chris@76
|
945 continue;
|
Chris@76
|
946 }
|
Chris@76
|
947
|
Chris@76
|
948 if (!empty($_POST['attach_del']) && !in_array($attachID, $_POST['attach_del']))
|
Chris@76
|
949 {
|
Chris@76
|
950 $deleted_attachments = true;
|
Chris@76
|
951 unset($_SESSION['temp_attachments'][$attachID]);
|
Chris@76
|
952 @unlink($current_attach_dir . '/' . $attachID);
|
Chris@76
|
953 continue;
|
Chris@76
|
954 }
|
Chris@76
|
955
|
Chris@76
|
956 $quantity++;
|
Chris@76
|
957 $total_size += filesize($current_attach_dir . '/' . $attachID);
|
Chris@76
|
958
|
Chris@76
|
959 $context['current_attachments'][] = array(
|
Chris@76
|
960 'name' => htmlspecialchars($name),
|
Chris@76
|
961 'id' => $attachID,
|
Chris@76
|
962 'approved' => 1,
|
Chris@76
|
963 );
|
Chris@76
|
964 }
|
Chris@76
|
965 }
|
Chris@76
|
966
|
Chris@76
|
967 if (!empty($_POST['attach_del']))
|
Chris@76
|
968 {
|
Chris@76
|
969 $del_temp = array();
|
Chris@76
|
970 foreach ($_POST['attach_del'] as $i => $dummy)
|
Chris@76
|
971 $del_temp[$i] = (int) $dummy;
|
Chris@76
|
972
|
Chris@76
|
973 foreach ($context['current_attachments'] as $k => $dummy)
|
Chris@76
|
974 if (!in_array($dummy['id'], $del_temp))
|
Chris@76
|
975 {
|
Chris@76
|
976 $context['current_attachments'][$k]['unchecked'] = true;
|
Chris@76
|
977 $deleted_attachments = !isset($deleted_attachments) || is_bool($deleted_attachments) ? 1 : $deleted_attachments + 1;
|
Chris@76
|
978 $quantity--;
|
Chris@76
|
979 }
|
Chris@76
|
980 }
|
Chris@76
|
981
|
Chris@76
|
982 if (!empty($_FILES['attachment']))
|
Chris@76
|
983 foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
|
Chris@76
|
984 {
|
Chris@76
|
985 if ($_FILES['attachment']['name'][$n] == '')
|
Chris@76
|
986 continue;
|
Chris@76
|
987
|
Chris@76
|
988 if (!is_uploaded_file($_FILES['attachment']['tmp_name'][$n]) || (@ini_get('open_basedir') == '' && !file_exists($_FILES['attachment']['tmp_name'][$n])))
|
Chris@76
|
989 fatal_lang_error('attach_timeout', 'critical');
|
Chris@76
|
990
|
Chris@76
|
991 if (!empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
|
Chris@76
|
992 fatal_lang_error('file_too_big', false, array($modSettings['attachmentSizeLimit']));
|
Chris@76
|
993
|
Chris@76
|
994 $quantity++;
|
Chris@76
|
995 if (!empty($modSettings['attachmentNumPerPostLimit']) && $quantity > $modSettings['attachmentNumPerPostLimit'])
|
Chris@76
|
996 fatal_lang_error('attachments_limit_per_post', false, array($modSettings['attachmentNumPerPostLimit']));
|
Chris@76
|
997
|
Chris@76
|
998 $total_size += $_FILES['attachment']['size'][$n];
|
Chris@76
|
999 if (!empty($modSettings['attachmentPostLimit']) && $total_size > $modSettings['attachmentPostLimit'] * 1024)
|
Chris@76
|
1000 fatal_lang_error('file_too_big', false, array($modSettings['attachmentPostLimit']));
|
Chris@76
|
1001
|
Chris@76
|
1002 if (!empty($modSettings['attachmentCheckExtensions']))
|
Chris@76
|
1003 {
|
Chris@76
|
1004 if (!in_array(strtolower(substr(strrchr($_FILES['attachment']['name'][$n], '.'), 1)), explode(',', strtolower($modSettings['attachmentExtensions']))))
|
Chris@76
|
1005 fatal_error($_FILES['attachment']['name'][$n] . '.<br />' . $txt['cant_upload_type'] . ' ' . $modSettings['attachmentExtensions'] . '.', false);
|
Chris@76
|
1006 }
|
Chris@76
|
1007
|
Chris@76
|
1008 if (!empty($modSettings['attachmentDirSizeLimit']))
|
Chris@76
|
1009 {
|
Chris@76
|
1010 // Make sure the directory isn't full.
|
Chris@76
|
1011 $dirSize = 0;
|
Chris@76
|
1012 $dir = @opendir($current_attach_dir) or fatal_lang_error('cant_access_upload_path', 'critical');
|
Chris@76
|
1013 while ($file = readdir($dir))
|
Chris@76
|
1014 {
|
Chris@76
|
1015 if ($file == '.' || $file == '..')
|
Chris@76
|
1016 continue;
|
Chris@76
|
1017
|
Chris@76
|
1018 if (preg_match('~^post_tmp_\d+_\d+$~', $file) != 0)
|
Chris@76
|
1019 {
|
Chris@76
|
1020 // Temp file is more than 5 hours old!
|
Chris@76
|
1021 if (filemtime($current_attach_dir . '/' . $file) < time() - 18000)
|
Chris@76
|
1022 @unlink($current_attach_dir . '/' . $file);
|
Chris@76
|
1023 continue;
|
Chris@76
|
1024 }
|
Chris@76
|
1025
|
Chris@76
|
1026 $dirSize += filesize($current_attach_dir . '/' . $file);
|
Chris@76
|
1027 }
|
Chris@76
|
1028 closedir($dir);
|
Chris@76
|
1029
|
Chris@76
|
1030 // Too big! Maybe you could zip it or something...
|
Chris@76
|
1031 if ($_FILES['attachment']['size'][$n] + $dirSize > $modSettings['attachmentDirSizeLimit'] * 1024)
|
Chris@76
|
1032 fatal_lang_error('ran_out_of_space');
|
Chris@76
|
1033 }
|
Chris@76
|
1034
|
Chris@76
|
1035 if (!is_writable($current_attach_dir))
|
Chris@76
|
1036 fatal_lang_error('attachments_no_write', 'critical');
|
Chris@76
|
1037
|
Chris@76
|
1038 $attachID = 'post_tmp_' . $user_info['id'] . '_' . $temp_start++;
|
Chris@76
|
1039 $_SESSION['temp_attachments'][$attachID] = basename($_FILES['attachment']['name'][$n]);
|
Chris@76
|
1040 $context['current_attachments'][] = array(
|
Chris@76
|
1041 'name' => htmlspecialchars(basename($_FILES['attachment']['name'][$n])),
|
Chris@76
|
1042 'id' => $attachID,
|
Chris@76
|
1043 'approved' => 1,
|
Chris@76
|
1044 );
|
Chris@76
|
1045
|
Chris@76
|
1046 $destName = $current_attach_dir . '/' . $attachID;
|
Chris@76
|
1047
|
Chris@76
|
1048 if (!move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
|
Chris@76
|
1049 fatal_lang_error('attach_timeout', 'critical');
|
Chris@76
|
1050 @chmod($destName, 0644);
|
Chris@76
|
1051 }
|
Chris@76
|
1052 }
|
Chris@76
|
1053
|
Chris@76
|
1054 // If we are coming here to make a reply, and someone has already replied... make a special warning message.
|
Chris@76
|
1055 if (isset($newRepliesError))
|
Chris@76
|
1056 {
|
Chris@76
|
1057 $context['post_error']['messages'][] = $newRepliesError == 1 ? $txt['error_new_reply'] : $txt['error_new_replies'];
|
Chris@76
|
1058 $context['error_type'] = 'minor';
|
Chris@76
|
1059 }
|
Chris@76
|
1060
|
Chris@76
|
1061 if (isset($oldTopicError))
|
Chris@76
|
1062 {
|
Chris@76
|
1063 $context['post_error']['messages'][] = sprintf($txt['error_old_topic'], $modSettings['oldTopicDays']);
|
Chris@76
|
1064 $context['error_type'] = 'minor';
|
Chris@76
|
1065 }
|
Chris@76
|
1066
|
Chris@76
|
1067 // What are you doing? Posting a poll, modifying, previewing, new post, or reply...
|
Chris@76
|
1068 if (isset($_REQUEST['poll']))
|
Chris@76
|
1069 $context['page_title'] = $txt['new_poll'];
|
Chris@76
|
1070 elseif ($context['make_event'])
|
Chris@76
|
1071 $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
|
Chris@76
|
1072 elseif (isset($_REQUEST['msg']))
|
Chris@76
|
1073 $context['page_title'] = $txt['modify_msg'];
|
Chris@76
|
1074 elseif (isset($_REQUEST['subject'], $context['preview_subject']))
|
Chris@76
|
1075 $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
|
Chris@76
|
1076 elseif (empty($topic))
|
Chris@76
|
1077 $context['page_title'] = $txt['start_new_topic'];
|
Chris@76
|
1078 else
|
Chris@76
|
1079 $context['page_title'] = $txt['post_reply'];
|
Chris@76
|
1080
|
Chris@76
|
1081 // Build the link tree.
|
Chris@76
|
1082 if (empty($topic))
|
Chris@76
|
1083 $context['linktree'][] = array(
|
Chris@76
|
1084 'name' => '<em>' . $txt['start_new_topic'] . '</em>'
|
Chris@76
|
1085 );
|
Chris@76
|
1086 else
|
Chris@76
|
1087 $context['linktree'][] = array(
|
Chris@76
|
1088 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'],
|
Chris@76
|
1089 'name' => $form_subject,
|
Chris@76
|
1090 'extra_before' => '<span' . ($settings['linktree_inline'] ? ' class="smalltext"' : '') . '><strong class="nav">' . $context['page_title'] . ' ( </strong></span>',
|
Chris@76
|
1091 'extra_after' => '<span' . ($settings['linktree_inline'] ? ' class="smalltext"' : '') . '><strong class="nav"> )</strong></span>'
|
Chris@76
|
1092 );
|
Chris@76
|
1093
|
Chris@76
|
1094 // Give wireless a linktree url to the post screen, so that they can switch to full version.
|
Chris@76
|
1095 if (WIRELESS)
|
Chris@76
|
1096 $context['linktree'][count($context['linktree']) - 1]['url'] = $scripturl . '?action=post;' . (!empty($topic) ? 'topic=' . $topic : 'board=' . $board) . '.' . $_REQUEST['start'] . (isset($_REQUEST['msg']) ? ';msg=' . (int) $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id'] : '');
|
Chris@76
|
1097
|
Chris@76
|
1098 // If they've unchecked an attachment, they may still want to attach that many more files, but don't allow more than num_allowed_attachments.
|
Chris@76
|
1099 // !!! This won't work if you're posting an event.
|
Chris@76
|
1100 $context['num_allowed_attachments'] = empty($modSettings['attachmentNumPerPostLimit']) ? 50 : min($modSettings['attachmentNumPerPostLimit'] - count($context['current_attachments']) + (isset($deleted_attachments) ? $deleted_attachments : 0), $modSettings['attachmentNumPerPostLimit']);
|
Chris@76
|
1101 $context['can_post_attachment'] = !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1 && (allowedTo('post_attachment') || ($modSettings['postmod_active'] && allowedTo('post_unapproved_attachments'))) && $context['num_allowed_attachments'] > 0;
|
Chris@76
|
1102 $context['can_post_attachment_unapproved'] = allowedTo('post_attachment');
|
Chris@76
|
1103
|
Chris@76
|
1104 $context['subject'] = addcslashes($form_subject, '"');
|
Chris@76
|
1105 $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message);
|
Chris@76
|
1106
|
Chris@76
|
1107 // Needed for the editor and message icons.
|
Chris@76
|
1108 require_once($sourcedir . '/Subs-Editor.php');
|
Chris@76
|
1109
|
Chris@76
|
1110 // Now create the editor.
|
Chris@76
|
1111 $editorOptions = array(
|
Chris@76
|
1112 'id' => 'message',
|
Chris@76
|
1113 'value' => $context['message'],
|
Chris@76
|
1114 'labels' => array(
|
Chris@76
|
1115 'post_button' => $context['submit_label'],
|
Chris@76
|
1116 ),
|
Chris@76
|
1117 // add height and width for the editor
|
Chris@76
|
1118 'height' => '175px',
|
Chris@76
|
1119 'width' => '100%',
|
Chris@76
|
1120 // We do XML preview here.
|
Chris@76
|
1121 'preview_type' => 2,
|
Chris@76
|
1122 );
|
Chris@76
|
1123 create_control_richedit($editorOptions);
|
Chris@76
|
1124
|
Chris@76
|
1125 // Store the ID.
|
Chris@76
|
1126 $context['post_box_name'] = $editorOptions['id'];
|
Chris@76
|
1127
|
Chris@76
|
1128 $context['attached'] = '';
|
Chris@76
|
1129 $context['make_poll'] = isset($_REQUEST['poll']);
|
Chris@76
|
1130
|
Chris@76
|
1131 // Message icons - customized icons are off?
|
Chris@76
|
1132 $context['icons'] = getMessageIcons($board);
|
Chris@76
|
1133
|
Chris@76
|
1134 if (!empty($context['icons']))
|
Chris@76
|
1135 $context['icons'][count($context['icons']) - 1]['is_last'] = true;
|
Chris@76
|
1136
|
Chris@76
|
1137 $context['icon_url'] = '';
|
Chris@76
|
1138 for ($i = 0, $n = count($context['icons']); $i < $n; $i++)
|
Chris@76
|
1139 {
|
Chris@76
|
1140 $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value'];
|
Chris@76
|
1141 if ($context['icons'][$i]['selected'])
|
Chris@76
|
1142 $context['icon_url'] = $context['icons'][$i]['url'];
|
Chris@76
|
1143 }
|
Chris@76
|
1144 if (empty($context['icon_url']))
|
Chris@76
|
1145 {
|
Chris@76
|
1146 $context['icon_url'] = $settings[file_exists($settings['theme_dir'] . '/images/post/' . $context['icon'] . '.gif') ? 'images_url' : 'default_images_url'] . '/post/' . $context['icon'] . '.gif';
|
Chris@76
|
1147 array_unshift($context['icons'], array(
|
Chris@76
|
1148 'value' => $context['icon'],
|
Chris@76
|
1149 'name' => $txt['current_icon'],
|
Chris@76
|
1150 'url' => $context['icon_url'],
|
Chris@76
|
1151 'is_last' => empty($context['icons']),
|
Chris@76
|
1152 'selected' => true,
|
Chris@76
|
1153 ));
|
Chris@76
|
1154 }
|
Chris@76
|
1155
|
Chris@76
|
1156 if (!empty($topic) && !empty($modSettings['topicSummaryPosts']))
|
Chris@76
|
1157 getTopic();
|
Chris@76
|
1158
|
Chris@76
|
1159 // If the user can post attachments prepare the warning labels.
|
Chris@76
|
1160 if ($context['can_post_attachment'])
|
Chris@76
|
1161 {
|
Chris@76
|
1162 $context['allowed_extensions'] = strtr($modSettings['attachmentExtensions'], array(',' => ', '));
|
Chris@76
|
1163 $context['attachment_restrictions'] = array();
|
Chris@76
|
1164 $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit');
|
Chris@76
|
1165 foreach ($attachmentRestrictionTypes as $type)
|
Chris@76
|
1166 if (!empty($modSettings[$type]))
|
Chris@76
|
1167 $context['attachment_restrictions'][] = sprintf($txt['attach_restrict_' . $type], $modSettings[$type]);
|
Chris@76
|
1168 }
|
Chris@76
|
1169
|
Chris@76
|
1170 $context['back_to_topic'] = isset($_REQUEST['goback']) || (isset($_REQUEST['msg']) && !isset($_REQUEST['subject']));
|
Chris@76
|
1171 $context['show_additional_options'] = !empty($_POST['additional_options']) || !empty($_SESSION['temp_attachments']) || !empty($deleted_attachments);
|
Chris@76
|
1172
|
Chris@76
|
1173 $context['is_new_topic'] = empty($topic);
|
Chris@76
|
1174 $context['is_new_post'] = !isset($_REQUEST['msg']);
|
Chris@76
|
1175 $context['is_first_post'] = $context['is_new_topic'] || (isset($_REQUEST['msg']) && $_REQUEST['msg'] == $id_first_msg);
|
Chris@76
|
1176
|
Chris@76
|
1177 // Do we need to show the visual verification image?
|
Chris@76
|
1178 $context['require_verification'] = !$user_info['is_mod'] && !$user_info['is_admin'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1));
|
Chris@76
|
1179 if ($context['require_verification'])
|
Chris@76
|
1180 {
|
Chris@76
|
1181 require_once($sourcedir . '/Subs-Editor.php');
|
Chris@76
|
1182 $verificationOptions = array(
|
Chris@76
|
1183 'id' => 'post',
|
Chris@76
|
1184 );
|
Chris@76
|
1185 $context['require_verification'] = create_control_verification($verificationOptions);
|
Chris@76
|
1186 $context['visual_verification_id'] = $verificationOptions['id'];
|
Chris@76
|
1187 }
|
Chris@76
|
1188
|
Chris@76
|
1189 // If they came from quick reply, and have to enter verification details, give them some notice.
|
Chris@76
|
1190 if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification']))
|
Chris@76
|
1191 {
|
Chris@76
|
1192 $context['post_error']['messages'][] = $txt['enter_verification_details'];
|
Chris@76
|
1193 $context['error_type'] = 'minor';
|
Chris@76
|
1194 }
|
Chris@76
|
1195
|
Chris@76
|
1196 // WYSIWYG only works if BBC is enabled
|
Chris@76
|
1197 $modSettings['disable_wysiwyg'] = !empty($modSettings['disable_wysiwyg']) || empty($modSettings['enableBBC']);
|
Chris@76
|
1198
|
Chris@76
|
1199 // Register this form in the session variables.
|
Chris@76
|
1200 checkSubmitOnce('register');
|
Chris@76
|
1201
|
Chris@76
|
1202 // Finally, load the template.
|
Chris@76
|
1203 if (WIRELESS && WIRELESS_PROTOCOL != 'wap')
|
Chris@76
|
1204 $context['sub_template'] = WIRELESS_PROTOCOL . '_post';
|
Chris@76
|
1205 elseif (!isset($_REQUEST['xml']))
|
Chris@76
|
1206 loadTemplate('Post');
|
Chris@76
|
1207 }
|
Chris@76
|
1208
|
Chris@76
|
1209 function Post2()
|
Chris@76
|
1210 {
|
Chris@76
|
1211 global $board, $topic, $txt, $modSettings, $sourcedir, $context;
|
Chris@76
|
1212 global $user_info, $board_info, $options, $smcFunc;
|
Chris@76
|
1213
|
Chris@76
|
1214 // Sneaking off, are we?
|
Chris@76
|
1215 if (empty($_POST) && empty($topic))
|
Chris@76
|
1216 redirectexit('action=post;board=' . $board . '.0');
|
Chris@76
|
1217 elseif (empty($_POST) && !empty($topic))
|
Chris@76
|
1218 redirectexit('action=post;topic=' . $topic . '.0');
|
Chris@76
|
1219
|
Chris@76
|
1220 // No need!
|
Chris@76
|
1221 $context['robot_no_index'] = true;
|
Chris@76
|
1222
|
Chris@76
|
1223 // If we came from WYSIWYG then turn it back into BBC regardless.
|
Chris@76
|
1224 if (!empty($_REQUEST['message_mode']) && isset($_REQUEST['message']))
|
Chris@76
|
1225 {
|
Chris@76
|
1226 require_once($sourcedir . '/Subs-Editor.php');
|
Chris@76
|
1227
|
Chris@76
|
1228 $_REQUEST['message'] = html_to_bbc($_REQUEST['message']);
|
Chris@76
|
1229
|
Chris@76
|
1230 // We need to unhtml it now as it gets done shortly.
|
Chris@76
|
1231 $_REQUEST['message'] = un_htmlspecialchars($_REQUEST['message']);
|
Chris@76
|
1232
|
Chris@76
|
1233 // We need this for everything else.
|
Chris@76
|
1234 $_POST['message'] = $_REQUEST['message'];
|
Chris@76
|
1235 }
|
Chris@76
|
1236
|
Chris@76
|
1237 // Previewing? Go back to start.
|
Chris@76
|
1238 if (isset($_REQUEST['preview']))
|
Chris@76
|
1239 return Post();
|
Chris@76
|
1240
|
Chris@76
|
1241 // Prevent double submission of this form.
|
Chris@76
|
1242 checkSubmitOnce('check');
|
Chris@76
|
1243
|
Chris@76
|
1244 // No errors as yet.
|
Chris@76
|
1245 $post_errors = array();
|
Chris@76
|
1246
|
Chris@76
|
1247 // If the session has timed out, let the user re-submit their form.
|
Chris@76
|
1248 if (checkSession('post', '', false) != '')
|
Chris@76
|
1249 $post_errors[] = 'session_timeout';
|
Chris@76
|
1250
|
Chris@76
|
1251 // Wrong verification code?
|
Chris@76
|
1252 if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)))
|
Chris@76
|
1253 {
|
Chris@76
|
1254 require_once($sourcedir . '/Subs-Editor.php');
|
Chris@76
|
1255 $verificationOptions = array(
|
Chris@76
|
1256 'id' => 'post',
|
Chris@76
|
1257 );
|
Chris@76
|
1258 $context['require_verification'] = create_control_verification($verificationOptions, true);
|
Chris@76
|
1259 if (is_array($context['require_verification']))
|
Chris@76
|
1260 $post_errors = array_merge($post_errors, $context['require_verification']);
|
Chris@76
|
1261 }
|
Chris@76
|
1262
|
Chris@76
|
1263 require_once($sourcedir . '/Subs-Post.php');
|
Chris@76
|
1264 loadLanguage('Post');
|
Chris@76
|
1265
|
Chris@76
|
1266 // If this isn't a new topic load the topic info that we need.
|
Chris@76
|
1267 if (!empty($topic))
|
Chris@76
|
1268 {
|
Chris@76
|
1269 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1270 SELECT locked, is_sticky, id_poll, approved, id_first_msg, id_last_msg, id_member_started, id_board
|
Chris@76
|
1271 FROM {db_prefix}topics
|
Chris@76
|
1272 WHERE id_topic = {int:current_topic}
|
Chris@76
|
1273 LIMIT 1',
|
Chris@76
|
1274 array(
|
Chris@76
|
1275 'current_topic' => $topic,
|
Chris@76
|
1276 )
|
Chris@76
|
1277 );
|
Chris@76
|
1278 $topic_info = $smcFunc['db_fetch_assoc']($request);
|
Chris@76
|
1279 $smcFunc['db_free_result']($request);
|
Chris@76
|
1280
|
Chris@76
|
1281 // Though the topic should be there, it might have vanished.
|
Chris@76
|
1282 if (!is_array($topic_info))
|
Chris@76
|
1283 fatal_lang_error('topic_doesnt_exist');
|
Chris@76
|
1284
|
Chris@76
|
1285 // Did this topic suddenly move? Just checking...
|
Chris@76
|
1286 if ($topic_info['id_board'] != $board)
|
Chris@76
|
1287 fatal_lang_error('not_a_topic');
|
Chris@76
|
1288 }
|
Chris@76
|
1289
|
Chris@76
|
1290 // Replying to a topic?
|
Chris@76
|
1291 if (!empty($topic) && !isset($_REQUEST['msg']))
|
Chris@76
|
1292 {
|
Chris@76
|
1293 // Don't allow a post if it's locked.
|
Chris@76
|
1294 if ($topic_info['locked'] != 0 && !allowedTo('moderate_board'))
|
Chris@76
|
1295 fatal_lang_error('topic_locked', false);
|
Chris@76
|
1296
|
Chris@76
|
1297 // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P.
|
Chris@76
|
1298 if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0)
|
Chris@76
|
1299 unset($_REQUEST['poll']);
|
Chris@76
|
1300
|
Chris@76
|
1301 // Do the permissions and approval stuff...
|
Chris@76
|
1302 $becomesApproved = true;
|
Chris@76
|
1303 if ($topic_info['id_member_started'] != $user_info['id'])
|
Chris@76
|
1304 {
|
Chris@76
|
1305 if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
|
Chris@76
|
1306 $becomesApproved = false;
|
Chris@76
|
1307 else
|
Chris@76
|
1308 isAllowedTo('post_reply_any');
|
Chris@76
|
1309 }
|
Chris@76
|
1310 elseif (!allowedTo('post_reply_any'))
|
Chris@76
|
1311 {
|
Chris@76
|
1312 if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own'))
|
Chris@76
|
1313 $becomesApproved = false;
|
Chris@76
|
1314 else
|
Chris@76
|
1315 isAllowedTo('post_reply_own');
|
Chris@76
|
1316 }
|
Chris@76
|
1317
|
Chris@76
|
1318 if (isset($_POST['lock']))
|
Chris@76
|
1319 {
|
Chris@76
|
1320 // Nothing is changed to the lock.
|
Chris@76
|
1321 if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
|
Chris@76
|
1322 unset($_POST['lock']);
|
Chris@76
|
1323 // You're have no permission to lock this topic.
|
Chris@76
|
1324 elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
|
Chris@76
|
1325 unset($_POST['lock']);
|
Chris@76
|
1326 // You are allowed to (un)lock your own topic only.
|
Chris@76
|
1327 elseif (!allowedTo('lock_any'))
|
Chris@76
|
1328 {
|
Chris@76
|
1329 // You cannot override a moderator lock.
|
Chris@76
|
1330 if ($topic_info['locked'] == 1)
|
Chris@76
|
1331 unset($_POST['lock']);
|
Chris@76
|
1332 else
|
Chris@76
|
1333 $_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
|
Chris@76
|
1334 }
|
Chris@76
|
1335 // Hail mighty moderator, (un)lock this topic immediately.
|
Chris@76
|
1336 else
|
Chris@76
|
1337 $_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
|
Chris@76
|
1338 }
|
Chris@76
|
1339
|
Chris@76
|
1340 // So you wanna (un)sticky this...let's see.
|
Chris@76
|
1341 if (isset($_POST['sticky']) && (empty($modSettings['enableStickyTopics']) || $_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky')))
|
Chris@76
|
1342 unset($_POST['sticky']);
|
Chris@76
|
1343
|
Chris@76
|
1344 // If the number of replies has changed, if the setting is enabled, go back to Post() - which handles the error.
|
Chris@76
|
1345 if (empty($options['no_new_reply_warning']) && isset($_POST['last_msg']) && $topic_info['id_last_msg'] > $_POST['last_msg'])
|
Chris@76
|
1346 {
|
Chris@76
|
1347 $_REQUEST['preview'] = true;
|
Chris@76
|
1348 return Post();
|
Chris@76
|
1349 }
|
Chris@76
|
1350
|
Chris@76
|
1351 $posterIsGuest = $user_info['is_guest'];
|
Chris@76
|
1352 }
|
Chris@76
|
1353 // Posting a new topic.
|
Chris@76
|
1354 elseif (empty($topic))
|
Chris@76
|
1355 {
|
Chris@76
|
1356 // Now don't be silly, new topics will get their own id_msg soon enough.
|
Chris@76
|
1357 unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
|
Chris@76
|
1358
|
Chris@76
|
1359 // Do like, the permissions, for safety and stuff...
|
Chris@76
|
1360 $becomesApproved = true;
|
Chris@76
|
1361 if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
|
Chris@76
|
1362 $becomesApproved = false;
|
Chris@76
|
1363 else
|
Chris@76
|
1364 isAllowedTo('post_new');
|
Chris@76
|
1365
|
Chris@76
|
1366 if (isset($_POST['lock']))
|
Chris@76
|
1367 {
|
Chris@76
|
1368 // New topics are by default not locked.
|
Chris@76
|
1369 if (empty($_POST['lock']))
|
Chris@76
|
1370 unset($_POST['lock']);
|
Chris@76
|
1371 // Besides, you need permission.
|
Chris@76
|
1372 elseif (!allowedTo(array('lock_any', 'lock_own')))
|
Chris@76
|
1373 unset($_POST['lock']);
|
Chris@76
|
1374 // A moderator-lock (1) can override a user-lock (2).
|
Chris@76
|
1375 else
|
Chris@76
|
1376 $_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
|
Chris@76
|
1377 }
|
Chris@76
|
1378
|
Chris@76
|
1379 if (isset($_POST['sticky']) && (empty($modSettings['enableStickyTopics']) || empty($_POST['sticky']) || !allowedTo('make_sticky')))
|
Chris@76
|
1380 unset($_POST['sticky']);
|
Chris@76
|
1381
|
Chris@76
|
1382 $posterIsGuest = $user_info['is_guest'];
|
Chris@76
|
1383 }
|
Chris@76
|
1384 // Modifying an existing message?
|
Chris@76
|
1385 elseif (isset($_REQUEST['msg']) && !empty($topic))
|
Chris@76
|
1386 {
|
Chris@76
|
1387 $_REQUEST['msg'] = (int) $_REQUEST['msg'];
|
Chris@76
|
1388
|
Chris@76
|
1389 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1390 SELECT id_member, poster_name, poster_email, poster_time, approved
|
Chris@76
|
1391 FROM {db_prefix}messages
|
Chris@76
|
1392 WHERE id_msg = {int:id_msg}
|
Chris@76
|
1393 LIMIT 1',
|
Chris@76
|
1394 array(
|
Chris@76
|
1395 'id_msg' => $_REQUEST['msg'],
|
Chris@76
|
1396 )
|
Chris@76
|
1397 );
|
Chris@76
|
1398 if ($smcFunc['db_num_rows']($request) == 0)
|
Chris@76
|
1399 fatal_lang_error('cant_find_messages', false);
|
Chris@76
|
1400 $row = $smcFunc['db_fetch_assoc']($request);
|
Chris@76
|
1401 $smcFunc['db_free_result']($request);
|
Chris@76
|
1402
|
Chris@76
|
1403 if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))
|
Chris@76
|
1404 fatal_lang_error('topic_locked', false);
|
Chris@76
|
1405
|
Chris@76
|
1406 if (isset($_POST['lock']))
|
Chris@76
|
1407 {
|
Chris@76
|
1408 // Nothing changes to the lock status.
|
Chris@76
|
1409 if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
|
Chris@76
|
1410 unset($_POST['lock']);
|
Chris@76
|
1411 // You're simply not allowed to (un)lock this.
|
Chris@76
|
1412 elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
|
Chris@76
|
1413 unset($_POST['lock']);
|
Chris@76
|
1414 // You're only allowed to lock your own topics.
|
Chris@76
|
1415 elseif (!allowedTo('lock_any'))
|
Chris@76
|
1416 {
|
Chris@76
|
1417 // You're not allowed to break a moderator's lock.
|
Chris@76
|
1418 if ($topic_info['locked'] == 1)
|
Chris@76
|
1419 unset($_POST['lock']);
|
Chris@76
|
1420 // Lock it with a soft lock or unlock it.
|
Chris@76
|
1421 else
|
Chris@76
|
1422 $_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
|
Chris@76
|
1423 }
|
Chris@76
|
1424 // You must be the moderator.
|
Chris@76
|
1425 else
|
Chris@76
|
1426 $_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
|
Chris@76
|
1427 }
|
Chris@76
|
1428
|
Chris@76
|
1429 // Change the sticky status of this topic?
|
Chris@76
|
1430 if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky']))
|
Chris@76
|
1431 unset($_POST['sticky']);
|
Chris@76
|
1432
|
Chris@76
|
1433 if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
|
Chris@76
|
1434 {
|
Chris@76
|
1435 if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
|
Chris@76
|
1436 fatal_lang_error('modify_post_time_passed', false);
|
Chris@76
|
1437 elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
|
Chris@76
|
1438 isAllowedTo('modify_replies');
|
Chris@76
|
1439 else
|
Chris@76
|
1440 isAllowedTo('modify_own');
|
Chris@76
|
1441 }
|
Chris@76
|
1442 elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
|
Chris@76
|
1443 {
|
Chris@76
|
1444 isAllowedTo('modify_replies');
|
Chris@76
|
1445
|
Chris@76
|
1446 // If you're modifying a reply, I say it better be logged...
|
Chris@76
|
1447 $moderationAction = true;
|
Chris@76
|
1448 }
|
Chris@76
|
1449 else
|
Chris@76
|
1450 {
|
Chris@76
|
1451 isAllowedTo('modify_any');
|
Chris@76
|
1452
|
Chris@76
|
1453 // Log it, assuming you're not modifying your own post.
|
Chris@76
|
1454 if ($row['id_member'] != $user_info['id'])
|
Chris@76
|
1455 $moderationAction = true;
|
Chris@76
|
1456 }
|
Chris@76
|
1457
|
Chris@76
|
1458 $posterIsGuest = empty($row['id_member']);
|
Chris@76
|
1459
|
Chris@76
|
1460 // Can they approve it?
|
Chris@76
|
1461 $can_approve = allowedTo('approve_posts');
|
Chris@76
|
1462 $becomesApproved = $modSettings['postmod_active'] ? ($can_approve && !$row['approved'] ? (!empty($_REQUEST['approve']) ? 1 : 0) : $row['approved']) : 1;
|
Chris@76
|
1463 $approve_has_changed = $row['approved'] != $becomesApproved;
|
Chris@76
|
1464
|
Chris@76
|
1465 if (!allowedTo('moderate_forum') || !$posterIsGuest)
|
Chris@76
|
1466 {
|
Chris@76
|
1467 $_POST['guestname'] = $row['poster_name'];
|
Chris@76
|
1468 $_POST['email'] = $row['poster_email'];
|
Chris@76
|
1469 }
|
Chris@76
|
1470 }
|
Chris@76
|
1471
|
Chris@76
|
1472 // If the poster is a guest evaluate the legality of name and email.
|
Chris@76
|
1473 if ($posterIsGuest)
|
Chris@76
|
1474 {
|
Chris@76
|
1475 $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']);
|
Chris@76
|
1476 $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
|
Chris@76
|
1477
|
Chris@76
|
1478 if ($_POST['guestname'] == '' || $_POST['guestname'] == '_')
|
Chris@76
|
1479 $post_errors[] = 'no_name';
|
Chris@76
|
1480 if ($smcFunc['strlen']($_POST['guestname']) > 25)
|
Chris@76
|
1481 $post_errors[] = 'long_name';
|
Chris@76
|
1482
|
Chris@76
|
1483 if (empty($modSettings['guest_post_no_email']))
|
Chris@76
|
1484 {
|
Chris@76
|
1485 // Only check if they changed it!
|
Chris@76
|
1486 if (!isset($row) || $row['poster_email'] != $_POST['email'])
|
Chris@76
|
1487 {
|
Chris@76
|
1488 if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == ''))
|
Chris@76
|
1489 $post_errors[] = 'no_email';
|
Chris@76
|
1490 if (!allowedTo('moderate_forum') && preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['email']) == 0)
|
Chris@76
|
1491 $post_errors[] = 'bad_email';
|
Chris@76
|
1492 }
|
Chris@76
|
1493
|
Chris@76
|
1494 // Now make sure this email address is not banned from posting.
|
Chris@76
|
1495 isBannedEmail($_POST['email'], 'cannot_post', sprintf($txt['you_are_post_banned'], $txt['guest_title']));
|
Chris@76
|
1496 }
|
Chris@76
|
1497
|
Chris@76
|
1498 // In case they are making multiple posts this visit, help them along by storing their name.
|
Chris@76
|
1499 if (empty($post_errors))
|
Chris@76
|
1500 {
|
Chris@76
|
1501 $_SESSION['guest_name'] = $_POST['guestname'];
|
Chris@76
|
1502 $_SESSION['guest_email'] = $_POST['email'];
|
Chris@76
|
1503 }
|
Chris@76
|
1504 }
|
Chris@76
|
1505
|
Chris@76
|
1506 // Check the subject and message.
|
Chris@76
|
1507 if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '')
|
Chris@76
|
1508 $post_errors[] = 'no_subject';
|
Chris@76
|
1509 if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '')
|
Chris@76
|
1510 $post_errors[] = 'no_message';
|
Chris@76
|
1511 elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
|
Chris@76
|
1512 $post_errors[] = 'long_message';
|
Chris@76
|
1513 else
|
Chris@76
|
1514 {
|
Chris@76
|
1515 // Prepare the message a bit for some additional testing.
|
Chris@76
|
1516 $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
|
Chris@76
|
1517
|
Chris@76
|
1518 // Preparse code. (Zef)
|
Chris@76
|
1519 if ($user_info['is_guest'])
|
Chris@76
|
1520 $user_info['name'] = $_POST['guestname'];
|
Chris@76
|
1521 preparsecode($_POST['message']);
|
Chris@76
|
1522
|
Chris@76
|
1523 // Let's see if there's still some content left without the tags.
|
Chris@76
|
1524 if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false))
|
Chris@76
|
1525 $post_errors[] = 'no_message';
|
Chris@76
|
1526 }
|
Chris@76
|
1527 if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '')
|
Chris@76
|
1528 $post_errors[] = 'no_event';
|
Chris@76
|
1529 // You are not!
|
Chris@76
|
1530 if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin'])
|
Chris@76
|
1531 fatal_error('Knave! Masquerader! Charlatan!', false);
|
Chris@76
|
1532
|
Chris@76
|
1533 // Validate the poll...
|
Chris@76
|
1534 if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
|
Chris@76
|
1535 {
|
Chris@76
|
1536 if (!empty($topic) && !isset($_REQUEST['msg']))
|
Chris@76
|
1537 fatal_lang_error('no_access', false);
|
Chris@76
|
1538
|
Chris@76
|
1539 // This is a new topic... so it's a new poll.
|
Chris@76
|
1540 if (empty($topic))
|
Chris@76
|
1541 isAllowedTo('poll_post');
|
Chris@76
|
1542 // Can you add to your own topics?
|
Chris@76
|
1543 elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any'))
|
Chris@76
|
1544 isAllowedTo('poll_add_own');
|
Chris@76
|
1545 // Can you add polls to any topic, then?
|
Chris@76
|
1546 else
|
Chris@76
|
1547 isAllowedTo('poll_add_any');
|
Chris@76
|
1548
|
Chris@76
|
1549 if (!isset($_POST['question']) || trim($_POST['question']) == '')
|
Chris@76
|
1550 $post_errors[] = 'no_question';
|
Chris@76
|
1551
|
Chris@76
|
1552 $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']);
|
Chris@76
|
1553
|
Chris@76
|
1554 // Get rid of empty ones.
|
Chris@76
|
1555 foreach ($_POST['options'] as $k => $option)
|
Chris@76
|
1556 if ($option == '')
|
Chris@76
|
1557 unset($_POST['options'][$k], $_POST['options'][$k]);
|
Chris@76
|
1558
|
Chris@76
|
1559 // What are you going to vote between with one choice?!?
|
Chris@76
|
1560 if (count($_POST['options']) < 2)
|
Chris@76
|
1561 $post_errors[] = 'poll_few';
|
Chris@76
|
1562 }
|
Chris@76
|
1563
|
Chris@76
|
1564 if ($posterIsGuest)
|
Chris@76
|
1565 {
|
Chris@76
|
1566 // If user is a guest, make sure the chosen name isn't taken.
|
Chris@76
|
1567 require_once($sourcedir . '/Subs-Members.php');
|
Chris@76
|
1568 if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name']))
|
Chris@76
|
1569 $post_errors[] = 'bad_name';
|
Chris@76
|
1570 }
|
Chris@76
|
1571 // If the user isn't a guest, get his or her name and email.
|
Chris@76
|
1572 elseif (!isset($_REQUEST['msg']))
|
Chris@76
|
1573 {
|
Chris@76
|
1574 $_POST['guestname'] = $user_info['username'];
|
Chris@76
|
1575 $_POST['email'] = $user_info['email'];
|
Chris@76
|
1576 }
|
Chris@76
|
1577
|
Chris@76
|
1578 // Any mistakes?
|
Chris@76
|
1579 if (!empty($post_errors))
|
Chris@76
|
1580 {
|
Chris@76
|
1581 loadLanguage('Errors');
|
Chris@76
|
1582 // Previewing.
|
Chris@76
|
1583 $_REQUEST['preview'] = true;
|
Chris@76
|
1584
|
Chris@76
|
1585 $context['post_error'] = array('messages' => array());
|
Chris@76
|
1586 foreach ($post_errors as $post_error)
|
Chris@76
|
1587 {
|
Chris@76
|
1588 $context['post_error'][$post_error] = true;
|
Chris@76
|
1589 if ($post_error == 'long_message')
|
Chris@76
|
1590 $txt['error_' . $post_error] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
|
Chris@76
|
1591
|
Chris@76
|
1592 $context['post_error']['messages'][] = $txt['error_' . $post_error];
|
Chris@76
|
1593 }
|
Chris@76
|
1594
|
Chris@76
|
1595 return Post();
|
Chris@76
|
1596 }
|
Chris@76
|
1597
|
Chris@76
|
1598 // Make sure the user isn't spamming the board.
|
Chris@76
|
1599 if (!isset($_REQUEST['msg']))
|
Chris@76
|
1600 spamProtection('post');
|
Chris@76
|
1601
|
Chris@76
|
1602 // At about this point, we're posting and that's that.
|
Chris@76
|
1603 ignore_user_abort(true);
|
Chris@76
|
1604 @set_time_limit(300);
|
Chris@76
|
1605
|
Chris@76
|
1606 // Add special html entities to the subject, name, and email.
|
Chris@76
|
1607 $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
|
Chris@76
|
1608 $_POST['guestname'] = htmlspecialchars($_POST['guestname']);
|
Chris@76
|
1609 $_POST['email'] = htmlspecialchars($_POST['email']);
|
Chris@76
|
1610
|
Chris@76
|
1611 // At this point, we want to make sure the subject isn't too long.
|
Chris@76
|
1612 if ($smcFunc['strlen']($_POST['subject']) > 100)
|
Chris@76
|
1613 $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
|
Chris@76
|
1614
|
Chris@76
|
1615 // Make the poll...
|
Chris@76
|
1616 if (isset($_REQUEST['poll']))
|
Chris@76
|
1617 {
|
Chris@76
|
1618 // Make sure that the user has not entered a ridiculous number of options..
|
Chris@76
|
1619 if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0)
|
Chris@76
|
1620 $_POST['poll_max_votes'] = 1;
|
Chris@76
|
1621 elseif ($_POST['poll_max_votes'] > count($_POST['options']))
|
Chris@76
|
1622 $_POST['poll_max_votes'] = count($_POST['options']);
|
Chris@76
|
1623 else
|
Chris@76
|
1624 $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
|
Chris@76
|
1625
|
Chris@76
|
1626 $_POST['poll_expire'] = (int) $_POST['poll_expire'];
|
Chris@76
|
1627 $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
|
Chris@76
|
1628
|
Chris@76
|
1629 // Just set it to zero if it's not there..
|
Chris@76
|
1630 if (!isset($_POST['poll_hide']))
|
Chris@76
|
1631 $_POST['poll_hide'] = 0;
|
Chris@76
|
1632 else
|
Chris@76
|
1633 $_POST['poll_hide'] = (int) $_POST['poll_hide'];
|
Chris@76
|
1634 $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0;
|
Chris@76
|
1635
|
Chris@76
|
1636 $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0;
|
Chris@76
|
1637 // Make sure guests are actually allowed to vote generally.
|
Chris@76
|
1638 if ($_POST['poll_guest_vote'])
|
Chris@76
|
1639 {
|
Chris@76
|
1640 require_once($sourcedir . '/Subs-Members.php');
|
Chris@76
|
1641 $allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
|
Chris@76
|
1642 if (!in_array(-1, $allowedVoteGroups['allowed']))
|
Chris@76
|
1643 $_POST['poll_guest_vote'] = 0;
|
Chris@76
|
1644 }
|
Chris@76
|
1645
|
Chris@76
|
1646 // If the user tries to set the poll too far in advance, don't let them.
|
Chris@76
|
1647 if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1)
|
Chris@76
|
1648 fatal_lang_error('poll_range_error', false);
|
Chris@76
|
1649 // Don't allow them to select option 2 for hidden results if it's not time limited.
|
Chris@76
|
1650 elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2)
|
Chris@76
|
1651 $_POST['poll_hide'] = 1;
|
Chris@76
|
1652
|
Chris@76
|
1653 // Clean up the question and answers.
|
Chris@76
|
1654 $_POST['question'] = htmlspecialchars($_POST['question']);
|
Chris@76
|
1655 $_POST['question'] = $smcFunc['truncate']($_POST['question'], 255);
|
Chris@76
|
1656 $_POST['question'] = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $_POST['question']);
|
Chris@76
|
1657 $_POST['options'] = htmlspecialchars__recursive($_POST['options']);
|
Chris@76
|
1658 }
|
Chris@76
|
1659
|
Chris@76
|
1660 // Check if they are trying to delete any current attachments....
|
Chris@76
|
1661 if (isset($_REQUEST['msg'], $_POST['attach_del']) && (allowedTo('post_attachment') || ($modSettings['postmod_active'] && allowedTo('post_unapproved_attachments'))))
|
Chris@76
|
1662 {
|
Chris@76
|
1663 $del_temp = array();
|
Chris@76
|
1664 foreach ($_POST['attach_del'] as $i => $dummy)
|
Chris@76
|
1665 $del_temp[$i] = (int) $dummy;
|
Chris@76
|
1666
|
Chris@76
|
1667 require_once($sourcedir . '/ManageAttachments.php');
|
Chris@76
|
1668 $attachmentQuery = array(
|
Chris@76
|
1669 'attachment_type' => 0,
|
Chris@76
|
1670 'id_msg' => (int) $_REQUEST['msg'],
|
Chris@76
|
1671 'not_id_attach' => $del_temp,
|
Chris@76
|
1672 );
|
Chris@76
|
1673 removeAttachments($attachmentQuery);
|
Chris@76
|
1674 }
|
Chris@76
|
1675
|
Chris@76
|
1676 // ...or attach a new file...
|
Chris@76
|
1677 if (isset($_FILES['attachment']['name']) || (!empty($_SESSION['temp_attachments']) && empty($_POST['from_qr'])))
|
Chris@76
|
1678 {
|
Chris@76
|
1679 // Verify they can post them!
|
Chris@76
|
1680 if (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_attachments'))
|
Chris@76
|
1681 isAllowedTo('post_attachment');
|
Chris@76
|
1682
|
Chris@76
|
1683 // Make sure we're uploading to the right place.
|
Chris@76
|
1684 if (!empty($modSettings['currentAttachmentUploadDir']))
|
Chris@76
|
1685 {
|
Chris@76
|
1686 if (!is_array($modSettings['attachmentUploadDir']))
|
Chris@76
|
1687 $modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
|
Chris@76
|
1688
|
Chris@76
|
1689 // The current directory, of course!
|
Chris@76
|
1690 $current_attach_dir = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
|
Chris@76
|
1691 }
|
Chris@76
|
1692 else
|
Chris@76
|
1693 $current_attach_dir = $modSettings['attachmentUploadDir'];
|
Chris@76
|
1694
|
Chris@76
|
1695 // If this isn't a new post, check the current attachments.
|
Chris@76
|
1696 if (isset($_REQUEST['msg']))
|
Chris@76
|
1697 {
|
Chris@76
|
1698 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1699 SELECT COUNT(*), SUM(size)
|
Chris@76
|
1700 FROM {db_prefix}attachments
|
Chris@76
|
1701 WHERE id_msg = {int:id_msg}
|
Chris@76
|
1702 AND attachment_type = {int:attachment_type}',
|
Chris@76
|
1703 array(
|
Chris@76
|
1704 'id_msg' => (int) $_REQUEST['msg'],
|
Chris@76
|
1705 'attachment_type' => 0,
|
Chris@76
|
1706 )
|
Chris@76
|
1707 );
|
Chris@76
|
1708 list ($quantity, $total_size) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
1709 $smcFunc['db_free_result']($request);
|
Chris@76
|
1710 }
|
Chris@76
|
1711 else
|
Chris@76
|
1712 {
|
Chris@76
|
1713 $quantity = 0;
|
Chris@76
|
1714 $total_size = 0;
|
Chris@76
|
1715 }
|
Chris@76
|
1716
|
Chris@76
|
1717 if (!empty($_SESSION['temp_attachments']))
|
Chris@76
|
1718 foreach ($_SESSION['temp_attachments'] as $attachID => $name)
|
Chris@76
|
1719 {
|
Chris@76
|
1720 if (preg_match('~^post_tmp_' . $user_info['id'] . '_\d+$~', $attachID) == 0)
|
Chris@76
|
1721 continue;
|
Chris@76
|
1722
|
Chris@76
|
1723 if (!empty($_POST['attach_del']) && !in_array($attachID, $_POST['attach_del']))
|
Chris@76
|
1724 {
|
Chris@76
|
1725 unset($_SESSION['temp_attachments'][$attachID]);
|
Chris@76
|
1726 @unlink($current_attach_dir . '/' . $attachID);
|
Chris@76
|
1727 continue;
|
Chris@76
|
1728 }
|
Chris@76
|
1729
|
Chris@76
|
1730 $_FILES['attachment']['tmp_name'][] = $attachID;
|
Chris@76
|
1731 $_FILES['attachment']['name'][] = $name;
|
Chris@76
|
1732 $_FILES['attachment']['size'][] = filesize($current_attach_dir . '/' . $attachID);
|
Chris@76
|
1733 list ($_FILES['attachment']['width'][], $_FILES['attachment']['height'][]) = @getimagesize($current_attach_dir . '/' . $attachID);
|
Chris@76
|
1734
|
Chris@76
|
1735 unset($_SESSION['temp_attachments'][$attachID]);
|
Chris@76
|
1736 }
|
Chris@76
|
1737
|
Chris@76
|
1738 if (!isset($_FILES['attachment']['name']))
|
Chris@76
|
1739 $_FILES['attachment']['tmp_name'] = array();
|
Chris@76
|
1740
|
Chris@76
|
1741 $attachIDs = array();
|
Chris@76
|
1742 foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
|
Chris@76
|
1743 {
|
Chris@76
|
1744 if ($_FILES['attachment']['name'][$n] == '')
|
Chris@76
|
1745 continue;
|
Chris@76
|
1746
|
Chris@76
|
1747 // Have we reached the maximum number of files we are allowed?
|
Chris@76
|
1748 $quantity++;
|
Chris@76
|
1749 if (!empty($modSettings['attachmentNumPerPostLimit']) && $quantity > $modSettings['attachmentNumPerPostLimit'])
|
Chris@76
|
1750 {
|
Chris@76
|
1751 checkSubmitOnce('free');
|
Chris@76
|
1752 fatal_lang_error('attachments_limit_per_post', false, array($modSettings['attachmentNumPerPostLimit']));
|
Chris@76
|
1753 }
|
Chris@76
|
1754
|
Chris@76
|
1755 // Check the total upload size for this post...
|
Chris@76
|
1756 $total_size += $_FILES['attachment']['size'][$n];
|
Chris@76
|
1757 if (!empty($modSettings['attachmentPostLimit']) && $total_size > $modSettings['attachmentPostLimit'] * 1024)
|
Chris@76
|
1758 {
|
Chris@76
|
1759 checkSubmitOnce('free');
|
Chris@76
|
1760 fatal_lang_error('file_too_big', false, array($modSettings['attachmentPostLimit']));
|
Chris@76
|
1761 }
|
Chris@76
|
1762
|
Chris@76
|
1763 $attachmentOptions = array(
|
Chris@76
|
1764 'post' => isset($_REQUEST['msg']) ? $_REQUEST['msg'] : 0,
|
Chris@76
|
1765 'poster' => $user_info['id'],
|
Chris@76
|
1766 'name' => $_FILES['attachment']['name'][$n],
|
Chris@76
|
1767 'tmp_name' => $_FILES['attachment']['tmp_name'][$n],
|
Chris@76
|
1768 'size' => $_FILES['attachment']['size'][$n],
|
Chris@76
|
1769 'approved' => !$modSettings['postmod_active'] || allowedTo('post_attachment'),
|
Chris@76
|
1770 );
|
Chris@76
|
1771
|
Chris@76
|
1772 if (createAttachment($attachmentOptions))
|
Chris@76
|
1773 {
|
Chris@76
|
1774 $attachIDs[] = $attachmentOptions['id'];
|
Chris@76
|
1775 if (!empty($attachmentOptions['thumb']))
|
Chris@76
|
1776 $attachIDs[] = $attachmentOptions['thumb'];
|
Chris@76
|
1777 }
|
Chris@76
|
1778 else
|
Chris@76
|
1779 {
|
Chris@76
|
1780 if (in_array('could_not_upload', $attachmentOptions['errors']))
|
Chris@76
|
1781 {
|
Chris@76
|
1782 checkSubmitOnce('free');
|
Chris@76
|
1783 fatal_lang_error('attach_timeout', 'critical');
|
Chris@76
|
1784 }
|
Chris@76
|
1785 if (in_array('too_large', $attachmentOptions['errors']))
|
Chris@76
|
1786 {
|
Chris@76
|
1787 checkSubmitOnce('free');
|
Chris@76
|
1788 fatal_lang_error('file_too_big', false, array($modSettings['attachmentSizeLimit']));
|
Chris@76
|
1789 }
|
Chris@76
|
1790 if (in_array('bad_extension', $attachmentOptions['errors']))
|
Chris@76
|
1791 {
|
Chris@76
|
1792 checkSubmitOnce('free');
|
Chris@76
|
1793 fatal_error($attachmentOptions['name'] . '.<br />' . $txt['cant_upload_type'] . ' ' . $modSettings['attachmentExtensions'] . '.', false);
|
Chris@76
|
1794 }
|
Chris@76
|
1795 if (in_array('directory_full', $attachmentOptions['errors']))
|
Chris@76
|
1796 {
|
Chris@76
|
1797 checkSubmitOnce('free');
|
Chris@76
|
1798 fatal_lang_error('ran_out_of_space', 'critical');
|
Chris@76
|
1799 }
|
Chris@76
|
1800 if (in_array('bad_filename', $attachmentOptions['errors']))
|
Chris@76
|
1801 {
|
Chris@76
|
1802 checkSubmitOnce('free');
|
Chris@76
|
1803 fatal_error(basename($attachmentOptions['name']) . '.<br />' . $txt['restricted_filename'] . '.', 'critical');
|
Chris@76
|
1804 }
|
Chris@76
|
1805 if (in_array('taken_filename', $attachmentOptions['errors']))
|
Chris@76
|
1806 {
|
Chris@76
|
1807 checkSubmitOnce('free');
|
Chris@76
|
1808 fatal_lang_error('filename_exists');
|
Chris@76
|
1809 }
|
Chris@76
|
1810 if (in_array('bad_attachment', $attachmentOptions['errors']))
|
Chris@76
|
1811 {
|
Chris@76
|
1812 checkSubmitOnce('free');
|
Chris@76
|
1813 fatal_lang_error('bad_attachment');
|
Chris@76
|
1814 }
|
Chris@76
|
1815 }
|
Chris@76
|
1816 }
|
Chris@76
|
1817 }
|
Chris@76
|
1818
|
Chris@76
|
1819 // Make the poll...
|
Chris@76
|
1820 if (isset($_REQUEST['poll']))
|
Chris@76
|
1821 {
|
Chris@76
|
1822 // Create the poll.
|
Chris@76
|
1823 $smcFunc['db_insert']('',
|
Chris@76
|
1824 '{db_prefix}polls',
|
Chris@76
|
1825 array(
|
Chris@76
|
1826 'question' => 'string-255', 'hide_results' => 'int', 'max_votes' => 'int', 'expire_time' => 'int', 'id_member' => 'int',
|
Chris@76
|
1827 'poster_name' => 'string-255', 'change_vote' => 'int', 'guest_vote' => 'int'
|
Chris@76
|
1828 ),
|
Chris@76
|
1829 array(
|
Chris@76
|
1830 $_POST['question'], $_POST['poll_hide'], $_POST['poll_max_votes'], (empty($_POST['poll_expire']) ? 0 : time() + $_POST['poll_expire'] * 3600 * 24), $user_info['id'],
|
Chris@76
|
1831 $_POST['guestname'], $_POST['poll_change_vote'], $_POST['poll_guest_vote'],
|
Chris@76
|
1832 ),
|
Chris@76
|
1833 array('id_poll')
|
Chris@76
|
1834 );
|
Chris@76
|
1835 $id_poll = $smcFunc['db_insert_id']('{db_prefix}polls', 'id_poll');
|
Chris@76
|
1836
|
Chris@76
|
1837 // Create each answer choice.
|
Chris@76
|
1838 $i = 0;
|
Chris@76
|
1839 $pollOptions = array();
|
Chris@76
|
1840 foreach ($_POST['options'] as $option)
|
Chris@76
|
1841 {
|
Chris@76
|
1842 $pollOptions[] = array($id_poll, $i, $option);
|
Chris@76
|
1843 $i++;
|
Chris@76
|
1844 }
|
Chris@76
|
1845
|
Chris@76
|
1846 $smcFunc['db_insert']('insert',
|
Chris@76
|
1847 '{db_prefix}poll_choices',
|
Chris@76
|
1848 array('id_poll' => 'int', 'id_choice' => 'int', 'label' => 'string-255'),
|
Chris@76
|
1849 $pollOptions,
|
Chris@76
|
1850 array('id_poll', 'id_choice')
|
Chris@76
|
1851 );
|
Chris@76
|
1852 }
|
Chris@76
|
1853 else
|
Chris@76
|
1854 $id_poll = 0;
|
Chris@76
|
1855
|
Chris@76
|
1856 // Creating a new topic?
|
Chris@76
|
1857 $newTopic = empty($_REQUEST['msg']) && empty($topic);
|
Chris@76
|
1858
|
Chris@76
|
1859 $_POST['icon'] = !empty($attachIDs) && $_POST['icon'] == 'xx' ? 'clip' : $_POST['icon'];
|
Chris@76
|
1860
|
Chris@76
|
1861 // Collect all parameters for the creation or modification of a post.
|
Chris@76
|
1862 $msgOptions = array(
|
Chris@76
|
1863 'id' => empty($_REQUEST['msg']) ? 0 : (int) $_REQUEST['msg'],
|
Chris@76
|
1864 'subject' => $_POST['subject'],
|
Chris@76
|
1865 'body' => $_POST['message'],
|
Chris@76
|
1866 'icon' => preg_replace('~[\./\\\\*:"\'<>]~', '', $_POST['icon']),
|
Chris@76
|
1867 'smileys_enabled' => !isset($_POST['ns']),
|
Chris@76
|
1868 'attachments' => empty($attachIDs) ? array() : $attachIDs,
|
Chris@76
|
1869 'approved' => $becomesApproved,
|
Chris@76
|
1870 );
|
Chris@76
|
1871 $topicOptions = array(
|
Chris@76
|
1872 'id' => empty($topic) ? 0 : $topic,
|
Chris@76
|
1873 'board' => $board,
|
Chris@76
|
1874 'poll' => isset($_REQUEST['poll']) ? $id_poll : null,
|
Chris@76
|
1875 'lock_mode' => isset($_POST['lock']) ? (int) $_POST['lock'] : null,
|
Chris@76
|
1876 'sticky_mode' => isset($_POST['sticky']) && !empty($modSettings['enableStickyTopics']) ? (int) $_POST['sticky'] : null,
|
Chris@76
|
1877 'mark_as_read' => true,
|
Chris@76
|
1878 'is_approved' => !$modSettings['postmod_active'] || empty($topic) || !empty($board_info['cur_topic_approved']),
|
Chris@76
|
1879 );
|
Chris@76
|
1880 $posterOptions = array(
|
Chris@76
|
1881 'id' => $user_info['id'],
|
Chris@76
|
1882 'name' => $_POST['guestname'],
|
Chris@76
|
1883 'email' => $_POST['email'],
|
Chris@76
|
1884 'update_post_count' => !$user_info['is_guest'] && !isset($_REQUEST['msg']) && $board_info['posts_count'],
|
Chris@76
|
1885 );
|
Chris@76
|
1886
|
Chris@76
|
1887 // This is an already existing message. Edit it.
|
Chris@76
|
1888 if (!empty($_REQUEST['msg']))
|
Chris@76
|
1889 {
|
Chris@76
|
1890 // Have admins allowed people to hide their screwups?
|
Chris@76
|
1891 if (time() - $row['poster_time'] > $modSettings['edit_wait_time'] || $user_info['id'] != $row['id_member'])
|
Chris@76
|
1892 {
|
Chris@76
|
1893 $msgOptions['modify_time'] = time();
|
Chris@76
|
1894 $msgOptions['modify_name'] = $user_info['name'];
|
Chris@76
|
1895 }
|
Chris@76
|
1896
|
Chris@76
|
1897 // This will save some time...
|
Chris@76
|
1898 if (empty($approve_has_changed))
|
Chris@76
|
1899 unset($msgOptions['approved']);
|
Chris@76
|
1900
|
Chris@76
|
1901 modifyPost($msgOptions, $topicOptions, $posterOptions);
|
Chris@76
|
1902 }
|
Chris@76
|
1903 // This is a new topic or an already existing one. Save it.
|
Chris@76
|
1904 else
|
Chris@76
|
1905 {
|
Chris@76
|
1906 createPost($msgOptions, $topicOptions, $posterOptions);
|
Chris@76
|
1907
|
Chris@76
|
1908 if (isset($topicOptions['id']))
|
Chris@76
|
1909 $topic = $topicOptions['id'];
|
Chris@76
|
1910 }
|
Chris@76
|
1911
|
Chris@76
|
1912 // Editing or posting an event?
|
Chris@76
|
1913 if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1))
|
Chris@76
|
1914 {
|
Chris@76
|
1915 require_once($sourcedir . '/Subs-Calendar.php');
|
Chris@76
|
1916
|
Chris@76
|
1917 // Make sure they can link an event to this post.
|
Chris@76
|
1918 canLinkEvent();
|
Chris@76
|
1919
|
Chris@76
|
1920 // Insert the event.
|
Chris@76
|
1921 $eventOptions = array(
|
Chris@76
|
1922 'board' => $board,
|
Chris@76
|
1923 'topic' => $topic,
|
Chris@76
|
1924 'title' => $_POST['evtitle'],
|
Chris@76
|
1925 'member' => $user_info['id'],
|
Chris@76
|
1926 'start_date' => sprintf('%04d-%02d-%02d', $_POST['year'], $_POST['month'], $_POST['day']),
|
Chris@76
|
1927 'span' => isset($_POST['span']) && $_POST['span'] > 0 ? min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1) : 0,
|
Chris@76
|
1928 );
|
Chris@76
|
1929 insertEvent($eventOptions);
|
Chris@76
|
1930 }
|
Chris@76
|
1931 elseif (isset($_POST['calendar']))
|
Chris@76
|
1932 {
|
Chris@76
|
1933 $_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
|
Chris@76
|
1934
|
Chris@76
|
1935 // Validate the post...
|
Chris@76
|
1936 require_once($sourcedir . '/Subs-Calendar.php');
|
Chris@76
|
1937 validateEventPost();
|
Chris@76
|
1938
|
Chris@76
|
1939 // If you're not allowed to edit any events, you have to be the poster.
|
Chris@76
|
1940 if (!allowedTo('calendar_edit_any'))
|
Chris@76
|
1941 {
|
Chris@76
|
1942 // Get the event's poster.
|
Chris@76
|
1943 $request = $smcFunc['db_query']('', '
|
Chris@76
|
1944 SELECT id_member
|
Chris@76
|
1945 FROM {db_prefix}calendar
|
Chris@76
|
1946 WHERE id_event = {int:id_event}',
|
Chris@76
|
1947 array(
|
Chris@76
|
1948 'id_event' => $_REQUEST['eventid'],
|
Chris@76
|
1949 )
|
Chris@76
|
1950 );
|
Chris@76
|
1951 $row2 = $smcFunc['db_fetch_assoc']($request);
|
Chris@76
|
1952 $smcFunc['db_free_result']($request);
|
Chris@76
|
1953
|
Chris@76
|
1954 // Silly hacker, Trix are for kids. ...probably trademarked somewhere, this is FAIR USE! (parody...)
|
Chris@76
|
1955 isAllowedTo('calendar_edit_' . ($row2['id_member'] == $user_info['id'] ? 'own' : 'any'));
|
Chris@76
|
1956 }
|
Chris@76
|
1957
|
Chris@76
|
1958 // Delete it?
|
Chris@76
|
1959 if (isset($_REQUEST['deleteevent']))
|
Chris@76
|
1960 $smcFunc['db_query']('', '
|
Chris@76
|
1961 DELETE FROM {db_prefix}calendar
|
Chris@76
|
1962 WHERE id_event = {int:id_event}',
|
Chris@76
|
1963 array(
|
Chris@76
|
1964 'id_event' => $_REQUEST['eventid'],
|
Chris@76
|
1965 )
|
Chris@76
|
1966 );
|
Chris@76
|
1967 // ... or just update it?
|
Chris@76
|
1968 else
|
Chris@76
|
1969 {
|
Chris@76
|
1970 $span = !empty($modSettings['cal_allowspan']) && !empty($_REQUEST['span']) ? min((int) $modSettings['cal_maxspan'], (int) $_REQUEST['span'] - 1) : 0;
|
Chris@76
|
1971 $start_time = mktime(0, 0, 0, (int) $_REQUEST['month'], (int) $_REQUEST['day'], (int) $_REQUEST['year']);
|
Chris@76
|
1972
|
Chris@76
|
1973 $smcFunc['db_query']('', '
|
Chris@76
|
1974 UPDATE {db_prefix}calendar
|
Chris@76
|
1975 SET end_date = {date:end_date},
|
Chris@76
|
1976 start_date = {date:start_date},
|
Chris@76
|
1977 title = {string:title}
|
Chris@76
|
1978 WHERE id_event = {int:id_event}',
|
Chris@76
|
1979 array(
|
Chris@76
|
1980 'end_date' => strftime('%Y-%m-%d', $start_time + $span * 86400),
|
Chris@76
|
1981 'start_date' => strftime('%Y-%m-%d', $start_time),
|
Chris@76
|
1982 'id_event' => $_REQUEST['eventid'],
|
Chris@76
|
1983 'title' => $smcFunc['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES),
|
Chris@76
|
1984 )
|
Chris@76
|
1985 );
|
Chris@76
|
1986 }
|
Chris@76
|
1987 updateSettings(array(
|
Chris@76
|
1988 'calendar_updated' => time(),
|
Chris@76
|
1989 ));
|
Chris@76
|
1990 }
|
Chris@76
|
1991
|
Chris@76
|
1992 // Marking read should be done even for editing messages....
|
Chris@76
|
1993 // Mark all the parents read. (since you just posted and they will be unread.)
|
Chris@76
|
1994 if (!$user_info['is_guest'] && !empty($board_info['parent_boards']))
|
Chris@76
|
1995 {
|
Chris@76
|
1996 $smcFunc['db_query']('', '
|
Chris@76
|
1997 UPDATE {db_prefix}log_boards
|
Chris@76
|
1998 SET id_msg = {int:id_msg}
|
Chris@76
|
1999 WHERE id_member = {int:current_member}
|
Chris@76
|
2000 AND id_board IN ({array_int:board_list})',
|
Chris@76
|
2001 array(
|
Chris@76
|
2002 'current_member' => $user_info['id'],
|
Chris@76
|
2003 'board_list' => array_keys($board_info['parent_boards']),
|
Chris@76
|
2004 'id_msg' => $modSettings['maxMsgID'],
|
Chris@76
|
2005 )
|
Chris@76
|
2006 );
|
Chris@76
|
2007 }
|
Chris@76
|
2008
|
Chris@76
|
2009 // Turn notification on or off. (note this just blows smoke if it's already on or off.)
|
Chris@76
|
2010 if (!empty($_POST['notify']) && allowedTo('mark_any_notify'))
|
Chris@76
|
2011 {
|
Chris@76
|
2012 $smcFunc['db_insert']('ignore',
|
Chris@76
|
2013 '{db_prefix}log_notify',
|
Chris@76
|
2014 array('id_member' => 'int', 'id_topic' => 'int', 'id_board' => 'int'),
|
Chris@76
|
2015 array($user_info['id'], $topic, 0),
|
Chris@76
|
2016 array('id_member', 'id_topic', 'id_board')
|
Chris@76
|
2017 );
|
Chris@76
|
2018 }
|
Chris@76
|
2019 elseif (!$newTopic)
|
Chris@76
|
2020 $smcFunc['db_query']('', '
|
Chris@76
|
2021 DELETE FROM {db_prefix}log_notify
|
Chris@76
|
2022 WHERE id_member = {int:current_member}
|
Chris@76
|
2023 AND id_topic = {int:current_topic}',
|
Chris@76
|
2024 array(
|
Chris@76
|
2025 'current_member' => $user_info['id'],
|
Chris@76
|
2026 'current_topic' => $topic,
|
Chris@76
|
2027 )
|
Chris@76
|
2028 );
|
Chris@76
|
2029
|
Chris@76
|
2030 // Log an act of moderation - modifying.
|
Chris@76
|
2031 if (!empty($moderationAction))
|
Chris@76
|
2032 logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
|
Chris@76
|
2033
|
Chris@76
|
2034 if (isset($_POST['lock']) && $_POST['lock'] != 2)
|
Chris@76
|
2035 logAction('lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
|
Chris@76
|
2036
|
Chris@76
|
2037 if (isset($_POST['sticky']) && !empty($modSettings['enableStickyTopics']))
|
Chris@76
|
2038 logAction('sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
|
Chris@76
|
2039
|
Chris@76
|
2040 // Notify any members who have notification turned on for this topic - only do this if it's going to be approved(!)
|
Chris@76
|
2041 if ($becomesApproved)
|
Chris@76
|
2042 {
|
Chris@76
|
2043 if ($newTopic)
|
Chris@76
|
2044 {
|
Chris@76
|
2045 $notifyData = array(
|
Chris@76
|
2046 'body' => $_POST['message'],
|
Chris@76
|
2047 'subject' => $_POST['subject'],
|
Chris@76
|
2048 'name' => $user_info['name'],
|
Chris@76
|
2049 'poster' => $user_info['id'],
|
Chris@76
|
2050 'msg' => $msgOptions['id'],
|
Chris@76
|
2051 'board' => $board,
|
Chris@76
|
2052 'topic' => $topic,
|
Chris@76
|
2053 );
|
Chris@76
|
2054 notifyMembersBoard($notifyData);
|
Chris@76
|
2055 }
|
Chris@76
|
2056 elseif (empty($_REQUEST['msg']))
|
Chris@76
|
2057 {
|
Chris@76
|
2058 // Only send it to everyone if the topic is approved, otherwise just to the topic starter if they want it.
|
Chris@76
|
2059 if ($topic_info['approved'])
|
Chris@76
|
2060 sendNotifications($topic, 'reply');
|
Chris@76
|
2061 else
|
Chris@76
|
2062 sendNotifications($topic, 'reply', array(), $topic_info['id_member_started']);
|
Chris@76
|
2063 }
|
Chris@76
|
2064 }
|
Chris@76
|
2065
|
Chris@76
|
2066 // Returning to the topic?
|
Chris@76
|
2067 if (!empty($_REQUEST['goback']))
|
Chris@76
|
2068 {
|
Chris@76
|
2069 // Mark the board as read.... because it might get confusing otherwise.
|
Chris@76
|
2070 $smcFunc['db_query']('', '
|
Chris@76
|
2071 UPDATE {db_prefix}log_boards
|
Chris@76
|
2072 SET id_msg = {int:maxMsgID}
|
Chris@76
|
2073 WHERE id_member = {int:current_member}
|
Chris@76
|
2074 AND id_board = {int:current_board}',
|
Chris@76
|
2075 array(
|
Chris@76
|
2076 'current_board' => $board,
|
Chris@76
|
2077 'current_member' => $user_info['id'],
|
Chris@76
|
2078 'maxMsgID' => $modSettings['maxMsgID'],
|
Chris@76
|
2079 )
|
Chris@76
|
2080 );
|
Chris@76
|
2081 }
|
Chris@76
|
2082
|
Chris@76
|
2083 if ($board_info['num_topics'] == 0)
|
Chris@76
|
2084 cache_put_data('board-' . $board, null, 120);
|
Chris@76
|
2085
|
Chris@76
|
2086 if (!empty($_POST['announce_topic']))
|
Chris@76
|
2087 redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
|
Chris@76
|
2088
|
Chris@76
|
2089 if (!empty($_POST['move']) && allowedTo('move_any'))
|
Chris@76
|
2090 redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
|
Chris@76
|
2091
|
Chris@76
|
2092 // Return to post if the mod is on.
|
Chris@76
|
2093 if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback']))
|
Chris@76
|
2094 redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], $context['browser']['is_ie']);
|
Chris@76
|
2095 elseif (!empty($_REQUEST['goback']))
|
Chris@76
|
2096 redirectexit('topic=' . $topic . '.new#new', $context['browser']['is_ie']);
|
Chris@76
|
2097 // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...*
|
Chris@76
|
2098 else
|
Chris@76
|
2099 redirectexit('board=' . $board . '.0');
|
Chris@76
|
2100 }
|
Chris@76
|
2101
|
Chris@76
|
2102 // General function for topic announcements.
|
Chris@76
|
2103 function AnnounceTopic()
|
Chris@76
|
2104 {
|
Chris@76
|
2105 global $context, $txt, $topic;
|
Chris@76
|
2106
|
Chris@76
|
2107 isAllowedTo('announce_topic');
|
Chris@76
|
2108
|
Chris@76
|
2109 validateSession();
|
Chris@76
|
2110
|
Chris@76
|
2111 if (empty($topic))
|
Chris@76
|
2112 fatal_lang_error('topic_gone', false);
|
Chris@76
|
2113
|
Chris@76
|
2114 loadLanguage('Post');
|
Chris@76
|
2115 loadTemplate('Post');
|
Chris@76
|
2116
|
Chris@76
|
2117 $subActions = array(
|
Chris@76
|
2118 'selectgroup' => 'AnnouncementSelectMembergroup',
|
Chris@76
|
2119 'send' => 'AnnouncementSend',
|
Chris@76
|
2120 );
|
Chris@76
|
2121
|
Chris@76
|
2122 $context['page_title'] = $txt['announce_topic'];
|
Chris@76
|
2123
|
Chris@76
|
2124 // Call the function based on the sub-action.
|
Chris@76
|
2125 $subActions[isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'selectgroup']();
|
Chris@76
|
2126 }
|
Chris@76
|
2127
|
Chris@76
|
2128 // Allow a user to chose the membergroups to send the announcement to.
|
Chris@76
|
2129 function AnnouncementSelectMembergroup()
|
Chris@76
|
2130 {
|
Chris@76
|
2131 global $txt, $context, $topic, $board, $board_info, $smcFunc;
|
Chris@76
|
2132
|
Chris@76
|
2133 $groups = array_merge($board_info['groups'], array(1));
|
Chris@76
|
2134 foreach ($groups as $id => $group)
|
Chris@76
|
2135 $groups[$id] = (int) $group;
|
Chris@76
|
2136
|
Chris@76
|
2137 $context['groups'] = array();
|
Chris@76
|
2138 if (in_array(0, $groups))
|
Chris@76
|
2139 {
|
Chris@76
|
2140 $context['groups'][0] = array(
|
Chris@76
|
2141 'id' => 0,
|
Chris@76
|
2142 'name' => $txt['announce_regular_members'],
|
Chris@76
|
2143 'member_count' => 'n/a',
|
Chris@76
|
2144 );
|
Chris@76
|
2145 }
|
Chris@76
|
2146
|
Chris@76
|
2147 // Get all membergroups that have access to the board the announcement was made on.
|
Chris@76
|
2148 $request = $smcFunc['db_query']('', '
|
Chris@76
|
2149 SELECT mg.id_group, COUNT(mem.id_member) AS num_members
|
Chris@76
|
2150 FROM {db_prefix}membergroups AS mg
|
Chris@76
|
2151 LEFT JOIN {db_prefix}members AS mem ON (mem.id_group = mg.id_group OR FIND_IN_SET(mg.id_group, mem.additional_groups) != 0 OR mg.id_group = mem.id_post_group)
|
Chris@76
|
2152 WHERE mg.id_group IN ({array_int:group_list})
|
Chris@76
|
2153 GROUP BY mg.id_group',
|
Chris@76
|
2154 array(
|
Chris@76
|
2155 'group_list' => $groups,
|
Chris@76
|
2156 'newbie_id_group' => 4,
|
Chris@76
|
2157 )
|
Chris@76
|
2158 );
|
Chris@76
|
2159 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
2160 {
|
Chris@76
|
2161 $context['groups'][$row['id_group']] = array(
|
Chris@76
|
2162 'id' => $row['id_group'],
|
Chris@76
|
2163 'name' => '',
|
Chris@76
|
2164 'member_count' => $row['num_members'],
|
Chris@76
|
2165 );
|
Chris@76
|
2166 }
|
Chris@76
|
2167 $smcFunc['db_free_result']($request);
|
Chris@76
|
2168
|
Chris@76
|
2169 // Now get the membergroup names.
|
Chris@76
|
2170 $request = $smcFunc['db_query']('', '
|
Chris@76
|
2171 SELECT id_group, group_name
|
Chris@76
|
2172 FROM {db_prefix}membergroups
|
Chris@76
|
2173 WHERE id_group IN ({array_int:group_list})',
|
Chris@76
|
2174 array(
|
Chris@76
|
2175 'group_list' => $groups,
|
Chris@76
|
2176 )
|
Chris@76
|
2177 );
|
Chris@76
|
2178 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
2179 $context['groups'][$row['id_group']]['name'] = $row['group_name'];
|
Chris@76
|
2180 $smcFunc['db_free_result']($request);
|
Chris@76
|
2181
|
Chris@76
|
2182 // Get the subject of the topic we're about to announce.
|
Chris@76
|
2183 $request = $smcFunc['db_query']('', '
|
Chris@76
|
2184 SELECT m.subject
|
Chris@76
|
2185 FROM {db_prefix}topics AS t
|
Chris@76
|
2186 INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
|
Chris@76
|
2187 WHERE t.id_topic = {int:current_topic}',
|
Chris@76
|
2188 array(
|
Chris@76
|
2189 'current_topic' => $topic,
|
Chris@76
|
2190 )
|
Chris@76
|
2191 );
|
Chris@76
|
2192 list ($context['topic_subject']) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
2193 $smcFunc['db_free_result']($request);
|
Chris@76
|
2194
|
Chris@76
|
2195 censorText($context['announce_topic']['subject']);
|
Chris@76
|
2196
|
Chris@76
|
2197 $context['move'] = isset($_REQUEST['move']) ? 1 : 0;
|
Chris@76
|
2198 $context['go_back'] = isset($_REQUEST['goback']) ? 1 : 0;
|
Chris@76
|
2199
|
Chris@76
|
2200 $context['sub_template'] = 'announce';
|
Chris@76
|
2201 }
|
Chris@76
|
2202
|
Chris@76
|
2203 // Send the announcement in chunks.
|
Chris@76
|
2204 function AnnouncementSend()
|
Chris@76
|
2205 {
|
Chris@76
|
2206 global $topic, $board, $board_info, $context, $modSettings;
|
Chris@76
|
2207 global $language, $scripturl, $txt, $user_info, $sourcedir, $smcFunc;
|
Chris@76
|
2208
|
Chris@76
|
2209 checkSession();
|
Chris@76
|
2210
|
Chris@76
|
2211 // !!! Might need an interface?
|
Chris@76
|
2212 $chunkSize = empty($modSettings['mail_queue']) ? 50 : 500;
|
Chris@76
|
2213
|
Chris@76
|
2214 $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
|
Chris@76
|
2215 $groups = array_merge($board_info['groups'], array(1));
|
Chris@76
|
2216
|
Chris@76
|
2217 if (isset($_POST['membergroups']))
|
Chris@76
|
2218 $_POST['who'] = explode(',', $_POST['membergroups']);
|
Chris@76
|
2219
|
Chris@76
|
2220 // Check whether at least one membergroup was selected.
|
Chris@76
|
2221 if (empty($_POST['who']))
|
Chris@76
|
2222 fatal_lang_error('no_membergroup_selected');
|
Chris@76
|
2223
|
Chris@76
|
2224 // Make sure all membergroups are integers and can access the board of the announcement.
|
Chris@76
|
2225 foreach ($_POST['who'] as $id => $mg)
|
Chris@76
|
2226 $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
|
Chris@76
|
2227
|
Chris@76
|
2228 // Get the topic subject and censor it.
|
Chris@76
|
2229 $request = $smcFunc['db_query']('', '
|
Chris@76
|
2230 SELECT m.id_msg, m.subject, m.body
|
Chris@76
|
2231 FROM {db_prefix}topics AS t
|
Chris@76
|
2232 INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
|
Chris@76
|
2233 WHERE t.id_topic = {int:current_topic}',
|
Chris@76
|
2234 array(
|
Chris@76
|
2235 'current_topic' => $topic,
|
Chris@76
|
2236 )
|
Chris@76
|
2237 );
|
Chris@76
|
2238 list ($id_msg, $context['topic_subject'], $message) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
2239 $smcFunc['db_free_result']($request);
|
Chris@76
|
2240
|
Chris@76
|
2241 censorText($context['topic_subject']);
|
Chris@76
|
2242 censorText($message);
|
Chris@76
|
2243
|
Chris@76
|
2244 $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($message, false, $id_msg), array('<br />' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']')))));
|
Chris@76
|
2245
|
Chris@76
|
2246 // We need this in order to be able send emails.
|
Chris@76
|
2247 require_once($sourcedir . '/Subs-Post.php');
|
Chris@76
|
2248
|
Chris@76
|
2249 // Select the email addresses for this batch.
|
Chris@76
|
2250 $request = $smcFunc['db_query']('', '
|
Chris@76
|
2251 SELECT mem.id_member, mem.email_address, mem.lngfile
|
Chris@76
|
2252 FROM {db_prefix}members AS mem
|
Chris@76
|
2253 WHERE mem.id_member != {int:current_member}' . (!empty($modSettings['allow_disableAnnounce']) ? '
|
Chris@76
|
2254 AND mem.notify_announcements = {int:notify_announcements}' : '') . '
|
Chris@76
|
2255 AND mem.is_activated = {int:is_activated}
|
Chris@76
|
2256 AND (mem.id_group IN ({array_int:group_list}) OR mem.id_post_group IN ({array_int:group_list}) OR FIND_IN_SET({raw:additional_group_list}, mem.additional_groups) != 0)
|
Chris@76
|
2257 AND mem.id_member > {int:start}
|
Chris@76
|
2258 ORDER BY mem.id_member
|
Chris@76
|
2259 LIMIT ' . $chunkSize,
|
Chris@76
|
2260 array(
|
Chris@76
|
2261 'current_member' => $user_info['id'],
|
Chris@76
|
2262 'group_list' => $_POST['who'],
|
Chris@76
|
2263 'notify_announcements' => 1,
|
Chris@76
|
2264 'is_activated' => 1,
|
Chris@76
|
2265 'start' => $context['start'],
|
Chris@76
|
2266 'additional_group_list' => implode(', mem.additional_groups) != 0 OR FIND_IN_SET(', $_POST['who']),
|
Chris@76
|
2267 )
|
Chris@76
|
2268 );
|
Chris@76
|
2269
|
Chris@76
|
2270 // All members have received a mail. Go to the next screen.
|
Chris@76
|
2271 if ($smcFunc['db_num_rows']($request) == 0)
|
Chris@76
|
2272 {
|
Chris@76
|
2273 if (!empty($_REQUEST['move']) && allowedTo('move_any'))
|
Chris@76
|
2274 redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
|
Chris@76
|
2275 elseif (!empty($_REQUEST['goback']))
|
Chris@76
|
2276 redirectexit('topic=' . $topic . '.new;boardseen#new', $context['browser']['is_ie']);
|
Chris@76
|
2277 else
|
Chris@76
|
2278 redirectexit('board=' . $board . '.0');
|
Chris@76
|
2279 }
|
Chris@76
|
2280
|
Chris@76
|
2281 // Loop through all members that'll receive an announcement in this batch.
|
Chris@76
|
2282 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
2283 {
|
Chris@76
|
2284 $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile'];
|
Chris@76
|
2285
|
Chris@76
|
2286 // If the language wasn't defined yet, load it and compose a notification message.
|
Chris@76
|
2287 if (!isset($announcements[$cur_language]))
|
Chris@76
|
2288 {
|
Chris@76
|
2289 $replacements = array(
|
Chris@76
|
2290 'TOPICSUBJECT' => $context['topic_subject'],
|
Chris@76
|
2291 'MESSAGE' => $message,
|
Chris@76
|
2292 'TOPICLINK' => $scripturl . '?topic=' . $topic . '.0',
|
Chris@76
|
2293 );
|
Chris@76
|
2294
|
Chris@76
|
2295 $emaildata = loadEmailTemplate('new_announcement', $replacements, $cur_language);
|
Chris@76
|
2296
|
Chris@76
|
2297 $announcements[$cur_language] = array(
|
Chris@76
|
2298 'subject' => $emaildata['subject'],
|
Chris@76
|
2299 'body' => $emaildata['body'],
|
Chris@76
|
2300 'recipients' => array(),
|
Chris@76
|
2301 );
|
Chris@76
|
2302 }
|
Chris@76
|
2303
|
Chris@76
|
2304 $announcements[$cur_language]['recipients'][$row['id_member']] = $row['email_address'];
|
Chris@76
|
2305 $context['start'] = $row['id_member'];
|
Chris@76
|
2306 }
|
Chris@76
|
2307 $smcFunc['db_free_result']($request);
|
Chris@76
|
2308
|
Chris@76
|
2309 // For each language send a different mail - low priority...
|
Chris@76
|
2310 foreach ($announcements as $lang => $mail)
|
Chris@76
|
2311 sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, null, false, 5);
|
Chris@76
|
2312
|
Chris@76
|
2313 $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1);
|
Chris@76
|
2314
|
Chris@76
|
2315 $context['move'] = empty($_REQUEST['move']) ? 0 : 1;
|
Chris@76
|
2316 $context['go_back'] = empty($_REQUEST['goback']) ? 0 : 1;
|
Chris@76
|
2317 $context['membergroups'] = implode(',', $_POST['who']);
|
Chris@76
|
2318 $context['sub_template'] = 'announcement_send';
|
Chris@76
|
2319
|
Chris@76
|
2320 // Go back to the correct language for the user ;).
|
Chris@76
|
2321 if (!empty($modSettings['userLanguage']))
|
Chris@76
|
2322 loadLanguage('Post');
|
Chris@76
|
2323 }
|
Chris@76
|
2324
|
Chris@76
|
2325 // Notify members of a new post.
|
Chris@76
|
2326 function notifyMembersBoard(&$topicData)
|
Chris@76
|
2327 {
|
Chris@76
|
2328 global $txt, $scripturl, $language, $user_info;
|
Chris@76
|
2329 global $modSettings, $sourcedir, $board, $smcFunc, $context;
|
Chris@76
|
2330
|
Chris@76
|
2331 require_once($sourcedir . '/Subs-Post.php');
|
Chris@76
|
2332
|
Chris@76
|
2333 // Do we have one or lots of topics?
|
Chris@76
|
2334 if (isset($topicData['body']))
|
Chris@76
|
2335 $topicData = array($topicData);
|
Chris@76
|
2336
|
Chris@76
|
2337 // Find out what boards we have... and clear out any rubbish!
|
Chris@76
|
2338 $boards = array();
|
Chris@76
|
2339 foreach ($topicData as $key => $topic)
|
Chris@76
|
2340 {
|
Chris@76
|
2341 if (!empty($topic['board']))
|
Chris@76
|
2342 $boards[$topic['board']][] = $key;
|
Chris@76
|
2343 else
|
Chris@76
|
2344 {
|
Chris@76
|
2345 unset($topic[$key]);
|
Chris@76
|
2346 continue;
|
Chris@76
|
2347 }
|
Chris@76
|
2348
|
Chris@76
|
2349 // Censor the subject and body...
|
Chris@76
|
2350 censorText($topicData[$key]['subject']);
|
Chris@76
|
2351 censorText($topicData[$key]['body']);
|
Chris@76
|
2352
|
Chris@76
|
2353 $topicData[$key]['subject'] = un_htmlspecialchars($topicData[$key]['subject']);
|
Chris@76
|
2354 $topicData[$key]['body'] = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($topicData[$key]['body'], false), array('<br />' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']')))));
|
Chris@76
|
2355 }
|
Chris@76
|
2356
|
Chris@76
|
2357 // Just the board numbers.
|
Chris@76
|
2358 $board_index = array_unique(array_keys($boards));
|
Chris@76
|
2359
|
Chris@76
|
2360 if (empty($board_index))
|
Chris@76
|
2361 return;
|
Chris@76
|
2362
|
Chris@76
|
2363 // Yea, we need to add this to the digest queue.
|
Chris@76
|
2364 $digest_insert = array();
|
Chris@76
|
2365 foreach ($topicData as $id => $data)
|
Chris@76
|
2366 $digest_insert[] = array($data['topic'], $data['msg'], 'topic', $user_info['id']);
|
Chris@76
|
2367 $smcFunc['db_insert']('',
|
Chris@76
|
2368 '{db_prefix}log_digest',
|
Chris@76
|
2369 array(
|
Chris@76
|
2370 'id_topic' => 'int', 'id_msg' => 'int', 'note_type' => 'string', 'exclude' => 'int',
|
Chris@76
|
2371 ),
|
Chris@76
|
2372 $digest_insert,
|
Chris@76
|
2373 array()
|
Chris@76
|
2374 );
|
Chris@76
|
2375
|
Chris@76
|
2376 // Find the members with notification on for these boards.
|
Chris@76
|
2377 $members = $smcFunc['db_query']('', '
|
Chris@76
|
2378 SELECT
|
Chris@76
|
2379 mem.id_member, mem.email_address, mem.notify_regularity, mem.notify_send_body, mem.lngfile,
|
Chris@76
|
2380 ln.sent, ln.id_board, mem.id_group, mem.additional_groups, b.member_groups,
|
Chris@76
|
2381 mem.id_post_group
|
Chris@76
|
2382 FROM {db_prefix}log_notify AS ln
|
Chris@76
|
2383 INNER JOIN {db_prefix}boards AS b ON (b.id_board = ln.id_board)
|
Chris@76
|
2384 INNER JOIN {db_prefix}members AS mem ON (mem.id_member = ln.id_member)
|
Chris@76
|
2385 WHERE ln.id_board IN ({array_int:board_list})
|
Chris@76
|
2386 AND mem.id_member != {int:current_member}
|
Chris@76
|
2387 AND mem.is_activated = {int:is_activated}
|
Chris@76
|
2388 AND mem.notify_types != {int:notify_types}
|
Chris@76
|
2389 AND mem.notify_regularity < {int:notify_regularity}
|
Chris@76
|
2390 ORDER BY mem.lngfile',
|
Chris@76
|
2391 array(
|
Chris@76
|
2392 'current_member' => $user_info['id'],
|
Chris@76
|
2393 'board_list' => $board_index,
|
Chris@76
|
2394 'is_activated' => 1,
|
Chris@76
|
2395 'notify_types' => 4,
|
Chris@76
|
2396 'notify_regularity' => 2,
|
Chris@76
|
2397 )
|
Chris@76
|
2398 );
|
Chris@76
|
2399 while ($rowmember = $smcFunc['db_fetch_assoc']($members))
|
Chris@76
|
2400 {
|
Chris@76
|
2401 if ($rowmember['id_group'] != 1)
|
Chris@76
|
2402 {
|
Chris@76
|
2403 $allowed = explode(',', $rowmember['member_groups']);
|
Chris@76
|
2404 $rowmember['additional_groups'] = explode(',', $rowmember['additional_groups']);
|
Chris@76
|
2405 $rowmember['additional_groups'][] = $rowmember['id_group'];
|
Chris@76
|
2406 $rowmember['additional_groups'][] = $rowmember['id_post_group'];
|
Chris@76
|
2407
|
Chris@76
|
2408 if (count(array_intersect($allowed, $rowmember['additional_groups'])) == 0)
|
Chris@76
|
2409 continue;
|
Chris@76
|
2410 }
|
Chris@76
|
2411
|
Chris@76
|
2412 $langloaded = loadLanguage('EmailTemplates', empty($rowmember['lngfile']) || empty($modSettings['userLanguage']) ? $language : $rowmember['lngfile'], false);
|
Chris@76
|
2413
|
Chris@76
|
2414 // Now loop through all the notifications to send for this board.
|
Chris@76
|
2415 if (empty($boards[$rowmember['id_board']]))
|
Chris@76
|
2416 continue;
|
Chris@76
|
2417
|
Chris@76
|
2418 $sentOnceAlready = 0;
|
Chris@76
|
2419 foreach ($boards[$rowmember['id_board']] as $key)
|
Chris@76
|
2420 {
|
Chris@76
|
2421 // Don't notify the guy who started the topic!
|
Chris@76
|
2422 //!!! In this case actually send them a "it's approved hooray" email
|
Chris@76
|
2423 if ($topicData[$key]['poster'] == $rowmember['id_member'])
|
Chris@76
|
2424 continue;
|
Chris@76
|
2425
|
Chris@76
|
2426 // Setup the string for adding the body to the message, if a user wants it.
|
Chris@76
|
2427 $send_body = empty($modSettings['disallow_sendBody']) && !empty($rowmember['notify_send_body']);
|
Chris@76
|
2428
|
Chris@76
|
2429 $replacements = array(
|
Chris@76
|
2430 'TOPICSUBJECT' => $topicData[$key]['subject'],
|
Chris@76
|
2431 'TOPICLINK' => $scripturl . '?topic=' . $topicData[$key]['topic'] . '.new#new',
|
Chris@76
|
2432 'MESSAGE' => $topicData[$key]['body'],
|
Chris@76
|
2433 'UNSUBSCRIBELINK' => $scripturl . '?action=notifyboard;board=' . $topicData[$key]['board'] . '.0',
|
Chris@76
|
2434 );
|
Chris@76
|
2435
|
Chris@76
|
2436 if (!$send_body)
|
Chris@76
|
2437 unset($replacements['MESSAGE']);
|
Chris@76
|
2438
|
Chris@76
|
2439 // Figure out which email to send off
|
Chris@76
|
2440 $emailtype = '';
|
Chris@76
|
2441
|
Chris@76
|
2442 // Send only if once is off or it's on and it hasn't been sent.
|
Chris@76
|
2443 if (!empty($rowmember['notify_regularity']) && !$sentOnceAlready && empty($rowmember['sent']))
|
Chris@76
|
2444 $emailtype = 'notify_boards_once';
|
Chris@76
|
2445 elseif (empty($rowmember['notify_regularity']))
|
Chris@76
|
2446 $emailtype = 'notify_boards';
|
Chris@76
|
2447
|
Chris@76
|
2448 if (!empty($emailtype))
|
Chris@76
|
2449 {
|
Chris@76
|
2450 $emailtype .= $send_body ? '_body' : '';
|
Chris@76
|
2451 $emaildata = loadEmailTemplate($emailtype, $replacements, $langloaded);
|
Chris@76
|
2452 sendmail($rowmember['email_address'], $emaildata['subject'], $emaildata['body'], null, null, false, 3);
|
Chris@76
|
2453 }
|
Chris@76
|
2454
|
Chris@76
|
2455 $sentOnceAlready = 1;
|
Chris@76
|
2456 }
|
Chris@76
|
2457 }
|
Chris@76
|
2458 $smcFunc['db_free_result']($members);
|
Chris@76
|
2459
|
Chris@76
|
2460 // Sent!
|
Chris@76
|
2461 $smcFunc['db_query']('', '
|
Chris@76
|
2462 UPDATE {db_prefix}log_notify
|
Chris@76
|
2463 SET sent = {int:is_sent}
|
Chris@76
|
2464 WHERE id_board IN ({array_int:board_list})
|
Chris@76
|
2465 AND id_member != {int:current_member}',
|
Chris@76
|
2466 array(
|
Chris@76
|
2467 'current_member' => $user_info['id'],
|
Chris@76
|
2468 'board_list' => $board_index,
|
Chris@76
|
2469 'is_sent' => 1,
|
Chris@76
|
2470 )
|
Chris@76
|
2471 );
|
Chris@76
|
2472 }
|
Chris@76
|
2473
|
Chris@76
|
2474 // Get the topic for display purposes.
|
Chris@76
|
2475 function getTopic()
|
Chris@76
|
2476 {
|
Chris@76
|
2477 global $topic, $modSettings, $context, $smcFunc, $counter, $options;
|
Chris@76
|
2478
|
Chris@76
|
2479 if (isset($_REQUEST['xml']))
|
Chris@76
|
2480 $limit = '
|
Chris@76
|
2481 LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']);
|
Chris@76
|
2482 else
|
Chris@76
|
2483 $limit = empty($modSettings['topicSummaryPosts']) ? '' : '
|
Chris@76
|
2484 LIMIT ' . (int) $modSettings['topicSummaryPosts'];
|
Chris@76
|
2485
|
Chris@76
|
2486 // If you're modifying, get only those posts before the current one. (otherwise get all.)
|
Chris@76
|
2487 $request = $smcFunc['db_query']('', '
|
Chris@76
|
2488 SELECT
|
Chris@76
|
2489 IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time,
|
Chris@76
|
2490 m.body, m.smileys_enabled, m.id_msg, m.id_member
|
Chris@76
|
2491 FROM {db_prefix}messages AS m
|
Chris@76
|
2492 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
|
Chris@76
|
2493 WHERE m.id_topic = {int:current_topic}' . (isset($_REQUEST['msg']) ? '
|
Chris@76
|
2494 AND m.id_msg < {int:id_msg}' : '') .(!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
|
Chris@76
|
2495 AND m.approved = {int:approved}') . '
|
Chris@76
|
2496 ORDER BY m.id_msg DESC' . $limit,
|
Chris@76
|
2497 array(
|
Chris@76
|
2498 'current_topic' => $topic,
|
Chris@76
|
2499 'id_msg' => isset($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0,
|
Chris@76
|
2500 'approved' => 1,
|
Chris@76
|
2501 )
|
Chris@76
|
2502 );
|
Chris@76
|
2503 $context['previous_posts'] = array();
|
Chris@76
|
2504 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
2505 {
|
Chris@76
|
2506 // Censor, BBC, ...
|
Chris@76
|
2507 censorText($row['body']);
|
Chris@76
|
2508 $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
|
Chris@76
|
2509
|
Chris@76
|
2510 // ...and store.
|
Chris@76
|
2511 $context['previous_posts'][] = array(
|
Chris@76
|
2512 'counter' => $counter++,
|
Chris@76
|
2513 'alternate' => $counter % 2,
|
Chris@76
|
2514 'poster' => $row['poster_name'],
|
Chris@76
|
2515 'message' => $row['body'],
|
Chris@76
|
2516 'time' => timeformat($row['poster_time']),
|
Chris@76
|
2517 'timestamp' => forum_time(true, $row['poster_time']),
|
Chris@76
|
2518 'id' => $row['id_msg'],
|
Chris@76
|
2519 'is_new' => !empty($context['new_replies']),
|
Chris@76
|
2520 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']),
|
Chris@76
|
2521 );
|
Chris@76
|
2522
|
Chris@76
|
2523 if (!empty($context['new_replies']))
|
Chris@76
|
2524 $context['new_replies']--;
|
Chris@76
|
2525 }
|
Chris@76
|
2526 $smcFunc['db_free_result']($request);
|
Chris@76
|
2527 }
|
Chris@76
|
2528
|
Chris@76
|
2529 function QuoteFast()
|
Chris@76
|
2530 {
|
Chris@76
|
2531 global $modSettings, $user_info, $txt, $settings, $context;
|
Chris@76
|
2532 global $sourcedir, $smcFunc;
|
Chris@76
|
2533
|
Chris@76
|
2534 loadLanguage('Post');
|
Chris@76
|
2535 if (!isset($_REQUEST['xml']))
|
Chris@76
|
2536 loadTemplate('Post');
|
Chris@76
|
2537
|
Chris@76
|
2538 include_once($sourcedir . '/Subs-Post.php');
|
Chris@76
|
2539
|
Chris@76
|
2540 $moderate_boards = boardsAllowedTo('moderate_board');
|
Chris@76
|
2541
|
Chris@76
|
2542 // Where we going if we need to?
|
Chris@76
|
2543 $context['post_box_name'] = isset($_GET['pb']) ? $_GET['pb'] : '';
|
Chris@76
|
2544
|
Chris@76
|
2545 $request = $smcFunc['db_query']('', '
|
Chris@76
|
2546 SELECT IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.body, m.id_topic, m.subject,
|
Chris@76
|
2547 m.id_board, m.id_member, m.approved
|
Chris@76
|
2548 FROM {db_prefix}messages AS m
|
Chris@76
|
2549 INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
|
Chris@76
|
2550 INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})
|
Chris@76
|
2551 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
|
Chris@76
|
2552 WHERE m.id_msg = {int:id_msg}' . (isset($_REQUEST['modify']) || (!empty($moderate_boards) && $moderate_boards[0] == 0) ? '' : '
|
Chris@76
|
2553 AND (t.locked = {int:not_locked}' . (empty($moderate_boards) ? '' : ' OR b.id_board IN ({array_int:moderation_board_list})') . ')') . '
|
Chris@76
|
2554 LIMIT 1',
|
Chris@76
|
2555 array(
|
Chris@76
|
2556 'current_member' => $user_info['id'],
|
Chris@76
|
2557 'moderation_board_list' => $moderate_boards,
|
Chris@76
|
2558 'id_msg' => (int) $_REQUEST['quote'],
|
Chris@76
|
2559 'not_locked' => 0,
|
Chris@76
|
2560 )
|
Chris@76
|
2561 );
|
Chris@76
|
2562 $context['close_window'] = $smcFunc['db_num_rows']($request) == 0;
|
Chris@76
|
2563 $row = $smcFunc['db_fetch_assoc']($request);
|
Chris@76
|
2564 $smcFunc['db_free_result']($request);
|
Chris@76
|
2565
|
Chris@76
|
2566 $context['sub_template'] = 'quotefast';
|
Chris@76
|
2567 if (!empty($row))
|
Chris@76
|
2568 $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
|
Chris@76
|
2569
|
Chris@76
|
2570 if (!empty($can_view_post))
|
Chris@76
|
2571 {
|
Chris@76
|
2572 // Remove special formatting we don't want anymore.
|
Chris@76
|
2573 $row['body'] = un_preparsecode($row['body']);
|
Chris@76
|
2574
|
Chris@76
|
2575 // Censor the message!
|
Chris@76
|
2576 censorText($row['body']);
|
Chris@76
|
2577
|
Chris@76
|
2578 $row['body'] = preg_replace('~<br ?/?' . '>~i', "\n", $row['body']);
|
Chris@76
|
2579
|
Chris@76
|
2580 // Want to modify a single message by double clicking it?
|
Chris@76
|
2581 if (isset($_REQUEST['modify']))
|
Chris@76
|
2582 {
|
Chris@76
|
2583 censorText($row['subject']);
|
Chris@76
|
2584
|
Chris@76
|
2585 $context['sub_template'] = 'modifyfast';
|
Chris@76
|
2586 $context['message'] = array(
|
Chris@76
|
2587 'id' => $_REQUEST['quote'],
|
Chris@76
|
2588 'body' => $row['body'],
|
Chris@76
|
2589 'subject' => addcslashes($row['subject'], '"'),
|
Chris@76
|
2590 );
|
Chris@76
|
2591
|
Chris@76
|
2592 return;
|
Chris@76
|
2593 }
|
Chris@76
|
2594
|
Chris@76
|
2595 // Remove any nested quotes.
|
Chris@76
|
2596 if (!empty($modSettings['removeNestedQuotes']))
|
Chris@76
|
2597 $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
|
Chris@76
|
2598
|
Chris@76
|
2599 // Make the body HTML if need be.
|
Chris@76
|
2600 if (!empty($_REQUEST['mode']))
|
Chris@76
|
2601 {
|
Chris@76
|
2602 require_once($sourcedir . '/Subs-Editor.php');
|
Chris@76
|
2603 $row['body'] = strtr($row['body'], array('<' => '#smlt#', '>' => '#smgt#', '&' => '#smamp#'));
|
Chris@76
|
2604 $row['body'] = bbc_to_html($row['body']);
|
Chris@76
|
2605 $lb = '<br />';
|
Chris@76
|
2606 }
|
Chris@76
|
2607 else
|
Chris@76
|
2608 $lb = "\n";
|
Chris@76
|
2609
|
Chris@76
|
2610 // Add a quote string on the front and end.
|
Chris@76
|
2611 $context['quote']['xml'] = '[quote author=' . $row['poster_name'] . ' link=topic=' . $row['id_topic'] . '.msg' . (int) $_REQUEST['quote'] . '#msg' . (int) $_REQUEST['quote'] . ' date=' . $row['poster_time'] . ']' . $lb . $row['body'] . $lb . '[/quote]';
|
Chris@76
|
2612 $context['quote']['text'] = strtr(un_htmlspecialchars($context['quote']['xml']), array('\'' => '\\\'', '\\' => '\\\\', "\n" => '\\n', '</script>' => '</\' + \'script>'));
|
Chris@76
|
2613 $context['quote']['xml'] = strtr($context['quote']['xml'], array(' ' => ' ', '<' => '<', '>' => '>'));
|
Chris@76
|
2614
|
Chris@76
|
2615 $context['quote']['mozilla'] = strtr($smcFunc['htmlspecialchars']($context['quote']['text']), array('"' => '"'));
|
Chris@76
|
2616 }
|
Chris@76
|
2617 // !!! Needs a nicer interface.
|
Chris@76
|
2618 // In case our message has been removed in the meantime.
|
Chris@76
|
2619 elseif (isset($_REQUEST['modify']))
|
Chris@76
|
2620 {
|
Chris@76
|
2621 $context['sub_template'] = 'modifyfast';
|
Chris@76
|
2622 $context['message'] = array(
|
Chris@76
|
2623 'id' => 0,
|
Chris@76
|
2624 'body' => '',
|
Chris@76
|
2625 'subject' => '',
|
Chris@76
|
2626 );
|
Chris@76
|
2627 }
|
Chris@76
|
2628 else
|
Chris@76
|
2629 $context['quote'] = array(
|
Chris@76
|
2630 'xml' => '',
|
Chris@76
|
2631 'mozilla' => '',
|
Chris@76
|
2632 'text' => '',
|
Chris@76
|
2633 );
|
Chris@76
|
2634 }
|
Chris@76
|
2635
|
Chris@76
|
2636 function JavaScriptModify()
|
Chris@76
|
2637 {
|
Chris@76
|
2638 global $sourcedir, $modSettings, $board, $topic, $txt;
|
Chris@76
|
2639 global $user_info, $context, $smcFunc, $language;
|
Chris@76
|
2640
|
Chris@76
|
2641 // We have to have a topic!
|
Chris@76
|
2642 if (empty($topic))
|
Chris@76
|
2643 obExit(false);
|
Chris@76
|
2644
|
Chris@76
|
2645 checkSession('get');
|
Chris@76
|
2646 require_once($sourcedir . '/Subs-Post.php');
|
Chris@76
|
2647
|
Chris@76
|
2648 // Assume the first message if no message ID was given.
|
Chris@76
|
2649 $request = $smcFunc['db_query']('', '
|
Chris@76
|
2650 SELECT
|
Chris@76
|
2651 t.locked, t.num_replies, t.id_member_started, t.id_first_msg,
|
Chris@76
|
2652 m.id_msg, m.id_member, m.poster_time, m.subject, m.smileys_enabled, m.body, m.icon,
|
Chris@76
|
2653 m.modified_time, m.modified_name, m.approved
|
Chris@76
|
2654 FROM {db_prefix}messages AS m
|
Chris@76
|
2655 INNER JOIN {db_prefix}topics AS t ON (t.id_topic = {int:current_topic})
|
Chris@76
|
2656 WHERE m.id_msg = {raw:id_msg}
|
Chris@76
|
2657 AND m.id_topic = {int:current_topic}' . (allowedTo('approve_posts') ? '' : (!$modSettings['postmod_active'] ? '
|
Chris@76
|
2658 AND (m.id_member != {int:guest_id} AND m.id_member = {int:current_member})' : '
|
Chris@76
|
2659 AND (m.approved = {int:is_approved} OR (m.id_member != {int:guest_id} AND m.id_member = {int:current_member}))')),
|
Chris@76
|
2660 array(
|
Chris@76
|
2661 'current_member' => $user_info['id'],
|
Chris@76
|
2662 'current_topic' => $topic,
|
Chris@76
|
2663 'id_msg' => empty($_REQUEST['msg']) ? 't.id_first_msg' : (int) $_REQUEST['msg'],
|
Chris@76
|
2664 'is_approved' => 1,
|
Chris@76
|
2665 'guest_id' => 0,
|
Chris@76
|
2666 )
|
Chris@76
|
2667 );
|
Chris@76
|
2668 if ($smcFunc['db_num_rows']($request) == 0)
|
Chris@76
|
2669 fatal_lang_error('no_board', false);
|
Chris@76
|
2670 $row = $smcFunc['db_fetch_assoc']($request);
|
Chris@76
|
2671 $smcFunc['db_free_result']($request);
|
Chris@76
|
2672
|
Chris@76
|
2673 // Change either body or subject requires permissions to modify messages.
|
Chris@76
|
2674 if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon']))
|
Chris@76
|
2675 {
|
Chris@76
|
2676 if (!empty($row['locked']))
|
Chris@76
|
2677 isAllowedTo('moderate_board');
|
Chris@76
|
2678
|
Chris@76
|
2679 if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
|
Chris@76
|
2680 {
|
Chris@76
|
2681 if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
|
Chris@76
|
2682 fatal_lang_error('modify_post_time_passed', false);
|
Chris@76
|
2683 elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
|
Chris@76
|
2684 isAllowedTo('modify_replies');
|
Chris@76
|
2685 else
|
Chris@76
|
2686 isAllowedTo('modify_own');
|
Chris@76
|
2687 }
|
Chris@76
|
2688 // Otherwise, they're locked out; someone who can modify the replies is needed.
|
Chris@76
|
2689 elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
|
Chris@76
|
2690 isAllowedTo('modify_replies');
|
Chris@76
|
2691 else
|
Chris@76
|
2692 isAllowedTo('modify_any');
|
Chris@76
|
2693
|
Chris@76
|
2694 // Only log this action if it wasn't your message.
|
Chris@76
|
2695 $moderationAction = $row['id_member'] != $user_info['id'];
|
Chris@76
|
2696 }
|
Chris@76
|
2697
|
Chris@76
|
2698 $post_errors = array();
|
Chris@76
|
2699 if (isset($_POST['subject']) && $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) !== '')
|
Chris@76
|
2700 {
|
Chris@76
|
2701 $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
|
Chris@76
|
2702
|
Chris@76
|
2703 // Maximum number of characters.
|
Chris@76
|
2704 if ($smcFunc['strlen']($_POST['subject']) > 100)
|
Chris@76
|
2705 $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
|
Chris@76
|
2706 }
|
Chris@76
|
2707 elseif (isset($_POST['subject']))
|
Chris@76
|
2708 {
|
Chris@76
|
2709 $post_errors[] = 'no_subject';
|
Chris@76
|
2710 unset($_POST['subject']);
|
Chris@76
|
2711 }
|
Chris@76
|
2712
|
Chris@76
|
2713 if (isset($_POST['message']))
|
Chris@76
|
2714 {
|
Chris@76
|
2715 if ($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message'])) === '')
|
Chris@76
|
2716 {
|
Chris@76
|
2717 $post_errors[] = 'no_message';
|
Chris@76
|
2718 unset($_POST['message']);
|
Chris@76
|
2719 }
|
Chris@76
|
2720 elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
|
Chris@76
|
2721 {
|
Chris@76
|
2722 $post_errors[] = 'long_message';
|
Chris@76
|
2723 unset($_POST['message']);
|
Chris@76
|
2724 }
|
Chris@76
|
2725 else
|
Chris@76
|
2726 {
|
Chris@76
|
2727 $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
|
Chris@76
|
2728
|
Chris@76
|
2729 preparsecode($_POST['message']);
|
Chris@76
|
2730
|
Chris@76
|
2731 if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), '<img>')) === '')
|
Chris@76
|
2732 {
|
Chris@76
|
2733 $post_errors[] = 'no_message';
|
Chris@76
|
2734 unset($_POST['message']);
|
Chris@76
|
2735 }
|
Chris@76
|
2736 }
|
Chris@76
|
2737 }
|
Chris@76
|
2738
|
Chris@76
|
2739 if (isset($_POST['lock']))
|
Chris@76
|
2740 {
|
Chris@76
|
2741 if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member']))
|
Chris@76
|
2742 unset($_POST['lock']);
|
Chris@76
|
2743 elseif (!allowedTo('lock_any'))
|
Chris@76
|
2744 {
|
Chris@76
|
2745 if ($row['locked'] == 1)
|
Chris@76
|
2746 unset($_POST['lock']);
|
Chris@76
|
2747 else
|
Chris@76
|
2748 $_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
|
Chris@76
|
2749 }
|
Chris@76
|
2750 elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked'])
|
Chris@76
|
2751 unset($_POST['lock']);
|
Chris@76
|
2752 else
|
Chris@76
|
2753 $_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
|
Chris@76
|
2754 }
|
Chris@76
|
2755
|
Chris@76
|
2756 if (isset($_POST['sticky']) && !allowedTo('make_sticky'))
|
Chris@76
|
2757 unset($_POST['sticky']);
|
Chris@76
|
2758
|
Chris@76
|
2759 if (empty($post_errors))
|
Chris@76
|
2760 {
|
Chris@76
|
2761 $msgOptions = array(
|
Chris@76
|
2762 'id' => $row['id_msg'],
|
Chris@76
|
2763 'subject' => isset($_POST['subject']) ? $_POST['subject'] : null,
|
Chris@76
|
2764 'body' => isset($_POST['message']) ? $_POST['message'] : null,
|
Chris@76
|
2765 'icon' => isset($_REQUEST['icon']) ? preg_replace('~[\./\\\\*\':"<>]~', '', $_REQUEST['icon']) : null,
|
Chris@76
|
2766 );
|
Chris@76
|
2767 $topicOptions = array(
|
Chris@76
|
2768 'id' => $topic,
|
Chris@76
|
2769 'board' => $board,
|
Chris@76
|
2770 'lock_mode' => isset($_POST['lock']) ? (int) $_POST['lock'] : null,
|
Chris@76
|
2771 'sticky_mode' => isset($_POST['sticky']) && !empty($modSettings['enableStickyTopics']) ? (int) $_POST['sticky'] : null,
|
Chris@76
|
2772 'mark_as_read' => true,
|
Chris@76
|
2773 );
|
Chris@76
|
2774 $posterOptions = array();
|
Chris@76
|
2775
|
Chris@76
|
2776 // Only consider marking as editing if they have edited the subject, message or icon.
|
Chris@76
|
2777 if ((isset($_POST['subject']) && $_POST['subject'] != $row['subject']) || (isset($_POST['message']) && $_POST['message'] != $row['body']) || (isset($_REQUEST['icon']) && $_REQUEST['icon'] != $row['icon']))
|
Chris@76
|
2778 {
|
Chris@76
|
2779 // And even then only if the time has passed...
|
Chris@76
|
2780 if (time() - $row['poster_time'] > $modSettings['edit_wait_time'] || $user_info['id'] != $row['id_member'])
|
Chris@76
|
2781 {
|
Chris@76
|
2782 $msgOptions['modify_time'] = time();
|
Chris@76
|
2783 $msgOptions['modify_name'] = $user_info['name'];
|
Chris@76
|
2784 }
|
Chris@76
|
2785 }
|
Chris@76
|
2786 // If nothing was changed there's no need to add an entry to the moderation log.
|
Chris@76
|
2787 else
|
Chris@76
|
2788 $moderationAction = false;
|
Chris@76
|
2789
|
Chris@76
|
2790 modifyPost($msgOptions, $topicOptions, $posterOptions);
|
Chris@76
|
2791
|
Chris@76
|
2792 // If we didn't change anything this time but had before put back the old info.
|
Chris@76
|
2793 if (!isset($msgOptions['modify_time']) && !empty($row['modified_time']))
|
Chris@76
|
2794 {
|
Chris@76
|
2795 $msgOptions['modify_time'] = $row['modified_time'];
|
Chris@76
|
2796 $msgOptions['modify_name'] = $row['modified_name'];
|
Chris@76
|
2797 }
|
Chris@76
|
2798
|
Chris@76
|
2799 // Changing the first subject updates other subjects to 'Re: new_subject'.
|
Chris@76
|
2800 if (isset($_POST['subject']) && isset($_REQUEST['change_all_subjects']) && $row['id_first_msg'] == $row['id_msg'] && !empty($row['num_replies']) && (allowedTo('modify_any') || ($row['id_member_started'] == $user_info['id'] && allowedTo('modify_replies'))))
|
Chris@76
|
2801 {
|
Chris@76
|
2802 // Get the proper (default language) response prefix first.
|
Chris@76
|
2803 if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
|
Chris@76
|
2804 {
|
Chris@76
|
2805 if ($language === $user_info['language'])
|
Chris@76
|
2806 $context['response_prefix'] = $txt['response_prefix'];
|
Chris@76
|
2807 else
|
Chris@76
|
2808 {
|
Chris@76
|
2809 loadLanguage('index', $language, false);
|
Chris@76
|
2810 $context['response_prefix'] = $txt['response_prefix'];
|
Chris@76
|
2811 loadLanguage('index');
|
Chris@76
|
2812 }
|
Chris@76
|
2813 cache_put_data('response_prefix', $context['response_prefix'], 600);
|
Chris@76
|
2814 }
|
Chris@76
|
2815
|
Chris@76
|
2816 $smcFunc['db_query']('', '
|
Chris@76
|
2817 UPDATE {db_prefix}messages
|
Chris@76
|
2818 SET subject = {string:subject}
|
Chris@76
|
2819 WHERE id_topic = {int:current_topic}
|
Chris@76
|
2820 AND id_msg != {int:id_first_msg}',
|
Chris@76
|
2821 array(
|
Chris@76
|
2822 'current_topic' => $topic,
|
Chris@76
|
2823 'id_first_msg' => $row['id_first_msg'],
|
Chris@76
|
2824 'subject' => $context['response_prefix'] . $_POST['subject'],
|
Chris@76
|
2825 )
|
Chris@76
|
2826 );
|
Chris@76
|
2827 }
|
Chris@76
|
2828
|
Chris@76
|
2829 if (!empty($moderationAction))
|
Chris@76
|
2830 logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
|
Chris@76
|
2831 }
|
Chris@76
|
2832
|
Chris@76
|
2833 if (isset($_REQUEST['xml']))
|
Chris@76
|
2834 {
|
Chris@76
|
2835 $context['sub_template'] = 'modifydone';
|
Chris@76
|
2836 if (empty($post_errors) && isset($msgOptions['subject']) && isset($msgOptions['body']))
|
Chris@76
|
2837 {
|
Chris@76
|
2838 $context['message'] = array(
|
Chris@76
|
2839 'id' => $row['id_msg'],
|
Chris@76
|
2840 'modified' => array(
|
Chris@76
|
2841 'time' => isset($msgOptions['modify_time']) ? timeformat($msgOptions['modify_time']) : '',
|
Chris@76
|
2842 'timestamp' => isset($msgOptions['modify_time']) ? forum_time(true, $msgOptions['modify_time']) : 0,
|
Chris@76
|
2843 'name' => isset($msgOptions['modify_time']) ? $msgOptions['modify_name'] : '',
|
Chris@76
|
2844 ),
|
Chris@76
|
2845 'subject' => $msgOptions['subject'],
|
Chris@76
|
2846 'first_in_topic' => $row['id_msg'] == $row['id_first_msg'],
|
Chris@76
|
2847 'body' => strtr($msgOptions['body'], array(']]>' => ']]]]><![CDATA[>')),
|
Chris@76
|
2848 );
|
Chris@76
|
2849
|
Chris@76
|
2850 censorText($context['message']['subject']);
|
Chris@76
|
2851 censorText($context['message']['body']);
|
Chris@76
|
2852
|
Chris@76
|
2853 $context['message']['body'] = parse_bbc($context['message']['body'], $row['smileys_enabled'], $row['id_msg']);
|
Chris@76
|
2854 }
|
Chris@76
|
2855 // Topic?
|
Chris@76
|
2856 elseif (empty($post_errors))
|
Chris@76
|
2857 {
|
Chris@76
|
2858 $context['sub_template'] = 'modifytopicdone';
|
Chris@76
|
2859 $context['message'] = array(
|
Chris@76
|
2860 'id' => $row['id_msg'],
|
Chris@76
|
2861 'modified' => array(
|
Chris@76
|
2862 'time' => isset($msgOptions['modify_time']) ? timeformat($msgOptions['modify_time']) : '',
|
Chris@76
|
2863 'timestamp' => isset($msgOptions['modify_time']) ? forum_time(true, $msgOptions['modify_time']) : 0,
|
Chris@76
|
2864 'name' => isset($msgOptions['modify_time']) ? $msgOptions['modify_name'] : '',
|
Chris@76
|
2865 ),
|
Chris@76
|
2866 'subject' => isset($msgOptions['subject']) ? $msgOptions['subject'] : '',
|
Chris@76
|
2867 );
|
Chris@76
|
2868
|
Chris@76
|
2869 censorText($context['message']['subject']);
|
Chris@76
|
2870 }
|
Chris@76
|
2871 else
|
Chris@76
|
2872 {
|
Chris@76
|
2873 $context['message'] = array(
|
Chris@76
|
2874 'id' => $row['id_msg'],
|
Chris@76
|
2875 'errors' => array(),
|
Chris@76
|
2876 'error_in_subject' => in_array('no_subject', $post_errors),
|
Chris@76
|
2877 'error_in_body' => in_array('no_message', $post_errors) || in_array('long_message', $post_errors),
|
Chris@76
|
2878 );
|
Chris@76
|
2879
|
Chris@76
|
2880 loadLanguage('Errors');
|
Chris@76
|
2881 foreach ($post_errors as $post_error)
|
Chris@76
|
2882 {
|
Chris@76
|
2883 if ($post_error == 'long_message')
|
Chris@76
|
2884 $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
|
Chris@76
|
2885 else
|
Chris@76
|
2886 $context['message']['errors'][] = $txt['error_' . $post_error];
|
Chris@76
|
2887 }
|
Chris@76
|
2888 }
|
Chris@76
|
2889 }
|
Chris@76
|
2890 else
|
Chris@76
|
2891 obExit(false);
|
Chris@76
|
2892 }
|
Chris@76
|
2893
|
Chris@76
|
2894 ?> |