2001-02-17 08:37:32 +00:00
|
|
|
<?php
|
2001-04-17 07:14:50 +00:00
|
|
|
/***************************************************************************
|
2001-08-26 13:53:41 +00:00
|
|
|
* posting.php
|
2001-04-17 07:14:50 +00:00
|
|
|
* -------------------
|
|
|
|
* begin : Saturday, Feb 13, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2001-08-30 22:20:23 +00:00
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2003-01-08 17:00:37 +00:00
|
|
|
// TODO for 2.2:
|
|
|
|
//
|
2003-02-26 13:17:45 +00:00
|
|
|
// * topic review additions -> quoting from previous posts ?
|
|
|
|
// * check for reply since started posting upon submission and display of 'between-posts' to allow re-defining of post
|
2003-01-08 17:00:37 +00:00
|
|
|
// * hidden form element containing sid to prevent remote posting - Edwin van Vliet
|
|
|
|
// * bbcode parsing -> see functions_posting.php
|
|
|
|
// * multichoice polls
|
|
|
|
// * permission defined ability for user to add poll options
|
2003-01-12 00:28:28 +00:00
|
|
|
// * Spellcheck? aspell? or some such?
|
2003-02-26 13:17:45 +00:00
|
|
|
// * Posting approval
|
2003-01-08 17:00:37 +00:00
|
|
|
|
2002-03-18 13:35:43 +00:00
|
|
|
define('IN_PHPBB', true);
|
2002-03-31 00:06:34 +00:00
|
|
|
$phpbb_root_path = './';
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'extension.inc');
|
|
|
|
include($phpbb_root_path . 'common.'.$phpEx);
|
2002-07-14 14:45:26 +00:00
|
|
|
include($phpbb_root_path . 'includes/functions_posting.'.$phpEx);
|
2003-02-27 23:37:02 +00:00
|
|
|
include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2002-10-28 00:08:18 +00:00
|
|
|
// Start session management
|
|
|
|
$user->start();
|
|
|
|
$auth->acl($user->data);
|
2003-05-18 11:12:04 +00:00
|
|
|
$user->setup();
|
2002-10-28 00:08:18 +00:00
|
|
|
|
2003-01-22 16:35:06 +00:00
|
|
|
// Grab only parameters needed here
|
|
|
|
$mode = (!empty($_REQUEST['mode'])) ? strval($_REQUEST['mode']) : '';
|
|
|
|
$post_id = (!empty($_REQUEST['p'])) ? intval($_REQUEST['p']) : false;
|
|
|
|
$topic_id = (!empty($_REQUEST['t'])) ? intval($_REQUEST['t']) : false;
|
|
|
|
$forum_id = (!empty($_REQUEST['f'])) ? intval($_REQUEST['f']) : false;
|
2003-03-10 19:39:50 +00:00
|
|
|
$lastclick = (isset($_POST['lastclick'])) ? intval($_POST['lastclick']) : 0;
|
2003-01-22 16:35:06 +00:00
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
$submit = (isset($_POST['post'])) ? true : false;
|
|
|
|
$preview = (isset($_POST['preview'])) ? true : false;
|
|
|
|
$save = (isset($_POST['save'])) ? true : false;
|
|
|
|
$cancel = (isset($_POST['cancel'])) ? true : false;
|
2003-03-02 13:32:53 +00:00
|
|
|
$confirm = (isset($_POST['confirm'])) ? true : false;
|
2003-03-10 19:39:50 +00:00
|
|
|
$delete = (isset($_POST['delete'])) ? true : false;
|
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
$refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['edit_comment']);
|
|
|
|
|
|
|
|
if (($delete) && (!$preview) && (!$refresh) && ($submit))
|
2003-03-10 19:39:50 +00:00
|
|
|
{
|
|
|
|
$mode = 'delete';
|
|
|
|
}
|
2003-02-26 19:53:10 +00:00
|
|
|
|
2002-10-20 19:19:07 +00:00
|
|
|
// Was cancel pressed? If so then redirect to the appropriate page
|
2003-03-10 19:39:50 +00:00
|
|
|
if ( ($cancel) || ((time() - $lastclick) < 2) )
|
2001-09-06 00:29:07 +00:00
|
|
|
{
|
2003-02-27 23:37:02 +00:00
|
|
|
$redirect = ($post_id) ? "viewtopic.$phpEx$SID&p=" . $post_id . "#" . $post_id : (($topic_id) ? "viewtopic.$phpEx$SID&t=" . $topic_id : (($forum_id) ? "viewforum.$phpEx$SID&f=" . $forum_id : "index.$phpEx$SID"));
|
2002-10-20 19:19:07 +00:00
|
|
|
redirect($redirect);
|
2001-09-06 00:29:07 +00:00
|
|
|
}
|
|
|
|
|
2002-10-28 00:08:18 +00:00
|
|
|
// What is all this following SQL for? Well, we need to know
|
|
|
|
// some basic information in all cases before we do anything.
|
2003-02-28 12:57:10 +00:00
|
|
|
$forum_validate = false;
|
|
|
|
$topic_validate = false;
|
|
|
|
$post_validate = false;
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2003-03-12 16:34:40 +00:00
|
|
|
// Easier validation
|
2003-05-02 15:50:11 +00:00
|
|
|
$forum_fields = array('forum_name' => 's', 'parent_id' => 'i', 'forum_parents' => 's', 'forum_status' => 'i', 'forum_type' => 'i', 'enable_icons' => 'i');
|
2003-03-12 16:34:40 +00:00
|
|
|
|
2003-04-22 16:47:34 +00:00
|
|
|
$topic_fields = array('topic_status' => 'i', 'topic_first_post_id' => 'i', 'topic_last_post_id' => 'i', 'topic_type' => 'i', 'topic_title' => 's', 'poll_last_vote' => 'i', 'poll_start' => 'i', 'poll_title' => 's', 'poll_max_options' => 'i', 'poll_length' => 'i');
|
2003-03-12 16:34:40 +00:00
|
|
|
|
2003-04-12 14:30:21 +00:00
|
|
|
$post_fields = array('post_time' => 'i', 'poster_id' => 'i', 'post_username' => 's', 'post_text' => 's', 'post_subject' => 's', 'post_checksum' => 's', 'post_attachment' => 'i', 'bbcode_uid' => 's', 'enable_magic_url' => 'i', 'enable_sig' => 'i', 'enable_smilies' => 'i', 'enable_bbcode' => 'i', 'post_edit_locked' => 'i');
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2003-04-09 22:17:55 +00:00
|
|
|
$sql = '';
|
2003-01-22 16:35:06 +00:00
|
|
|
switch ($mode)
|
2002-02-18 12:34:38 +00:00
|
|
|
{
|
2002-10-28 00:08:18 +00:00
|
|
|
case 'post':
|
2003-02-26 13:17:45 +00:00
|
|
|
if (!$forum_id)
|
2002-10-30 18:59:09 +00:00
|
|
|
{
|
2003-02-26 00:37:43 +00:00
|
|
|
trigger_error($user->lang['NO_FORUM']);
|
2002-10-30 18:59:09 +00:00
|
|
|
}
|
|
|
|
|
2003-03-12 16:34:40 +00:00
|
|
|
$sql = "SELECT *
|
|
|
|
FROM " . FORUMS_TABLE . "
|
2003-02-26 19:53:10 +00:00
|
|
|
WHERE forum_id = " . $forum_id;
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2003-02-28 12:57:10 +00:00
|
|
|
$forum_validate = true;
|
2002-10-04 13:09:10 +00:00
|
|
|
break;
|
2002-10-30 00:57:27 +00:00
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
case 'reply':
|
2003-02-26 13:17:45 +00:00
|
|
|
if (!$topic_id)
|
2002-03-21 01:03:47 +00:00
|
|
|
{
|
2003-02-26 00:37:43 +00:00
|
|
|
trigger_error($user->lang['NO_TOPIC']);
|
2002-03-21 01:03:47 +00:00
|
|
|
}
|
|
|
|
|
2003-03-12 16:34:40 +00:00
|
|
|
$sql = "SELECT t.*, f.*
|
2003-03-20 13:21:58 +00:00
|
|
|
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
|
2003-02-27 23:37:02 +00:00
|
|
|
WHERE t.topic_id = " . $topic_id . "
|
|
|
|
AND f.forum_id = t.forum_id";
|
2002-10-30 00:57:27 +00:00
|
|
|
|
2003-05-05 22:48:17 +00:00
|
|
|
$forum_validate = $topic_validate = true;
|
2003-02-27 23:37:02 +00:00
|
|
|
break;
|
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
case 'quote':
|
2002-10-28 00:08:18 +00:00
|
|
|
case 'edit':
|
2002-10-04 13:09:10 +00:00
|
|
|
case 'delete':
|
2003-02-26 13:17:45 +00:00
|
|
|
if (!$post_id)
|
2002-10-04 13:09:10 +00:00
|
|
|
{
|
2003-02-26 00:37:43 +00:00
|
|
|
trigger_error($user->lang['NO_POST']);
|
2002-10-04 13:09:10 +00:00
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2003-03-12 16:34:40 +00:00
|
|
|
$sql = "SELECT p.*, t.*, f.*, u.username
|
2003-02-28 12:57:10 +00:00
|
|
|
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . USERS_TABLE . " u
|
2003-02-27 23:37:02 +00:00
|
|
|
WHERE p.post_id = " . $post_id . "
|
2002-10-04 13:09:10 +00:00
|
|
|
AND t.topic_id = p.topic_id
|
2003-02-28 12:57:10 +00:00
|
|
|
AND u.user_id = p.poster_id
|
2003-02-27 23:37:02 +00:00
|
|
|
AND f.forum_id = t.forum_id";
|
2003-05-05 22:48:17 +00:00
|
|
|
$forum_validate = $topic_validate = $post_validate = true;
|
2003-02-28 12:57:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'topicreview':
|
|
|
|
if (!$topic_id)
|
|
|
|
{
|
|
|
|
trigger_error($user->lang['NO_TOPIC']);
|
|
|
|
}
|
|
|
|
|
|
|
|
topic_review($topic_id, false);
|
2002-10-30 18:59:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'smilies':
|
|
|
|
generate_smilies('window');
|
2002-10-04 13:09:10 +00:00
|
|
|
break;
|
2001-09-06 00:29:07 +00:00
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
default:
|
2003-02-26 00:37:43 +00:00
|
|
|
trigger_error($user->lang['NO_MODE']);
|
2002-02-18 12:34:38 +00:00
|
|
|
}
|
2001-07-06 01:09:42 +00:00
|
|
|
|
2003-05-01 18:24:18 +00:00
|
|
|
$message_parser = new parse_message(0); // <- TODO: add constant (MSG_POST/MSG_PM)
|
|
|
|
|
2002-10-30 00:57:27 +00:00
|
|
|
if ($sql != '')
|
2002-10-28 00:08:18 +00:00
|
|
|
{
|
|
|
|
$result = $db->sql_query($sql);
|
2003-01-22 16:35:06 +00:00
|
|
|
|
2003-03-12 16:34:40 +00:00
|
|
|
$row = $db->sql_fetchrow($result);
|
2002-10-28 00:08:18 +00:00
|
|
|
$db->sql_freeresult($result);
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2003-04-23 22:00:32 +00:00
|
|
|
// temp temp temp
|
|
|
|
$postrow = $row;
|
|
|
|
$quote_username = (!empty($row['username'])) ? $row['username'] : $row['post_username'];
|
|
|
|
|
2003-03-12 16:34:40 +00:00
|
|
|
$forum_id = intval($row['forum_id']);
|
|
|
|
$topic_id = intval($row['topic_id']);
|
|
|
|
$post_id = intval($row['post_id']);
|
|
|
|
|
2003-05-08 01:14:14 +00:00
|
|
|
$user->setup(false, $row['forum_style']);
|
|
|
|
|
2003-05-03 23:58:45 +00:00
|
|
|
if ($row['forum_password'])
|
|
|
|
{
|
|
|
|
login_forum_box($row);
|
|
|
|
}
|
|
|
|
|
2003-03-20 13:21:58 +00:00
|
|
|
foreach ($forum_fields as $var => $type)
|
2003-03-12 16:34:40 +00:00
|
|
|
{
|
|
|
|
switch ($type)
|
|
|
|
{
|
|
|
|
case 'i':
|
|
|
|
$$var = ($forum_validate) ? intval($row[$var]) : false;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
$$var = ($forum_validate) ? trim($row[$var]) : '';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$$var = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-20 13:21:58 +00:00
|
|
|
foreach ($topic_fields as $var => $type)
|
2003-03-12 16:34:40 +00:00
|
|
|
{
|
|
|
|
switch ($type)
|
|
|
|
{
|
|
|
|
case 'i':
|
|
|
|
$$var = ($topic_validate) ? intval($row[$var]) : false;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
$$var = ($topic_validate) ? trim($row[$var]) : '';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$$var = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-20 13:21:58 +00:00
|
|
|
foreach ($post_fields as $var => $type)
|
2003-03-12 16:34:40 +00:00
|
|
|
{
|
|
|
|
switch ($type)
|
|
|
|
{
|
|
|
|
case 'i':
|
|
|
|
$$var = ($post_validate) ? intval($row[$var]) : false;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
$$var = ($post_validate) ? trim($row[$var]) : '';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$$var = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$post_subject = ($post_validate) ? $post_subject : $topic_title;
|
|
|
|
|
|
|
|
$poll_length = ($poll_length) ? $poll_length/3600 : $poll_length;
|
2003-03-10 19:39:50 +00:00
|
|
|
$poll_options = array();
|
|
|
|
|
|
|
|
// Get Poll Data
|
|
|
|
if ($poll_start)
|
|
|
|
{
|
|
|
|
$sql = "SELECT poll_option_text
|
2003-03-20 13:21:58 +00:00
|
|
|
FROM " . POLL_OPTIONS_TABLE . "
|
|
|
|
WHERE topic_id = " . $topic_id . "
|
|
|
|
ORDER BY poll_option_id";
|
2003-03-10 19:39:50 +00:00
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
$poll_options[] = trim($row['poll_option_text']);
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
}
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2003-05-01 18:24:18 +00:00
|
|
|
$message_parser->filename_data['filecomment'] = ( isset($_POST['filecomment']) ) ? trim( strip_tags($_POST['filecomment'])) : '';
|
|
|
|
$message_parser->filename_data['filename'] = ( $_FILES['fileupload']['name'] != 'none' ) ? trim($_FILES['fileupload']['name']) : '';
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
|
|
// Get Attachment Data
|
2003-05-01 18:24:18 +00:00
|
|
|
$message_parser->attachment_data = (isset($_POST['attachment_data'])) ? $_POST['attachment_data'] : array();
|
2003-05-02 15:50:11 +00:00
|
|
|
|
|
|
|
if ($post_attachment && !$submit && !$refresh && !$preview && $mode == 'edit')
|
2003-03-22 15:48:46 +00:00
|
|
|
{
|
2003-05-01 18:24:18 +00:00
|
|
|
$sql = 'SELECT d.*
|
|
|
|
FROM ' . ATTACHMENTS_TABLE . ' a, ' . ATTACHMENTS_DESC_TABLE . ' d
|
|
|
|
WHERE a.post_id = ' . $post_id . '
|
2003-03-22 15:48:46 +00:00
|
|
|
AND a.attach_id = d.attach_id
|
2003-05-01 18:24:18 +00:00
|
|
|
ORDER BY d.filetime ' . ((!$config['display_order']) ? 'DESC' : 'ASC');
|
2003-03-22 15:48:46 +00:00
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
2003-05-01 18:24:18 +00:00
|
|
|
$message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result));
|
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
$db->sql_freeresult($result);
|
|
|
|
}
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($poster_id == ANONYMOUS || !$poster_id)
|
2003-02-28 12:57:10 +00:00
|
|
|
{
|
|
|
|
$username = ($post_validate) ? trim($post_username) : '';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$username = ($post_validate) ? trim($username) : '';
|
|
|
|
}
|
2002-10-30 00:57:27 +00:00
|
|
|
|
2003-03-12 16:34:40 +00:00
|
|
|
$enable_urls = $enable_magic_url;
|
|
|
|
|
|
|
|
if (!$post_validate)
|
|
|
|
{
|
|
|
|
$enable_sig = (intval($config['allow_sig']) && $user->data['user_attachsig']) ? true : false;
|
|
|
|
$enable_smilies = (intval($config['allow_smilies']) && $user->data['user_allowsmile']) ? true : false;
|
|
|
|
$enable_bbcode = (intval($config['allow_bbcode']) && $user->data['user_allowbbcode']) ? true : false;
|
|
|
|
$enable_urls = true;
|
|
|
|
}
|
|
|
|
|
2003-03-02 13:32:53 +00:00
|
|
|
$enable_magic_url = false;
|
2003-02-28 12:57:10 +00:00
|
|
|
}
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2002-10-30 00:57:27 +00:00
|
|
|
// Notify user checkbox
|
2003-01-22 16:35:06 +00:00
|
|
|
if ($mode != 'post' && $user->data['user_id'] != ANONYMOUS)
|
2002-10-30 00:57:27 +00:00
|
|
|
{
|
|
|
|
$sql = "SELECT topic_id
|
2003-03-20 13:21:58 +00:00
|
|
|
FROM " . TOPICS_WATCH_TABLE . "
|
|
|
|
WHERE topic_id = " . $topic_id . "
|
|
|
|
AND user_id = " . $user->data['user_id'];
|
2002-10-30 00:57:27 +00:00
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
$notify_set = ($db->sql_fetchrow($result)) ? true : false;
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
}
|
|
|
|
|
2003-02-27 12:56:36 +00:00
|
|
|
// Collect general Permissions to be used within the complete page
|
|
|
|
$perm = array(
|
2003-05-02 15:50:11 +00:00
|
|
|
'm_lock' => $auth->acl_get('m_lock', $forum_id),
|
|
|
|
'm_edit' => $auth->acl_get('m_edit', $forum_id),
|
|
|
|
'm_delete' => $auth->acl_get('m_delete', $forum_id),
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
'u_delete' => $auth->acl_get('f_delete', $forum_id),
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
'f_attach' => $auth->acl_get('f_attach', $forum_id),
|
|
|
|
'f_news' => $auth->acl_get('f_news', $forum_id),
|
|
|
|
'f_announce' => $auth->acl_get('f_announce', $forum_id),
|
|
|
|
'f_sticky' => $auth->acl_get('f_sticky', $forum_id),
|
2003-04-10 21:35:31 +00:00
|
|
|
'f_ignoreflood' => $auth->acl_get('f_ignoreflood', $forum_id),
|
2003-05-02 15:50:11 +00:00
|
|
|
'f_sigs' => $auth->acl_get('f_sigs', $forum_id),
|
|
|
|
'f_save' => $auth->acl_get('f_save', $forum_id)
|
2003-02-27 12:56:36 +00:00
|
|
|
);
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
if (!$auth->acl_get('f_' . $mode, $forum_id) && $forum_type == FORUM_POST)
|
2002-10-20 19:19:07 +00:00
|
|
|
{
|
2003-02-26 00:37:43 +00:00
|
|
|
trigger_error($user->lang['USER_CANNOT_' . strtoupper($mode)]);
|
2002-10-28 00:08:18 +00:00
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
2002-11-01 12:23:08 +00:00
|
|
|
// Forum/Topic locked?
|
2003-05-02 15:50:11 +00:00
|
|
|
if (($forum_status == ITEM_LOCKED || $topic_status == ITEM_LOCKED) && !$perm['m_edit'])
|
2002-11-01 12:23:08 +00:00
|
|
|
{
|
2003-02-27 23:37:02 +00:00
|
|
|
$message = ($forum_status == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED';
|
2002-11-01 12:23:08 +00:00
|
|
|
trigger_error($user->lang[$message]);
|
|
|
|
}
|
|
|
|
|
2002-10-30 00:57:27 +00:00
|
|
|
// Can we edit this post?
|
2003-05-02 15:50:11 +00:00
|
|
|
if (($mode == 'edit' || $mode == 'delete') && !$perm['m_edit'] && $config['edit_time'] && $post_time > time() - $config['edit_time'])
|
2002-10-28 00:08:18 +00:00
|
|
|
{
|
2003-02-26 00:37:43 +00:00
|
|
|
trigger_error($user->lang['CANNOT_EDIT_TIME']);
|
2002-10-04 13:09:10 +00:00
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
|
2003-02-26 19:53:10 +00:00
|
|
|
// Do we want to edit our post ?
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($mode == 'edit' && !$perm['m_edit'] && $user->data['user_id'] != $poster_id)
|
2003-02-26 19:53:10 +00:00
|
|
|
{
|
2003-02-27 23:37:02 +00:00
|
|
|
trigger_error($user->lang['USER_CANNOT_EDIT']);
|
2003-02-26 19:53:10 +00:00
|
|
|
}
|
|
|
|
|
2003-04-12 14:30:21 +00:00
|
|
|
// Is edit posting locked ?
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($mode == 'edit' && $post_edit_locked && !$auth->acl_get('m_', $forum_id))
|
2003-04-12 14:30:21 +00:00
|
|
|
{
|
|
|
|
trigger_error($user->lang['CANNOT_EDIT_POST_LOCKED']);
|
|
|
|
}
|
|
|
|
|
2003-04-16 21:16:57 +00:00
|
|
|
if ($mode == 'edit')
|
|
|
|
{
|
|
|
|
$message_parser->bbcode_uid = $row['bbcode_uid'];
|
|
|
|
}
|
|
|
|
|
2003-03-02 13:32:53 +00:00
|
|
|
// Delete triggered ?
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($mode == 'delete' && (($poster_id == $user->data['user_id'] && $user->data['user_id'] != ANONYMOUS && $perm['u_delete'] && $post_id == $topic_last_post_id) || $perm['m_delete']))
|
2003-03-02 13:32:53 +00:00
|
|
|
{
|
|
|
|
// Do we need to confirm ?
|
|
|
|
if ($confirm)
|
|
|
|
{
|
|
|
|
$post_data = array(
|
|
|
|
'topic_first_post_id' => $topic_first_post_id,
|
|
|
|
'topic_last_post_id' => $topic_last_post_id,
|
|
|
|
'user_id' => $poster_id
|
|
|
|
);
|
|
|
|
|
2003-04-18 13:07:19 +00:00
|
|
|
$search = new fulltext_search();
|
|
|
|
|
|
|
|
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
|
|
|
|
2003-04-19 10:28:37 +00:00
|
|
|
$topic_sql = array();
|
2003-05-05 22:48:17 +00:00
|
|
|
$forum_update_sql = $user_update_sql = '';
|
2003-04-19 10:28:37 +00:00
|
|
|
$topic_update_sql = 'topic_replies = topic_replies - 1, topic_replies_real = topic_replies_real - 1';
|
|
|
|
|
2003-04-18 13:07:19 +00:00
|
|
|
// User tries to delete the post twice ? Exit... we do not want the topics table screwed up.
|
2003-04-19 10:28:37 +00:00
|
|
|
if (!delete_posts('post_id', array($post_id), FALSE))
|
2003-04-18 13:07:19 +00:00
|
|
|
{
|
|
|
|
trigger_error($user->lang['ALREADY_DELETED']);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only one post... delete topic
|
|
|
|
if ($post_data['topic_first_post_id'] == $post_data['topic_last_post_id'])
|
|
|
|
{
|
2003-04-19 10:28:37 +00:00
|
|
|
delete_topics('topic_id', array($topic_id), FALSE);
|
|
|
|
$forum_update_sql .= ($forum_update_sql != '') ? ', ' : '';
|
|
|
|
$forum_update_sql .= 'forum_topics = forum_topics - 1, forum_topics_real = forum_topics_real - 1';
|
2003-04-18 13:07:19 +00:00
|
|
|
}
|
|
|
|
|
2003-04-19 10:28:37 +00:00
|
|
|
// Sync last post informations
|
|
|
|
$db->sql_transaction();
|
|
|
|
|
|
|
|
$forum_update_sql .= ($forum_update_sql != '') ? ', forum_posts = forum_posts - 1' : 'forum_posts = forum_posts - 1';
|
|
|
|
|
|
|
|
if ($auth->acl_get('f_postcount', $forum_id))
|
|
|
|
{
|
|
|
|
$user_update_sql .= ($user_update_sql != '') ? ', user_posts = user_posts - 1' : 'user_posts = user_posts - 1';
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = "SELECT p.post_id, p.poster_id, p.post_username, u.username
|
|
|
|
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
|
|
|
|
WHERE p.topic_id = " . $topic_id . "
|
|
|
|
AND p.poster_id = u.user_id
|
|
|
|
AND p.post_approved = 1
|
|
|
|
ORDER BY p.post_time DESC";
|
|
|
|
$result = $db->sql_query_limit($sql, 1);
|
|
|
|
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
// If Post is first post, but not the only post... make next post the topic starter one. ;)
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($post_data['topic_first_post_id'] != $post_data['topic_last_post_id'] && $post_id == $post_data['topic_first_post_id'])
|
2003-04-19 10:28:37 +00:00
|
|
|
{
|
|
|
|
$topic_sql = array(
|
2003-05-02 15:50:11 +00:00
|
|
|
'topic_first_post_id' => intval($row['post_id']),
|
|
|
|
'topic_first_poster_name' => ($row['poster_id'] == ANONYMOUS) ? trim($row['post_username']) : trim($row['username'])
|
2003-04-19 10:28:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$post_data['next_post_id'] = intval($row['post_id']);
|
|
|
|
|
|
|
|
// Update Forum, Topic and User with the gathered Informations
|
|
|
|
if ($forum_update_sql != '')
|
|
|
|
{
|
|
|
|
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
|
|
SET ' . $forum_update_sql . '
|
|
|
|
WHERE forum_id = ' . $forum_id;
|
|
|
|
$db->sql_query($sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($topic_update_sql != '' || count($topic_sql) > 0)
|
|
|
|
{
|
|
|
|
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
|
|
SET ' . ( (count($topic_sql) > 0) ? $db->sql_build_array('UPDATE', $topic_sql) : '') . ( ($topic_update_sql != '') ? ((count($topic_sql) > 0) ? ', ' . $topic_update_sql : $topic_update_sql) : '') . '
|
|
|
|
WHERE topic_id = ' . $topic_id;
|
|
|
|
$db->sql_query($sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($user_update_sql != '')
|
|
|
|
{
|
|
|
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
|
|
|
SET ' . $user_update_sql . '
|
|
|
|
WHERE user_id = ' . $post_data['user_id'];
|
|
|
|
$db->sql_query($sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update Forum stats...
|
|
|
|
if ($post_data['topic_first_post_id'] != $post_data['topic_last_post_id'])
|
|
|
|
{
|
|
|
|
update_last_post_information('topic', $topic_id);
|
|
|
|
}
|
|
|
|
update_last_post_information('forum', $forum_id);
|
2003-05-05 22:48:17 +00:00
|
|
|
|
2003-04-19 10:28:37 +00:00
|
|
|
$db->sql_transaction('commit');
|
|
|
|
|
2003-04-18 13:07:19 +00:00
|
|
|
if ($post_data['topic_first_post_id'] == $post_data['topic_last_post_id'])
|
|
|
|
{
|
2003-05-05 22:48:17 +00:00
|
|
|
$meta_info = "viewforum.$phpEx$SID&f=$forum_id";
|
2003-04-18 13:07:19 +00:00
|
|
|
$message = $user->lang['DELETED'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-05-05 22:48:17 +00:00
|
|
|
$meta_info = "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=" . $post_data['next_post_id'] . '#' . $post_data['next_post_id'];
|
|
|
|
$message = $user->lang['DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], "<a href=\"viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=" . $post_data['next_post_id'] . '#' . $post_data['next_post_id'] . '">', '</a>');
|
2003-04-18 13:07:19 +00:00
|
|
|
}
|
|
|
|
|
2003-05-05 22:48:17 +00:00
|
|
|
meta_refresh(3, $meta_info);
|
|
|
|
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], "<a href=\"viewforum.$phpEx$SID&f=$forum_id\">", '</a>');
|
2003-04-18 13:07:19 +00:00
|
|
|
trigger_error($message);
|
2003-03-02 13:32:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$s_hidden_fields = '<input type="hidden" name="p" value="' . $post_id . '" /><input type="hidden" name="mode" value="delete" />';
|
|
|
|
|
2003-05-03 23:58:45 +00:00
|
|
|
page_header($user->lang['DELETE_MESSAGE']);
|
2003-03-02 13:32:53 +00:00
|
|
|
|
|
|
|
$template->set_filenames(array(
|
|
|
|
'body' => 'confirm_body.html')
|
|
|
|
);
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2003-05-02 15:50:11 +00:00
|
|
|
'MESSAGE_TITLE' => $user->lang['DELETE_MESSAGE'],
|
|
|
|
'MESSAGE_TEXT' => $user->lang['CONFIRM_DELETE'],
|
2003-03-02 13:32:53 +00:00
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
'S_CONFIRM_ACTION' => $phpbb_root_path . 'posting.' . $phpEx . $SID,
|
|
|
|
'S_HIDDEN_FIELDS' => $s_hidden_fields)
|
2003-03-02 13:32:53 +00:00
|
|
|
);
|
|
|
|
|
2003-05-03 23:58:45 +00:00
|
|
|
page_footer();
|
2003-03-02 13:32:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($mode == 'delete' && $poster_id != $user->data['user_id'] && !$perm['u_delete'])
|
2003-03-02 13:32:53 +00:00
|
|
|
{
|
|
|
|
trigger_error($user->lang['DELETE_OWN_POSTS']);
|
|
|
|
}
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($mode == 'delete' && $poster_id == $user->data['user_id'] && $perm['u_delete'] && $post_id != $topic_last_post_id)
|
2003-03-02 13:32:53 +00:00
|
|
|
{
|
|
|
|
trigger_error($user->lang['CANNOT_DELETE_REPLIED']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($mode == 'delete')
|
|
|
|
{
|
|
|
|
trigger_error('USER_CANNOT_DELETE');
|
|
|
|
}
|
2002-11-07 22:02:49 +00:00
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($submit || $preview || $refresh)
|
2002-10-04 13:09:10 +00:00
|
|
|
{
|
2003-02-27 23:37:02 +00:00
|
|
|
$topic_cur_post_id = (isset($_POST['topic_cur_post_id'])) ? intval($_POST['topic_cur_post_id']) : false;
|
|
|
|
$subject = (!empty($_POST['subject'])) ? trim(htmlspecialchars(strip_tags($_POST['subject']))) : '';
|
2003-03-10 19:39:50 +00:00
|
|
|
|
2003-05-05 22:48:17 +00:00
|
|
|
if (strcmp($subject, strtoupper($subject)) == 0 && $subject != '')
|
2003-03-10 19:39:50 +00:00
|
|
|
{
|
|
|
|
$subject = phpbb_strtolower($subject);
|
|
|
|
}
|
|
|
|
|
2003-04-13 23:20:26 +00:00
|
|
|
$message_parser->message = (!empty($_POST['message'])) ? trim(stripslashes($_POST['message'])) : '';
|
2003-04-22 16:47:34 +00:00
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
$username = (!empty($_POST['username'])) ? trim($_POST['username']) : '';
|
|
|
|
$topic_type = (!empty($_POST['topic_type'])) ? intval($_POST['topic_type']) : POST_NORMAL;
|
|
|
|
$icon_id = (!empty($_POST['icon'])) ? intval($_POST['icon']) : 0;
|
|
|
|
|
2003-04-23 22:00:32 +00:00
|
|
|
/*
|
|
|
|
$enable_html = ($config['allow_html'] && empty($_POST['disable_html']) && $auth->acl_get('f_html', $forum_id)) ? TRUE : FALSE;
|
|
|
|
$enable_bbcode = ($config['allow_bbcode'] && empty($_POST['disable_bbcode']) && $auth->acl_get('f_bbcode', $forum_id)) ? TRUE : FALSE;
|
|
|
|
$enable_smilies = ($config['allow_smilies'] && empty($_POST['disable_smilies']) && $auth->acl_get('f_smilies', $forum_id)) ? TRUE : FALSE;
|
|
|
|
$enable_sig = ($config['allow_sig'] && !empty($_POST['attach_sig']) && $auth->acl_get('f_sigs', $forum_id)) ? TRUE : FALSE;
|
|
|
|
*/
|
2003-05-05 22:48:17 +00:00
|
|
|
$enable_html = (!$config['allow_html']) ? 0 : ((!empty($_POST['disable_html'])) ? 0 : 1);
|
|
|
|
$enable_bbcode = (!$config['allow_bbcode']) ? 0 : ((!empty($_POST['disable_bbcode'])) ? 0 : 1);
|
|
|
|
$enable_smilies = (!$config['allow_smilies']) ? 0 : ((!empty($_POST['disable_smilies'])) ? 0 : 1);
|
2003-03-02 13:32:53 +00:00
|
|
|
$enable_urls = (isset($_POST['disable_magic_url'])) ? 0 : 1;
|
2003-05-05 22:48:17 +00:00
|
|
|
$enable_sig = (!$config['allow_sig']) ? false : ((!empty($_POST['attach_sig'])) ? true : false);
|
2003-04-23 22:00:32 +00:00
|
|
|
|
2003-03-10 19:39:50 +00:00
|
|
|
$notify = (!empty($_POST['notify'])) ? true : false;
|
2003-04-12 14:30:21 +00:00
|
|
|
$topic_lock = (isset($_POST['lock_topic'])) ? true : false;
|
|
|
|
$post_lock = (isset($_POST['lock_post'])) ? true : false;
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
|
|
$poll_delete = (isset($_POST['poll_delete'])) ? true : false;
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($poll_delete && (($mode == 'edit' && !empty($poll_options) && empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $perm['u_delete']) || $perm['m_delete']))
|
2003-03-10 19:39:50 +00:00
|
|
|
{
|
2003-04-18 13:07:19 +00:00
|
|
|
// Delete Poll
|
|
|
|
$sql = "DELETE FROM " . POLL_OPTIONS_TABLE . "
|
|
|
|
WHERE topic_id = " . $topic_id;
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
|
|
|
$sql = "DELETE FROM " . POLL_VOTES_TABLE . "
|
|
|
|
WHERE topic_id = " . $topic_id;
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
|
|
|
$topic_sql = array(
|
2003-04-22 16:47:34 +00:00
|
|
|
'poll_title' => '',
|
|
|
|
'poll_start' => 0,
|
|
|
|
'poll_length' => 0,
|
|
|
|
'poll_last_vote' => 0,
|
|
|
|
'poll_max_options' => 0
|
2003-04-18 13:07:19 +00:00
|
|
|
);
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
|
|
SET ' . $db->sql_build_array('UPDATE', $topic_sql) . '
|
|
|
|
WHERE topic_id = ' . $topic_id;
|
2003-04-18 13:07:19 +00:00
|
|
|
$db->sql_query($sql);
|
2003-03-10 19:39:50 +00:00
|
|
|
|
2003-05-05 22:48:17 +00:00
|
|
|
$poll_title = $poll_length = $poll_option_text = $poll_max_options = '';
|
2003-03-10 19:39:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$poll_title = (!empty($_POST['poll_title'])) ? trim($_POST['poll_title']) : '';
|
|
|
|
$poll_length = (!empty($_POST['poll_length'])) ? $_POST['poll_length'] : '';
|
|
|
|
$poll_option_text = (!empty($_POST['poll_option_text'])) ? $_POST['poll_option_text'] : '';
|
2003-04-22 16:47:34 +00:00
|
|
|
$poll_max_options = (!empty($_POST['poll_max_options'])) ? $_POST['poll_max_options'] : 1;
|
2003-03-10 19:39:50 +00:00
|
|
|
}
|
2003-02-27 23:37:02 +00:00
|
|
|
|
|
|
|
$err_msg = '';
|
|
|
|
$current_time = time();
|
|
|
|
|
2002-11-21 01:35:53 +00:00
|
|
|
// If replying/quoting and last post id has changed
|
|
|
|
// give user option of continuing submit or return to post
|
2003-02-26 13:17:45 +00:00
|
|
|
// notify and show user the post made between his request and the final submit
|
2003-05-02 15:50:11 +00:00
|
|
|
if (($mode == 'reply' || $mode == 'quote') && $topic_cur_post_id != $topic_last_post_id)
|
2002-11-21 01:35:53 +00:00
|
|
|
{
|
2003-04-20 16:49:26 +00:00
|
|
|
$template->assign_vars(array(
|
|
|
|
'S_POST_REVIEW' => true)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Define censored word matches
|
|
|
|
if (empty($censors))
|
|
|
|
{
|
|
|
|
$censors = array();
|
|
|
|
obtain_word_list($censors);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go ahead and pull all data for the remaining posts
|
|
|
|
$sql = "SELECT u.username, u.user_id, p.*
|
|
|
|
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
|
|
|
|
WHERE p.topic_id = $topic_id
|
|
|
|
AND p.poster_id = u.user_id
|
|
|
|
AND p.post_id > " . $topic_cur_post_id . "
|
2003-04-20 19:46:15 +00:00
|
|
|
AND p.post_approved = 1
|
2003-04-20 16:49:26 +00:00
|
|
|
ORDER BY p.post_time DESC";
|
|
|
|
$result = $db->sql_query_limit($sql, $config['posts_per_page']);
|
|
|
|
|
|
|
|
if ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
$i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
$poster_id = $row['user_id'];
|
|
|
|
$poster = $row['username'];
|
|
|
|
|
|
|
|
// Handle anon users posting with usernames
|
|
|
|
if ($poster_id == ANONYMOUS && $row['post_username'] != '')
|
|
|
|
{
|
|
|
|
$poster = $row['post_username'];
|
|
|
|
$poster_rank = $user->lang['GUEST'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : '';
|
|
|
|
|
|
|
|
$message = $row['post_text'];
|
|
|
|
|
|
|
|
$message = (empty($row['enable_smilies']) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $message);
|
|
|
|
|
|
|
|
if (count($censors['match']))
|
|
|
|
{
|
|
|
|
$post_subject = preg_replace($censors['match'], $censors['replace'], $post_subject);
|
|
|
|
$message = preg_replace($censors['match'], $censors['replace'], $message);
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_block_vars('post_postrow', array(
|
|
|
|
'MINI_POST_IMG' => $user->img('icon_post', $user->lang['POST']),
|
|
|
|
'POSTER_NAME' => $poster,
|
|
|
|
'POST_DATE' => $user->format_date($row['post_time']),
|
|
|
|
'POST_SUBJECT' => $post_subject,
|
|
|
|
'MESSAGE' => nl2br($message),
|
|
|
|
|
|
|
|
'S_ROW_COUNT' => $i++)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
while ($row = $db->sql_fetchrow($result));
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
$submit = FALSE;
|
|
|
|
$refresh = TRUE;
|
2002-11-21 01:35:53 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 16:35:06 +00:00
|
|
|
// Grab md5 'checksum' of new message
|
2003-04-11 19:51:38 +00:00
|
|
|
$message_md5 = md5($message_parser->message);
|
2002-10-30 00:57:27 +00:00
|
|
|
|
|
|
|
// Check checksum ... don't re-parse message if the same
|
2003-04-23 22:00:32 +00:00
|
|
|
// TODO: parse message if any of enable_* switches has changed
|
2003-01-22 16:35:06 +00:00
|
|
|
if ($mode != 'edit' || $message_md5 != $post_checksum)
|
2002-10-04 13:09:10 +00:00
|
|
|
{
|
2002-10-28 00:08:18 +00:00
|
|
|
// Parse message
|
2003-04-23 22:00:32 +00:00
|
|
|
if ($result = $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $auth->acl_get('f_img', $forum_id), $auth->acl_get('f_flash', $forum_id)))
|
2002-10-28 00:08:18 +00:00
|
|
|
{
|
|
|
|
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-11 16:21:35 +00:00
|
|
|
$result = $message_parser->parse_attachments($mode, $post_id, $submit, $preview, $refresh);
|
|
|
|
|
|
|
|
if (count($result))
|
2003-03-22 15:48:46 +00:00
|
|
|
{
|
2003-05-11 16:21:35 +00:00
|
|
|
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . implode('<br />', $result);
|
2003-03-22 15:48:46 +00:00
|
|
|
}
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($mode != 'edit' && !$preview && !$refresh && !$perm['f_ignoreflood'])
|
2002-10-28 00:08:18 +00:00
|
|
|
{
|
|
|
|
// Flood check
|
|
|
|
$where_sql = ($user->data['user_id'] == ANONYMOUS) ? "poster_ip = '$user->ip'" : 'poster_id = ' . $user->data['user_id'];
|
|
|
|
$sql = "SELECT MAX(post_time) AS last_post_time
|
|
|
|
FROM " . POSTS_TABLE . "
|
2003-03-20 13:21:58 +00:00
|
|
|
WHERE " . $where_sql;
|
2002-10-28 00:08:18 +00:00
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
if ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
2003-04-10 19:11:09 +00:00
|
|
|
if (intval($row['last_post_time']) && ($current_time - intval($row['last_post_time'])) < intval($config['flood_interval']))
|
2002-10-28 00:08:18 +00:00
|
|
|
{
|
2002-11-09 00:47:14 +00:00
|
|
|
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['FLOOD_ERROR'];
|
2002-10-28 00:08:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate username
|
2003-01-22 16:35:06 +00:00
|
|
|
if (($username != '' && $user->data['user_id'] == ANONYMOUS) || ($mode == 'edit' && $post_username != ''))
|
2002-10-28 00:08:18 +00:00
|
|
|
{
|
2003-04-22 19:44:00 +00:00
|
|
|
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
2003-03-10 19:39:50 +00:00
|
|
|
$userdata = new userdata();
|
2002-10-28 00:08:18 +00:00
|
|
|
$username = strip_tags(htmlspecialchars($username));
|
2003-03-10 19:39:50 +00:00
|
|
|
if (($result = $userdata->validate_username($username)) != false)
|
2002-10-28 00:08:18 +00:00
|
|
|
{
|
2002-10-30 00:57:27 +00:00
|
|
|
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result;
|
2002-10-28 00:08:18 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-15 22:54:48 +00:00
|
|
|
|
2002-10-28 00:08:18 +00:00
|
|
|
// Parse subject
|
2003-05-02 15:50:11 +00:00
|
|
|
if ($subject == '' && ($mode == 'post' || ($mode == 'edit' && $topic_first_post_id == $post_id)))
|
2002-10-28 00:08:18 +00:00
|
|
|
{
|
2003-02-26 19:53:10 +00:00
|
|
|
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['EMPTY_SUBJECT'];
|
2002-02-18 12:34:38 +00:00
|
|
|
}
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2003-03-10 19:39:50 +00:00
|
|
|
$poll_data = array(
|
|
|
|
'poll_title' => $poll_title,
|
|
|
|
'poll_length' => $poll_length,
|
2003-04-22 16:47:34 +00:00
|
|
|
'poll_max_options' => $poll_max_options,
|
2003-03-10 19:39:50 +00:00
|
|
|
'poll_option_text' => $poll_option_text,
|
|
|
|
'poll_start' => $poll_start,
|
|
|
|
'poll_last_vote' => $poll_last_vote,
|
|
|
|
'enable_html' => $enable_html,
|
|
|
|
'enable_bbcode' => $enable_bbcode,
|
2003-04-11 19:51:38 +00:00
|
|
|
'bbcode_uid' => $message_parser->bbcode_uid,
|
2003-03-10 19:39:50 +00:00
|
|
|
'enable_urls' => $enable_urls,
|
|
|
|
'enable_smilies' => $enable_smilies
|
|
|
|
);
|
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
$poll = array();
|
2003-03-12 14:21:57 +00:00
|
|
|
if (($result = $message_parser->parse_poll($poll, $poll_data)) != '')
|
2003-03-10 19:39:50 +00:00
|
|
|
{
|
|
|
|
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
$poll_options = $poll['poll_options'];
|
|
|
|
$poll_title = $poll['poll_title'];
|
2002-10-30 00:57:27 +00:00
|
|
|
|
|
|
|
// Check topic type
|
|
|
|
if ($topic_type != POST_NORMAL)
|
|
|
|
{
|
|
|
|
$auth_option = '';
|
|
|
|
switch ($topic_type)
|
|
|
|
{
|
2003-05-05 22:48:17 +00:00
|
|
|
case POST_GLOBAL:
|
|
|
|
$auth_option = 'global';
|
2002-10-30 00:57:27 +00:00
|
|
|
break;
|
2003-02-26 19:53:10 +00:00
|
|
|
case POST_ANNOUNCE:
|
2003-02-27 12:56:36 +00:00
|
|
|
$auth_option = 'announce';
|
2002-10-30 00:57:27 +00:00
|
|
|
break;
|
2003-02-26 19:53:10 +00:00
|
|
|
case POST_STICKY:
|
2003-02-27 12:56:36 +00:00
|
|
|
$auth_option = 'sticky';
|
2002-10-30 00:57:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-02-27 12:56:36 +00:00
|
|
|
if (!$perm['f_' . $auth_option])
|
2002-10-30 00:57:27 +00:00
|
|
|
{
|
2003-02-27 12:56:36 +00:00
|
|
|
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['CANNOT_POST_' . strtoupper($auth_option)];
|
2002-10-30 00:57:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-28 20:39:06 +00:00
|
|
|
// Store message, sync counters
|
2003-04-20 16:49:26 +00:00
|
|
|
if ($err_msg == '' && $submit)
|
2002-10-28 00:08:18 +00:00
|
|
|
{
|
2003-04-12 14:30:21 +00:00
|
|
|
// Lock/Unlock Topic
|
|
|
|
$change_topic_status = $topic_status;
|
|
|
|
|
|
|
|
if ($topic_status == ITEM_LOCKED && !$topic_lock && $perm['m_lock'])
|
|
|
|
{
|
|
|
|
$change_topic_status = ITEM_UNLOCKED;
|
|
|
|
}
|
|
|
|
else if ($topic_status == ITEM_UNLOCKED && $topic_lock && $perm['m_lock'])
|
|
|
|
{
|
|
|
|
$change_topic_status = ITEM_LOCKED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($change_topic_status != $topic_status)
|
|
|
|
{
|
|
|
|
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
|
|
|
|
|
|
|
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
|
|
SET topic_status = ' . $change_topic_status . '
|
|
|
|
WHERE topic_id = ' . $topic_id . '
|
|
|
|
AND topic_moved_id = 0';
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
|
|
|
add_log('mod', $forum_id, $topic_id, 'logm_' . (($change_topic_status == ITEM_LOCKED) ? 'lock' : 'unlock'));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lock/Unlock Post Edit
|
|
|
|
if ($mode == 'edit' && $post_edit_locked == ITEM_LOCKED && !$post_lock && $perm['m_edit'])
|
|
|
|
{
|
|
|
|
$post_edit_locked = ITEM_UNLOCKED;
|
|
|
|
}
|
|
|
|
else if ($mode == 'edit' && $post_edit_locked == ITEM_UNLOCKED && $post_lock && $perm['m_edit'])
|
|
|
|
{
|
|
|
|
$post_edit_locked = ITEM_LOCKED;
|
|
|
|
}
|
|
|
|
|
2003-03-02 13:32:53 +00:00
|
|
|
$post_data = array(
|
2003-02-27 23:37:02 +00:00
|
|
|
'topic_first_post_id' => $topic_first_post_id,
|
|
|
|
'post_id' => $post_id,
|
|
|
|
'topic_id' => $topic_id,
|
|
|
|
'forum_id' => $forum_id,
|
|
|
|
'icon_id' => $icon_id,
|
|
|
|
'poster_id' => $poster_id,
|
2003-03-10 19:39:50 +00:00
|
|
|
'enable_sig' => $enable_sig,
|
2003-02-27 23:37:02 +00:00
|
|
|
'enable_bbcode' => $enable_bbcode,
|
|
|
|
'enable_html' => $enable_html,
|
|
|
|
'enable_smilies' => $enable_smilies,
|
|
|
|
'enable_urls' => $enable_urls,
|
|
|
|
'message_md5' => $message_md5,
|
|
|
|
'post_checksum' => $post_checksum,
|
|
|
|
'forum_parents' => $forum_parents,
|
|
|
|
'notify' => $notify,
|
2003-04-11 00:19:29 +00:00
|
|
|
'notify_set' => $notify_set,
|
2003-04-12 14:30:21 +00:00
|
|
|
'post_edit_locked' => $post_edit_locked,
|
2003-04-11 00:19:29 +00:00
|
|
|
'bbcode_bitfield' => $message_parser->bbcode_bitfield
|
2002-10-28 00:08:18 +00:00
|
|
|
);
|
2003-03-10 19:39:50 +00:00
|
|
|
|
2003-05-01 18:24:18 +00:00
|
|
|
submit_post($mode, $message_parser->message, $subject, $username, $topic_type, $message_parser->bbcode_uid, $poll, $message_parser->attachment_data, $message_parser->filename_data, $post_data);
|
2003-02-27 23:37:02 +00:00
|
|
|
}
|
2002-11-27 13:24:46 +00:00
|
|
|
|
2003-04-13 23:20:26 +00:00
|
|
|
$post_text = $message_parser->message;
|
2003-02-27 23:37:02 +00:00
|
|
|
$post_subject = $topic_title = stripslashes($subject);
|
|
|
|
}
|
2002-10-28 00:08:18 +00:00
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
if ($err_msg)
|
2003-02-26 19:53:10 +00:00
|
|
|
{
|
2003-02-27 23:37:02 +00:00
|
|
|
$preview = false;
|
|
|
|
}
|
2001-08-10 22:00:12 +00:00
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
if ($preview)
|
|
|
|
{
|
2003-02-26 19:53:10 +00:00
|
|
|
if (empty($censors))
|
|
|
|
{
|
|
|
|
$censors = array();
|
|
|
|
obtain_word_list($censors);
|
|
|
|
}
|
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
$post_time = $current_time;
|
2003-04-11 00:19:29 +00:00
|
|
|
|
|
|
|
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
2003-04-16 21:16:57 +00:00
|
|
|
$bbcode = new bbcode($message_parser->bbcode_bitfield);
|
2003-04-11 00:19:29 +00:00
|
|
|
|
2003-04-13 23:20:26 +00:00
|
|
|
$preview_message = format_display($message_parser->message, $enable_html, $enable_bbcode, $message_parser->bbcode_uid, $enable_urls, $enable_smilies, $enable_sig);
|
2003-05-11 16:21:35 +00:00
|
|
|
|
2003-03-10 19:39:50 +00:00
|
|
|
$preview_subject = (sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], $subject) : $subject;
|
|
|
|
|
|
|
|
// Poll Preview
|
2003-05-11 16:21:35 +00:00
|
|
|
if ( ($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && empty($poll_last_vote))) && ($auth->acl_get('f_poll', $forum_id) || $auth->acl_get('m_edit', $forum_id)) )
|
2003-02-27 23:37:02 +00:00
|
|
|
{
|
2003-04-11 19:51:38 +00:00
|
|
|
decode_text($poll_title, $message_parser->bbcode_uid);
|
|
|
|
$preview_poll_title = format_display(stripslashes($poll_title), $enable_html, $enable_bbcode, $message_parser->bbcode_uid, $enable_urls, $enable_smilies, false, false);
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'S_HAS_POLL_OPTIONS' => (sizeof($poll_options)) ? true : false,
|
2003-05-05 22:48:17 +00:00
|
|
|
'POLL_QUESTION' => $preview_poll_title)
|
2003-03-10 19:39:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($poll_options as $option)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('poll_option', array(
|
2003-04-11 19:51:38 +00:00
|
|
|
'POLL_OPTION_CAPTION' => format_display(stripslashes($option), $enable_html, $enable_bbcode, $message_parser->bbcode_uid, $enable_urls, $enable_smilies, false, false))
|
2003-03-10 19:39:50 +00:00
|
|
|
);
|
|
|
|
}
|
2003-02-27 23:37:02 +00:00
|
|
|
}
|
2003-02-26 19:53:10 +00:00
|
|
|
}
|
2001-12-16 18:13:34 +00:00
|
|
|
|
2003-03-10 19:39:50 +00:00
|
|
|
// Decode text for message display
|
2003-04-17 23:47:26 +00:00
|
|
|
$bbcode_uid = ($mode == 'quote' && !$preview) ? $row['bbcode_uid'] : $message_parser->bbcode_uid;
|
|
|
|
|
|
|
|
decode_text($post_text, $bbcode_uid);
|
2003-04-16 21:16:57 +00:00
|
|
|
if ($subject)
|
|
|
|
{
|
2003-04-17 23:47:26 +00:00
|
|
|
decode_text($subject, $bbcode_uid);
|
2003-04-16 21:16:57 +00:00
|
|
|
}
|
2003-02-27 23:37:02 +00:00
|
|
|
|
2003-03-12 14:21:57 +00:00
|
|
|
// Save us some processing time. ;)
|
2003-04-20 16:49:26 +00:00
|
|
|
if (count($poll_options))
|
2003-04-16 21:16:57 +00:00
|
|
|
{
|
|
|
|
$poll_options_tmp = implode("\n", $poll_options);
|
|
|
|
decode_text($poll_options_tmp);
|
|
|
|
$poll_options = explode("\n", $poll_options_tmp);
|
|
|
|
}
|
2003-03-10 19:39:50 +00:00
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
if (($mode == 'quote') && (!$preview) && (!$refresh))
|
2003-02-27 23:37:02 +00:00
|
|
|
{
|
2003-04-23 22:00:32 +00:00
|
|
|
$post_text = '[quote="' . $quote_username . '"]' . trim($post_text) . "[/quote]\n";
|
2003-02-27 23:37:02 +00:00
|
|
|
}
|
2001-08-10 22:00:12 +00:00
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
if ( (($mode == 'reply') || ($mode == 'quote')) && (!$preview) && (!$refresh))
|
2003-03-10 19:39:50 +00:00
|
|
|
{
|
|
|
|
$post_subject = ( ( !preg_match('/^Re:/', $post_subject) ) ? 'Re: ' : '' ) . $post_subject;
|
|
|
|
}
|
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
// MAIN POSTING PAGE BEGINS HERE
|
2002-11-07 22:02:49 +00:00
|
|
|
|
|
|
|
// Forum moderators?
|
2003-02-27 23:37:02 +00:00
|
|
|
get_moderators($moderators, $forum_id);
|
2001-06-13 17:36:58 +00:00
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
// Generate smilies and topic icon listings
|
|
|
|
generate_smilies('inline');
|
2001-08-10 22:00:12 +00:00
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
// Generate Topic icons
|
2003-04-18 13:07:19 +00:00
|
|
|
$s_topic_icons = false;
|
|
|
|
if ($enable_icons)
|
|
|
|
{
|
|
|
|
// Grab icons
|
|
|
|
$icons = array();
|
|
|
|
obtain_icons($icons);
|
|
|
|
|
|
|
|
if (sizeof($icons))
|
|
|
|
{
|
|
|
|
foreach ($icons as $id => $data)
|
|
|
|
{
|
|
|
|
if ($data['display'])
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('topic_icon', array(
|
|
|
|
'ICON_ID' => $id,
|
|
|
|
'ICON_IMG' => $phpbb_root_path . $config['icons_path'] . '/' . $data['img'],
|
|
|
|
'ICON_WIDTH' => $data['width'],
|
|
|
|
'ICON_HEIGHT' => $data['height'],
|
|
|
|
|
|
|
|
'S_ICON_CHECKED' => ($id == $icon_id && $mode != 'reply') ? ' checked="checked"' : '')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$s_topic_icons = true;
|
|
|
|
}
|
|
|
|
}
|
2002-10-28 00:08:18 +00:00
|
|
|
|
2003-02-26 19:53:10 +00:00
|
|
|
// Topic type selection ... only for first post in topic.
|
2002-02-18 12:34:38 +00:00
|
|
|
$topic_type_toggle = '';
|
2003-02-27 23:37:02 +00:00
|
|
|
if ( ($mode == 'post') || (($mode == 'edit') && ($post_id == $topic_first_post_id)) )
|
2001-06-13 17:36:58 +00:00
|
|
|
{
|
2003-02-26 19:53:10 +00:00
|
|
|
$topic_types = array(
|
|
|
|
'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'),
|
|
|
|
'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT')
|
2003-02-27 23:37:02 +00:00
|
|
|
// 'global_announce' => array('const' => POST_GLOBAL_ANNOUNCE, 'lang' => 'POST_GLOBAL_ANNOUNCE')
|
2003-02-26 19:53:10 +00:00
|
|
|
);
|
|
|
|
|
2003-03-20 13:21:58 +00:00
|
|
|
foreach ($topic_types as $auth_key => $topic_value)
|
2001-06-13 17:36:58 +00:00
|
|
|
{
|
2003-02-27 12:56:36 +00:00
|
|
|
if ($perm['f_' . $auth_key])
|
2001-06-07 07:56:45 +00:00
|
|
|
{
|
2003-02-26 19:53:10 +00:00
|
|
|
$topic_type_toggle .= '<input type="radio" name="topic_type" value="' . $topic_value['const'] . '"';
|
2003-02-27 23:37:02 +00:00
|
|
|
if ($topic_type == $topic_value['const'])
|
2003-02-26 19:53:10 +00:00
|
|
|
{
|
|
|
|
$topic_type_toggle .= ' checked="checked"';
|
|
|
|
}
|
|
|
|
$topic_type_toggle .= ' /> ' . $user->lang[$topic_value['lang']] . ' ';
|
2001-06-07 07:56:45 +00:00
|
|
|
}
|
2001-07-04 00:34:33 +00:00
|
|
|
}
|
|
|
|
|
2002-11-01 12:23:08 +00:00
|
|
|
if ($topic_type_toggle != '')
|
2001-07-04 00:34:33 +00:00
|
|
|
{
|
2003-02-27 23:37:02 +00:00
|
|
|
$topic_type_toggle = (($mode == 'edit') ? $user->lang['CHANGE_TOPIC_TO'] : $user->lang['POST_TOPIC_AS']) . ': <input type="radio" name="topic_type" value="' . POST_NORMAL . '"' . (($topic_type == POST_NORMAL) ? ' checked="checked"' : '') . ' /> ' . $user->lang['POST_NORMAL'] . ' ' . $topic_type_toggle;
|
2001-06-13 17:36:58 +00:00
|
|
|
}
|
|
|
|
}
|
2001-04-17 07:14:50 +00:00
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
// HTML, BBCode, Smilies, Images and Flash status
|
2003-02-27 23:37:02 +00:00
|
|
|
$html_status = (intval($config['allow_html']) && $auth->acl_get('f_html', $forum_id)) ? true : false;
|
|
|
|
$bbcode_status = (intval($config['allow_bbcode']) && $auth->acl_get('f_bbcode', $forum_id)) ? true : false;
|
|
|
|
$smilies_status = (intval($config['allow_smilies']) && $auth->acl_get('f_smilies', $forum_id)) ? true : false;
|
|
|
|
$img_status = (intval($config['allow_img']) && $auth->acl_get('f_img', $forum_id)) ? true : false;
|
|
|
|
$flash_status = (intval($config['allow_flash']) && $auth->acl_get('f_flash', $forum_id)) ? true : false;
|
|
|
|
|
|
|
|
$html_checked = (isset($enable_html)) ? !$enable_html : ((intval($config['allow_html'])) ? !$user->data['user_allowhtml'] : 1);
|
|
|
|
$bbcode_checked = (isset($enable_bbcode)) ? !$enable_bbcode : ((intval($config['allow_bbcode'])) ? !$user->data['user_allowbbcode'] : 1);
|
|
|
|
$smilies_checked = (isset($enable_smilies)) ? !$enable_smilies : ((intval($config['allow_smilies'])) ? !$user->data['user_allowsmile'] : 1);
|
2002-10-30 00:57:27 +00:00
|
|
|
$urls_checked = (isset($enable_urls)) ? !$enable_urls : 0;
|
2003-03-10 19:39:50 +00:00
|
|
|
$sig_checked = $enable_sig;
|
2002-10-30 00:57:27 +00:00
|
|
|
$notify_checked = (isset($notify_set)) ? $notify_set : (($user->data['user_id'] != ANONYMOUS) ? $user->data['user_notify'] : 0);
|
2003-02-27 23:37:02 +00:00
|
|
|
$lock_topic_checked = (isset($topic_lock)) ? $topic_lock : (($topic_status == ITEM_LOCKED) ? 1 : 0);
|
2003-04-12 14:30:21 +00:00
|
|
|
$lock_post_checked = (isset($post_lock)) ? $post_lock : $post_edit_locked;
|
2002-10-04 13:09:10 +00:00
|
|
|
|
2003-01-20 05:12:38 +00:00
|
|
|
// Page title & action URL, include session_id for security purpose
|
2003-02-27 23:37:02 +00:00
|
|
|
$s_action = "posting.$phpEx?sid=" . $user->session_id . "&mode=$mode&f=" . $forum_id;
|
2003-02-28 12:57:10 +00:00
|
|
|
$s_action .= ($topic_id) ? '&t=' . $topic_id : '';
|
|
|
|
$s_action .= ($post_id) ? '&p=' . $post_id : '';
|
|
|
|
|
2003-01-22 16:35:06 +00:00
|
|
|
switch ($mode)
|
2001-08-10 22:00:12 +00:00
|
|
|
{
|
2002-10-28 00:08:18 +00:00
|
|
|
case 'post':
|
2002-11-09 00:47:14 +00:00
|
|
|
$page_title = $user->lang['POST_TOPIC'];
|
2001-09-06 00:29:07 +00:00
|
|
|
break;
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2003-02-26 19:53:10 +00:00
|
|
|
case 'quote':
|
2001-09-06 00:29:07 +00:00
|
|
|
case 'reply':
|
2002-11-09 00:47:14 +00:00
|
|
|
$page_title = $user->lang['POST_REPLY'];
|
2001-09-06 00:29:07 +00:00
|
|
|
break;
|
|
|
|
|
2003-02-28 12:57:10 +00:00
|
|
|
case 'delete':
|
2002-10-28 00:08:18 +00:00
|
|
|
case 'edit':
|
2002-11-18 21:04:45 +00:00
|
|
|
$page_title = $user->lang['EDIT_POST'];
|
2001-08-10 22:00:12 +00:00
|
|
|
}
|
2001-08-09 22:21:55 +00:00
|
|
|
|
2003-02-26 00:37:43 +00:00
|
|
|
// Build navigation links
|
2003-02-26 19:53:10 +00:00
|
|
|
$forum_data = array(
|
2003-02-27 23:37:02 +00:00
|
|
|
'parent_id' => $parent_id,
|
2003-02-26 19:53:10 +00:00
|
|
|
'forum_parents' => $forum_parents,
|
|
|
|
'forum_name' => $forum_name,
|
2003-02-27 23:37:02 +00:00
|
|
|
'forum_id' => $forum_id,
|
2003-02-26 19:53:10 +00:00
|
|
|
'forum_desc' => ''
|
|
|
|
);
|
2003-02-26 00:37:43 +00:00
|
|
|
generate_forum_nav($forum_data);
|
2003-01-22 16:35:06 +00:00
|
|
|
|
2003-03-10 19:39:50 +00:00
|
|
|
$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $topic_last_post_id . '" />' : '';
|
|
|
|
$s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . time() . '" />';
|
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || @ini_get('file_uploads') == '0' || !$config['allow_attachments']) ? '' : 'enctype="multipart/form-data"';
|
2003-03-10 19:39:50 +00:00
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
// Start assigning vars for main posting page ...
|
2002-02-18 12:34:38 +00:00
|
|
|
$template->assign_vars(array(
|
2003-02-27 23:37:02 +00:00
|
|
|
'L_POST_A' => $page_title,
|
2003-01-22 16:35:06 +00:00
|
|
|
'L_ICON' => ($mode == 'reply' || $mode == 'quote') ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'],
|
2003-02-27 23:37:02 +00:00
|
|
|
'L_MESSAGE_BODY_EXPLAIN'=> (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '',
|
2002-10-28 00:08:18 +00:00
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
'FORUM_NAME' => $forum_name,
|
|
|
|
'FORUM_DESC' => (!empty($forum_desc)) ? strip_tags($forum_desc) : '',
|
|
|
|
'TOPIC_TITLE' => $topic_title,
|
2003-04-15 23:12:28 +00:00
|
|
|
'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '',
|
2003-02-28 12:57:10 +00:00
|
|
|
'USERNAME' => (((!$preview) && ($mode != 'quote')) || ($preview)) ? stripslashes($username) : '',
|
2003-03-10 19:39:50 +00:00
|
|
|
'SUBJECT' => $post_subject,
|
2003-02-27 23:37:02 +00:00
|
|
|
'PREVIEW_SUBJECT' => ($preview) ? $preview_subject : '',
|
|
|
|
'MESSAGE' => trim($post_text),
|
|
|
|
'PREVIEW_MESSAGE' => ($preview) ? $preview_message : '',
|
|
|
|
'HTML_STATUS' => ($html_status) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF'],
|
|
|
|
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . "faq.$phpEx$SID&mode=bbcode" . '" target="_phpbbcode">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . "faq.$phpEx$SID&mode=bbcode" . '" target="_phpbbcode">', '</a>'),
|
|
|
|
'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
|
|
|
|
'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
|
|
|
|
'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
|
2003-04-11 19:51:38 +00:00
|
|
|
'MINI_POST_IMG' => $user->img('icon_post', $user->lang['POST']),
|
2003-02-27 23:37:02 +00:00
|
|
|
'POST_DATE' => ($post_time) ? $user->format_date($post_time) : '',
|
|
|
|
'ERROR_MESSAGE' => $err_msg,
|
|
|
|
|
|
|
|
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=" . $forum_id,
|
|
|
|
'U_VIEWTOPIC' => ($mode != 'post') ? "viewtopic.$phpEx$SID&" . $forum_id . "&t=" . $topic_id : '',
|
2003-02-28 12:57:10 +00:00
|
|
|
'U_REVIEW_TOPIC' => ($mode != 'post') ? "posting.$phpEx$SID&mode=topicreview&f=" . $forum_id . "&t=" . $topic_id : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
|
|
|
|
'S_DISPLAY_PREVIEW' => ($preview),
|
2003-02-28 12:57:10 +00:00
|
|
|
'S_DISPLAY_REVIEW' => ($mode == 'reply' || $mode == 'quote') ? true : false,
|
2003-02-27 23:37:02 +00:00
|
|
|
'S_DISPLAY_USERNAME' => ($user->data['user_id'] == ANONYMOUS || ($mode == 'edit' && $post_username)) ? true : false,
|
|
|
|
'S_SHOW_TOPIC_ICONS' => $s_topic_icons,
|
|
|
|
'S_DELETE_ALLOWED' => ($mode == 'edit' && ( ($post_id == $topic_last_post_id && $poster_id == $user->data['user_id'] && $perm['u_delete']) || ($perm['m_delete']))) ? true : false,
|
|
|
|
'S_HTML_ALLOWED' => $html_status,
|
2002-10-30 00:57:27 +00:00
|
|
|
'S_HTML_CHECKED' => ($html_checked) ? 'checked="checked"' : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
'S_BBCODE_ALLOWED' => $bbcode_status,
|
2002-10-30 00:57:27 +00:00
|
|
|
'S_BBCODE_CHECKED' => ($bbcode_checked) ? 'checked="checked"' : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
'S_SMILIES_ALLOWED' => $smilies_status,
|
2002-10-30 00:57:27 +00:00
|
|
|
'S_SMILIES_CHECKED' => ($smilies_checked) ? 'checked="checked"' : '',
|
2003-03-10 19:39:50 +00:00
|
|
|
'S_SIG_ALLOWED' => ( ($perm['f_sigs']) && ($config['allow_sig']) ) ? true : false,
|
2002-10-30 00:57:27 +00:00
|
|
|
'S_SIGNATURE_CHECKED' => ($sig_checked) ? 'checked="checked"' : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
'S_NOTIFY_ALLOWED' => ($user->data['user_id'] != ANONYMOUS) ? true : false,
|
2002-10-30 00:57:27 +00:00
|
|
|
'S_NOTIFY_CHECKED' => ($notify_checked) ? 'checked="checked"' : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
'S_LOCK_TOPIC_ALLOWED' => ( ($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($perm['m_lock']) ) ? true : false,
|
|
|
|
'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? 'checked="checked"' : '',
|
2003-04-12 14:30:21 +00:00
|
|
|
'S_LOCK_POST_ALLOWED' => (($mode == 'edit') && ($perm['m_edit'])) ? true : false,
|
|
|
|
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? 'checked="checked"' : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
'S_MAGIC_URL_CHECKED' => ($urls_checked) ? 'checked="checked"' : '',
|
|
|
|
'S_TYPE_TOGGLE' => $topic_type_toggle,
|
|
|
|
'S_SAVE_ALLOWED' => ($perm['f_save']) ? true : false,
|
2003-03-22 15:48:46 +00:00
|
|
|
'S_FORM_ENCTYPE' => $form_enctype,
|
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
'S_POST_ACTION' => $s_action,
|
2003-03-10 19:39:50 +00:00
|
|
|
'S_HIDDEN_FIELDS' => $s_hidden_fields)
|
2001-06-13 17:36:58 +00:00
|
|
|
);
|
|
|
|
|
2003-03-10 19:39:50 +00:00
|
|
|
// Poll entry
|
2003-03-22 15:48:46 +00:00
|
|
|
if ( ( ($mode == 'post') || ( ($mode == 'edit') && ($post_id == $topic_first_post_id) && (empty($poll_last_vote)) )) && ( ($auth->acl_get('f_poll', $forum_id)) || ($perm['m_edit']) ))
|
2003-03-10 19:39:50 +00:00
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'S_SHOW_POLL_BOX' => true,
|
|
|
|
'S_POLL_DELETE' => ($mode == 'edit' && !empty($poll_options) && ((empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $perm['u_delete']) || $perm['m_delete'])) ? true : false,
|
|
|
|
|
|
|
|
'L_POLL_OPTIONS_EXPLAIN'=> sprintf($user->lang['POLL_OPTIONS_EXPLAIN'], $config['max_poll_options']),
|
|
|
|
|
2003-04-22 16:47:34 +00:00
|
|
|
'POLL_TITLE' => $poll_title,
|
|
|
|
'POLL_OPTIONS' => (!empty($poll_options)) ? implode("\n", $poll_options) : '',
|
|
|
|
'POLL_MAX_OPTIONS' => (!empty($poll_max_options)) ? $poll_max_options : 1,
|
|
|
|
'POLL_LENGTH' => $poll_length)
|
2003-03-10 19:39:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
// Attachment entry
|
|
|
|
if (($perm['f_attach']) || ($perm['m_edit']))
|
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'S_SHOW_ATTACH_BOX' => true)
|
|
|
|
);
|
|
|
|
|
2003-05-01 18:24:18 +00:00
|
|
|
if (count($message_parser->attachment_data))
|
2003-03-22 15:48:46 +00:00
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'S_HAS_ATTACHMENTS' => true)
|
|
|
|
);
|
|
|
|
|
2003-05-01 18:24:18 +00:00
|
|
|
$count = 0;
|
|
|
|
foreach ($message_parser->attachment_data as $attach_row)
|
2003-03-22 15:48:46 +00:00
|
|
|
{
|
2003-05-01 18:24:18 +00:00
|
|
|
$hidden = '';
|
|
|
|
$attach_row['real_filename'] = stripslashes($attach_row['real_filename']);
|
|
|
|
|
|
|
|
foreach ($attach_row as $key => $value)
|
2003-03-22 15:48:46 +00:00
|
|
|
{
|
2003-05-01 18:24:18 +00:00
|
|
|
$hidden .= '<input type="hidden" name="attachment_data[' . $count . '][' . $key . ']" value="' . $value . '" />';
|
2003-03-22 15:48:46 +00:00
|
|
|
}
|
2003-05-01 18:24:18 +00:00
|
|
|
|
|
|
|
$download_link = ($attach_row['attach_id'] == '-1') ? $config['upload_dir'] . '/' . $attach_row['physical_filename'] : $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . intval($attach_row['attach_id']);
|
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
$template->assign_block_vars('attach_row', array(
|
2003-05-01 18:24:18 +00:00
|
|
|
'FILENAME' => $attach_row['real_filename'],
|
|
|
|
'ATTACH_FILENAME' => $attach_row['physical_filename'],
|
|
|
|
'FILE_COMMENT' => stripslashes(htmlspecialchars($attach_row['comment'])),
|
|
|
|
'ATTACH_ID' => $attach_row['attach_id'],
|
|
|
|
'ASSOC_INDEX' => $count,
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
|
|
'U_VIEW_ATTACHMENT' => $download_link,
|
|
|
|
'S_HIDDEN' => $hidden)
|
|
|
|
);
|
2003-05-01 18:24:18 +00:00
|
|
|
|
|
|
|
$count++;
|
2003-03-22 15:48:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2003-05-01 18:24:18 +00:00
|
|
|
'FILE_COMMENT' => stripslashes(htmlspecialchars($message_parser->filename_data['filecomment'])),
|
2003-03-22 15:48:46 +00:00
|
|
|
'FILESIZE' => $config['max_filesize'],
|
2003-05-01 18:24:18 +00:00
|
|
|
'FILENAME' => $message_parser->filename_data['filename'])
|
2003-03-22 15:48:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2002-10-04 13:09:10 +00:00
|
|
|
// Output page ...
|
2003-05-03 23:58:45 +00:00
|
|
|
page_header($page_title);
|
2002-10-04 13:09:10 +00:00
|
|
|
|
|
|
|
$template->set_filenames(array(
|
2002-11-21 01:35:53 +00:00
|
|
|
'body' => 'posting_body.html')
|
2002-10-04 13:09:10 +00:00
|
|
|
);
|
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
make_jumpbox('viewforum.'.$phpEx);
|
2001-10-16 11:12:32 +00:00
|
|
|
|
2003-02-28 12:57:10 +00:00
|
|
|
// Topic review
|
|
|
|
if ($mode == 'reply' || $mode == 'quote')
|
|
|
|
{
|
|
|
|
topic_review($topic_id, true);
|
|
|
|
}
|
|
|
|
|
2003-05-03 23:58:45 +00:00
|
|
|
page_footer();
|
2001-06-13 17:36:58 +00:00
|
|
|
|
2003-04-18 13:07:19 +00:00
|
|
|
// FUNCTIONS
|
|
|
|
|
|
|
|
// Topic Review
|
|
|
|
function topic_review($topic_id, $is_inline_review = false)
|
|
|
|
{
|
2003-05-17 17:33:44 +00:00
|
|
|
global $template;
|
|
|
|
|
|
|
|
if ($is_inline_review)
|
|
|
|
{
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'S_DISPLAY_INLINE' => true)
|
|
|
|
);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-04-23 22:00:32 +00:00
|
|
|
global $user, $auth, $db, $template, $bbcode;
|
2003-04-24 18:21:29 +00:00
|
|
|
global $censors, $config, $phpbb_root_path, $phpEx, $SID;
|
2003-04-18 13:07:19 +00:00
|
|
|
|
|
|
|
// Define censored word matches
|
|
|
|
if (empty($censors))
|
|
|
|
{
|
|
|
|
$censors = array();
|
|
|
|
obtain_word_list($censors);
|
|
|
|
}
|
|
|
|
|
2003-05-17 17:33:44 +00:00
|
|
|
// Get topic info ...
|
|
|
|
$sql = "SELECT t.topic_title, f.forum_id
|
|
|
|
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
|
|
|
|
WHERE t.topic_id = $topic_id
|
|
|
|
AND f.forum_id = t.forum_id";
|
|
|
|
$result = $db->sql_query($sql);
|
2003-04-18 13:07:19 +00:00
|
|
|
|
2003-05-17 17:33:44 +00:00
|
|
|
if (!($row = $db->sql_fetchrow($result)))
|
|
|
|
{
|
|
|
|
trigger_error($user->lang['NO_TOPIC']);
|
|
|
|
}
|
2003-04-18 13:07:19 +00:00
|
|
|
|
2003-05-17 17:33:44 +00:00
|
|
|
$forum_id = intval($row['forum_id']);
|
|
|
|
$topic_title = $row['topic_title'];
|
2003-04-18 13:07:19 +00:00
|
|
|
|
2003-05-17 17:33:44 +00:00
|
|
|
if (!$auth->acl_get('f_read', $forum_id))
|
|
|
|
{
|
|
|
|
trigger_error($user->lang['SORRY_AUTH_READ']);
|
2003-04-18 13:07:19 +00:00
|
|
|
}
|
2003-05-17 17:33:44 +00:00
|
|
|
|
|
|
|
if (count($censors['match']))
|
2003-04-18 13:07:19 +00:00
|
|
|
{
|
2003-05-17 17:33:44 +00:00
|
|
|
$topic_title = preg_replace($censors['match'], $censors['replace'], $topic_title);
|
2003-04-18 13:07:19 +00:00
|
|
|
}
|
|
|
|
|
2003-05-17 17:33:44 +00:00
|
|
|
$page_title = $user->lang['TOPIC_REVIEW'] . ' - ' . $topic_title;
|
|
|
|
|
2003-04-23 22:00:32 +00:00
|
|
|
if (!isset($bbcode))
|
|
|
|
{
|
|
|
|
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
|
|
|
|
$bbcode = new bbcode(pow(2, 32) - 1);
|
|
|
|
}
|
|
|
|
|
2003-04-18 13:07:19 +00:00
|
|
|
// Go ahead and pull all data for this topic
|
|
|
|
$sql = "SELECT u.username, u.user_id, p.*
|
|
|
|
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
|
|
|
|
WHERE p.topic_id = $topic_id
|
|
|
|
AND p.poster_id = u.user_id
|
2003-04-22 19:44:00 +00:00
|
|
|
AND p.post_approved = 1
|
2003-04-18 13:07:19 +00:00
|
|
|
ORDER BY p.post_time DESC";
|
|
|
|
$result = $db->sql_query_limit($sql, $config['posts_per_page']);
|
|
|
|
|
|
|
|
// Okay, let's do the loop, yeah come on baby let's do the loop
|
|
|
|
// and it goes like this ...
|
|
|
|
if ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
$i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
$poster_id = $row['user_id'];
|
|
|
|
$poster = $row['username'];
|
|
|
|
|
|
|
|
// Handle anon users posting with usernames
|
|
|
|
if ($poster_id == ANONYMOUS && $row['post_username'] != '')
|
|
|
|
{
|
|
|
|
$poster = $row['post_username'];
|
|
|
|
$poster_rank = $user->lang['GUEST'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : '';
|
|
|
|
|
|
|
|
$message = $row['post_text'];
|
|
|
|
|
|
|
|
$message = (empty($row['enable_smilies']) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $message);
|
|
|
|
|
2003-04-23 22:00:32 +00:00
|
|
|
$bbcode->bbcode_second_pass(&$message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
|
|
|
|
2003-04-18 13:07:19 +00:00
|
|
|
if (count($censors['match']))
|
|
|
|
{
|
|
|
|
$post_subject = preg_replace($censors['match'], $censors['replace'], $post_subject);
|
|
|
|
$message = preg_replace($censors['match'], $censors['replace'], $message);
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_block_vars('postrow', array(
|
|
|
|
'MINI_POST_IMG' => $user->img('icon_post', $user->lang['POST']),
|
|
|
|
'POSTER_NAME' => $poster,
|
|
|
|
'POST_DATE' => $user->format_date($row['post_time']),
|
|
|
|
'POST_SUBJECT' => $post_subject,
|
2003-05-18 11:12:04 +00:00
|
|
|
'POST_ID' => $row['post_id'],
|
2003-04-18 13:07:19 +00:00
|
|
|
'MESSAGE' => nl2br($message),
|
|
|
|
|
|
|
|
'S_ROW_COUNT' => $i++)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
while ($row = $db->sql_fetchrow($result));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trigger_error($user->lang['NO_TOPIC']);
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
2003-05-17 17:33:44 +00:00
|
|
|
page_header($page_title);
|
2003-04-18 13:07:19 +00:00
|
|
|
|
2003-05-17 17:33:44 +00:00
|
|
|
$template->set_filenames(array(
|
|
|
|
'body' => 'posting_topic_review.html')
|
|
|
|
);
|
2003-04-18 13:07:19 +00:00
|
|
|
|
2003-05-17 17:33:44 +00:00
|
|
|
page_footer();
|
2003-04-18 13:07:19 +00:00
|
|
|
}
|
|
|
|
|
2003-04-20 16:49:26 +00:00
|
|
|
// Temp Function - strtolower (will have a look at iconv later) - borrowed from php.net
|
|
|
|
function phpbb_strtolower($string)
|
|
|
|
{
|
|
|
|
$new_string = '';
|
|
|
|
|
|
|
|
for ($i = 0; $i < strlen($string); $i++)
|
|
|
|
{
|
|
|
|
if (ord(substr($string, $i, 1)) > 0xa0)
|
|
|
|
{
|
|
|
|
$new_string .= strtolower(substr($string, $i, 2));
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$new_string .= strtolower(substr($string, $i, 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $new_string;
|
|
|
|
}
|
2003-04-18 13:07:19 +00:00
|
|
|
|
2003-01-08 17:00:37 +00:00
|
|
|
?>
|