Register
phpBB.com Wiki · Home Projects Help

root / trunk / phpBB / posting.php

1 2 thefinn
<?php
2 7736 acydburn
/**
3 5114 acydburn
*
4 5114 acydburn
* @package phpBB3
5 5114 acydburn
* @version $Id$
6 7736 acydburn
* @copyright (c) 2005 phpBB Group
7 7736 acydburn
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 5114 acydburn
*
9 5114 acydburn
*/
10 2 thefinn
11 5114 acydburn
/**
12 5883 acydburn
* @ignore
13 5114 acydburn
*/
14 4767 acydburn
define('IN_PHPBB', true);
15 8572 acydburn
if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './');
16 8572 acydburn
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
17 8572 acydburn
include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
18 8572 acydburn
include(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT);
19 8572 acydburn
include(PHPBB_ROOT_PATH . 'includes/functions_display.' . PHP_EXT);
20 8572 acydburn
include(PHPBB_ROOT_PATH . 'includes/message_parser.' . PHP_EXT);
21 169 thefinn
22 4167 psotfx
23 2972 psotfx
// Start session management
24 5247 acydburn
$user->session_begin();
25 2972 psotfx
$auth->acl($user->data);
26 2972 psotfx
27 4167 psotfx
28 3354 psotfx
// Grab only parameters needed here
29 4539 acydburn
$post_id	= request_var('p', 0);
30 4539 acydburn
$topic_id	= request_var('t', 0);
31 4539 acydburn
$forum_id	= request_var('f', 0);
32 4668 acydburn
$draft_id	= request_var('d', 0);
33 4539 acydburn
$lastclick	= request_var('lastclick', 0);
34 3354 psotfx
35 5902 acydburn
$submit		= (isset($_POST['post'])) ? true : false;
36 5902 acydburn
$preview	= (isset($_POST['preview'])) ? true : false;
37 5902 acydburn
$save		= (isset($_POST['save'])) ? true : false;
38 5902 acydburn
$load		= (isset($_POST['load'])) ? true : false;
39 5902 acydburn
$delete		= (isset($_POST['delete'])) ? true : false;
40 5967 acydburn
$cancel		= (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false;
41 3553 acydburn
42 6803 acydburn
$refresh	= (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false;
43 4767 acydburn
$mode		= ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', '');
44 3631 acydburn
45 5902 acydburn
$error = $post_data = array();
46 4620 psotfx
$current_time = time();
47 4170 psotfx
48 8889 Kellanved
if ($config['enable_post_confirm'] && !$user->data['is_registered'])
49 8889 Kellanved
{
50 8889 Kellanved
	include(PHPBB_ROOT_PATH . 'includes/captcha/captcha_factory.' . PHP_EXT);
51 8889 Kellanved
	$captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']);
52 8889 Kellanved
	$captcha->init(CONFIRM_POST);
53 8889 Kellanved
}
54 8889 Kellanved
55 2958 psotfx
// Was cancel pressed? If so then redirect to the appropriate page
56 4890 acydburn
if ($cancel || ($current_time - $lastclick < 2 && $submit))
57 378 psotfx
{
58 8572 acydburn
	$redirect = ($post_id) ? append_sid('viewtopic', 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid('viewtopic', 't=' . $topic_id) : (($forum_id) ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('index')));
59 2958 psotfx
	redirect($redirect);
60 378 psotfx
}
61 378 psotfx
62 5678 acydburn
if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$forum_id)
63 4460 acydburn
{
64 4575 acydburn
	trigger_error('NO_FORUM');
65 4460 acydburn
}
66 4460 acydburn
67 6015 acydburn
// We need to know some basic information in all cases before we do anything.
68 3354 psotfx
switch ($mode)
69 2183 psotfx
{
70 2972 psotfx
	case 'post':
71 4139 acydburn
		$sql = 'SELECT *
72 4139 acydburn
			FROM ' . FORUMS_TABLE . "
73 4139 acydburn
			WHERE forum_id = $forum_id";
74 5486 acydburn
	break;
75 2983 psotfx
76 4614 acydburn
	case 'bump':
77 2923 psotfx
	case 'reply':
78 3543 acydburn
		if (!$topic_id)
79 582 psotfx
		{
80 4575 acydburn
			trigger_error('NO_TOPIC');
81 2183 psotfx
		}
82 824 psotfx
83 4968 acydburn
		$sql = 'SELECT f.*, t.*
84 4139 acydburn
			FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
85 4139 acydburn
			WHERE t.topic_id = $topic_id
86 4970 psotfx
				AND (f.forum_id = t.forum_id
87 4213 psotfx
					OR f.forum_id = $forum_id)";
88 5486 acydburn
	break;
89 4970 psotfx
90 2923 psotfx
	case 'quote':
91 2972 psotfx
	case 'edit':
92 2923 psotfx
	case 'delete':
93 3543 acydburn
		if (!$post_id)
94 2383 psotfx
		{
95 7356 davidmj
			$user->setup('posting');
96 4575 acydburn
			trigger_error('NO_POST');
97 2383 psotfx
		}
98 2305 psotfx
99 6698 acydburn
		$sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield
100 4139 acydburn
			FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u
101 4139 acydburn
			WHERE p.post_id = $post_id
102 2923 psotfx
				AND t.topic_id = p.topic_id
103 3575 acydburn
				AND u.user_id = p.poster_id
104 4970 psotfx
				AND (f.forum_id = t.forum_id
105 4213 psotfx
					OR f.forum_id = $forum_id)";
106 5486 acydburn
	break;
107 326 thefinn
108 2986 psotfx
	case 'smilies':
109 4883 acydburn
		$sql = '';
110 4544 acydburn
		generate_smilies('window', $forum_id);
111 5486 acydburn
	break;
112 2986 psotfx
113 4883 acydburn
	case 'popup':
114 5678 acydburn
		if ($forum_id)
115 5678 acydburn
		{
116 5678 acydburn
			$sql = 'SELECT forum_style
117 5678 acydburn
				FROM ' . FORUMS_TABLE . '
118 5678 acydburn
				WHERE forum_id = ' . $forum_id;
119 5678 acydburn
		}
120 5678 acydburn
		else
121 5678 acydburn
		{
122 5678 acydburn
			upload_popup();
123 8961 acydburn
			return;
124 5678 acydburn
		}
125 5486 acydburn
	break;
126 4883 acydburn
127 2923 psotfx
	default:
128 4170 psotfx
		$sql = '';
129 5902 acydburn
	break;
130 987 psotfx
}
131 2183 psotfx
132 5902 acydburn
if (!$sql)
133 2972 psotfx
{
134 7356 davidmj
	$user->setup('posting');
135 5902 acydburn
	trigger_error('NO_POST_MODE');
136 5902 acydburn
}
137 3354 psotfx
138 5902 acydburn
$result = $db->sql_query($sql);
139 5902 acydburn
$post_data = $db->sql_fetchrow($result);
140 5902 acydburn
$db->sql_freeresult($result);
141 3572 acydburn
142 6478 acydburn
if (!$post_data)
143 6478 acydburn
{
144 7356 davidmj
	if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply'))
145 7356 davidmj
	{
146 7356 davidmj
		$user->setup('posting');
147 7356 davidmj
	}
148 6478 acydburn
	trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST');
149 6478 acydburn
}
150 6478 acydburn
151 5902 acydburn
if ($mode == 'popup')
152 5902 acydburn
{
153 5902 acydburn
	upload_popup($post_data['forum_style']);
154 8961 acydburn
	return;
155 2972 psotfx
}
156 2983 psotfx
157 6190 acydburn
$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']);
158 6190 acydburn
159 5902 acydburn
// Use post_row values in favor of submitted ones...
160 5902 acydburn
$forum_id	= (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id;
161 5902 acydburn
$topic_id	= (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id;
162 5902 acydburn
$post_id	= (!empty($post_data['post_id'])) ? (int) $post_data['post_id'] : (int) $post_id;
163 5902 acydburn
164 5902 acydburn
// Need to login to passworded forum first?
165 5902 acydburn
if ($post_data['forum_password'])
166 2983 psotfx
{
167 5902 acydburn
	login_forum_box(array(
168 5902 acydburn
		'forum_id'			=> $forum_id,
169 5902 acydburn
		'forum_password'	=> $post_data['forum_password'])
170 5902 acydburn
	);
171 2983 psotfx
}
172 2983 psotfx
173 5765 acydburn
// Check permissions
174 7804 acydburn
if ($user->data['is_bot'])
175 7804 acydburn
{
176 8572 acydburn
	redirect(append_sid('index'));
177 7804 acydburn
}
178 5902 acydburn
179 5902 acydburn
// Is the user able to read within this forum?
180 5902 acydburn
if (!$auth->acl_get('f_read', $forum_id))
181 2958 psotfx
{
182 6619 acydburn
	if ($user->data['user_id'] != ANONYMOUS)
183 4836 acydburn
	{
184 5765 acydburn
		trigger_error('USER_CANNOT_READ');
185 4836 acydburn
	}
186 4970 psotfx
187 5765 acydburn
	login_box('', $user->lang['LOGIN_EXPLAIN_POST']);
188 5765 acydburn
}
189 5765 acydburn
190 5902 acydburn
// Permission to do the action asked?
191 6135 acydburn
$is_authed = false;
192 6135 acydburn
193 6135 acydburn
switch ($mode)
194 5765 acydburn
{
195 6135 acydburn
	case 'post':
196 6135 acydburn
		if ($auth->acl_get('f_post', $forum_id))
197 6135 acydburn
		{
198 6135 acydburn
			$is_authed = true;
199 6135 acydburn
		}
200 6135 acydburn
	break;
201 6135 acydburn
202 6135 acydburn
	case 'bump':
203 6135 acydburn
		if ($auth->acl_get('f_bump', $forum_id))
204 6135 acydburn
		{
205 6135 acydburn
			$is_authed = true;
206 6135 acydburn
		}
207 6135 acydburn
	break;
208 6135 acydburn
209 6135 acydburn
	case 'quote':
210 6831 acydburn
211 6831 acydburn
		$post_data['post_edit_locked'] = 0;
212 6831 acydburn
213 6831 acydburn
	// no break;
214 6831 acydburn
215 6135 acydburn
	case 'reply':
216 6135 acydburn
		if ($auth->acl_get('f_reply', $forum_id))
217 6135 acydburn
		{
218 6135 acydburn
			$is_authed = true;
219 6135 acydburn
		}
220 6135 acydburn
	break;
221 6135 acydburn
222 6135 acydburn
	case 'edit':
223 6135 acydburn
		if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id))
224 6135 acydburn
		{
225 6135 acydburn
			$is_authed = true;
226 6135 acydburn
		}
227 6135 acydburn
	break;
228 6135 acydburn
229 6135 acydburn
	case 'delete':
230 6135 acydburn
		if ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id))
