|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package phpBB3
|
|
indvdum@0
|
5 |
* @version $Id$
|
|
indvdum@0
|
6 |
* @copyright (c) 2005 phpBB Group
|
|
indvdum@0
|
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
8 |
*
|
|
indvdum@0
|
9 |
*/
|
|
indvdum@0
|
10 |
|
|
indvdum@0
|
11 |
/**
|
|
indvdum@0
|
12 |
* @ignore
|
|
indvdum@0
|
13 |
*/
|
|
indvdum@0
|
14 |
define('IN_PHPBB', true);
|
|
indvdum@0
|
15 |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
|
|
indvdum@0
|
16 |
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|
indvdum@0
|
17 |
include($phpbb_root_path . 'common.' . $phpEx);
|
|
indvdum@0
|
18 |
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
|
indvdum@0
|
19 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
indvdum@0
|
20 |
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
|
|
indvdum@0
|
21 |
|
|
indvdum@0
|
22 |
|
|
indvdum@0
|
23 |
// Start session management
|
|
indvdum@0
|
24 |
$user->session_begin();
|
|
indvdum@0
|
25 |
$auth->acl($user->data);
|
|
indvdum@0
|
26 |
|
|
indvdum@0
|
27 |
|
|
indvdum@0
|
28 |
// Grab only parameters needed here
|
|
indvdum@0
|
29 |
$post_id = request_var('p', 0);
|
|
indvdum@0
|
30 |
$topic_id = request_var('t', 0);
|
|
indvdum@0
|
31 |
$forum_id = request_var('f', 0);
|
|
indvdum@0
|
32 |
$draft_id = request_var('d', 0);
|
|
indvdum@0
|
33 |
$lastclick = request_var('lastclick', 0);
|
|
indvdum@0
|
34 |
|
|
indvdum@0
|
35 |
$submit = (isset($_POST['post'])) ? true : false;
|
|
indvdum@0
|
36 |
$preview = (isset($_POST['preview'])) ? true : false;
|
|
indvdum@0
|
37 |
$save = (isset($_POST['save'])) ? true : false;
|
|
indvdum@0
|
38 |
$load = (isset($_POST['load'])) ? true : false;
|
|
indvdum@0
|
39 |
$delete = (isset($_POST['delete'])) ? true : false;
|
|
indvdum@0
|
40 |
$cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false;
|
|
indvdum@0
|
41 |
|
|
indvdum@0
|
42 |
$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['full_editor']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false;
|
|
indvdum@0
|
43 |
$mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', '');
|
|
indvdum@0
|
44 |
|
|
indvdum@0
|
45 |
$error = $post_data = array();
|
|
indvdum@0
|
46 |
$current_time = time();
|
|
indvdum@0
|
47 |
|
|
indvdum@0
|
48 |
// Was cancel pressed? If so then redirect to the appropriate page
|
|
indvdum@0
|
49 |
if ($cancel || ($current_time - $lastclick < 2 && $submit))
|
|
indvdum@0
|
50 |
{
|
|
indvdum@0
|
51 |
$f = ($forum_id) ? 'f=' . $forum_id . '&' : '';
|
|
indvdum@0
|
52 |
$redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}index.$phpEx")));
|
|
indvdum@0
|
53 |
redirect($redirect);
|
|
indvdum@0
|
54 |
}
|
|
indvdum@0
|
55 |
|
|
indvdum@0
|
56 |
if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$forum_id)
|
|
indvdum@0
|
57 |
{
|
|
indvdum@0
|
58 |
trigger_error('NO_FORUM');
|
|
indvdum@0
|
59 |
}
|
|
indvdum@0
|
60 |
|
|
indvdum@0
|
61 |
// We need to know some basic information in all cases before we do anything.
|
|
indvdum@0
|
62 |
switch ($mode)
|
|
indvdum@0
|
63 |
{
|
|
indvdum@0
|
64 |
case 'post':
|
|
indvdum@0
|
65 |
$sql = 'SELECT *
|
|
indvdum@0
|
66 |
FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
67 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
68 |
break;
|
|
indvdum@0
|
69 |
|
|
indvdum@0
|
70 |
case 'bump':
|
|
indvdum@0
|
71 |
case 'reply':
|
|
indvdum@0
|
72 |
if (!$topic_id)
|
|
indvdum@0
|
73 |
{
|
|
indvdum@0
|
74 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
75 |
}
|
|
indvdum@0
|
76 |
|
|
indvdum@0
|
77 |
// Force forum id
|
|
indvdum@0
|
78 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
79 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
80 |
WHERE topic_id = ' . $topic_id;
|
|
indvdum@0
|
81 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
82 |
$f_id = (int) $db->sql_fetchfield('forum_id');
|
|
indvdum@0
|
83 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
84 |
|
|
indvdum@0
|
85 |
$forum_id = (!$f_id) ? $forum_id : $f_id;
|
|
indvdum@0
|
86 |
|
|
indvdum@0
|
87 |
$sql = 'SELECT f.*, t.*
|
|
indvdum@0
|
88 |
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
|
indvdum@0
|
89 |
WHERE t.topic_id = $topic_id
|
|
indvdum@0
|
90 |
AND (f.forum_id = t.forum_id
|
|
indvdum@0
|
91 |
OR f.forum_id = $forum_id)" .
|
|
indvdum@0
|
92 |
(($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1');
|
|
indvdum@0
|
93 |
break;
|
|
indvdum@0
|
94 |
|
|
indvdum@0
|
95 |
case 'quote':
|
|
indvdum@0
|
96 |
case 'edit':
|
|
indvdum@0
|
97 |
case 'delete':
|
|
indvdum@0
|
98 |
if (!$post_id)
|
|
indvdum@0
|
99 |
{
|
|
indvdum@0
|
100 |
$user->setup('posting');
|
|
indvdum@0
|
101 |
trigger_error('NO_POST');
|
|
indvdum@0
|
102 |
}
|
|
indvdum@0
|
103 |
|
|
indvdum@0
|
104 |
// Force forum id
|
|
indvdum@0
|
105 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
106 |
FROM ' . POSTS_TABLE . '
|
|
indvdum@0
|
107 |
WHERE post_id = ' . $post_id;
|
|
indvdum@0
|
108 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
109 |
$f_id = (int) $db->sql_fetchfield('forum_id');
|
|
indvdum@0
|
110 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
111 |
|
|
indvdum@0
|
112 |
$forum_id = (!$f_id) ? $forum_id : $f_id;
|
|
indvdum@0
|
113 |
|
|
indvdum@0
|
114 |
$sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield
|
|
indvdum@0
|
115 |
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u
|
|
indvdum@0
|
116 |
WHERE p.post_id = $post_id
|
|
indvdum@0
|
117 |
AND t.topic_id = p.topic_id
|
|
indvdum@0
|
118 |
AND u.user_id = p.poster_id
|
|
indvdum@0
|
119 |
AND (f.forum_id = t.forum_id
|
|
indvdum@0
|
120 |
OR f.forum_id = $forum_id)" .
|
|
indvdum@0
|
121 |
(($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1');
|
|
indvdum@0
|
122 |
break;
|
|
indvdum@0
|
123 |
|
|
indvdum@0
|
124 |
case 'smilies':
|
|
indvdum@0
|
125 |
$sql = '';
|
|
indvdum@0
|
126 |
generate_smilies('window', $forum_id);
|
|
indvdum@0
|
127 |
break;
|
|
indvdum@0
|
128 |
|
|
indvdum@0
|
129 |
case 'popup':
|
|
indvdum@0
|
130 |
if ($forum_id)
|
|
indvdum@0
|
131 |
{
|
|
indvdum@0
|
132 |
$sql = 'SELECT forum_style
|
|
indvdum@0
|
133 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
134 |
WHERE forum_id = ' . $forum_id;
|
|
indvdum@0
|
135 |
}
|
|
indvdum@0
|
136 |
else
|
|
indvdum@0
|
137 |
{
|
|
indvdum@0
|
138 |
upload_popup();
|
|
indvdum@0
|
139 |
return;
|
|
indvdum@0
|
140 |
}
|
|
indvdum@0
|
141 |
break;
|
|
indvdum@0
|
142 |
|
|
indvdum@0
|
143 |
default:
|
|
indvdum@0
|
144 |
$sql = '';
|
|
indvdum@0
|
145 |
break;
|
|
indvdum@0
|
146 |
}
|
|
indvdum@0
|
147 |
|
|
indvdum@0
|
148 |
if (!$sql)
|
|
indvdum@0
|
149 |
{
|
|
indvdum@0
|
150 |
$user->setup('posting');
|
|
indvdum@0
|
151 |
trigger_error('NO_POST_MODE');
|
|
indvdum@0
|
152 |
}
|
|
indvdum@0
|
153 |
|
|
indvdum@0
|
154 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
155 |
$post_data = $db->sql_fetchrow($result);
|
|
indvdum@0
|
156 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
157 |
|
|
indvdum@0
|
158 |
if (!$post_data)
|
|
indvdum@0
|
159 |
{
|
|
indvdum@0
|
160 |
if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply'))
|
|
indvdum@0
|
161 |
{
|
|
indvdum@0
|
162 |
$user->setup('posting');
|
|
indvdum@0
|
163 |
}
|
|
indvdum@0
|
164 |
trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST');
|
|
indvdum@0
|
165 |
}
|
|
indvdum@0
|
166 |
|
|
indvdum@0
|
167 |
// Not able to reply to unapproved posts/topics
|
|
indvdum@0
|
168 |
// TODO: add more descriptive language key
|
|
indvdum@0
|
169 |
if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && !$post_data['topic_approved']) || ($mode == 'quote' && !$post_data['post_approved'])))
|
|
indvdum@0
|
170 |
{
|
|
indvdum@0
|
171 |
trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED');
|
|
indvdum@0
|
172 |
}
|
|
indvdum@0
|
173 |
|
|
indvdum@0
|
174 |
if ($mode == 'popup')
|
|
indvdum@0
|
175 |
{
|
|
indvdum@0
|
176 |
upload_popup($post_data['forum_style']);
|
|
indvdum@0
|
177 |
return;
|
|
indvdum@0
|
178 |
}
|
|
indvdum@0
|
179 |
|
|
indvdum@0
|
180 |
$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']);
|
|
indvdum@0
|
181 |
|
|
indvdum@0
|
182 |
if ($config['enable_post_confirm'] && !$user->data['is_registered'])
|
|
indvdum@0
|
183 |
{
|
|
indvdum@0
|
184 |
include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
|
|
indvdum@0
|
185 |
$captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']);
|
|
indvdum@0
|
186 |
$captcha->init(CONFIRM_POST);
|
|
indvdum@0
|
187 |
}
|
|
indvdum@0
|
188 |
|
|
indvdum@0
|
189 |
// Use post_row values in favor of submitted ones...
|
|
indvdum@0
|
190 |
$forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id;
|
|
indvdum@0
|
191 |
$topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id;
|
|
indvdum@0
|
192 |
$post_id = (!empty($post_data['post_id'])) ? (int) $post_data['post_id'] : (int) $post_id;
|
|
indvdum@0
|
193 |
|
|
indvdum@0
|
194 |
// Need to login to passworded forum first?
|
|
indvdum@0
|
195 |
if ($post_data['forum_password'])
|
|
indvdum@0
|
196 |
{
|
|
indvdum@0
|
197 |
login_forum_box(array(
|
|
indvdum@0
|
198 |
'forum_id' => $forum_id,
|
|
indvdum@0
|
199 |
'forum_password' => $post_data['forum_password'])
|
|
indvdum@0
|
200 |
);
|
|
indvdum@0
|
201 |
}
|
|
indvdum@0
|
202 |
|
|
indvdum@0
|
203 |
// Check permissions
|
|
indvdum@0
|
204 |
if ($user->data['is_bot'])
|
|
indvdum@0
|
205 |
{
|
|
indvdum@0
|
206 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
indvdum@0
|
207 |
}
|
|
indvdum@0
|
208 |
|
|
indvdum@0
|
209 |
// Is the user able to read within this forum?
|
|
indvdum@0
|
210 |
if (!$auth->acl_get('f_read', $forum_id))
|
|
indvdum@0
|
211 |
{
|
|
indvdum@0
|
212 |
if ($user->data['user_id'] != ANONYMOUS)
|
|
indvdum@0
|
213 |
{
|
|
indvdum@0
|
214 |
trigger_error('USER_CANNOT_READ');
|
|
indvdum@0
|
215 |
}
|
|
indvdum@0
|
216 |
|
|
indvdum@0
|
217 |
login_box('', $user->lang['LOGIN_EXPLAIN_POST']);
|
|
indvdum@0
|
218 |
}
|
|
indvdum@0
|
219 |
|
|
indvdum@0
|
220 |
// Permission to do the action asked?
|
|
indvdum@0
|
221 |
$is_authed = false;
|
|
indvdum@0
|
222 |
|
|
indvdum@0
|
223 |
switch ($mode)
|
|
indvdum@0
|
224 |
{
|
|
indvdum@0
|
225 |
case 'post':
|
|
indvdum@0
|
226 |
if ($auth->acl_get('f_post', $forum_id))
|
|
indvdum@0
|
227 |
{
|
|
indvdum@0
|
228 |
$is_authed = true;
|
|
indvdum@0
|
229 |
}
|
|
indvdum@0
|
230 |
break;
|
|
indvdum@0
|
231 |
|
|
indvdum@0
|
232 |
case 'bump':
|
|
indvdum@0
|
233 |
if ($auth->acl_get('f_bump', $forum_id))
|
|
indvdum@0
|
234 |
{
|
|
indvdum@0
|
235 |
$is_authed = true;
|
|
indvdum@0
|
236 |
}
|
|
indvdum@0
|
237 |
break;
|
|
indvdum@0
|
238 |
|
|
indvdum@0
|
239 |
case 'quote':
|
|
indvdum@0
|
240 |
|
|
indvdum@0
|
241 |
$post_data['post_edit_locked'] = 0;
|
|
indvdum@0
|
242 |
|
|
indvdum@0
|
243 |
// no break;
|
|
indvdum@0
|
244 |
|
|
indvdum@0
|
245 |
case 'reply':
|
|
indvdum@0
|
246 |
if ($auth->acl_get('f_reply', $forum_id))
|
|
indvdum@0
|
247 |
{
|
|
indvdum@0
|
248 |
$is_authed = true;
|
|
indvdum@0
|
249 |
}
|
|
indvdum@0
|
250 |
break;
|
|
indvdum@0
|
251 |
|
|
indvdum@0
|
252 |
case 'edit':
|
|
indvdum@0
|
253 |
if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id))
|
|
indvdum@0
|
254 |
{
|
|
indvdum@0
|
255 |
$is_authed = true;
|
|
indvdum@0
|
256 |
}
|
|
indvdum@0
|
257 |
break;
|
|
indvdum@0
|
258 |
|
|
indvdum@0
|
259 |
case 'delete':
|
|
indvdum@0
|
260 |
if ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id))
|
|
indvdum@0
|
261 |
{
|
|
indvdum@0
|
262 |
$is_authed = true;
|
|
indvdum@0
|
263 |
}
|
|
indvdum@0
|
264 |
break;
|
|
indvdum@0
|
265 |
}
|
|
indvdum@0
|
266 |
|
|
indvdum@0
|
267 |
if (!$is_authed)
|
|
indvdum@0
|
268 |
{
|
|
indvdum@0
|
269 |
$check_auth = ($mode == 'quote') ? 'reply' : $mode;
|
|
indvdum@0
|
270 |
|
|
indvdum@0
|
271 |
if ($user->data['is_registered'])
|
|
indvdum@0
|
272 |
{
|
|
indvdum@0
|
273 |
trigger_error('USER_CANNOT_' . strtoupper($check_auth));
|
|
indvdum@0
|
274 |
}
|
|
indvdum@0
|
275 |
|
|
indvdum@0
|
276 |
login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]);
|
|
indvdum@0
|
277 |
}
|
|
indvdum@0
|
278 |
|
|
indvdum@0
|
279 |
// Is the user able to post within this forum?
|
|
indvdum@0
|
280 |
if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply')))
|
|
indvdum@0
|
281 |
{
|
|
indvdum@0
|
282 |
trigger_error('USER_CANNOT_FORUM_POST');
|
|
indvdum@0
|
283 |
}
|
|
indvdum@0
|
284 |
|
|
indvdum@0
|
285 |
// Forum/Topic locked?
|
|
indvdum@0
|
286 |
if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $forum_id))
|
|
indvdum@0
|
287 |
{
|
|
indvdum@0
|
288 |
trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED');
|
|
indvdum@0
|
289 |
}
|
|
indvdum@0
|
290 |
|
|
indvdum@0
|
291 |
// Can we edit this post ... if we're a moderator with rights then always yes
|
|
indvdum@0
|
292 |
// else it depends on editing times, lock status and if we're the correct user
|
|
indvdum@0
|
293 |
if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id))
|
|
indvdum@0
|
294 |
{
|
|
indvdum@0
|
295 |
if ($user->data['user_id'] != $post_data['poster_id'])
|
|
indvdum@0
|
296 |
{
|
|
indvdum@0
|
297 |
trigger_error('USER_CANNOT_EDIT');
|
|
indvdum@0
|
298 |
}
|
|
indvdum@0
|
299 |
|
|
indvdum@0
|
300 |
if (!($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']))
|
|
indvdum@0
|
301 |
{
|
|
indvdum@0
|
302 |
trigger_error('CANNOT_EDIT_TIME');
|
|
indvdum@0
|
303 |
}
|
|
indvdum@0
|
304 |
|
|
indvdum@0
|
305 |
if ($post_data['post_edit_locked'])
|
|
indvdum@0
|
306 |
{
|
|
indvdum@0
|
307 |
trigger_error('CANNOT_EDIT_POST_LOCKED');
|
|
indvdum@0
|
308 |
}
|
|
indvdum@0
|
309 |
}
|
|
indvdum@0
|
310 |
|
|
indvdum@0
|
311 |
// Handle delete mode...
|
|
indvdum@0
|
312 |
if ($mode == 'delete')
|
|
indvdum@0
|
313 |
{
|
|
indvdum@0
|
314 |
handle_post_delete($forum_id, $topic_id, $post_id, $post_data);
|
|
indvdum@0
|
315 |
return;
|
|
indvdum@0
|
316 |
}
|
|
indvdum@0
|
317 |
|
|
indvdum@0
|
318 |
// Handle bump mode...
|
|
indvdum@0
|
319 |
if ($mode == 'bump')
|
|
indvdum@0
|
320 |
{
|
|
indvdum@0
|
321 |
if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id'])
|
|
indvdum@0
|
322 |
&& check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}"))
|
|
indvdum@0
|
323 |
{
|
|
indvdum@0
|
324 |
$meta_url = phpbb_bump_topic($forum_id, $topic_id, $post_data, $current_time);
|
|
indvdum@0
|
325 |
meta_refresh(3, $meta_url);
|
|
indvdum@0
|
326 |
|
|
indvdum@0
|
327 |
$message = $user->lang['TOPIC_BUMPED'] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $meta_url . '">', '</a>');
|
|
indvdum@0
|
328 |
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>');
|
|
indvdum@0
|
329 |
|
|
indvdum@0
|
330 |
trigger_error($message);
|
|
indvdum@0
|
331 |
}
|
|
indvdum@0
|
332 |
|
|
indvdum@0
|
333 |
trigger_error('BUMP_ERROR');
|
|
indvdum@0
|
334 |
}
|
|
indvdum@0
|
335 |
|
|
indvdum@0
|
336 |
// Subject length limiting to 60 characters if first post...
|
|
indvdum@0
|
337 |
if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id']))
|
|
indvdum@0
|
338 |
{
|
|
indvdum@0
|
339 |
$template->assign_var('S_NEW_MESSAGE', true);
|
|
indvdum@0
|
340 |
}
|
|
indvdum@0
|
341 |
|
|
indvdum@0
|
342 |
// Determine some vars
|
|
indvdum@0
|
343 |
if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS)
|
|
indvdum@0
|
344 |
{
|
|
indvdum@0
|
345 |
$post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : $user->lang['GUEST'];
|
|
indvdum@0
|
346 |
}
|
|
indvdum@0
|
347 |
else
|
|
indvdum@0
|
348 |
{
|
|
indvdum@0
|
349 |
$post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : '';
|
|
indvdum@0
|
350 |
}
|
|
indvdum@0
|
351 |
|
|
indvdum@0
|
352 |
$post_data['post_edit_locked'] = (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0;
|
|
indvdum@0
|
353 |
$post_data['post_subject_md5'] = (isset($post_data['post_subject']) && $mode == 'edit') ? md5($post_data['post_subject']) : '';
|
|
indvdum@0
|
354 |
$post_data['post_subject'] = (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : '');
|
|
indvdum@0
|
355 |
$post_data['topic_time_limit'] = (isset($post_data['topic_time_limit'])) ? (($post_data['topic_time_limit']) ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit']) : 0;
|
|
indvdum@0
|
356 |
$post_data['poll_length'] = (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0;
|
|
indvdum@0
|
357 |
$post_data['poll_start'] = (!empty($post_data['poll_start'])) ? (int) $post_data['poll_start'] : 0;
|
|
indvdum@0
|
358 |
$post_data['icon_id'] = (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id'];
|
|
indvdum@0
|
359 |
$post_data['poll_options'] = array();
|
|
indvdum@0
|
360 |
|
|
indvdum@0
|
361 |
// Get Poll Data
|
|
indvdum@0
|
362 |
if ($post_data['poll_start'])
|
|
indvdum@0
|
363 |
{
|
|
indvdum@0
|
364 |
$sql = 'SELECT poll_option_text
|
|
indvdum@0
|
365 |
FROM ' . POLL_OPTIONS_TABLE . "
|
|
indvdum@0
|
366 |
WHERE topic_id = $topic_id
|
|
indvdum@0
|
367 |
ORDER BY poll_option_id";
|
|
indvdum@0
|
368 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
369 |
|
|
indvdum@0
|
370 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
371 |
{
|
|
indvdum@0
|
372 |
$post_data['poll_options'][] = trim($row['poll_option_text']);
|
|
indvdum@0
|
373 |
}
|
|
indvdum@0
|
374 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
375 |
}
|
|
indvdum@0
|
376 |
|
|
indvdum@0
|
377 |
if ($mode == 'edit')
|
|
indvdum@0
|
378 |
{
|
|
indvdum@0
|
379 |
$original_poll_data = array(
|
|
indvdum@0
|
380 |
'poll_title' => $post_data['poll_title'],
|
|
indvdum@0
|
381 |
'poll_length' => $post_data['poll_length'],
|
|
indvdum@0
|
382 |
'poll_max_options' => $post_data['poll_max_options'],
|
|
indvdum@0
|
383 |
'poll_option_text' => implode("\n", $post_data['poll_options']),
|
|
indvdum@0
|
384 |
'poll_start' => $post_data['poll_start'],
|
|
indvdum@0
|
385 |
'poll_last_vote' => $post_data['poll_last_vote'],
|
|
indvdum@0
|
386 |
'poll_vote_change' => $post_data['poll_vote_change'],
|
|
indvdum@0
|
387 |
);
|
|
indvdum@0
|
388 |
}
|
|
indvdum@0
|
389 |
|
|
indvdum@0
|
390 |
$orig_poll_options_size = sizeof($post_data['poll_options']);
|
|
indvdum@0
|
391 |
|
|
indvdum@0
|
392 |
$message_parser = new parse_message();
|
|
indvdum@0
|
393 |
|
|
indvdum@0
|
394 |
if (isset($post_data['post_text']))
|
|
indvdum@0
|
395 |
{
|
|
indvdum@0
|
396 |
$message_parser->message = &$post_data['post_text'];
|
|
indvdum@0
|
397 |
unset($post_data['post_text']);
|
|
indvdum@0
|
398 |
}
|
|
indvdum@0
|
399 |
|
|
indvdum@0
|
400 |
// Set some default variables
|
|
indvdum@0
|
401 |
$uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0);
|
|
indvdum@0
|
402 |
|
|
indvdum@0
|
403 |
foreach ($uninit as $var_name => $default_value)
|
|
indvdum@0
|
404 |
{
|
|
indvdum@0
|
405 |
if (!isset($post_data[$var_name]))
|
|
indvdum@0
|
406 |
{
|
|
indvdum@0
|
407 |
$post_data[$var_name] = $default_value;
|
|
indvdum@0
|
408 |
}
|
|
indvdum@0
|
409 |
}
|
|
indvdum@0
|
410 |
unset($uninit);
|
|
indvdum@0
|
411 |
|
|
indvdum@0
|
412 |
// Always check if the submitted attachment data is valid and belongs to the user.
|
|
indvdum@0
|
413 |
// Further down (especially in submit_post()) we do not check this again.
|
|
indvdum@0
|
414 |
$message_parser->get_submitted_attachment_data($post_data['poster_id']);
|
|
indvdum@0
|
415 |
|
|
indvdum@0
|
416 |
if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit')
|
|
indvdum@0
|
417 |
{
|
|
indvdum@0
|
418 |
// Do not change to SELECT *
|
|
indvdum@0
|
419 |
$sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename
|
|
indvdum@0
|
420 |
FROM ' . ATTACHMENTS_TABLE . "
|
|
indvdum@0
|
421 |
WHERE post_msg_id = $post_id
|
|
indvdum@0
|
422 |
AND in_message = 0
|
|
indvdum@0
|
423 |
AND is_orphan = 0
|
|
indvdum@0
|
424 |
ORDER BY filetime DESC";
|
|
indvdum@0
|
425 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
426 |
$message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result));
|
|
indvdum@0
|
427 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
428 |
}
|
|
indvdum@0
|
429 |
|
|
indvdum@0
|
430 |
if ($post_data['poster_id'] == ANONYMOUS)
|
|
indvdum@0
|
431 |
{
|
|
indvdum@0
|
432 |
$post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['post_username']) : '';
|
|
indvdum@0
|
433 |
}
|
|
indvdum@0
|
434 |
else
|
|
indvdum@0
|
435 |
{
|
|
indvdum@0
|
436 |
$post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['username']) : '';
|
|
indvdum@0
|
437 |
}
|
|
indvdum@0
|
438 |
|
|
indvdum@0
|
439 |
$post_data['enable_urls'] = $post_data['enable_magic_url'];
|
|
indvdum@0
|
440 |
|
|
indvdum@0
|
441 |
if ($mode != 'edit')
|
|
indvdum@0
|
442 |
{
|
|
indvdum@0
|
443 |
$post_data['enable_sig'] = ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false;
|
|
indvdum@0
|
444 |
$post_data['enable_smilies'] = ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false;
|
|
indvdum@0
|
445 |
$post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false;
|
|
indvdum@0
|
446 |
$post_data['enable_urls'] = true;
|
|
indvdum@0
|
447 |
}
|
|
indvdum@0
|
448 |
|
|
indvdum@0
|
449 |
$post_data['enable_magic_url'] = $post_data['drafts'] = false;
|
|
indvdum@0
|
450 |
|
|
indvdum@0
|
451 |
// User own some drafts?
|
|
indvdum@0
|
452 |
if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote'))
|
|
indvdum@0
|
453 |
{
|
|
indvdum@0
|
454 |
$sql = 'SELECT draft_id
|
|
indvdum@0
|
455 |
FROM ' . DRAFTS_TABLE . '
|
|
indvdum@0
|
456 |
WHERE user_id = ' . $user->data['user_id'] .
|
|
indvdum@0
|
457 |
(($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') .
|
|
indvdum@0
|
458 |
(($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') .
|
|
indvdum@0
|
459 |
(($draft_id) ? " AND draft_id <> $draft_id" : '');
|
|
indvdum@0
|
460 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
461 |
|
|
indvdum@0
|
462 |
if ($db->sql_fetchrow($result))
|
|
indvdum@0
|
463 |
{
|
|
indvdum@0
|
464 |
$post_data['drafts'] = true;
|
|
indvdum@0
|
465 |
}
|
|
indvdum@0
|
466 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
467 |
}
|
|
indvdum@0
|
468 |
|
|
indvdum@0
|
469 |
$check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1);
|
|
indvdum@0
|
470 |
|
|
indvdum@0
|
471 |
// Check if user is watching this topic
|
|
indvdum@0
|
472 |
if ($mode != 'post' && $config['allow_topic_notify'] && $user->data['is_registered'])
|
|
indvdum@0
|
473 |
{
|
|
indvdum@0
|
474 |
$sql = 'SELECT topic_id
|
|
indvdum@0
|
475 |
FROM ' . TOPICS_WATCH_TABLE . '
|
|
indvdum@0
|
476 |
WHERE topic_id = ' . $topic_id . '
|
|
indvdum@0
|
477 |
AND user_id = ' . $user->data['user_id'];
|
|
indvdum@0
|
478 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
479 |
$post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id');
|
|
indvdum@0
|
480 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
481 |
}
|
|
indvdum@0
|
482 |
|
|
indvdum@0
|
483 |
// Do we want to edit our post ?
|
|
indvdum@0
|
484 |
if ($mode == 'edit' && $post_data['bbcode_uid'])
|
|
indvdum@0
|
485 |
{
|
|
indvdum@0
|
486 |
$message_parser->bbcode_uid = $post_data['bbcode_uid'];
|
|
indvdum@0
|
487 |
}
|
|
indvdum@0
|
488 |
|
|
indvdum@0
|
489 |
// HTML, BBCode, Smilies, Images and Flash status
|
|
indvdum@0
|
490 |
$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false;
|
|
indvdum@0
|
491 |
$smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false;
|
|
indvdum@0
|
492 |
$img_status = ($bbcode_status && $auth->acl_get('f_img', $forum_id)) ? true : false;
|
|
indvdum@0
|
493 |
$url_status = ($config['allow_post_links']) ? true : false;
|
|
indvdum@0
|
494 |
$flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash']) ? true : false;
|
|
indvdum@0
|
495 |
$quote_status = true;
|
|
indvdum@0
|
496 |
|
|
indvdum@0
|
497 |
// Save Draft
|
|
indvdum@0
|
498 |
if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote'))
|
|
indvdum@0
|
499 |
{
|
|
indvdum@0
|
500 |
$subject = utf8_normalize_nfc(request_var('subject', '', true));
|
|
indvdum@0
|
501 |
$subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject;
|
|
indvdum@0
|
502 |
$message = utf8_normalize_nfc(request_var('message', '', true));
|
|
indvdum@0
|
503 |
|
|
indvdum@0
|
504 |
if ($subject && $message)
|
|
indvdum@0
|
505 |
{
|
|
indvdum@0
|
506 |
if (confirm_box(true))
|
|
indvdum@0
|
507 |
{
|
|
indvdum@0
|
508 |
$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
|
|
indvdum@0
|
509 |
'user_id' => (int) $user->data['user_id'],
|
|
indvdum@0
|
510 |
'topic_id' => (int) $topic_id,
|
|
indvdum@0
|
511 |
'forum_id' => (int) $forum_id,
|
|
indvdum@0
|
512 |
'save_time' => (int) $current_time,
|
|
indvdum@0
|
513 |
'draft_subject' => (string) $subject,
|
|
indvdum@0
|
514 |
'draft_message' => (string) $message)
|
|
indvdum@0
|
515 |
);
|
|
indvdum@0
|
516 |
$db->sql_query($sql);
|
|
indvdum@0
|
517 |
|
|
indvdum@0
|
518 |
$meta_info = ($mode == 'post') ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id");
|
|
indvdum@0
|
519 |
|
|
indvdum@0
|
520 |
meta_refresh(3, $meta_info);
|
|
indvdum@0
|
521 |
|
|
indvdum@0
|
522 |
$message = $user->lang['DRAFT_SAVED'] . '<br /><br />';
|
|
indvdum@0
|
523 |
$message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $meta_info . '">', '</a>') . '<br /><br />' : '';
|
|
indvdum@0
|
524 |
$message .= sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>');
|
|
indvdum@0
|
525 |
|
|
indvdum@0
|
526 |
trigger_error($message);
|
|
indvdum@0
|
527 |
}
|
|
indvdum@0
|
528 |
else
|
|
indvdum@0
|
529 |
{
|
|
indvdum@0
|
530 |
$s_hidden_fields = build_hidden_fields(array(
|
|
indvdum@0
|
531 |
'mode' => $mode,
|
|
indvdum@0
|
532 |
'save' => true,
|
|
indvdum@0
|
533 |
'f' => $forum_id,
|
|
indvdum@0
|
534 |
't' => $topic_id,
|
|
indvdum@0
|
535 |
'subject' => $subject,
|
|
indvdum@0
|
536 |
'message' => $message,
|
|
indvdum@0
|
537 |
'attachment_data' => $message_parser->attachment_data,
|
|
indvdum@0
|
538 |
)
|
|
indvdum@0
|
539 |
);
|
|
indvdum@0
|
540 |
|
|
indvdum@0
|
541 |
$hidden_fields = array(
|
|
indvdum@0
|
542 |
'icon_id' => 0,
|
|
indvdum@0
|
543 |
|
|
indvdum@0
|
544 |
'disable_bbcode' => false,
|
|
indvdum@0
|
545 |
'disable_smilies' => false,
|
|
indvdum@0
|
546 |
'disable_magic_url' => false,
|
|
indvdum@0
|
547 |
'attach_sig' => true,
|
|
indvdum@0
|
548 |
'lock_topic' => false,
|
|
indvdum@0
|
549 |
|
|
indvdum@0
|
550 |
'topic_type' => POST_NORMAL,
|
|
indvdum@0
|
551 |
'topic_time_limit' => 0,
|
|
indvdum@0
|
552 |
|
|
indvdum@0
|
553 |
'poll_title' => '',
|
|
indvdum@0
|
554 |
'poll_option_text' => '',
|
|
indvdum@0
|
555 |
'poll_max_options' => 1,
|
|
indvdum@0
|
556 |
'poll_length' => 0,
|
|
indvdum@0
|
557 |
'poll_vote_change' => false,
|
|
indvdum@0
|
558 |
);
|
|
indvdum@0
|
559 |
|
|
indvdum@0
|
560 |
foreach ($hidden_fields as $name => $default)
|
|
indvdum@0
|
561 |
{
|
|
indvdum@0
|
562 |
if (!isset($_POST[$name]))
|
|
indvdum@0
|
563 |
{
|
|
indvdum@0
|
564 |
// Don't include it, if its not available
|
|
indvdum@0
|
565 |
unset($hidden_fields[$name]);
|
|
indvdum@0
|
566 |
continue;
|
|
indvdum@0
|
567 |
}
|
|
indvdum@0
|
568 |
|
|
indvdum@0
|
569 |
if (is_bool($default))
|
|
indvdum@0
|
570 |
{
|
|
indvdum@0
|
571 |
// Use the string representation
|
|
indvdum@0
|
572 |
$hidden_fields[$name] = request_var($name, '');
|
|
indvdum@0
|
573 |
}
|
|
indvdum@0
|
574 |
else
|
|
indvdum@0
|
575 |
{
|
|
indvdum@0
|
576 |
$hidden_fields[$name] = request_var($name, $default);
|
|
indvdum@0
|
577 |
}
|
|
indvdum@0
|
578 |
}
|
|
indvdum@0
|
579 |
|
|
indvdum@0
|
580 |
$s_hidden_fields .= build_hidden_fields($hidden_fields);
|
|
indvdum@0
|
581 |
|
|
indvdum@0
|
582 |
confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields);
|
|
indvdum@0
|
583 |
}
|
|
indvdum@0
|
584 |
}
|
|
indvdum@0
|
585 |
else
|
|
indvdum@0
|
586 |
{
|
|
indvdum@0
|
587 |
if (utf8_clean_string($subject) === '')
|
|
indvdum@0
|
588 |
{
|
|
indvdum@0
|
589 |
$error[] = $user->lang['EMPTY_SUBJECT'];
|
|
indvdum@0
|
590 |
}
|
|
indvdum@0
|
591 |
|
|
indvdum@0
|
592 |
if (utf8_clean_string($message) === '')
|
|
indvdum@0
|
593 |
{
|
|
indvdum@0
|
594 |
$error[] = $user->lang['TOO_FEW_CHARS'];
|
|
indvdum@0
|
595 |
}
|
|
indvdum@0
|
596 |
}
|
|
indvdum@0
|
597 |
unset($subject, $message);
|
|
indvdum@0
|
598 |
}
|
|
indvdum@0
|
599 |
|
|
indvdum@0
|
600 |
// Load requested Draft
|
|
indvdum@0
|
601 |
if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $user->data['is_registered'] && $auth->acl_get('u_savedrafts'))
|
|
indvdum@0
|
602 |
{
|
|
indvdum@0
|
603 |
$sql = 'SELECT draft_subject, draft_message
|
|
indvdum@0
|
604 |
FROM ' . DRAFTS_TABLE . "
|
|
indvdum@0
|
605 |
WHERE draft_id = $draft_id
|
|
indvdum@0
|
606 |
AND user_id = " . $user->data['user_id'];
|
|
indvdum@0
|
607 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
608 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
609 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
610 |
|
|
indvdum@0
|
611 |
if ($row)
|
|
indvdum@0
|
612 |
{
|
|
indvdum@0
|
613 |
$post_data['post_subject'] = $row['draft_subject'];
|
|
indvdum@0
|
614 |
$message_parser->message = $row['draft_message'];
|
|
indvdum@0
|
615 |
|
|
indvdum@0
|
616 |
$template->assign_var('S_DRAFT_LOADED', true);
|
|
indvdum@0
|
617 |
}
|
|
indvdum@0
|
618 |
else
|
|
indvdum@0
|
619 |
{
|
|
indvdum@0
|
620 |
$draft_id = 0;
|
|
indvdum@0
|
621 |
}
|
|
indvdum@0
|
622 |
}
|
|
indvdum@0
|
623 |
|
|
indvdum@0
|
624 |
// Load draft overview
|
|
indvdum@0
|
625 |
if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_data['drafts'])
|
|
indvdum@0
|
626 |
{
|
|
indvdum@0
|
627 |
load_drafts($topic_id, $forum_id);
|
|
indvdum@0
|
628 |
}
|
|
indvdum@0
|
629 |
|
|
indvdum@0
|
630 |
|
|
indvdum@0
|
631 |
if ($submit || $preview || $refresh)
|
|
indvdum@0
|
632 |
{
|
|
indvdum@0
|
633 |
$post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0);
|
|
indvdum@0
|
634 |
$post_data['post_subject'] = utf8_normalize_nfc(request_var('subject', '', true));
|
|
indvdum@0
|
635 |
$message_parser->message = utf8_normalize_nfc(request_var('message', '', true));
|
|
indvdum@0
|
636 |
|
|
indvdum@0
|
637 |
$post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true));
|
|
indvdum@0
|
638 |
$post_data['post_edit_reason'] = (!empty($_POST['edit_reason']) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : '';
|
|
indvdum@0
|
639 |
|
|
indvdum@0
|
640 |
$post_data['orig_topic_type'] = $post_data['topic_type'];
|
|
indvdum@0
|
641 |
$post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL));
|
|
indvdum@0
|
642 |
$post_data['topic_time_limit'] = request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0));
|
|
indvdum@0
|
643 |
|
|
indvdum@0
|
644 |
if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id))
|
|
indvdum@0
|
645 |
{
|
|
indvdum@0
|
646 |
$post_data['icon_id'] = request_var('icon', (int) $post_data['icon_id']);
|
|
indvdum@0
|
647 |
}
|
|
indvdum@0
|
648 |
|
|
indvdum@0
|
649 |
$post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true;
|
|
indvdum@0
|
650 |
$post_data['enable_smilies'] = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true;
|
|
indvdum@0
|
651 |
$post_data['enable_urls'] = (isset($_POST['disable_magic_url'])) ? 0 : 1;
|
|
indvdum@0
|
652 |
$post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false);
|
|
indvdum@0
|
653 |
|
|
indvdum@0
|
654 |
if ($config['allow_topic_notify'] && $user->data['is_registered'])
|
|
indvdum@0
|
655 |
{
|
|
indvdum@0
|
656 |
$notify = (isset($_POST['notify'])) ? true : false;
|
|
indvdum@0
|
657 |
}
|
|
indvdum@0
|
658 |
else
|
|
indvdum@0
|
659 |
{
|
|
indvdum@0
|
660 |
$notify = false;
|
|
indvdum@0
|
661 |
}
|
|
indvdum@0
|
662 |
|
|
indvdum@0
|
663 |
$topic_lock = (isset($_POST['lock_topic'])) ? true : false;
|
|
indvdum@0
|
664 |
$post_lock = (isset($_POST['lock_post'])) ? true : false;
|
|
indvdum@0
|
665 |
$poll_delete = (isset($_POST['poll_delete'])) ? true : false;
|
|
indvdum@0
|
666 |
|
|
indvdum@0
|
667 |
if ($submit)
|
|
indvdum@0
|
668 |
{
|
|
indvdum@0
|
669 |
$status_switch = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1);
|
|
indvdum@0
|
670 |
$status_switch = ($status_switch != $check_value);
|
|
indvdum@0
|
671 |
}
|
|
indvdum@0
|
672 |
else
|
|
indvdum@0
|
673 |
{
|
|
indvdum@0
|
674 |
$status_switch = 1;
|
|
indvdum@0
|
675 |
}
|
|
indvdum@0
|
676 |
|
|
indvdum@0
|
677 |
// Delete Poll
|
|
indvdum@0
|
678 |
if ($poll_delete && $mode == 'edit' && sizeof($post_data['poll_options']) &&
|
|
indvdum@0
|
679 |
((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id)))
|
|
indvdum@0
|
680 |
{
|
|
indvdum@0
|
681 |
if ($submit && check_form_key('posting'))
|
|
indvdum@0
|
682 |
{
|
|
indvdum@0
|
683 |
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . "
|
|
indvdum@0
|
684 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
685 |
$db->sql_query($sql);
|
|
indvdum@0
|
686 |
|
|
indvdum@0
|
687 |
$sql = 'DELETE FROM ' . POLL_VOTES_TABLE . "
|
|
indvdum@0
|
688 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
689 |
$db->sql_query($sql);
|
|
indvdum@0
|
690 |
|
|
indvdum@0
|
691 |
$topic_sql = array(
|
|
indvdum@0
|
692 |
'poll_title' => '',
|
|
indvdum@0
|
693 |
'poll_start' => 0,
|
|
indvdum@0
|
694 |
'poll_length' => 0,
|
|
indvdum@0
|
695 |
'poll_last_vote' => 0,
|
|
indvdum@0
|
696 |
'poll_max_options' => 0,
|
|
indvdum@0
|
697 |
'poll_vote_change' => 0
|
|
indvdum@0
|
698 |
);
|
|
indvdum@0
|
699 |
|
|
indvdum@0
|
700 |
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
indvdum@0
|
701 |
SET ' . $db->sql_build_array('UPDATE', $topic_sql) . "
|
|
indvdum@0
|
702 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
703 |
$db->sql_query($sql);
|
|
indvdum@0
|
704 |
}
|
|
indvdum@0
|
705 |
|
|
indvdum@0
|
706 |
$post_data['poll_title'] = $post_data['poll_option_text'] = '';
|
|
indvdum@0
|
707 |
$post_data['poll_vote_change'] = $post_data['poll_max_options'] = $post_data['poll_length'] = 0;
|
|
indvdum@0
|
708 |
}
|
|
indvdum@0
|
709 |
else
|
|
indvdum@0
|
710 |
{
|
|
indvdum@0
|
711 |
$post_data['poll_title'] = utf8_normalize_nfc(request_var('poll_title', '', true));
|
|
indvdum@0
|
712 |
$post_data['poll_length'] = request_var('poll_length', 0);
|
|
indvdum@0
|
713 |
$post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true));
|
|
indvdum@0
|
714 |
$post_data['poll_max_options'] = request_var('poll_max_options', 1);
|
|
indvdum@0
|
715 |
$post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0;
|
|
indvdum@0
|
716 |
}
|
|
indvdum@0
|
717 |
|
|
indvdum@0
|
718 |
// If replying/quoting and last post id has changed
|
|
indvdum@0
|
719 |
// give user option to continue submit or return to post
|
|
indvdum@0
|
720 |
// notify and show user the post made between his request and the final submit
|
|
indvdum@0
|
721 |
if (($mode == 'reply' || $mode == 'quote') && $post_data['topic_cur_post_id'] && $post_data['topic_cur_post_id'] != $post_data['topic_last_post_id'])
|
|
indvdum@0
|
722 |
{
|
|
indvdum@0
|
723 |
// Only do so if it is allowed forum-wide
|
|
indvdum@0
|
724 |
if ($post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW)
|
|
indvdum@0
|
725 |
{
|
|
indvdum@0
|
726 |
if (topic_review($topic_id, $forum_id, 'post_review', $post_data['topic_cur_post_id']))
|
|
indvdum@0
|
727 |
{
|
|
indvdum@0
|
728 |
$template->assign_var('S_POST_REVIEW', true);
|
|
indvdum@0
|
729 |
}
|
|
indvdum@0
|
730 |
|
|
indvdum@0
|
731 |
$submit = false;
|
|
indvdum@0
|
732 |
$refresh = true;
|
|
indvdum@0
|
733 |
}
|
|
indvdum@0
|
734 |
}
|
|
indvdum@0
|
735 |
|
|
indvdum@0
|
736 |
// Parse Attachments - before checksum is calculated
|
|
indvdum@0
|
737 |
$message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh);
|
|
indvdum@0
|
738 |
|
|
indvdum@0
|
739 |
// Grab md5 'checksum' of new message
|
|
indvdum@0
|
740 |
$message_md5 = md5($message_parser->message);
|
|
indvdum@0
|
741 |
|
|
indvdum@0
|
742 |
// If editing and checksum has changed we know the post was edited while we're editing
|
|
indvdum@0
|
743 |
// Notify and show user the changed post
|
|
indvdum@0
|
744 |
if ($mode == 'edit' && $post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW)
|
|
indvdum@0
|
745 |
{
|
|
indvdum@0
|
746 |
$edit_post_message_checksum = request_var('edit_post_message_checksum', '');
|
|
indvdum@0
|
747 |
$edit_post_subject_checksum = request_var('edit_post_subject_checksum', '');
|
|
indvdum@0
|
748 |
|
|
indvdum@0
|
749 |
// $post_data['post_checksum'] is the checksum of the post submitted in the meantime
|
|
indvdum@0
|
750 |
// $message_md5 is the checksum of the post we're about to submit
|
|
indvdum@0
|
751 |
// $edit_post_message_checksum is the checksum of the post we're editing
|
|
indvdum@0
|
752 |
// ...
|
|
indvdum@0
|
753 |
|
|
indvdum@0
|
754 |
// We make sure nobody else made exactly the same change
|
|
indvdum@0
|
755 |
// we're about to submit by also checking $message_md5 != $post_data['post_checksum']
|
|
indvdum@0
|
756 |
if (($edit_post_message_checksum !== '' && $edit_post_message_checksum != $post_data['post_checksum'] && $message_md5 != $post_data['post_checksum'])
|
|
indvdum@0
|
757 |
|| ($edit_post_subject_checksum !== '' && $edit_post_subject_checksum != $post_data['post_subject_md5'] && md5($post_data['post_subject']) != $post_data['post_subject_md5']))
|
|
indvdum@0
|
758 |
{
|
|
indvdum@0
|
759 |
if (topic_review($topic_id, $forum_id, 'post_review_edit', $post_id))
|
|
indvdum@0
|
760 |
{
|
|
indvdum@0
|
761 |
$template->assign_vars(array(
|
|
indvdum@0
|
762 |
'S_POST_REVIEW' => true,
|
|
indvdum@0
|
763 |
|
|
indvdum@0
|
764 |
'L_POST_REVIEW' => $user->lang['POST_REVIEW_EDIT'],
|
|
indvdum@0
|
765 |
'L_POST_REVIEW_EXPLAIN' => $user->lang['POST_REVIEW_EDIT_EXPLAIN'],
|
|
indvdum@0
|
766 |
));
|
|
indvdum@0
|
767 |
}
|
|
indvdum@0
|
768 |
|
|
indvdum@0
|
769 |
$submit = false;
|
|
indvdum@0
|
770 |
$refresh = true;
|
|
indvdum@0
|
771 |
}
|
|
indvdum@0
|
772 |
}
|
|
indvdum@0
|
773 |
|
|
indvdum@0
|
774 |
// Check checksum ... don't re-parse message if the same
|
|
indvdum@0
|
775 |
$update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN) ? true : false;
|
|
indvdum@0
|
776 |
|
|
indvdum@0
|
777 |
// Also check if subject got updated...
|
|
indvdum@0
|
778 |
$update_subject = $mode != 'edit' || ($post_data['post_subject_md5'] && $post_data['post_subject_md5'] != md5($post_data['post_subject']));
|
|
indvdum@0
|
779 |
|
|
indvdum@0
|
780 |
// Parse message
|
|
indvdum@0
|
781 |
if ($update_message)
|
|
indvdum@0
|
782 |
{
|
|
indvdum@0
|
783 |
if (sizeof($message_parser->warn_msg))
|
|
indvdum@0
|
784 |
{
|
|
indvdum@0
|
785 |
$error[] = implode('<br />', $message_parser->warn_msg);
|
|
indvdum@0
|
786 |
$message_parser->warn_msg = array();
|
|
indvdum@0
|
787 |
}
|
|
indvdum@0
|
788 |
|
|
indvdum@0
|
789 |
$message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']);
|
|
indvdum@0
|
790 |
|
|
indvdum@0
|
791 |
// On a refresh we do not care about message parsing errors
|
|
indvdum@0
|
792 |
if (sizeof($message_parser->warn_msg) && $refresh)
|
|
indvdum@0
|
793 |
{
|
|
indvdum@0
|
794 |
$message_parser->warn_msg = array();
|
|
indvdum@0
|
795 |
}
|
|
indvdum@0
|
796 |
}
|
|
indvdum@0
|
797 |
else
|
|
indvdum@0
|
798 |
{
|
|
indvdum@0
|
799 |
$message_parser->bbcode_bitfield = $post_data['bbcode_bitfield'];
|
|
indvdum@0
|
800 |
}
|
|
indvdum@0
|
801 |
|
|
indvdum@0
|
802 |
if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id))
|
|
indvdum@0
|
803 |
{
|
|
indvdum@0
|
804 |
// Flood check
|
|
indvdum@0
|
805 |
$last_post_time = 0;
|
|
indvdum@0
|
806 |
|
|
indvdum@0
|
807 |
if ($user->data['is_registered'])
|
|
indvdum@0
|
808 |
{
|
|
indvdum@0
|
809 |
$last_post_time = $user->data['user_lastpost_time'];
|
|
indvdum@0
|
810 |
}
|
|
indvdum@0
|
811 |
else
|
|
indvdum@0
|
812 |
{
|
|
indvdum@0
|
813 |
$sql = 'SELECT post_time AS last_post_time
|
|
indvdum@0
|
814 |
FROM ' . POSTS_TABLE . "
|
|
indvdum@0
|
815 |
WHERE poster_ip = '" . $user->ip . "'
|
|
indvdum@0
|
816 |
AND post_time > " . ($current_time - $config['flood_interval']);
|
|
indvdum@0
|
817 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
818 |
if ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
819 |
{
|
|
indvdum@0
|
820 |
$last_post_time = $row['last_post_time'];
|
|
indvdum@0
|
821 |
}
|
|
indvdum@0
|
822 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
823 |
}
|
|
indvdum@0
|
824 |
|
|
indvdum@0
|
825 |
if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval']))
|
|
indvdum@0
|
826 |
{
|
|
indvdum@0
|
827 |
$error[] = $user->lang['FLOOD_ERROR'];
|
|
indvdum@0
|
828 |
}
|
|
indvdum@0
|
829 |
}
|
|
indvdum@0
|
830 |
|
|
indvdum@0
|
831 |
// Validate username
|
|
indvdum@0
|
832 |
if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username']))
|
|
indvdum@0
|
833 |
{
|
|
indvdum@0
|
834 |
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
indvdum@0
|
835 |
|
|
indvdum@0
|
836 |
$user->add_lang('ucp');
|
|
indvdum@0
|
837 |
|
|
indvdum@0
|
838 |
if (($result = validate_username($post_data['username'], (!empty($post_data['post_username'])) ? $post_data['post_username'] : '')) !== false)
|
|
indvdum@0
|
839 |
{
|
|
indvdum@0
|
840 |
$error[] = $user->lang[$result . '_USERNAME'];
|
|
indvdum@0
|
841 |
}
|
|
indvdum@0
|
842 |
|
|
indvdum@0
|
843 |
if (($result = validate_string($post_data['username'], false, $config['min_name_chars'], $config['max_name_chars'])) !== false)
|
|
indvdum@0
|
844 |
{
|
|
indvdum@0
|
845 |
$min_max_amount = ($result == 'TOO_SHORT') ? $config['min_name_chars'] : $config['max_name_chars'];
|
|
indvdum@0
|
846 |
$error[] = sprintf($user->lang['FIELD_' . $result], $user->lang['USERNAME'], $min_max_amount);
|
|
indvdum@0
|
847 |
}
|
|
indvdum@0
|
848 |
}
|
|
indvdum@0
|
849 |
|
|
indvdum@0
|
850 |
if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply')))
|
|
indvdum@0
|
851 |
{
|
|
indvdum@0
|
852 |
$captcha_data = array(
|
|
indvdum@0
|
853 |
'message' => utf8_normalize_nfc(request_var('message', '', true)),
|
|
indvdum@0
|
854 |
'subject' => utf8_normalize_nfc(request_var('subject', '', true)),
|
|
indvdum@0
|
855 |
'username' => utf8_normalize_nfc(request_var('username', '', true)),
|
|
indvdum@0
|
856 |
);
|
|
indvdum@0
|
857 |
$vc_response = $captcha->validate($captcha_data);
|
|
indvdum@0
|
858 |
if ($vc_response)
|
|
indvdum@0
|
859 |
{
|
|
indvdum@0
|
860 |
$error[] = $vc_response;
|
|
indvdum@0
|
861 |
}
|
|
indvdum@0
|
862 |
}
|
|
indvdum@0
|
863 |
|
|
indvdum@0
|
864 |
// check form
|
|
indvdum@0
|
865 |
if (($submit || $preview) && !check_form_key('posting'))
|
|
indvdum@0
|
866 |
{
|
|
indvdum@0
|
867 |
$error[] = $user->lang['FORM_INVALID'];
|
|
indvdum@0
|
868 |
}
|
|
indvdum@0
|
869 |
|
|
indvdum@0
|
870 |
// Parse subject
|
|
indvdum@0
|
871 |
if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id)))
|
|
indvdum@0
|
872 |
{
|
|
indvdum@0
|
873 |
$error[] = $user->lang['EMPTY_SUBJECT'];
|
|
indvdum@0
|
874 |
}
|
|
indvdum@0
|
875 |
|
|
indvdum@0
|
876 |
$post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0;
|
|
indvdum@0
|
877 |
|
|
indvdum@0
|
878 |
if ($post_data['poll_option_text'] &&
|
|
indvdum@0
|
879 |
($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/))
|
|
indvdum@0
|
880 |
&& $auth->acl_get('f_poll', $forum_id))
|
|
indvdum@0
|
881 |
{
|
|
indvdum@0
|
882 |
$poll = array(
|
|
indvdum@0
|
883 |
'poll_title' => $post_data['poll_title'],
|
|
indvdum@0
|
884 |
'poll_length' => $post_data['poll_length'],
|
|
indvdum@0
|
885 |
'poll_max_options' => $post_data['poll_max_options'],
|
|
indvdum@0
|
886 |
'poll_option_text' => $post_data['poll_option_text'],
|
|
indvdum@0
|
887 |
'poll_start' => $post_data['poll_start'],
|
|
indvdum@0
|
888 |
'poll_last_vote' => $post_data['poll_last_vote'],
|
|
indvdum@0
|
889 |
'poll_vote_change' => $post_data['poll_vote_change'],
|
|
indvdum@0
|
890 |
'enable_bbcode' => $post_data['enable_bbcode'],
|
|
indvdum@0
|
891 |
'enable_urls' => $post_data['enable_urls'],
|
|
indvdum@0
|
892 |
'enable_smilies' => $post_data['enable_smilies'],
|
|
indvdum@0
|
893 |
'img_status' => $img_status
|
|
indvdum@0
|
894 |
);
|
|
indvdum@0
|
895 |
|
|
indvdum@0
|
896 |
$message_parser->parse_poll($poll);
|
|
indvdum@0
|
897 |
|
|
indvdum@0
|
898 |
$post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : array();
|
|
indvdum@0
|
899 |
$post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : '';
|
|
indvdum@0
|
900 |
|
|
indvdum@0
|
901 |
/* We reset votes, therefore also allow removing options
|
|
indvdum@0
|
902 |
if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size))
|
|
indvdum@0
|
903 |
{
|
|
indvdum@0
|
904 |
$message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS'];
|
|
indvdum@0
|
905 |
}*/
|
|
indvdum@0
|
906 |
}
|
|
indvdum@0
|
907 |
else if ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'] && $auth->acl_get('f_poll', $forum_id))
|
|
indvdum@0
|
908 |
{
|
|
indvdum@0
|
909 |
// The user removed all poll options, this is equal to deleting the poll.
|
|
indvdum@0
|
910 |
$poll = array(
|
|
indvdum@0
|
911 |
'poll_title' => '',
|
|
indvdum@0
|
912 |
'poll_length' => 0,
|
|
indvdum@0
|
913 |
'poll_max_options' => 0,
|
|
indvdum@0
|
914 |
'poll_option_text' => '',
|
|
indvdum@0
|
915 |
'poll_start' => 0,
|
|
indvdum@0
|
916 |
'poll_last_vote' => 0,
|
|
indvdum@0
|
917 |
'poll_vote_change' => 0,
|
|
indvdum@0
|
918 |
'poll_options' => array(),
|
|
indvdum@0
|
919 |
);
|
|
indvdum@0
|
920 |
|
|
indvdum@0
|
921 |
$post_data['poll_options'] = array();
|
|
indvdum@0
|
922 |
$post_data['poll_title'] = '';
|
|
indvdum@0
|
923 |
$post_data['poll_start'] = $post_data['poll_length'] = $post_data['poll_max_options'] = $post_data['poll_last_vote'] = $post_data['poll_vote_change'] = 0;
|
|
indvdum@0
|
924 |
}
|
|
indvdum@0
|
925 |
else if (!$auth->acl_get('f_poll', $forum_id) && ($mode == 'edit') && ($post_id == $post_data['topic_first_post_id']) && ($original_poll_data['poll_title'] != ''))
|
|
indvdum@0
|
926 |
{
|
|
indvdum@0
|
927 |
// We have a poll but the editing user is not permitted to create/edit it.
|
|
indvdum@0
|
928 |
// So we just keep the original poll-data.
|
|
indvdum@0
|
929 |
$poll = array_merge($original_poll_data, array(
|
|
indvdum@0
|
930 |
'enable_bbcode' => $post_data['enable_bbcode'],
|
|
indvdum@0
|
931 |
'enable_urls' => $post_data['enable_urls'],
|
|
indvdum@0
|
932 |
'enable_smilies' => $post_data['enable_smilies'],
|
|
indvdum@0
|
933 |
'img_status' => $img_status,
|
|
indvdum@0
|
934 |
));
|
|
indvdum@0
|
935 |
|
|
indvdum@0
|
936 |
$message_parser->parse_poll($poll);
|
|
indvdum@0
|
937 |
|
|
indvdum@0
|
938 |
$post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : array();
|
|
indvdum@0
|
939 |
$post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : '';
|
|
indvdum@0
|
940 |
}
|
|
indvdum@0
|
941 |
else
|
|
indvdum@0
|
942 |
{
|
|
indvdum@0
|
943 |
$poll = array();
|
|
indvdum@0
|
944 |
}
|
|
indvdum@0
|
945 |
|
|
indvdum@0
|
946 |
// Check topic type
|
|
indvdum@0
|
947 |
if ($post_data['topic_type'] != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id)))
|
|
indvdum@0
|
948 |
{
|
|
indvdum@0
|
949 |
switch ($post_data['topic_type'])
|
|
indvdum@0
|
950 |
{
|
|
indvdum@0
|
951 |
case POST_GLOBAL:
|
|
indvdum@0
|
952 |
case POST_ANNOUNCE:
|
|
indvdum@0
|
953 |
$auth_option = 'f_announce';
|
|
indvdum@0
|
954 |
break;
|
|
indvdum@0
|
955 |
|
|
indvdum@0
|
956 |
case POST_STICKY:
|
|
indvdum@0
|
957 |
$auth_option = 'f_sticky';
|
|
indvdum@0
|
958 |
break;
|
|
indvdum@0
|
959 |
|
|
indvdum@0
|
960 |
default:
|
|
indvdum@0
|
961 |
$auth_option = '';
|
|
indvdum@0
|
962 |
break;
|
|
indvdum@0
|
963 |
}
|
|
indvdum@0
|
964 |
|
|
indvdum@0
|
965 |
if (!$auth->acl_get($auth_option, $forum_id))
|
|
indvdum@0
|
966 |
{
|
|
indvdum@0
|
967 |
// There is a special case where a user edits his post whereby the topic type got changed by an admin/mod.
|
|
indvdum@0
|
968 |
// Another case would be a mod not having sticky permissions for example but edit permissions.
|
|
indvdum@0
|
969 |
if ($mode == 'edit')
|
|
indvdum@0
|
970 |
{
|
|
indvdum@0
|
971 |
// To prevent non-authed users messing around with the topic type we reset it to the original one.
|
|
indvdum@0
|
972 |
$post_data['topic_type'] = $post_data['orig_topic_type'];
|
|
indvdum@0
|
973 |
}
|
|
indvdum@0
|
974 |
else
|
|
indvdum@0
|
975 |
{
|
|
indvdum@0
|
976 |
$error[] = $user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))];
|
|
indvdum@0
|
977 |
}
|
|
indvdum@0
|
978 |
}
|
|
indvdum@0
|
979 |
}
|
|
indvdum@0
|
980 |
|
|
indvdum@0
|
981 |
if (sizeof($message_parser->warn_msg))
|
|
indvdum@0
|
982 |
{
|
|
indvdum@0
|
983 |
$error[] = implode('<br />', $message_parser->warn_msg);
|
|
indvdum@0
|
984 |
}
|
|
indvdum@0
|
985 |
|
|
indvdum@0
|
986 |
// DNSBL check
|
|
indvdum@0
|
987 |
if ($config['check_dnsbl'] && !$refresh)
|
|
indvdum@0
|
988 |
{
|
|
indvdum@0
|
989 |
if (($dnsbl = $user->check_dnsbl('post')) !== false)
|
|
indvdum@0
|
990 |
{
|
|
indvdum@0
|
991 |
$error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]);
|
|
indvdum@0
|
992 |
}
|
|
indvdum@0
|
993 |
}
|
|
indvdum@0
|
994 |
|
|
indvdum@0
|
995 |
// Store message, sync counters
|
|
indvdum@0
|
996 |
if (!sizeof($error) && $submit)
|
|
indvdum@0
|
997 |
{
|
|
indvdum@0
|
998 |
// Check if we want to de-globalize the topic... and ask for new forum
|
|
indvdum@0
|
999 |
if ($post_data['topic_type'] != POST_GLOBAL)
|
|
indvdum@0
|
1000 |
{
|
|
indvdum@0
|
1001 |
$sql = 'SELECT topic_type, forum_id
|
|
indvdum@0
|
1002 |
FROM ' . TOPICS_TABLE . "
|
|
indvdum@0
|
1003 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
1004 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1005 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1006 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1007 |
|
|
indvdum@0
|
1008 |
if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL)
|
|
indvdum@0
|
1009 |
{
|
|
indvdum@0
|
1010 |
$to_forum_id = request_var('to_forum_id', 0);
|
|
indvdum@0
|
1011 |
|
|
indvdum@0
|
1012 |
if ($to_forum_id)
|
|
indvdum@0
|
1013 |
{
|
|
indvdum@0
|
1014 |
$sql = 'SELECT forum_type
|
|
indvdum@0
|
1015 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1016 |
WHERE forum_id = ' . $to_forum_id;
|
|
indvdum@0
|
1017 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1018 |
$forum_type = (int) $db->sql_fetchfield('forum_type');
|
|
indvdum@0
|
1019 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1020 |
|
|
indvdum@0
|
1021 |
if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id)))
|
|
indvdum@0
|
1022 |
{
|
|
indvdum@0
|
1023 |
$to_forum_id = 0;
|
|
indvdum@0
|
1024 |
}
|
|
indvdum@0
|
1025 |
}
|
|
indvdum@0
|
1026 |
|
|
indvdum@0
|
1027 |
if (!$to_forum_id)
|
|
indvdum@0
|
1028 |
{
|
|
indvdum@0
|
1029 |
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
|
indvdum@0
|
1030 |
|
|
indvdum@0
|
1031 |
$template->assign_vars(array(
|
|
indvdum@0
|
1032 |
'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true),
|
|
indvdum@0
|
1033 |
'S_UNGLOBALISE' => true)
|
|
indvdum@0
|
1034 |
);
|
|
indvdum@0
|
1035 |
|
|
indvdum@0
|
1036 |
$submit = false;
|
|
indvdum@0
|
1037 |
$refresh = true;
|
|
indvdum@0
|
1038 |
}
|
|
indvdum@0
|
1039 |
else
|
|
indvdum@0
|
1040 |
{
|
|
indvdum@0
|
1041 |
if (!$auth->acl_get('f_post', $to_forum_id))
|
|
indvdum@0
|
1042 |
{
|
|
indvdum@0
|
1043 |
// This will only be triggered if the user tried to trick the forum.
|
|
indvdum@0
|
1044 |
trigger_error('NOT_AUTHORISED');
|
|
indvdum@0
|
1045 |
}
|
|
indvdum@0
|
1046 |
|
|
indvdum@0
|
1047 |
$forum_id = $to_forum_id;
|
|
indvdum@0
|
1048 |
}
|
|
indvdum@0
|
1049 |
}
|
|
indvdum@0
|
1050 |
}
|
|
indvdum@0
|
1051 |
|
|
indvdum@0
|
1052 |
if ($submit)
|
|
indvdum@0
|
1053 |
{
|
|
indvdum@0
|
1054 |
// Lock/Unlock Topic
|
|
indvdum@0
|
1055 |
$change_topic_status = $post_data['topic_status'];
|
|
indvdum@0
|
1056 |
$perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false;
|
|
indvdum@0
|
1057 |
|
|
indvdum@0
|
1058 |
if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock)
|
|
indvdum@0
|
1059 |
{
|
|
indvdum@0
|
1060 |
$change_topic_status = ITEM_UNLOCKED;
|
|
indvdum@0
|
1061 |
}
|
|
indvdum@0
|
1062 |
else if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock)
|
|
indvdum@0
|
1063 |
{
|
|
indvdum@0
|
1064 |
$change_topic_status = ITEM_LOCKED;
|
|
indvdum@0
|
1065 |
}
|
|
indvdum@0
|
1066 |
|
|
indvdum@0
|
1067 |
if ($change_topic_status != $post_data['topic_status'])
|
|
indvdum@0
|
1068 |
{
|
|
indvdum@0
|
1069 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
indvdum@0
|
1070 |
SET topic_status = $change_topic_status
|
|
indvdum@0
|
1071 |
WHERE topic_id = $topic_id
|
|
indvdum@0
|
1072 |
AND topic_moved_id = 0";
|
|
indvdum@0
|
1073 |
$db->sql_query($sql);
|
|
indvdum@0
|
1074 |
|
|
indvdum@0
|
1075 |
$user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : '';
|
|
indvdum@0
|
1076 |
|
|
indvdum@0
|
1077 |
add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']);
|
|
indvdum@0
|
1078 |
}
|
|
indvdum@0
|
1079 |
|
|
indvdum@0
|
1080 |
// Lock/Unlock Post Edit
|
|
indvdum@0
|
1081 |
if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id))
|
|
indvdum@0
|
1082 |
{
|
|
indvdum@0
|
1083 |
$post_data['post_edit_locked'] = ITEM_UNLOCKED;
|
|
indvdum@0
|
1084 |
}
|
|
indvdum@0
|
1085 |
else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id))
|
|
indvdum@0
|
1086 |
{
|
|
indvdum@0
|
1087 |
$post_data['post_edit_locked'] = ITEM_LOCKED;
|
|
indvdum@0
|
1088 |
}
|
|
indvdum@0
|
1089 |
|
|
indvdum@0
|
1090 |
$data = array(
|
|
indvdum@0
|
1091 |
'topic_title' => (empty($post_data['topic_title'])) ? $post_data['post_subject'] : $post_data['topic_title'],
|
|
indvdum@0
|
1092 |
'topic_first_post_id' => (isset($post_data['topic_first_post_id'])) ? (int) $post_data['topic_first_post_id'] : 0,
|
|
indvdum@0
|
1093 |
'topic_last_post_id' => (isset($post_data['topic_last_post_id'])) ? (int) $post_data['topic_last_post_id'] : 0,
|
|
indvdum@0
|
1094 |
'topic_time_limit' => (int) $post_data['topic_time_limit'],
|
|
indvdum@0
|
1095 |
'topic_attachment' => (isset($post_data['topic_attachment'])) ? (int) $post_data['topic_attachment'] : 0,
|
|
indvdum@0
|
1096 |
'post_id' => (int) $post_id,
|
|
indvdum@0
|
1097 |
'topic_id' => (int) $topic_id,
|
|
indvdum@0
|
1098 |
'forum_id' => (int) $forum_id,
|
|
indvdum@0
|
1099 |
'icon_id' => (int) $post_data['icon_id'],
|
|
indvdum@0
|
1100 |
'poster_id' => (int) $post_data['poster_id'],
|
|
indvdum@0
|
1101 |
'enable_sig' => (bool) $post_data['enable_sig'],
|
|
indvdum@0
|
1102 |
'enable_bbcode' => (bool) $post_data['enable_bbcode'],
|
|
indvdum@0
|
1103 |
'enable_smilies' => (bool) $post_data['enable_smilies'],
|
|
indvdum@0
|
1104 |
'enable_urls' => (bool) $post_data['enable_urls'],
|
|
indvdum@0
|
1105 |
'enable_indexing' => (bool) $post_data['enable_indexing'],
|
|
indvdum@0
|
1106 |
'message_md5' => (string) $message_md5,
|
|
indvdum@0
|
1107 |
'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time,
|
|
indvdum@0
|
1108 |
'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '',
|
|
indvdum@0
|
1109 |
'post_edit_reason' => $post_data['post_edit_reason'],
|
|
indvdum@0
|
1110 |
'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0),
|
|
indvdum@0
|
1111 |
'forum_parents' => $post_data['forum_parents'],
|
|
indvdum@0
|
1112 |
'forum_name' => $post_data['forum_name'],
|
|
indvdum@0
|
1113 |
'notify' => $notify,
|
|
indvdum@0
|
1114 |
'notify_set' => $post_data['notify_set'],
|
|
indvdum@0
|
1115 |
'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : $user->ip,
|
|
indvdum@0
|
1116 |
'post_edit_locked' => (int) $post_data['post_edit_locked'],
|
|
indvdum@0
|
1117 |
'bbcode_bitfield' => $message_parser->bbcode_bitfield,
|
|
indvdum@0
|
1118 |
'bbcode_uid' => $message_parser->bbcode_uid,
|
|
indvdum@0
|
1119 |
'message' => $message_parser->message,
|
|
indvdum@0
|
1120 |
'attachment_data' => $message_parser->attachment_data,
|
|
indvdum@0
|
1121 |
'filename_data' => $message_parser->filename_data,
|
|
indvdum@0
|
1122 |
|
|
indvdum@0
|
1123 |
'topic_approved' => (isset($post_data['topic_approved'])) ? $post_data['topic_approved'] : false,
|
|
indvdum@0
|
1124 |
'post_approved' => (isset($post_data['post_approved'])) ? $post_data['post_approved'] : false,
|
|
indvdum@0
|
1125 |
);
|
|
indvdum@0
|
1126 |
|
|
indvdum@0
|
1127 |
if ($mode == 'edit')
|
|
indvdum@0
|
1128 |
{
|
|
indvdum@0
|
1129 |
$data['topic_replies_real'] = $post_data['topic_replies_real'];
|
|
indvdum@0
|
1130 |
$data['topic_replies'] = $post_data['topic_replies'];
|
|
indvdum@0
|
1131 |
}
|
|
indvdum@0
|
1132 |
|
|
indvdum@0
|
1133 |
// The last parameter tells submit_post if search indexer has to be run
|
|
indvdum@0
|
1134 |
$redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false);
|
|
indvdum@0
|
1135 |
|
|
indvdum@0
|
1136 |
if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))
|
|
indvdum@0
|
1137 |
{
|
|
indvdum@0
|
1138 |
$captcha->reset();
|
|
indvdum@0
|
1139 |
}
|
|
indvdum@0
|
1140 |
|
|
indvdum@0
|
1141 |
// Check the permissions for post approval. Moderators are not affected.
|
|
indvdum@0
|
1142 |
if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id']) && empty($data['force_approved_state'])) || (isset($data['force_approved_state']) && !$data['force_approved_state']))
|
|
indvdum@0
|
1143 |
{
|
|
indvdum@0
|
1144 |
meta_refresh(10, $redirect_url);
|
|
indvdum@0
|
1145 |
$message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD'];
|
|
indvdum@0
|
1146 |
$message .= (($user->data['user_id'] == ANONYMOUS) ? '' : ' '. $user->lang['POST_APPROVAL_NOTIFY']);
|
|
indvdum@0
|
1147 |
}
|
|
indvdum@0
|
1148 |
else
|
|
indvdum@0
|
1149 |
{
|
|
indvdum@0
|
1150 |
meta_refresh(3, $redirect_url);
|
|
indvdum@0
|
1151 |
|
|
indvdum@0
|
1152 |
$message = ($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED';
|
|
indvdum@0
|
1153 |
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $redirect_url . '">', '</a>');
|
|
indvdum@0
|
1154 |
}
|
|
indvdum@0
|
1155 |
|
|
indvdum@0
|
1156 |
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $data['forum_id']) . '">', '</a>');
|
|
indvdum@0
|
1157 |
trigger_error($message);
|
|
indvdum@0
|
1158 |
}
|
|
indvdum@0
|
1159 |
}
|
|
indvdum@0
|
1160 |
}
|
|
indvdum@0
|
1161 |
|
|
indvdum@0
|
1162 |
// Preview
|
|
indvdum@0
|
1163 |
if (!sizeof($error) && $preview)
|
|
indvdum@0
|
1164 |
{
|
|
indvdum@0
|
1165 |
$post_data['post_time'] = ($mode == 'edit') ? $post_data['post_time'] : $current_time;
|
|
indvdum@0
|
1166 |
|
|
indvdum@0
|
1167 |
$preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false);
|
|
indvdum@0
|
1168 |
|
|
indvdum@0
|
1169 |
$preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : $user->data['user_sig'];
|
|
indvdum@0
|
1170 |
$preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : $user->data['user_sig_bbcode_uid'];
|
|
indvdum@0
|
1171 |
$preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield'];
|
|
indvdum@0
|
1172 |
|
|
indvdum@0
|
1173 |
// Signature
|
|
indvdum@0
|
1174 |
if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id))
|
|
indvdum@0
|
1175 |
{
|
|
indvdum@0
|
1176 |
$parse_sig = new parse_message($preview_signature);
|
|
indvdum@0
|
1177 |
$parse_sig->bbcode_uid = $preview_signature_uid;
|
|
indvdum@0
|
1178 |
$parse_sig->bbcode_bitfield = $preview_signature_bitfield;
|
|
indvdum@0
|
1179 |
|
|
indvdum@0
|
1180 |
// Not sure about parameters for bbcode/smilies/urls... in signatures
|
|
indvdum@0
|
1181 |
$parse_sig->format_display($config['allow_sig_bbcode'], $config['allow_sig_links'], $config['allow_sig_smilies']);
|
|
indvdum@0
|
1182 |
$preview_signature = $parse_sig->message;
|
|
indvdum@0
|
1183 |
unset($parse_sig);
|
|
indvdum@0
|
1184 |
}
|
|
indvdum@0
|
1185 |
else
|
|
indvdum@0
|
1186 |
{
|
|
indvdum@0
|
1187 |
$preview_signature = '';
|
|
indvdum@0
|
1188 |
}
|
|
indvdum@0
|
1189 |
|
|
indvdum@0
|
1190 |
$preview_subject = censor_text($post_data['post_subject']);
|
|
indvdum@0
|
1191 |
|
|
indvdum@0
|
1192 |
// Poll Preview
|
|
indvdum@0
|
1193 |
if (!$poll_delete && ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/))
|
|
indvdum@0
|
1194 |
&& $auth->acl_get('f_poll', $forum_id))
|
|
indvdum@0
|
1195 |
{
|
|
indvdum@0
|
1196 |
$parse_poll = new parse_message($post_data['poll_title']);
|
|
indvdum@0
|
1197 |
$parse_poll->bbcode_uid = $message_parser->bbcode_uid;
|
|
indvdum@0
|
1198 |
$parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield;
|
|
indvdum@0
|
1199 |
|
|
indvdum@0
|
1200 |
$parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']);
|
|
indvdum@0
|
1201 |
|
|
indvdum@0
|
1202 |
if ($post_data['poll_length'])
|
|
indvdum@0
|
1203 |
{
|
|
indvdum@0
|
1204 |
$poll_end = ($post_data['poll_length'] * 86400) + (($post_data['poll_start']) ? $post_data['poll_start'] : time());
|
|
indvdum@0
|
1205 |
}
|
|
indvdum@0
|
1206 |
|
|
indvdum@0
|
1207 |
$template->assign_vars(array(
|
|
indvdum@0
|
1208 |
'S_HAS_POLL_OPTIONS' => (sizeof($post_data['poll_options'])),
|
|
indvdum@0
|
1209 |
'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false,
|
|
indvdum@0
|
1210 |
|
|
indvdum@0
|
1211 |
'POLL_QUESTION' => $parse_poll->message,
|
|
indvdum@0
|
1212 |
|
|
indvdum@0
|
1213 |
'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '',
|
|
indvdum@0
|
1214 |
'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options']))
|
|
indvdum@0
|
1215 |
);
|
|
indvdum@0
|
1216 |
|
|
indvdum@0
|
1217 |
$parse_poll->message = implode("\n", $post_data['poll_options']);
|
|
indvdum@0
|
1218 |
$parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']);
|
|
indvdum@0
|
1219 |
$preview_poll_options = explode('<br />', $parse_poll->message);
|
|
indvdum@0
|
1220 |
unset($parse_poll);
|
|
indvdum@0
|
1221 |
|
|
indvdum@0
|
1222 |
foreach ($preview_poll_options as $key => $option)
|
|
indvdum@0
|
1223 |
{
|
|
indvdum@0
|
1224 |
$template->assign_block_vars('poll_option', array(
|
|
indvdum@0
|
1225 |
'POLL_OPTION_CAPTION' => $option,
|
|
indvdum@0
|
1226 |
'POLL_OPTION_ID' => $key + 1)
|
|
indvdum@0
|
1227 |
);
|
|
indvdum@0
|
1228 |
}
|
|
indvdum@0
|
1229 |
unset($preview_poll_options);
|
|
indvdum@0
|
1230 |
}
|
|
indvdum@0
|
1231 |
|
|
indvdum@0
|
1232 |
// Attachment Preview
|
|
indvdum@0
|
1233 |
if (sizeof($message_parser->attachment_data))
|
|
indvdum@0
|
1234 |
{
|
|
indvdum@0
|
1235 |
$template->assign_var('S_HAS_ATTACHMENTS', true);
|
|
indvdum@0
|
1236 |
|
|
indvdum@0
|
1237 |
$update_count = array();
|
|
indvdum@0
|
1238 |
$attachment_data = $message_parser->attachment_data;
|
|
indvdum@0
|
1239 |
|
|
indvdum@0
|
1240 |
parse_attachments($forum_id, $preview_message, $attachment_data, $update_count, true);
|
|
indvdum@0
|
1241 |
|
|
indvdum@0
|
1242 |
foreach ($attachment_data as $i => $attachment)
|
|
indvdum@0
|
1243 |
{
|
|
indvdum@0
|
1244 |
$template->assign_block_vars('attachment', array(
|
|
indvdum@0
|
1245 |
'DISPLAY_ATTACHMENT' => $attachment)
|
|
indvdum@0
|
1246 |
);
|
|
indvdum@0
|
1247 |
}
|
|
indvdum@0
|
1248 |
unset($attachment_data);
|
|
indvdum@0
|
1249 |
}
|
|
indvdum@0
|
1250 |
|
|
indvdum@0
|
1251 |
if (!sizeof($error))
|
|
indvdum@0
|
1252 |
{
|
|
indvdum@0
|
1253 |
$template->assign_vars(array(
|
|
indvdum@0
|
1254 |
'PREVIEW_SUBJECT' => $preview_subject,
|
|
indvdum@0
|
1255 |
'PREVIEW_MESSAGE' => $preview_message,
|
|
indvdum@0
|
1256 |
'PREVIEW_SIGNATURE' => $preview_signature,
|
|
indvdum@0
|
1257 |
|
|
indvdum@0
|
1258 |
'S_DISPLAY_PREVIEW' => true)
|
|
indvdum@0
|
1259 |
);
|
|
indvdum@0
|
1260 |
}
|
|
indvdum@0
|
1261 |
}
|
|
indvdum@0
|
1262 |
|
|
indvdum@0
|
1263 |
// Decode text for message display
|
|
indvdum@0
|
1264 |
$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid;
|
|
indvdum@0
|
1265 |
$message_parser->decode_message($post_data['bbcode_uid']);
|
|
indvdum@0
|
1266 |
|
|
indvdum@0
|
1267 |
if ($mode == 'quote' && !$submit && !$preview && !$refresh)
|
|
indvdum@0
|
1268 |
{
|
|
indvdum@0
|
1269 |
if ($config['allow_bbcode'])
|
|
indvdum@0
|
1270 |
{
|
|
indvdum@0
|
1271 |
$message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
|
|
indvdum@0
|
1272 |
}
|
|
indvdum@0
|
1273 |
else
|
|
indvdum@0
|
1274 |
{
|
|
indvdum@0
|
1275 |
$offset = 0;
|
|
indvdum@0
|
1276 |
$quote_string = "> ";
|
|
indvdum@0
|
1277 |
$message = censor_text(trim($message_parser->message));
|
|
indvdum@0
|
1278 |
// see if we are nesting. It's easily tricked but should work for one level of nesting
|
|
indvdum@0
|
1279 |
if (strpos($message, ">") !== false)
|
|
indvdum@0
|
1280 |
{
|
|
indvdum@0
|
1281 |
$offset = 10;
|
|
indvdum@0
|
1282 |
}
|
|
indvdum@0
|
1283 |
$message = utf8_wordwrap($message, 75 + $offset, "\n");
|
|
indvdum@0
|
1284 |
|
|
indvdum@0
|
1285 |
$message = $quote_string . $message;
|
|
indvdum@0
|
1286 |
$message = str_replace("\n", "\n" . $quote_string, $message);
|
|
indvdum@0
|
1287 |
$message_parser->message = $post_data['quote_username'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n";
|
|
indvdum@0
|
1288 |
}
|
|
indvdum@0
|
1289 |
}
|
|
indvdum@0
|
1290 |
|
|
indvdum@0
|
1291 |
if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh)
|
|
indvdum@0
|
1292 |
{
|
|
indvdum@0
|
1293 |
$post_data['post_subject'] = ((strpos($post_data['post_subject'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($post_data['post_subject']);
|
|
indvdum@0
|
1294 |
}
|
|
indvdum@0
|
1295 |
|
|
indvdum@0
|
1296 |
$attachment_data = $message_parser->attachment_data;
|
|
indvdum@0
|
1297 |
$filename_data = $message_parser->filename_data;
|
|
indvdum@0
|
1298 |
$post_data['post_text'] = $message_parser->message;
|
|
indvdum@0
|
1299 |
|
|
indvdum@0
|
1300 |
if (sizeof($post_data['poll_options']) || !empty($post_data['poll_title']))
|
|
indvdum@0
|
1301 |
{
|
|
indvdum@0
|
1302 |
$message_parser->message = $post_data['poll_title'];
|
|
indvdum@0
|
1303 |
$message_parser->bbcode_uid = $post_data['bbcode_uid'];
|
|
indvdum@0
|
1304 |
|
|
indvdum@0
|
1305 |
$message_parser->decode_message();
|
|
indvdum@0
|
1306 |
$post_data['poll_title'] = $message_parser->message;
|
|
indvdum@0
|
1307 |
|
|
indvdum@0
|
1308 |
$message_parser->message = implode("\n", $post_data['poll_options']);
|
|
indvdum@0
|
1309 |
$message_parser->decode_message();
|
|
indvdum@0
|
1310 |
$post_data['poll_options'] = explode("\n", $message_parser->message);
|
|
indvdum@0
|
1311 |
}
|
|
indvdum@0
|
1312 |
|
|
indvdum@0
|
1313 |
// MAIN POSTING PAGE BEGINS HERE
|
|
indvdum@0
|
1314 |
|
|
indvdum@0
|
1315 |
// Forum moderators?
|
|
indvdum@0
|
1316 |
$moderators = array();
|
|
indvdum@0
|
1317 |
if ($config['load_moderators'])
|
|
indvdum@0
|
1318 |
{
|
|
indvdum@0
|
1319 |
get_moderators($moderators, $forum_id);
|
|
indvdum@0
|
1320 |
}
|
|
indvdum@0
|
1321 |
|
|
indvdum@0
|
1322 |
// Generate smiley listing
|
|
indvdum@0
|
1323 |
generate_smilies('inline', $forum_id);
|
|
indvdum@0
|
1324 |
|
|
indvdum@0
|
1325 |
// Generate inline attachment select box
|
|
indvdum@0
|
1326 |
posting_gen_inline_attachments($attachment_data);
|
|
indvdum@0
|
1327 |
|
|
indvdum@0
|
1328 |
// Do show topic type selection only in first post.
|
|
indvdum@0
|
1329 |
$topic_type_toggle = false;
|
|
indvdum@0
|
1330 |
|
|
indvdum@0
|
1331 |
if ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']))
|
|
indvdum@0
|
1332 |
{
|
|
indvdum@0
|
1333 |
$topic_type_toggle = posting_gen_topic_types($forum_id, $post_data['topic_type']);
|
|
indvdum@0
|
1334 |
}
|
|
indvdum@0
|
1335 |
|
|
indvdum@0
|
1336 |
$s_topic_icons = false;
|
|
indvdum@0
|
1337 |
if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id))
|
|
indvdum@0
|
1338 |
{
|
|
indvdum@0
|
1339 |
$s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']);
|
|
indvdum@0
|
1340 |
}
|
|
indvdum@0
|
1341 |
|
|
indvdum@0
|
1342 |
$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1);
|
|
indvdum@0
|
1343 |
$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : (($config['allow_smilies']) ? !$user->optionget('smilies') : 1);
|
|
indvdum@0
|
1344 |
$urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0;
|
|
indvdum@0
|
1345 |
$sig_checked = $post_data['enable_sig'];
|
|
indvdum@0
|
1346 |
$lock_topic_checked = (isset($topic_lock) && $topic_lock) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0);
|
|
indvdum@0
|
1347 |
$lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked'];
|
|
indvdum@0
|
1348 |
|
|
indvdum@0
|
1349 |
// If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting
|
|
indvdum@0
|
1350 |
$notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set'];
|
|
indvdum@0
|
1351 |
$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set);
|
|
indvdum@0
|
1352 |
|
|
indvdum@0
|
1353 |
// Page title & action URL
|
|
indvdum@0
|
1354 |
$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&f=$forum_id");
|
|
indvdum@0
|
1355 |
$s_action .= ($topic_id) ? "&t=$topic_id" : '';
|
|
indvdum@0
|
1356 |
$s_action .= ($post_id) ? "&p=$post_id" : '';
|
|
indvdum@0
|
1357 |
|
|
indvdum@0
|
1358 |
switch ($mode)
|
|
indvdum@0
|
1359 |
{
|
|
indvdum@0
|
1360 |
case 'post':
|
|
indvdum@0
|
1361 |
$page_title = $user->lang['POST_TOPIC'];
|
|
indvdum@0
|
1362 |
break;
|
|
indvdum@0
|
1363 |
|
|
indvdum@0
|
1364 |
case 'quote':
|
|
indvdum@0
|
1365 |
case 'reply':
|
|
indvdum@0
|
1366 |
$page_title = $user->lang['POST_REPLY'];
|
|
indvdum@0
|
1367 |
break;
|
|
indvdum@0
|
1368 |
|
|
indvdum@0
|
1369 |
case 'delete':
|
|
indvdum@0
|
1370 |
case 'edit':
|
|
indvdum@0
|
1371 |
$page_title = $user->lang['EDIT_POST'];
|
|
indvdum@0
|
1372 |
break;
|
|
indvdum@0
|
1373 |
}
|
|
indvdum@0
|
1374 |
|
|
indvdum@0
|
1375 |
// Build Navigation Links
|
|
indvdum@0
|
1376 |
generate_forum_nav($post_data);
|
|
indvdum@0
|
1377 |
|
|
indvdum@0
|
1378 |
// Build Forum Rules
|
|
indvdum@0
|
1379 |
generate_forum_rules($post_data);
|
|
indvdum@0
|
1380 |
|
|
indvdum@0
|
1381 |
// Posting uses is_solved for legacy reasons. Plugins have to use is_solved to force themselves to be displayed.
|
|
indvdum@0
|
1382 |
if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))
|
|
indvdum@0
|
1383 |
{
|
|
indvdum@0
|
1384 |
|
|
indvdum@0
|
1385 |
$template->assign_vars(array(
|
|
indvdum@0
|
1386 |
'S_CONFIRM_CODE' => true,
|
|
indvdum@0
|
1387 |
'CAPTCHA_TEMPLATE' => $captcha->get_template(),
|
|
indvdum@0
|
1388 |
));
|
|
indvdum@0
|
1389 |
}
|
|
indvdum@0
|
1390 |
|
|
indvdum@0
|
1391 |
$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $post_data['topic_last_post_id'] . '" />' : '';
|
|
indvdum@0
|
1392 |
$s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . $current_time . '" />';
|
|
indvdum@0
|
1393 |
$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . request_var('draft_loaded', $draft_id) . '" />' : '';
|
|
indvdum@0
|
1394 |
|
|
indvdum@0
|
1395 |
if ($mode == 'edit')
|
|
indvdum@0
|
1396 |
{
|
|
indvdum@0
|
1397 |
$s_hidden_fields .= build_hidden_fields(array(
|
|
indvdum@0
|
1398 |
'edit_post_message_checksum' => $post_data['post_checksum'],
|
|
indvdum@0
|
1399 |
'edit_post_subject_checksum' => $post_data['post_subject_md5'],
|
|
indvdum@0
|
1400 |
));
|
|
indvdum@0
|
1401 |
}
|
|
indvdum@0
|
1402 |
|
|
indvdum@0
|
1403 |
// Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
|
|
indvdum@0
|
1404 |
if (isset($captcha) && $captcha->is_solved() !== false)
|
|
indvdum@0
|
1405 |
{
|
|
indvdum@0
|
1406 |
$s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields());
|
|
indvdum@0
|
1407 |
}
|
|
indvdum@0
|
1408 |
|
|
indvdum@0
|
1409 |
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"';
|
|
indvdum@0
|
1410 |
add_form_key('posting');
|
|
indvdum@0
|
1411 |
|
|
indvdum@0
|
1412 |
|
|
indvdum@0
|
1413 |
// Start assigning vars for main posting page ...
|
|
indvdum@0
|
1414 |
$template->assign_vars(array(
|
|
indvdum@0
|
1415 |
'L_POST_A' => $page_title,
|
|
indvdum@0
|
1416 |
'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'],
|
|
indvdum@0
|
1417 |
'L_MESSAGE_BODY_EXPLAIN' => (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '',
|
|
indvdum@0
|
1418 |
|
|
indvdum@0
|
1419 |
'FORUM_NAME' => $post_data['forum_name'],
|
|
indvdum@0
|
1420 |
'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '',
|
|
indvdum@0
|
1421 |
'TOPIC_TITLE' => censor_text($post_data['topic_title']),
|
|
indvdum@0
|
1422 |
'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '',
|
|
indvdum@0
|
1423 |
'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '',
|
|
indvdum@0
|
1424 |
'SUBJECT' => $post_data['post_subject'],
|
|
indvdum@0
|
1425 |
'MESSAGE' => $post_data['post_text'],
|
|
indvdum@0
|
1426 |
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
|
|
indvdum@0
|
1427 |
'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
|
|
indvdum@0
|
1428 |
'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
|
|
indvdum@0
|
1429 |
'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
|
|
indvdum@0
|
1430 |
'URL_STATUS' => ($bbcode_status && $url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
|
|
indvdum@0
|
1431 |
'MAX_FONT_SIZE' => (int) $config['max_post_font_size'],
|
|
indvdum@0
|
1432 |
'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']),
|
|
indvdum@0
|
1433 |
'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '',
|
|
indvdum@0
|
1434 |
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
|
|
indvdum@0
|
1435 |
'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'],
|
|
indvdum@0
|
1436 |
'EDIT_REASON' => $post_data['post_edit_reason'],
|
|
indvdum@0
|
1437 |
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"),
|
|
indvdum@0
|
1438 |
'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '',
|
|
indvdum@0
|
1439 |
'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"),
|
|
indvdum@0
|
1440 |
'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup")),
|
|
indvdum@0
|
1441 |
|
|
indvdum@0
|
1442 |
'S_PRIVMSGS' => false,
|
|
indvdum@0
|
1443 |
'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false,
|
|
indvdum@0
|
1444 |
'S_EDIT_POST' => ($mode == 'edit') ? true : false,
|
|
indvdum@0
|
1445 |
'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
|
|
indvdum@0
|
1446 |
'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false,
|
|
indvdum@0
|
1447 |
'S_SHOW_TOPIC_ICONS' => $s_topic_icons,
|
|
indvdum@0
|
1448 |
'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false,
|
|
indvdum@0
|
1449 |
'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0,
|
|
indvdum@0
|
1450 |
'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '',
|
|
indvdum@0
|
1451 |
'S_SMILIES_ALLOWED' => $smilies_status,
|
|
indvdum@0
|
1452 |
'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '',
|
|
indvdum@0
|
1453 |
'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['is_registered']) ? true : false,
|
|
indvdum@0
|
1454 |
'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '',
|
|
indvdum@0
|
1455 |
'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !$config['allow_topic_notify'] || !$config['email_enable']) ? false : true,
|
|
indvdum@0
|
1456 |
'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '',
|
|
indvdum@0
|
1457 |
'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false,
|
|
indvdum@0
|
1458 |
'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '',
|
|
indvdum@0
|
1459 |
'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
|
|
indvdum@0
|
1460 |
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '',
|
|
indvdum@0
|
1461 |
'S_LINKS_ALLOWED' => $url_status,
|
|
indvdum@0
|
1462 |
'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '',
|
|
indvdum@0
|
1463 |
'S_TYPE_TOGGLE' => $topic_type_toggle,
|
|
indvdum@0
|
1464 |
'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $mode != 'edit') ? true : false,
|
|
indvdum@0
|
1465 |
'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $post_data['drafts']) ? true : false,
|
|
indvdum@0
|
1466 |
'S_FORM_ENCTYPE' => $form_enctype,
|
|
indvdum@0
|
1467 |
|
|
indvdum@0
|
1468 |
'S_BBCODE_IMG' => $img_status,
|
|
indvdum@0
|
1469 |
'S_BBCODE_URL' => $url_status,
|
|
indvdum@0
|
1470 |
'S_BBCODE_FLASH' => $flash_status,
|
|
indvdum@0
|
1471 |
'S_BBCODE_QUOTE' => $quote_status,
|
|
indvdum@0
|
1472 |
|
|
indvdum@0
|
1473 |
'S_POST_ACTION' => $s_action,
|
|
indvdum@0
|
1474 |
'S_HIDDEN_FIELDS' => $s_hidden_fields)
|
|
indvdum@0
|
1475 |
);
|
|
indvdum@0
|
1476 |
|
|
indvdum@0
|
1477 |
// Build custom bbcodes array
|
|
indvdum@0
|
1478 |
display_custom_bbcodes();
|
|
indvdum@0
|
1479 |
|
|
indvdum@0
|
1480 |
// Poll entry
|
|
indvdum@0
|
1481 |
if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/))
|
|
indvdum@0
|
1482 |
&& $auth->acl_get('f_poll', $forum_id))
|
|
indvdum@0
|
1483 |
{
|
|
indvdum@0
|
1484 |
$template->assign_vars(array(
|
|
indvdum@0
|
1485 |
'S_SHOW_POLL_BOX' => true,
|
|
indvdum@0
|
1486 |
'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)),
|
|
indvdum@0
|
1487 |
'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))),
|
|
indvdum@0
|
1488 |
'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false,
|
|
indvdum@0
|
1489 |
|
|
indvdum@0
|
1490 |
'L_POLL_OPTIONS_EXPLAIN' => sprintf($user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], $config['max_poll_options']),
|
|
indvdum@0
|
1491 |
|
|
indvdum@0
|
1492 |
'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '',
|
|
indvdum@0
|
1493 |
'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '',
|
|
indvdum@0
|
1494 |
'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '',
|
|
indvdum@0
|
1495 |
'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1,
|
|
indvdum@0
|
1496 |
'POLL_LENGTH' => $post_data['poll_length'])
|
|
indvdum@0
|
1497 |
);
|
|
indvdum@0
|
1498 |
}
|
|
indvdum@0
|
1499 |
|
|
indvdum@0
|
1500 |
// Show attachment box for adding attachments if true
|
|
indvdum@0
|
1501 |
$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype);
|
|
indvdum@0
|
1502 |
|
|
indvdum@0
|
1503 |
// Attachment entry
|
|
indvdum@0
|
1504 |
posting_gen_attachment_entry($attachment_data, $filename_data, $allowed);
|
|
indvdum@0
|
1505 |
|
|
indvdum@0
|
1506 |
// Output page ...
|
|
indvdum@0
|
1507 |
page_header($page_title, false);
|
|
indvdum@0
|
1508 |
|
|
indvdum@0
|
1509 |
$template->set_filenames(array(
|
|
indvdum@0
|
1510 |
'body' => 'posting_body.html')
|
|
indvdum@0
|
1511 |
);
|
|
indvdum@0
|
1512 |
|
|
indvdum@0
|
1513 |
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
|
|
indvdum@0
|
1514 |
|
|
indvdum@0
|
1515 |
// Topic review
|
|
indvdum@0
|
1516 |
if ($mode == 'reply' || $mode == 'quote')
|
|
indvdum@0
|
1517 |
{
|
|
indvdum@0
|
1518 |
if (topic_review($topic_id, $forum_id))
|
|
indvdum@0
|
1519 |
{
|
|
indvdum@0
|
1520 |
$template->assign_var('S_DISPLAY_REVIEW', true);
|
|
indvdum@0
|
1521 |
}
|
|
indvdum@0
|
1522 |
}
|
|
indvdum@0
|
1523 |
|
|
indvdum@0
|
1524 |
page_footer();
|
|
indvdum@0
|
1525 |
|
|
indvdum@0
|
1526 |
/**
|
|
indvdum@0
|
1527 |
* Show upload popup (progress bar)
|
|
indvdum@0
|
1528 |
*/
|
|
indvdum@0
|
1529 |
function upload_popup($forum_style = 0)
|
|
indvdum@0
|
1530 |
{
|
|
indvdum@0
|
1531 |
global $template, $user;
|
|
indvdum@0
|
1532 |
|
|
indvdum@0
|
1533 |
($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting');
|
|
indvdum@0
|
1534 |
|
|
indvdum@0
|
1535 |
page_header($user->lang['PROGRESS_BAR'], false);
|
|
indvdum@0
|
1536 |
|
|
indvdum@0
|
1537 |
$template->set_filenames(array(
|
|
indvdum@0
|
1538 |
'popup' => 'posting_progress_bar.html')
|
|
indvdum@0
|
1539 |
);
|
|
indvdum@0
|
1540 |
|
|
indvdum@0
|
1541 |
$template->assign_vars(array(
|
|
indvdum@0
|
1542 |
'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS']))
|
|
indvdum@0
|
1543 |
);
|
|
indvdum@0
|
1544 |
|
|
indvdum@0
|
1545 |
$template->display('popup');
|
|
indvdum@0
|
1546 |
|
|
indvdum@0
|
1547 |
garbage_collection();
|
|
indvdum@0
|
1548 |
exit_handler();
|
|
indvdum@0
|
1549 |
}
|
|
indvdum@0
|
1550 |
|
|
indvdum@0
|
1551 |
/**
|
|
indvdum@0
|
1552 |
* Do the various checks required for removing posts as well as removing it
|
|
indvdum@0
|
1553 |
*/
|
|
indvdum@0
|
1554 |
function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data)
|
|
indvdum@0
|
1555 |
{
|
|
indvdum@0
|
1556 |
global $user, $db, $auth, $config;
|
|
indvdum@0
|
1557 |
global $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
1558 |
|
|
indvdum@0
|
1559 |
// If moderator removing post or user itself removing post, present a confirmation screen
|
|
indvdum@0
|
1560 |
if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])))
|
|
indvdum@0
|
1561 |
{
|
|
indvdum@0
|
1562 |
$s_hidden_fields = build_hidden_fields(array(
|
|
indvdum@0
|
1563 |
'p' => $post_id,
|
|
indvdum@0
|
1564 |
'f' => $forum_id,
|
|
indvdum@0
|
1565 |
'mode' => 'delete')
|
|
indvdum@0
|
1566 |
);
|
|
indvdum@0
|
1567 |
|
|
indvdum@0
|
1568 |
if (confirm_box(true))
|
|
indvdum@0
|
1569 |
{
|
|
indvdum@0
|
1570 |
$data = array(
|
|
indvdum@0
|
1571 |
'topic_first_post_id' => $post_data['topic_first_post_id'],
|
|
indvdum@0
|
1572 |
'topic_last_post_id' => $post_data['topic_last_post_id'],
|
|
indvdum@0
|
1573 |
'topic_replies_real' => $post_data['topic_replies_real'],
|
|
indvdum@0
|
1574 |
'topic_approved' => $post_data['topic_approved'],
|
|
indvdum@0
|
1575 |
'topic_type' => $post_data['topic_type'],
|
|
indvdum@0
|
1576 |
'post_approved' => $post_data['post_approved'],
|
|
indvdum@0
|
1577 |
'post_reported' => $post_data['post_reported'],
|
|
indvdum@0
|
1578 |
'post_time' => $post_data['post_time'],
|
|
indvdum@0
|
1579 |
'poster_id' => $post_data['poster_id'],
|
|
indvdum@0
|
1580 |
'post_postcount' => $post_data['post_postcount']
|
|
indvdum@0
|
1581 |
);
|
|
indvdum@0
|
1582 |
|
|
indvdum@0
|
1583 |
$next_post_id = delete_post($forum_id, $topic_id, $post_id, $data);
|
|
indvdum@0
|
1584 |
$post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username'];
|
|
indvdum@0
|
1585 |
|
|
indvdum@0
|
1586 |
if ($next_post_id === false)
|
|
indvdum@0
|
1587 |
{
|
|
indvdum@0
|
1588 |
add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title'], $post_username);
|
|
indvdum@0
|
1589 |
|
|
indvdum@0
|
1590 |
$meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id");
|
|
indvdum@0
|
1591 |
$message = $user->lang['POST_DELETED'];
|
|
indvdum@0
|
1592 |
}
|
|
indvdum@0
|
1593 |
else
|
|
indvdum@0
|
1594 |
{
|
|
indvdum@0
|
1595 |
add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject'], $post_username);
|
|
indvdum@0
|
1596 |
|
|
indvdum@0
|
1597 |
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id";
|
|
indvdum@0
|
1598 |
$message = $user->lang['POST_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $meta_info . '">', '</a>');
|
|
indvdum@0
|
1599 |
}
|
|
indvdum@0
|
1600 |
|
|
indvdum@0
|
1601 |
meta_refresh(3, $meta_info);
|
|
indvdum@0
|
1602 |
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>');
|
|
indvdum@0
|
1603 |
trigger_error($message);
|
|
indvdum@0
|
1604 |
}
|
|
indvdum@0
|
1605 |
else
|
|
indvdum@0
|
1606 |
{
|
|
indvdum@0
|
1607 |
confirm_box(false, 'DELETE_POST', $s_hidden_fields);
|
|
indvdum@0
|
1608 |
}
|
|
indvdum@0
|
1609 |
}
|
|
indvdum@0
|
1610 |
|
|
indvdum@0
|
1611 |
// If we are here the user is not able to delete - present the correct error message
|
|
indvdum@0
|
1612 |
if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id))
|
|
indvdum@0
|
1613 |
{
|
|
indvdum@0
|
1614 |
trigger_error('DELETE_OWN_POSTS');
|
|
indvdum@0
|
1615 |
}
|
|
indvdum@0
|
1616 |
|
|
indvdum@0
|
1617 |
if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id'])
|
|
indvdum@0
|
1618 |
{
|
|
indvdum@0
|
1619 |
trigger_error('CANNOT_DELETE_REPLIED');
|
|
indvdum@0
|
1620 |
}
|
|
indvdum@0
|
1621 |
|
|
indvdum@0
|
1622 |
trigger_error('USER_CANNOT_DELETE');
|
|
indvdum@0
|
1623 |
}
|
|
indvdum@0
|
1624 |
|
|
indvdum@0
|
1625 |
?> |