|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
*
|
|
|
f2e824 |
* @package phpBB3
|
|
|
f2e824 |
* @version $Id: posting.php 9048 2008-11-04 15:54:43Z toonarmy $
|
|
|
f2e824 |
* @copyright (c) 2005 phpBB Group
|
|
|
f2e824 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
f2e824 |
*
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* @ignore
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
define('IN_PHPBB', true);
|
|
|
f2e824 |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
|
|
|
f2e824 |
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|
|
f2e824 |
include($phpbb_root_path . 'common.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
// Start session management
|
|
|
f2e824 |
$user->session_begin();
|
|
|
f2e824 |
$auth->acl($user->data);
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
// Grab only parameters needed here
|
|
|
f2e824 |
$post_id = request_var('p', 0);
|
|
|
f2e824 |
$topic_id = request_var('t', 0);
|
|
|
f2e824 |
$forum_id = request_var('f', 0);
|
|
|
f2e824 |
$draft_id = request_var('d', 0);
|
|
|
f2e824 |
$lastclick = request_var('lastclick', 0);
|
|
|
f2e824 |
|
|
|
f2e824 |
$submit = (isset($_POST['post'])) ? true : false;
|
|
|
f2e824 |
$preview = (isset($_POST['preview'])) ? true : false;
|
|
|
f2e824 |
$save = (isset($_POST['save'])) ? true : false;
|
|
|
f2e824 |
$load = (isset($_POST['load'])) ? true : false;
|
|
|
f2e824 |
$delete = (isset($_POST['delete'])) ? true : false;
|
|
|
f2e824 |
$cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false;
|
|
|
f2e824 |
|
|
|
f2e824 |
$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false;
|
|
|
f2e824 |
$mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', '');
|
|
|
f2e824 |
|
|
|
f2e824 |
$error = $post_data = array();
|
|
|
f2e824 |
$current_time = time();
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
// Was cancel pressed? If so then redirect to the appropriate page
|
|
|
f2e824 |
if ($cancel || ($current_time - $lastclick < 2 && $submit))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}index.$phpEx")));
|
|
|
f2e824 |
redirect($redirect);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$forum_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('NO_FORUM');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// We need to know some basic information in all cases before we do anything.
|
|
|
f2e824 |
switch ($mode)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
case 'post':
|
|
|
f2e824 |
$sql = 'SELECT *
|
|
|
f2e824 |
FROM ' . FORUMS_TABLE . "
|
|
|
f2e824 |
WHERE forum_id = $forum_id";
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'bump':
|
|
|
f2e824 |
case 'reply':
|
|
|
f2e824 |
if (!$topic_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('NO_TOPIC');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'SELECT f.*, t.*
|
|
|
f2e824 |
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
|
|
f2e824 |
WHERE t.topic_id = $topic_id
|
|
|
f2e824 |
AND (f.forum_id = t.forum_id
|
|
|
f2e824 |
OR f.forum_id = $forum_id)";
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'quote':
|
|
|
f2e824 |
case 'edit':
|
|
|
f2e824 |
case 'delete':
|
|
|
f2e824 |
if (!$post_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$user->setup('posting');
|
|
|
f2e824 |
trigger_error('NO_POST');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield
|
|
|
f2e824 |
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u
|
|
|
f2e824 |
WHERE p.post_id = $post_id
|
|
|
f2e824 |
AND t.topic_id = p.topic_id
|
|
|
f2e824 |
AND u.user_id = p.poster_id
|
|
|
f2e824 |
AND (f.forum_id = t.forum_id
|
|
|
f2e824 |
OR f.forum_id = $forum_id)";
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'smilies':
|
|
|
f2e824 |
$sql = '';
|
|
|
f2e824 |
generate_smilies('window', $forum_id);
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'popup':
|
|
|
f2e824 |
if ($forum_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'SELECT forum_style
|
|
|
f2e824 |
FROM ' . FORUMS_TABLE . '
|
|
|
f2e824 |
WHERE forum_id = ' . $forum_id;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
upload_popup();
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
default:
|
|
|
f2e824 |
$sql = '';
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$sql)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$user->setup('posting');
|
|
|
f2e824 |
trigger_error('NO_POST_MODE');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
$post_data = $db->sql_fetchrow($result);
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$post_data)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$user->setup('posting');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($mode == 'popup')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
upload_popup($post_data['forum_style']);
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Use post_row values in favor of submitted ones...
|
|
|
f2e824 |
$forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id;
|
|
|
f2e824 |
$topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id;
|
|
|
f2e824 |
$post_id = (!empty($post_data['post_id'])) ? (int) $post_data['post_id'] : (int) $post_id;
|
|
|
f2e824 |
|
|
|
f2e824 |
// Need to login to passworded forum first?
|
|
|
f2e824 |
if ($post_data['forum_password'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
login_forum_box(array(
|
|
|
f2e824 |
'forum_id' => $forum_id,
|
|
|
f2e824 |
'forum_password' => $post_data['forum_password'])
|
|
|
f2e824 |
);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Check permissions
|
|
|
f2e824 |
if ($user->data['is_bot'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Is the user able to read within this forum?
|
|
|
f2e824 |
if (!$auth->acl_get('f_read', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if ($user->data['user_id'] != ANONYMOUS)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('USER_CANNOT_READ');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
login_box('', $user->lang['LOGIN_EXPLAIN_POST']);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Permission to do the action asked?
|
|
|
f2e824 |
$is_authed = false;
|
|
|
f2e824 |
|
|
|
f2e824 |
switch ($mode)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
case 'post':
|
|
|
f2e824 |
if ($auth->acl_get('f_post', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$is_authed = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'bump':
|
|
|
f2e824 |
if ($auth->acl_get('f_bump', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$is_authed = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'quote':
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['post_edit_locked'] = 0;
|
|
|
f2e824 |
|
|
|
f2e824 |
// no break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'reply':
|
|
|
f2e824 |
if ($auth->acl_get('f_reply', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$is_authed = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'edit':
|
|
|
f2e824 |
if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$is_authed = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'delete':
|
|
|
f2e824 |
if ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$is_authed = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$is_authed)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$check_auth = ($mode == 'quote') ? 'reply' : $mode;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($user->data['is_registered'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('USER_CANNOT_' . strtoupper($check_auth));
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Is the user able to post within this forum?
|
|
|
f2e824 |
if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply')))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('USER_CANNOT_FORUM_POST');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Forum/Topic locked?
|
|
|
f2e824 |
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))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Can we edit this post ... if we're a moderator with rights then always yes
|
|
|
f2e824 |
// else it depends on editing times, lock status and if we're the correct user
|
|
|
f2e824 |
if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if ($user->data['user_id'] != $post_data['poster_id'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('USER_CANNOT_EDIT');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('CANNOT_EDIT_TIME');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($post_data['post_edit_locked'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('CANNOT_EDIT_POST_LOCKED');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Handle delete mode...
|
|
|
f2e824 |
if ($mode == 'delete')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
handle_post_delete($forum_id, $topic_id, $post_id, $post_data);
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Handle bump mode...
|
|
|
f2e824 |
if ($mode == 'bump')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
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'])
|
|
|
f2e824 |
&& check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}"))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$db->sql_transaction('begin');
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'UPDATE ' . POSTS_TABLE . "
|
|
|
f2e824 |
SET post_time = $current_time
|
|
|
f2e824 |
WHERE post_id = {$post_data['topic_last_post_id']}
|
|
|
f2e824 |
AND topic_id = $topic_id";
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
|
f2e824 |
SET topic_last_post_time = $current_time,
|
|
|
f2e824 |
topic_bumped = 1,
|
|
|
f2e824 |
topic_bumper = " . $user->data['user_id'] . "
|
|
|
f2e824 |
WHERE topic_id = $topic_id";
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
update_post_information('forum', $forum_id);
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'UPDATE ' . USERS_TABLE . "
|
|
|
f2e824 |
SET user_lastpost_time = $current_time
|
|
|
f2e824 |
WHERE user_id = " . $user->data['user_id'];
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
$db->sql_transaction('commit');
|
|
|
f2e824 |
|
|
|
f2e824 |
markread('post', $forum_id, $topic_id, $current_time);
|
|
|
f2e824 |
|
|
|
f2e824 |
add_log('mod', $forum_id, $topic_id, 'LOG_BUMP_TOPIC', $post_data['topic_title']);
|
|
|
f2e824 |
|
|
|
f2e824 |
$meta_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}";
|
|
|
f2e824 |
meta_refresh(3, $meta_url);
|
|
|
f2e824 |
|
|
|
f2e824 |
$message = $user->lang['TOPIC_BUMPED'] . '
' . sprintf($user->lang['VIEW_MESSAGE'], '', '');
|
|
|
f2e824 |
$message .= '
' . sprintf($user->lang['RETURN_FORUM'], '', '');
|
|
|
f2e824 |
|
|
|
f2e824 |
trigger_error($message);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
trigger_error('BUMP_ERROR');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Subject length limiting to 60 characters if first post...
|
|
|
f2e824 |
if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_var('S_NEW_MESSAGE', true);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Determine some vars
|
|
|
f2e824 |
if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : $user->lang['GUEST'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : '';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['post_edit_locked'] = (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0;
|
|
|
f2e824 |
$post_data['post_subject'] = (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : '');
|
|
|
f2e824 |
$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;
|
|
|
f2e824 |
$post_data['poll_length'] = (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0;
|
|
|
f2e824 |
$post_data['poll_start'] = (!empty($post_data['poll_start'])) ? (int) $post_data['poll_start'] : 0;
|
|
|
f2e824 |
$post_data['icon_id'] = (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id'];
|
|
|
f2e824 |
$post_data['poll_options'] = array();
|
|
|
f2e824 |
|
|
|
f2e824 |
// Get Poll Data
|
|
|
f2e824 |
if ($post_data['poll_start'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'SELECT poll_option_text
|
|
|
f2e824 |
FROM ' . POLL_OPTIONS_TABLE . "
|
|
|
f2e824 |
WHERE topic_id = $topic_id
|
|
|
f2e824 |
ORDER BY poll_option_id";
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
while ($row = $db->sql_fetchrow($result))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['poll_options'][] = trim($row['poll_option_text']);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$orig_poll_options_size = sizeof($post_data['poll_options']);
|
|
|
f2e824 |
|
|
|
f2e824 |
$message_parser = new parse_message();
|
|
|
f2e824 |
|
|
|
f2e824 |
if (isset($post_data['post_text']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$message_parser->message = &$post_data['post_text'];
|
|
|
f2e824 |
unset($post_data['post_text']);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Set some default variables
|
|
|
f2e824 |
$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);
|
|
|
f2e824 |
|
|
|
f2e824 |
foreach ($uninit as $var_name => $default_value)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (!isset($post_data[$var_name]))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data[$var_name] = $default_value;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
unset($uninit);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Always check if the submitted attachment data is valid and belongs to the user.
|
|
|
f2e824 |
// Further down (especially in submit_post()) we do not check this again.
|
|
|
f2e824 |
$message_parser->get_submitted_attachment_data($post_data['poster_id']);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// Do not change to SELECT *
|
|
|
f2e824 |
$sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename
|
|
|
f2e824 |
FROM ' . ATTACHMENTS_TABLE . "
|
|
|
f2e824 |
WHERE post_msg_id = $post_id
|
|
|
f2e824 |
AND in_message = 0
|
|
|
f2e824 |
AND is_orphan = 0
|
|
|
f2e824 |
ORDER BY filetime DESC";
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
$message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result));
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($post_data['poster_id'] == ANONYMOUS)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['post_username']) : '';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['username']) : '';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['enable_urls'] = $post_data['enable_magic_url'];
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($mode != 'edit')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['enable_sig'] = ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false;
|
|
|
f2e824 |
$post_data['enable_smilies'] = ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false;
|
|
|
f2e824 |
$post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false;
|
|
|
f2e824 |
$post_data['enable_urls'] = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['enable_magic_url'] = $post_data['drafts'] = false;
|
|
|
f2e824 |
|
|
|
f2e824 |
// User own some drafts?
|
|
|
f2e824 |
if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'SELECT draft_id
|
|
|
f2e824 |
FROM ' . DRAFTS_TABLE . '
|
|
|
f2e824 |
WHERE user_id = ' . $user->data['user_id'] .
|
|
|
f2e824 |
(($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') .
|
|
|
f2e824 |
(($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') .
|
|
|
f2e824 |
(($draft_id) ? " AND draft_id <> $draft_id" : '');
|
|
|
f2e824 |
$result = $db->sql_query_limit($sql, 1);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($db->sql_fetchrow($result))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['drafts'] = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$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);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Check if user is watching this topic
|
|
|
f2e824 |
if ($mode != 'post' && $config['allow_topic_notify'] && $user->data['is_registered'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'SELECT topic_id
|
|
|
f2e824 |
FROM ' . TOPICS_WATCH_TABLE . '
|
|
|
f2e824 |
WHERE topic_id = ' . $topic_id . '
|
|
|
f2e824 |
AND user_id = ' . $user->data['user_id'];
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
$post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id');
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Do we want to edit our post ?
|
|
|
f2e824 |
if ($mode == 'edit' && $post_data['bbcode_uid'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$message_parser->bbcode_uid = $post_data['bbcode_uid'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// HTML, BBCode, Smilies, Images and Flash status
|
|
|
f2e824 |
$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false;
|
|
|
f2e824 |
$smilies_status = ($bbcode_status && $config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false;
|
|
|
f2e824 |
$img_status = ($bbcode_status && $auth->acl_get('f_img', $forum_id)) ? true : false;
|
|
|
f2e824 |
$url_status = ($config['allow_post_links']) ? true : false;
|
|
|
f2e824 |
$flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash']) ? true : false;
|
|
|
f2e824 |
$quote_status = ($auth->acl_get('f_reply', $forum_id)) ? true : false;
|
|
|
f2e824 |
|
|
|
f2e824 |
// Save Draft
|
|
|
f2e824 |
if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$subject = utf8_normalize_nfc(request_var('subject', '', true));
|
|
|
f2e824 |
$subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject;
|
|
|
f2e824 |
$message = utf8_normalize_nfc(request_var('message', '', true));
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($subject && $message)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (confirm_box(true))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
|
|
|
f2e824 |
'user_id' => (int) $user->data['user_id'],
|
|
|
f2e824 |
'topic_id' => (int) $topic_id,
|
|
|
f2e824 |
'forum_id' => (int) $forum_id,
|
|
|
f2e824 |
'save_time' => (int) $current_time,
|
|
|
f2e824 |
'draft_subject' => (string) $subject,
|
|
|
f2e824 |
'draft_message' => (string) $message)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
$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");
|
|
|
f2e824 |
|
|
|
f2e824 |
meta_refresh(3, $meta_info);
|
|
|
f2e824 |
|
|
|
f2e824 |
$message = $user->lang['DRAFT_SAVED'] . '
';
|
|
|
f2e824 |
$message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '', '') . '
' : '';
|
|
|
f2e824 |
$message .= sprintf($user->lang['RETURN_FORUM'], '', '');
|
|
|
f2e824 |
|
|
|
f2e824 |
trigger_error($message);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$s_hidden_fields = build_hidden_fields(array(
|
|
|
f2e824 |
'mode' => $mode,
|
|
|
f2e824 |
'save' => true,
|
|
|
f2e824 |
'f' => $forum_id,
|
|
|
f2e824 |
't' => $topic_id,
|
|
|
f2e824 |
'subject' => $subject,
|
|
|
f2e824 |
'message' => $message,
|
|
|
f2e824 |
'attachment_data' => $message_parser->attachment_data,
|
|
|
f2e824 |
)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (utf8_clean_string($subject) === '')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = $user->lang['EMPTY_SUBJECT'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (utf8_clean_string($message) === '')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = $user->lang['TOO_FEW_CHARS'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
unset($subject, $message);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Load requested Draft
|
|
|
f2e824 |
if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $user->data['is_registered'] && $auth->acl_get('u_savedrafts'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'SELECT draft_subject, draft_message
|
|
|
f2e824 |
FROM ' . DRAFTS_TABLE . "
|
|
|
f2e824 |
WHERE draft_id = $draft_id
|
|
|
f2e824 |
AND user_id = " . $user->data['user_id'];
|
|
|
f2e824 |
$result = $db->sql_query_limit($sql, 1);
|
|
|
f2e824 |
$row = $db->sql_fetchrow($result);
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($row)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['post_subject'] = $row['draft_subject'];
|
|
|
f2e824 |
$message_parser->message = $row['draft_message'];
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_var('S_DRAFT_LOADED', true);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$draft_id = 0;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Load draft overview
|
|
|
f2e824 |
if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_data['drafts'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
load_drafts($topic_id, $forum_id);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$solved_captcha = false;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($submit || $preview || $refresh)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0);
|
|
|
f2e824 |
$post_data['post_subject'] = utf8_normalize_nfc(request_var('subject', '', true));
|
|
|
f2e824 |
$message_parser->message = utf8_normalize_nfc(request_var('message', '', true));
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true));
|
|
|
f2e824 |
$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)) : '';
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['orig_topic_type'] = $post_data['topic_type'];
|
|
|
f2e824 |
$post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL));
|
|
|
f2e824 |
$post_data['topic_time_limit'] = request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0));
|
|
|
f2e824 |
$post_data['icon_id'] = request_var('icon', 0);
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true;
|
|
|
f2e824 |
$post_data['enable_smilies'] = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true;
|
|
|
f2e824 |
$post_data['enable_urls'] = (isset($_POST['disable_magic_url'])) ? 0 : 1;
|
|
|
f2e824 |
$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);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($config['allow_topic_notify'] && $user->data['is_registered'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$notify = (isset($_POST['notify'])) ? true : false;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$notify = false;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$topic_lock = (isset($_POST['lock_topic'])) ? true : false;
|
|
|
f2e824 |
$post_lock = (isset($_POST['lock_post'])) ? true : false;
|
|
|
f2e824 |
$poll_delete = (isset($_POST['poll_delete'])) ? true : false;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($submit)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$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);
|
|
|
f2e824 |
$status_switch = ($status_switch != $check_value);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$status_switch = 1;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Delete Poll
|
|
|
f2e824 |
if ($poll_delete && $mode == 'edit' && sizeof($post_data['poll_options']) &&
|
|
|
f2e824 |
((!$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)))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if ($submit && check_form_key('posting'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . "
|
|
|
f2e824 |
WHERE topic_id = $topic_id";
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'DELETE FROM ' . POLL_VOTES_TABLE . "
|
|
|
f2e824 |
WHERE topic_id = $topic_id";
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
$topic_sql = array(
|
|
|
f2e824 |
'poll_title' => '',
|
|
|
f2e824 |
'poll_start' => 0,
|
|
|
f2e824 |
'poll_length' => 0,
|
|
|
f2e824 |
'poll_last_vote' => 0,
|
|
|
f2e824 |
'poll_max_options' => 0,
|
|
|
f2e824 |
'poll_vote_change' => 0
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
|
f2e824 |
SET ' . $db->sql_build_array('UPDATE', $topic_sql) . "
|
|
|
f2e824 |
WHERE topic_id = $topic_id";
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['poll_title'] = $post_data['poll_option_text'] = '';
|
|
|
f2e824 |
$post_data['poll_vote_change'] = $post_data['poll_max_options'] = $post_data['poll_length'] = 0;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['poll_title'] = utf8_normalize_nfc(request_var('poll_title', '', true));
|
|
|
f2e824 |
$post_data['poll_length'] = request_var('poll_length', 0);
|
|
|
f2e824 |
$post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true));
|
|
|
f2e824 |
$post_data['poll_max_options'] = request_var('poll_max_options', 1);
|
|
|
f2e824 |
$post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// If replying/quoting and last post id has changed
|
|
|
f2e824 |
// give user option to continue submit or return to post
|
|
|
f2e824 |
// notify and show user the post made between his request and the final submit
|
|
|
f2e824 |
if (($mode == 'reply' || $mode == 'quote') && $post_data['topic_cur_post_id'] && $post_data['topic_cur_post_id'] != $post_data['topic_last_post_id'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// Only do so if it is allowed forum-wide
|
|
|
f2e824 |
if ($post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (topic_review($topic_id, $forum_id, 'post_review', $post_data['topic_cur_post_id']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_var('S_POST_REVIEW', true);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$submit = false;
|
|
|
f2e824 |
$refresh = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Parse Attachments - before checksum is calculated
|
|
|
f2e824 |
$message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Grab md5 'checksum' of new message
|
|
|
f2e824 |
$message_md5 = md5($message_parser->message);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Check checksum ... don't re-parse message if the same
|
|
|
f2e824 |
$update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN) ? true : false;
|
|
|
f2e824 |
|
|
|
f2e824 |
// Parse message
|
|
|
f2e824 |
if ($update_message)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (sizeof($message_parser->warn_msg))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = implode(' ', $message_parser->warn_msg);
|
|
|
f2e824 |
$message_parser->warn_msg = array();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$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']);
|
|
|
f2e824 |
|
|
|
f2e824 |
// On a refresh we do not care about message parsing errors
|
|
|
f2e824 |
if (sizeof($message_parser->warn_msg) && $refresh)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$message_parser->warn_msg = array();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$message_parser->bbcode_bitfield = $post_data['bbcode_bitfield'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// Flood check
|
|
|
f2e824 |
$last_post_time = 0;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($user->data['is_registered'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$last_post_time = $user->data['user_lastpost_time'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'SELECT post_time AS last_post_time
|
|
|
f2e824 |
FROM ' . POSTS_TABLE . "
|
|
|
f2e824 |
WHERE poster_ip = '" . $user->ip . "'
|
|
|
f2e824 |
AND post_time > " . ($current_time - $config['flood_interval']);
|
|
|
f2e824 |
$result = $db->sql_query_limit($sql, 1);
|
|
|
f2e824 |
if ($row = $db->sql_fetchrow($result))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$last_post_time = $row['last_post_time'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = $user->lang['FLOOD_ERROR'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Validate username
|
|
|
f2e824 |
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']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (($result = validate_username($post_data['username'], (!empty($post_data['post_username'])) ? $post_data['post_username'] : '')) !== false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$user->add_lang('ucp');
|
|
|
f2e824 |
$error[] = $user->lang[$result . '_USERNAME'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply')))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$confirm_id = request_var('confirm_id', '');
|
|
|
f2e824 |
$confirm_code = request_var('confirm_code', '');
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'SELECT code
|
|
|
f2e824 |
FROM ' . CONFIRM_TABLE . "
|
|
|
f2e824 |
WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'
|
|
|
f2e824 |
AND session_id = '" . $db->sql_escape($user->session_id) . "'
|
|
|
f2e824 |
AND confirm_type = " . CONFIRM_POST;
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
$confirm_row = $db->sql_fetchrow($result);
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (empty($confirm_row['code']) || strcasecmp($confirm_row['code'], $confirm_code) !== 0)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = $user->lang['CONFIRM_CODE_WRONG'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$solved_captcha = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// check form
|
|
|
f2e824 |
if (($submit || $preview) && !check_form_key('posting'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = $user->lang['FORM_INVALID'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Parse subject
|
|
|
f2e824 |
if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id)))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = $user->lang['EMPTY_SUBJECT'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($post_data['poll_option_text'] &&
|
|
|
f2e824 |
($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/))
|
|
|
f2e824 |
&& $auth->acl_get('f_poll', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$poll = array(
|
|
|
f2e824 |
'poll_title' => $post_data['poll_title'],
|
|
|
f2e824 |
'poll_length' => $post_data['poll_length'],
|
|
|
f2e824 |
'poll_max_options' => $post_data['poll_max_options'],
|
|
|
f2e824 |
'poll_option_text' => $post_data['poll_option_text'],
|
|
|
f2e824 |
'poll_start' => $post_data['poll_start'],
|
|
|
f2e824 |
'poll_last_vote' => $post_data['poll_last_vote'],
|
|
|
f2e824 |
'poll_vote_change' => $post_data['poll_vote_change'],
|
|
|
f2e824 |
'enable_bbcode' => $post_data['enable_bbcode'],
|
|
|
f2e824 |
'enable_urls' => $post_data['enable_urls'],
|
|
|
f2e824 |
'enable_smilies' => $post_data['enable_smilies'],
|
|
|
f2e824 |
'img_status' => $img_status
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$message_parser->parse_poll($poll);
|
|
|
f2e824 |
|
|
|
f2e824 |
$post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : '';
|
|
|
f2e824 |
$post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : '';
|
|
|
f2e824 |
|
|
|
f2e824 |
/* We reset votes, therefore also allow removing options
|
|
|
f2e824 |
if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS'];
|
|
|
f2e824 |
}*/
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$poll = array();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Check topic type
|
|
|
f2e824 |
if ($post_data['topic_type'] != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id)))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
switch ($post_data['topic_type'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
case POST_GLOBAL:
|
|
|
f2e824 |
case POST_ANNOUNCE:
|
|
|
f2e824 |
$auth_option = 'f_announce';
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case POST_STICKY:
|
|
|
f2e824 |
$auth_option = 'f_sticky';
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
default:
|
|
|
f2e824 |
$auth_option = '';
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$auth->acl_get($auth_option, $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// There is a special case where a user edits his post whereby the topic type got changed by an admin/mod.
|
|
|
f2e824 |
// Another case would be a mod not having sticky permissions for example but edit permissions.
|
|
|
f2e824 |
if ($mode == 'edit')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// To prevent non-authed users messing around with the topic type we reset it to the original one.
|
|
|
f2e824 |
$post_data['topic_type'] = $post_data['orig_topic_type'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = $user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (sizeof($message_parser->warn_msg))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = implode(' ', $message_parser->warn_msg);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// DNSBL check
|
|
|
f2e824 |
if ($config['check_dnsbl'] && !$refresh)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (($dnsbl = $user->check_dnsbl('post')) !== false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Store message, sync counters
|
|
|
f2e824 |
if (!sizeof($error) && $submit)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// Check if we want to de-globalize the topic... and ask for new forum
|
|
|
f2e824 |
if ($post_data['topic_type'] != POST_GLOBAL)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'SELECT topic_type, forum_id
|
|
|
f2e824 |
FROM ' . TOPICS_TABLE . "
|
|
|
f2e824 |
WHERE topic_id = $topic_id";
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
$row = $db->sql_fetchrow($result);
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$to_forum_id = request_var('to_forum_id', 0);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($to_forum_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'SELECT forum_type
|
|
|
f2e824 |
FROM ' . FORUMS_TABLE . '
|
|
|
f2e824 |
WHERE forum_id = ' . $to_forum_id;
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
$forum_type = (int) $db->sql_fetchfield('forum_type');
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$to_forum_id = 0;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$to_forum_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true),
|
|
|
f2e824 |
'S_UNGLOBALISE' => true)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$submit = false;
|
|
|
f2e824 |
$refresh = true;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (!$auth->acl_get('f_post', $to_forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// This will only be triggered if the user tried to trick the forum.
|
|
|
f2e824 |
trigger_error('NOT_AUTHORISED');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$forum_id = $to_forum_id;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($submit)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// Lock/Unlock Topic
|
|
|
f2e824 |
$change_topic_status = $post_data['topic_status'];
|
|
|
f2e824 |
$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;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$change_topic_status = ITEM_UNLOCKED;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$change_topic_status = ITEM_LOCKED;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($change_topic_status != $post_data['topic_status'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
|
f2e824 |
SET topic_status = $change_topic_status
|
|
|
f2e824 |
WHERE topic_id = $topic_id
|
|
|
f2e824 |
AND topic_moved_id = 0";
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
$user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : '';
|
|
|
f2e824 |
|
|
|
f2e824 |
add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Lock/Unlock Post Edit
|
|
|
f2e824 |
if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['post_edit_locked'] = ITEM_UNLOCKED;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['post_edit_locked'] = ITEM_LOCKED;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$data = array(
|
|
|
f2e824 |
'topic_title' => (empty($post_data['topic_title'])) ? $post_data['post_subject'] : $post_data['topic_title'],
|
|
|
f2e824 |
'topic_first_post_id' => (isset($post_data['topic_first_post_id'])) ? (int) $post_data['topic_first_post_id'] : 0,
|
|
|
f2e824 |
'topic_last_post_id' => (isset($post_data['topic_last_post_id'])) ? (int) $post_data['topic_last_post_id'] : 0,
|
|
|
f2e824 |
'topic_time_limit' => (int) $post_data['topic_time_limit'],
|
|
|
f2e824 |
'topic_attachment' => (isset($post_data['topic_attachment'])) ? (int) $post_data['topic_attachment'] : 0,
|
|
|
f2e824 |
'post_id' => (int) $post_id,
|
|
|
f2e824 |
'topic_id' => (int) $topic_id,
|
|
|
f2e824 |
'forum_id' => (int) $forum_id,
|
|
|
f2e824 |
'icon_id' => (int) $post_data['icon_id'],
|
|
|
f2e824 |
'poster_id' => (int) $post_data['poster_id'],
|
|
|
f2e824 |
'enable_sig' => (bool) $post_data['enable_sig'],
|
|
|
f2e824 |
'enable_bbcode' => (bool) $post_data['enable_bbcode'],
|
|
|
f2e824 |
'enable_smilies' => (bool) $post_data['enable_smilies'],
|
|
|
f2e824 |
'enable_urls' => (bool) $post_data['enable_urls'],
|
|
|
f2e824 |
'enable_indexing' => (bool) $post_data['enable_indexing'],
|
|
|
f2e824 |
'message_md5' => (string) $message_md5,
|
|
|
f2e824 |
'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time,
|
|
|
f2e824 |
'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '',
|
|
|
f2e824 |
'post_edit_reason' => $post_data['post_edit_reason'],
|
|
|
f2e824 |
'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0),
|
|
|
f2e824 |
'forum_parents' => $post_data['forum_parents'],
|
|
|
f2e824 |
'forum_name' => $post_data['forum_name'],
|
|
|
f2e824 |
'notify' => $notify,
|
|
|
f2e824 |
'notify_set' => $post_data['notify_set'],
|
|
|
f2e824 |
'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : $user->ip,
|
|
|
f2e824 |
'post_edit_locked' => (int) $post_data['post_edit_locked'],
|
|
|
f2e824 |
'bbcode_bitfield' => $message_parser->bbcode_bitfield,
|
|
|
f2e824 |
'bbcode_uid' => $message_parser->bbcode_uid,
|
|
|
f2e824 |
'message' => $message_parser->message,
|
|
|
f2e824 |
'attachment_data' => $message_parser->attachment_data,
|
|
|
f2e824 |
'filename_data' => $message_parser->filename_data,
|
|
|
f2e824 |
|
|
|
f2e824 |
'topic_approved' => (isset($post_data['topic_approved'])) ? $post_data['topic_approved'] : false,
|
|
|
f2e824 |
'post_approved' => (isset($post_data['post_approved'])) ? $post_data['post_approved'] : false,
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($mode == 'edit')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$data['topic_replies_real'] = $post_data['topic_replies_real'];
|
|
|
f2e824 |
$data['topic_replies'] = $post_data['topic_replies'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected.
|
|
|
f2e824 |
if ((($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
meta_refresh(10, $redirect_url);
|
|
|
f2e824 |
$message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD'];
|
|
|
f2e824 |
$message .= (($user->data['user_id'] == ANONYMOUS) ? '' : ' '. $user->lang['POST_APPROVAL_NOTIFY']);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
meta_refresh(3, $redirect_url);
|
|
|
f2e824 |
|
|
|
f2e824 |
$message = ($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED';
|
|
|
f2e824 |
$message = $user->lang[$message] . '
' . sprintf($user->lang['VIEW_MESSAGE'], '', '');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$message .= '
' . sprintf($user->lang['RETURN_FORUM'], '', '');
|
|
|
f2e824 |
trigger_error($message);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Preview
|
|
|
f2e824 |
if (!sizeof($error) && $preview)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['post_time'] = ($mode == 'edit') ? $post_data['post_time'] : $current_time;
|
|
|
f2e824 |
|
|
|
f2e824 |
$preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false);
|
|
|
f2e824 |
|
|
|
f2e824 |
$preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : $user->data['user_sig'];
|
|
|
f2e824 |
$preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : $user->data['user_sig_bbcode_uid'];
|
|
|
f2e824 |
$preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield'];
|
|
|
f2e824 |
|
|
|
f2e824 |
// Signature
|
|
|
f2e824 |
if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$parse_sig = new parse_message($preview_signature);
|
|
|
f2e824 |
$parse_sig->bbcode_uid = $preview_signature_uid;
|
|
|
f2e824 |
$parse_sig->bbcode_bitfield = $preview_signature_bitfield;
|
|
|
f2e824 |
|
|
|
f2e824 |
// Not sure about parameters for bbcode/smilies/urls... in signatures
|
|
|
f2e824 |
$parse_sig->format_display($config['allow_sig_bbcode'], true, $config['allow_sig_smilies']);
|
|
|
f2e824 |
$preview_signature = $parse_sig->message;
|
|
|
f2e824 |
unset($parse_sig);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$preview_signature = '';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$preview_subject = censor_text($post_data['post_subject']);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Poll Preview
|
|
|
f2e824 |
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))*/))
|
|
|
f2e824 |
&& $auth->acl_get('f_poll', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$parse_poll = new parse_message($post_data['poll_title']);
|
|
|
f2e824 |
$parse_poll->bbcode_uid = $message_parser->bbcode_uid;
|
|
|
f2e824 |
$parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield;
|
|
|
f2e824 |
|
|
|
f2e824 |
$parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($post_data['poll_length'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$poll_end = ($post_data['poll_length'] * 86400) + (($post_data['poll_start']) ? $post_data['poll_start'] : time());
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'S_HAS_POLL_OPTIONS' => (sizeof($post_data['poll_options'])),
|
|
|
f2e824 |
'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false,
|
|
|
f2e824 |
|
|
|
f2e824 |
'POLL_QUESTION' => $parse_poll->message,
|
|
|
f2e824 |
|
|
|
f2e824 |
'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '',
|
|
|
f2e824 |
'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']))
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$parse_poll->message = implode("\n", $post_data['poll_options']);
|
|
|
f2e824 |
$parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']);
|
|
|
f2e824 |
$preview_poll_options = explode(' ', $parse_poll->message);
|
|
|
f2e824 |
unset($parse_poll);
|
|
|
f2e824 |
|
|
|
f2e824 |
foreach ($preview_poll_options as $key => $option)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_block_vars('poll_option', array(
|
|
|
f2e824 |
'POLL_OPTION_CAPTION' => $option,
|
|
|
f2e824 |
'POLL_OPTION_ID' => $key + 1)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
unset($preview_poll_options);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Attachment Preview
|
|
|
f2e824 |
if (sizeof($message_parser->attachment_data))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_var('S_HAS_ATTACHMENTS', true);
|
|
|
f2e824 |
|
|
|
f2e824 |
$update_count = array();
|
|
|
f2e824 |
$attachment_data = $message_parser->attachment_data;
|
|
|
f2e824 |
|
|
|
f2e824 |
parse_attachments($forum_id, $preview_message, $attachment_data, $update_count, true);
|
|
|
f2e824 |
|
|
|
f2e824 |
foreach ($attachment_data as $i => $attachment)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_block_vars('attachment', array(
|
|
|
f2e824 |
'DISPLAY_ATTACHMENT' => $attachment)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
unset($attachment_data);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!sizeof($error))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'PREVIEW_SUBJECT' => $preview_subject,
|
|
|
f2e824 |
'PREVIEW_MESSAGE' => $preview_message,
|
|
|
f2e824 |
'PREVIEW_SIGNATURE' => $preview_signature,
|
|
|
f2e824 |
|
|
|
f2e824 |
'S_DISPLAY_PREVIEW' => true)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Decode text for message display
|
|
|
f2e824 |
$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid;
|
|
|
f2e824 |
$message_parser->decode_message($post_data['bbcode_uid']);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($mode == 'quote' && !$submit && !$preview && !$refresh)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$post_data['post_subject'] = ((strpos($post_data['post_subject'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($post_data['post_subject']);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$attachment_data = $message_parser->attachment_data;
|
|
|
f2e824 |
$filename_data = $message_parser->filename_data;
|
|
|
f2e824 |
$post_data['post_text'] = $message_parser->message;
|
|
|
f2e824 |
|
|
|
f2e824 |
if (sizeof($post_data['poll_options']) && $post_data['poll_title'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$message_parser->message = $post_data['poll_title'];
|
|
|
f2e824 |
$message_parser->bbcode_uid = $post_data['bbcode_uid'];
|
|
|
f2e824 |
|
|
|
f2e824 |
$message_parser->decode_message();
|
|
|
f2e824 |
$post_data['poll_title'] = $message_parser->message;
|
|
|
f2e824 |
|
|
|
f2e824 |
$message_parser->message = implode("\n", $post_data['poll_options']);
|
|
|
f2e824 |
$message_parser->decode_message();
|
|
|
f2e824 |
$post_data['poll_options'] = explode("\n", $message_parser->message);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// MAIN POSTING PAGE BEGINS HERE
|
|
|
f2e824 |
|
|
|
f2e824 |
// Forum moderators?
|
|
|
f2e824 |
$moderators = array();
|
|
|
f2e824 |
get_moderators($moderators, $forum_id);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Generate smiley listing
|
|
|
f2e824 |
generate_smilies('inline', $forum_id);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Generate inline attachment select box
|
|
|
f2e824 |
posting_gen_inline_attachments($attachment_data);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Do show topic type selection only in first post.
|
|
|
f2e824 |
$topic_type_toggle = false;
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$topic_type_toggle = posting_gen_topic_types($forum_id, $post_data['topic_type']);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$s_topic_icons = false;
|
|
|
f2e824 |
if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1);
|
|
|
f2e824 |
$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : (($config['allow_smilies']) ? !$user->optionget('smilies') : 1);
|
|
|
f2e824 |
$urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0;
|
|
|
f2e824 |
$sig_checked = $post_data['enable_sig'];
|
|
|
f2e824 |
$lock_topic_checked = (isset($topic_lock) && $topic_lock) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0);
|
|
|
f2e824 |
$lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked'];
|
|
|
f2e824 |
|
|
|
f2e824 |
// 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
|
|
|
f2e824 |
$notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set'];
|
|
|
f2e824 |
$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Page title & action URL, include session_id for security purpose
|
|
|
f2e824 |
$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&f=$forum_id", true, $user->session_id);
|
|
|
f2e824 |
$s_action .= ($topic_id) ? "&t=$topic_id" : '';
|
|
|
f2e824 |
$s_action .= ($post_id) ? "&p=$post_id" : '';
|
|
|
f2e824 |
|
|
|
f2e824 |
switch ($mode)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
case 'post':
|
|
|
f2e824 |
$page_title = $user->lang['POST_TOPIC'];
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'quote':
|
|
|
f2e824 |
case 'reply':
|
|
|
f2e824 |
$page_title = $user->lang['POST_REPLY'];
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
|
|
|
f2e824 |
case 'delete':
|
|
|
f2e824 |
case 'edit':
|
|
|
f2e824 |
$page_title = $user->lang['EDIT_POST'];
|
|
|
f2e824 |
break;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Build Navigation Links
|
|
|
f2e824 |
generate_forum_nav($post_data);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Build Forum Rules
|
|
|
f2e824 |
generate_forum_rules($post_data);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($config['enable_post_confirm'] && !$user->data['is_registered'] && $solved_captcha === false && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
// Show confirm image
|
|
|
f2e824 |
$sql = 'DELETE FROM ' . CONFIRM_TABLE . "
|
|
|
f2e824 |
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
|
|
|
f2e824 |
AND confirm_type = " . CONFIRM_POST;
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Generate code
|
|
|
f2e824 |
$code = gen_rand_string(mt_rand(5, 8));
|
|
|
f2e824 |
$confirm_id = md5(unique_id($user->ip));
|
|
|
f2e824 |
$seed = hexdec(substr(unique_id(), 4, 10));
|
|
|
f2e824 |
|
|
|
f2e824 |
// compute $seed % 0x7fffffff
|
|
|
f2e824 |
$seed -= 0x7fffffff * floor($seed / 0x7fffffff);
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array(
|
|
|
f2e824 |
'confirm_id' => (string) $confirm_id,
|
|
|
f2e824 |
'session_id' => (string) $user->session_id,
|
|
|
f2e824 |
'confirm_type' => (int) CONFIRM_POST,
|
|
|
f2e824 |
'code' => (string) $code,
|
|
|
f2e824 |
'seed' => (int) $seed)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'S_CONFIRM_CODE' => true,
|
|
|
f2e824 |
'CONFIRM_ID' => $confirm_id,
|
|
|
f2e824 |
'CONFIRM_IMAGE' => '',
|
|
|
f2e824 |
'L_POST_CONFIRM_EXPLAIN' => sprintf($user->lang['POST_CONFIRM_EXPLAIN'], '', ''),
|
|
|
f2e824 |
));
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $post_data['topic_last_post_id'] . '" />' : '';
|
|
|
f2e824 |
$s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . $current_time . '" />';
|
|
|
f2e824 |
$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . request_var('draft_loaded', $draft_id) . '" />' : '';
|
|
|
f2e824 |
|
|
|
f2e824 |
// Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
|
|
|
f2e824 |
if ($solved_captcha !== false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$s_hidden_fields .= build_hidden_fields(array(
|
|
|
f2e824 |
'confirm_id' => request_var('confirm_id', ''),
|
|
|
f2e824 |
'confirm_code' => request_var('confirm_code', ''))
|
|
|
f2e824 |
);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$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"';
|
|
|
f2e824 |
add_form_key('posting');
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
// Start assigning vars for main posting page ...
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'L_POST_A' => $page_title,
|
|
|
f2e824 |
'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'],
|
|
|
f2e824 |
'L_MESSAGE_BODY_EXPLAIN' => (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '',
|
|
|
f2e824 |
|
|
|
f2e824 |
'FORUM_NAME' => $post_data['forum_name'],
|
|
|
f2e824 |
'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']) : '',
|
|
|
f2e824 |
'TOPIC_TITLE' => censor_text($post_data['topic_title']),
|
|
|
f2e824 |
'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '',
|
|
|
f2e824 |
'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '',
|
|
|
f2e824 |
'SUBJECT' => $post_data['post_subject'],
|
|
|
f2e824 |
'MESSAGE' => $post_data['post_text'],
|
|
|
f2e824 |
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_OFF'], '', ''),
|
|
|
f2e824 |
'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
|
|
|
f2e824 |
'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
|
|
|
f2e824 |
'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
|
|
|
f2e824 |
'URL_STATUS' => ($bbcode_status && $url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
|
|
|
f2e824 |
'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']),
|
|
|
f2e824 |
'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '',
|
|
|
f2e824 |
'ERROR' => (sizeof($error)) ? implode(' ', $error) : '',
|
|
|
f2e824 |
'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'],
|
|
|
f2e824 |
'EDIT_REASON' => $post_data['post_edit_reason'],
|
|
|
f2e824 |
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"),
|
|
|
f2e824 |
'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '',
|
|
|
f2e824 |
'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"),
|
|
|
f2e824 |
'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup")),
|
|
|
f2e824 |
|
|
|
f2e824 |
'S_PRIVMSGS' => false,
|
|
|
f2e824 |
'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false,
|
|
|
f2e824 |
'S_EDIT_POST' => ($mode == 'edit') ? true : false,
|
|
|
f2e824 |
'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
|
|
|
f2e824 |
'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false,
|
|
|
f2e824 |
'S_SHOW_TOPIC_ICONS' => $s_topic_icons,
|
|
|
f2e824 |
'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['edit_time'] * 60) || !$config['edit_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false,
|
|
|
f2e824 |
'S_BBCODE_ALLOWED' => $bbcode_status,
|
|
|
f2e824 |
'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '',
|
|
|
f2e824 |
'S_SMILIES_ALLOWED' => $smilies_status,
|
|
|
f2e824 |
'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '',
|
|
|
f2e824 |
'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['is_registered']) ? true : false,
|
|
|
f2e824 |
'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '',
|
|
|
f2e824 |
'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,
|
|
|
f2e824 |
'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '',
|
|
|
f2e824 |
'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,
|
|
|
f2e824 |
'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '',
|
|
|
f2e824 |
'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
|
|
|
f2e824 |
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '',
|
|
|
f2e824 |
'S_LINKS_ALLOWED' => $url_status,
|
|
|
f2e824 |
'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '',
|
|
|
f2e824 |
'S_TYPE_TOGGLE' => $topic_type_toggle,
|
|
|
f2e824 |
'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $mode != 'edit') ? true : false,
|
|
|
f2e824 |
'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $post_data['drafts']) ? true : false,
|
|
|
f2e824 |
'S_FORM_ENCTYPE' => $form_enctype,
|
|
|
f2e824 |
|
|
|
f2e824 |
'S_BBCODE_IMG' => $img_status,
|
|
|
f2e824 |
'S_BBCODE_URL' => $url_status,
|
|
|
f2e824 |
'S_BBCODE_FLASH' => $flash_status,
|
|
|
f2e824 |
'S_BBCODE_QUOTE' => $quote_status,
|
|
|
f2e824 |
|
|
|
f2e824 |
'S_POST_ACTION' => $s_action,
|
|
|
f2e824 |
'S_HIDDEN_FIELDS' => $s_hidden_fields)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Build custom bbcodes array
|
|
|
f2e824 |
display_custom_bbcodes();
|
|
|
f2e824 |
|
|
|
f2e824 |
// Poll entry
|
|
|
f2e824 |
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))*/))
|
|
|
f2e824 |
&& $auth->acl_get('f_poll', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'S_SHOW_POLL_BOX' => true,
|
|
|
f2e824 |
'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id)),
|
|
|
f2e824 |
'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))),
|
|
|
f2e824 |
'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false,
|
|
|
f2e824 |
|
|
|
f2e824 |
'L_POLL_OPTIONS_EXPLAIN' => sprintf($user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], $config['max_poll_options']),
|
|
|
f2e824 |
|
|
|
f2e824 |
'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '',
|
|
|
f2e824 |
'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '',
|
|
|
f2e824 |
'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '',
|
|
|
f2e824 |
'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1,
|
|
|
f2e824 |
'POLL_LENGTH' => $post_data['poll_length'])
|
|
|
f2e824 |
);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Show attachment box for adding attachments if true
|
|
|
f2e824 |
$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Attachment entry
|
|
|
f2e824 |
posting_gen_attachment_entry($attachment_data, $filename_data, $allowed);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Output page ...
|
|
|
f2e824 |
page_header($page_title);
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->set_filenames(array(
|
|
|
f2e824 |
'body' => 'posting_body.html')
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
|
|
|
f2e824 |
|
|
|
f2e824 |
// Topic review
|
|
|
f2e824 |
if ($mode == 'reply' || $mode == 'quote')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (topic_review($topic_id, $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$template->assign_var('S_DISPLAY_REVIEW', true);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
page_footer();
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Show upload popup (progress bar)
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function upload_popup($forum_style = 0)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $template, $user;
|
|
|
f2e824 |
|
|
|
f2e824 |
($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting');
|
|
|
f2e824 |
|
|
|
f2e824 |
page_header($user->lang['PROGRESS_BAR']);
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->set_filenames(array(
|
|
|
f2e824 |
'popup' => 'posting_progress_bar.html')
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS']))
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->display('popup');
|
|
|
f2e824 |
|
|
|
f2e824 |
garbage_collection();
|
|
|
f2e824 |
exit_handler();
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Do the various checks required for removing posts as well as removing it
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
global $user, $db, $auth, $config;
|
|
|
f2e824 |
global $phpbb_root_path, $phpEx;
|
|
|
f2e824 |
|
|
|
f2e824 |
// If moderator removing post or user itself removing post, present a confirmation screen
|
|
|
f2e824 |
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['edit_time'] * 60) || !$config['edit_time'])))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$s_hidden_fields = build_hidden_fields(array(
|
|
|
f2e824 |
'p' => $post_id,
|
|
|
f2e824 |
'f' => $forum_id,
|
|
|
f2e824 |
'mode' => 'delete')
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (confirm_box(true))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$data = array(
|
|
|
f2e824 |
'topic_first_post_id' => $post_data['topic_first_post_id'],
|
|
|
f2e824 |
'topic_last_post_id' => $post_data['topic_last_post_id'],
|
|
|
f2e824 |
'topic_replies_real' => $post_data['topic_replies_real'],
|
|
|
f2e824 |
'topic_approved' => $post_data['topic_approved'],
|
|
|
f2e824 |
'topic_type' => $post_data['topic_type'],
|
|
|
f2e824 |
'post_approved' => $post_data['post_approved'],
|
|
|
f2e824 |
'post_reported' => $post_data['post_reported'],
|
|
|
f2e824 |
'post_time' => $post_data['post_time'],
|
|
|
f2e824 |
'poster_id' => $post_data['poster_id'],
|
|
|
f2e824 |
'post_postcount' => $post_data['post_postcount']
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$next_post_id = delete_post($forum_id, $topic_id, $post_id, $data);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($next_post_id === false)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title']);
|
|
|
f2e824 |
|
|
|
f2e824 |
$meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id");
|
|
|
f2e824 |
$message = $user->lang['POST_DELETED'];
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject']);
|
|
|
f2e824 |
|
|
|
f2e824 |
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id";
|
|
|
f2e824 |
$message = $user->lang['POST_DELETED'] . '
' . sprintf($user->lang['RETURN_TOPIC'], '', '');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
meta_refresh(3, $meta_info);
|
|
|
f2e824 |
$message .= '
' . sprintf($user->lang['RETURN_FORUM'], '', '');
|
|
|
f2e824 |
trigger_error($message);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
confirm_box(false, 'DELETE_POST', $s_hidden_fields);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// If we are here the user is not able to delete - present the correct error message
|
|
|
f2e824 |
if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('DELETE_OWN_POSTS');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('CANNOT_DELETE_REPLIED');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
trigger_error('USER_CANNOT_DELETE');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
?>
|