231 6135 acydburn
		{
232 6135 acydburn
			$is_authed = true;
233 6135 acydburn
		}
234 6135 acydburn
	break;
235 6135 acydburn
}
236 6135 acydburn
237 6135 acydburn
if (!$is_authed)
238 6135 acydburn
{
239 6135 acydburn
	$check_auth = ($mode == 'quote') ? 'reply' : $mode;
240 6135 acydburn
241 5765 acydburn
	if ($user->data['is_registered'])
242 5765 acydburn
	{
243 5765 acydburn
		trigger_error('USER_CANNOT_' . strtoupper($check_auth));
244 5765 acydburn
	}
245 5765 acydburn
246 4970 psotfx
	login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]);
247 2972 psotfx
}
248 502 psotfx
249 5902 acydburn
// Is the user able to post within this forum?
250 5902 acydburn
if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply')))
251 5902 acydburn
{
252 5902 acydburn
	trigger_error('USER_CANNOT_FORUM_POST');
253 5902 acydburn
}
254 5902 acydburn
255 2997 psotfx
// Forum/Topic locked?
256 5902 acydburn
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))
257 2997 psotfx
{
258 5902 acydburn
	trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED');
259 2997 psotfx
}
260 2997 psotfx
261 4970 psotfx
// Can we edit this post ... if we're a moderator with rights then always yes
262 4970 psotfx
// else it depends on editing times, lock status and if we're the correct user
263 5902 acydburn
if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id))
264 2972 psotfx
{
265 5902 acydburn
	if ($user->data['user_id'] != $post_data['poster_id'])
266 4970 psotfx
	{
267 4970 psotfx
		trigger_error('USER_CANNOT_EDIT');
268 4970 psotfx
	}
269 4970 psotfx
270 6104 acydburn
	if (!($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']))
271 4883 acydburn
	{
272 4883 acydburn
		trigger_error('CANNOT_EDIT_TIME');
273 4883 acydburn
	}
274 2849 psotfx
275 5902 acydburn
	if ($post_data['post_edit_locked'])
276 4883 acydburn
	{
277 4883 acydburn
		trigger_error('CANNOT_EDIT_POST_LOCKED');
278 4883 acydburn
	}
279 3553 acydburn
}
280 3553 acydburn
281 5902 acydburn
// Handle delete mode...
282 5902 acydburn
if ($mode == 'delete')
283 3858 ludovic_arnaud
{
284 5902 acydburn
	handle_post_delete($forum_id, $topic_id, $post_id, $post_data);
285 8961 acydburn
	return;
286 3858 ludovic_arnaud
}
287 3858 ludovic_arnaud
288 5902 acydburn
// Handle bump mode...
289 5902 acydburn
if ($mode == 'bump')
290 3582 acydburn
{
291 8776 Kellanved
	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'])
292 8776 Kellanved
	   && check_link_hash(request_var('hash', ''),"topic_{$post_data['topic_id']}"))
293 3582 acydburn
	{
294 6015 acydburn
		$db->sql_transaction('begin');
295 4970 psotfx
296 6015 acydburn
		$sql = 'UPDATE ' . POSTS_TABLE . "
297 5902 acydburn
			SET post_time = $current_time
298 5902 acydburn
			WHERE post_id = {$post_data['topic_last_post_id']}
299 6015 acydburn
				AND topic_id = $topic_id";
300 6015 acydburn
		$db->sql_query($sql);
301 4970 psotfx
302 6015 acydburn
		$sql = 'UPDATE ' . TOPICS_TABLE . "
303 5902 acydburn
			SET topic_last_post_time = $current_time,
304 5902 acydburn
				topic_bumped = 1,
305 5902 acydburn
				topic_bumper = " . $user->data['user_id'] . "
306 6015 acydburn
			WHERE topic_id = $topic_id";
307 6015 acydburn
		$db->sql_query($sql);
308 5157 acydburn
309 5902 acydburn
		update_post_information('forum', $forum_id);
310 5157 acydburn
311 6015 acydburn
		$sql = 'UPDATE ' . USERS_TABLE . "
312 5902 acydburn
			SET user_lastpost_time = $current_time
313 6015 acydburn
			WHERE user_id = " . $user->data['user_id'];
314 6015 acydburn
		$db->sql_query($sql);
315 3883 acydburn
316 5902 acydburn
		$db->sql_transaction('commit');
317 5902 acydburn
318 5902 acydburn
		markread('post', $forum_id, $topic_id, $current_time);
319 5902 acydburn
320 6022 acydburn
		add_log('mod', $forum_id, $topic_id, 'LOG_BUMP_TOPIC', $post_data['topic_title']);
321 5902 acydburn
322 8572 acydburn
		$meta_url = append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}";
323 5902 acydburn
		meta_refresh(3, $meta_url);
324 5902 acydburn
325 5902 acydburn
		$message = $user->lang['TOPIC_BUMPED'] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $meta_url . '">', '</a>');
326 8572 acydburn
		$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid('viewforum', 'f=' . $forum_id) . '">', '</a>');
327 5902 acydburn
328 3883 acydburn
		trigger_error($message);
329 3582 acydburn
	}
330 6015 acydburn
331 5902 acydburn
	trigger_error('BUMP_ERROR');
332 5902 acydburn
}
333 5902 acydburn
334 8034 acydburn
// Subject length limiting to 60 characters if first post...
335 8034 acydburn
if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id']))
336 8034 acydburn
{
337 8034 acydburn
	$template->assign_var('S_NEW_MESSAGE', true);
338 8034 acydburn
}
339 5902 acydburn
340 5902 acydburn
// Determine some vars
341 7777 kellanved
if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS)
342 7777 kellanved
{
343 7777 kellanved
	$post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : $user->lang['GUEST'];
344 7777 kellanved
}
345 7777 kellanved
else
346 7777 kellanved
{
347 7777 kellanved
	$post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : '';
348 7777 kellanved
}
349 8034 acydburn
350 5902 acydburn
$post_data['post_edit_locked']	= (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0;
351 5902 acydburn
$post_data['post_subject']		= (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : '');
352 5902 acydburn
$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;
353 5902 acydburn
$post_data['poll_length']		= (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0;
354 5902 acydburn
$post_data['poll_start']		= (!empty($post_data['poll_start'])) ? (int) $post_data['poll_start'] : 0;
355 5902 acydburn
$post_data['icon_id']			= (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id'];
356 5902 acydburn
$post_data['poll_options']		= array();
357 5902 acydburn
358 5902 acydburn
// Get Poll Data
359 5902 acydburn
if ($post_data['poll_start'])
360 5902 acydburn
{
361 5902 acydburn
	$sql = 'SELECT poll_option_text
362 5902 acydburn
		FROM ' . POLL_OPTIONS_TABLE . "
363 5902 acydburn
		WHERE topic_id = $topic_id
364 5902 acydburn
		ORDER BY poll_option_id";
365 5902 acydburn
	$result = $db->sql_query($sql);
366 5902 acydburn
367 5902 acydburn
	while ($row = $db->sql_fetchrow($result))
368 3582 acydburn
	{
369 5902 acydburn
		$post_data['poll_options'][] = trim($row['poll_option_text']);
370 3582 acydburn
	}
371 5902 acydburn
	$db->sql_freeresult($result);
372 3582 acydburn
}
373 3582 acydburn
374 5902 acydburn
$orig_poll_options_size = sizeof($post_data['poll_options']);
375 4167 psotfx
376 5902 acydburn
$message_parser = new parse_message();
377 5902 acydburn
378 5902 acydburn
if (isset($post_data['post_text']))
379 3582 acydburn
{
380 5902 acydburn
	$message_parser->message = &$post_data['post_text'];
381 5902 acydburn
	unset($post_data['post_text']);
382 3582 acydburn
}
383 3582 acydburn
384 5902 acydburn
// Set some default variables
385 5922 acydburn
$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);
386 6014 acydburn
387 5902 acydburn
foreach ($uninit as $var_name => $default_value)
388 3582 acydburn
{
389 5902 acydburn
	if (!isset($post_data[$var_name]))
390 5902 acydburn
	{
391 5902 acydburn
		$post_data[$var_name] = $default_value;
392 5902 acydburn
	}
393 3582 acydburn
}
394 5902 acydburn
unset($uninit);
395 3582 acydburn
396 6364 acydburn
// Always check if the submitted attachment data is valid and belongs to the user.
397 6364 acydburn
// Further down (especially in submit_post()) we do not check this again.
398 6014 acydburn
$message_parser->get_submitted_attachment_data($post_data['poster_id']);
399 6014 acydburn
400 5902 acydburn
if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit')
401 3582 acydburn
{
402 6015 acydburn
	// Do not change to SELECT *
403 6364 acydburn
	$sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename
404 5902 acydburn
		FROM ' . ATTACHMENTS_TABLE . "
405 5902 acydburn
		WHERE post_msg_id = $post_id
406 5902 acydburn
			AND in_message = 0
407 6364 acydburn
			AND is_orphan = 0
408 6628 acydburn
		ORDER BY filetime DESC";
409 5902 acydburn
	$result = $db->sql_query($sql);
410 5902 acydburn
	$message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result));
411 5902 acydburn
	$db->sql_freeresult($result);
412 3582 acydburn
}
413 3582 acydburn
414 5902 acydburn
if ($post_data['poster_id'] == ANONYMOUS)
415 5902 acydburn
{
416 5902 acydburn
	$post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['post_username']) : '';
417 5902 acydburn
}
418 5902 acydburn
else
419 5902 acydburn
{
420 5902 acydburn
	$post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['username']) : '';
421 5902 acydburn
}
422 4167 psotfx
423 5902 acydburn
$post_data['enable_urls'] = $post_data['enable_magic_url'];
424 4047 ludovic_arnaud
425 5902 acydburn
if ($mode != 'edit')
426 4614 acydburn
{
427 5902 acydburn
	$post_data['enable_sig']		= ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false;
428 5902 acydburn
	$post_data['enable_smilies']	= ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false;
429 5902 acydburn
	$post_data['enable_bbcode']		= ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false;
430 5902 acydburn
	$post_data['enable_urls']		= true;
431 5902 acydburn
}
432 4614 acydburn
433 5902 acydburn
$post_data['enable_magic_url'] = $post_data['drafts'] = false;
434 4614 acydburn
435 5902 acydburn
// User own some drafts?
436 7384 acydburn
if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote'))
437 5902 acydburn
{
438