2001-02-17 08:37:32 +00:00
|
|
|
|
<?php
|
2003-08-29 18:06:56 +00:00
|
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// $Id$
|
|
|
|
|
//
|
|
|
|
|
// FILENAME : posting.php
|
|
|
|
|
// STARTED : Sat Feb 17, 2001
|
|
|
|
|
// COPYRIGHT : <20> 2001, 2003 phpBB Group
|
|
|
|
|
// WWW : http://www.phpbb.com/
|
|
|
|
|
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
|
|
|
|
|
//
|
|
|
|
|
// -------------------------------------------------------------
|
2001-08-30 22:20:23 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
define('IN_PHPBB', TRUE);
|
2002-03-31 00:06:34 +00:00
|
|
|
|
$phpbb_root_path = './';
|
2003-09-07 13:46:51 +00:00
|
|
|
|
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
2001-07-13 16:14:37 +00:00
|
|
|
|
include($phpbb_root_path . 'common.'.$phpEx);
|
2003-08-30 12:21:31 +00:00
|
|
|
|
include($phpbb_root_path . 'includes/functions_admin.'.$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
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2002-10-28 00:08:18 +00:00
|
|
|
|
// Start session management
|
|
|
|
|
$user->start();
|
|
|
|
|
$auth->acl($user->data);
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-01-22 16:35:06 +00:00
|
|
|
|
// Grab only parameters needed here
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$mode = request_var('mode', '');
|
|
|
|
|
$post_id = request_var('p', 0);
|
|
|
|
|
$topic_id = request_var('t', 0);
|
|
|
|
|
$forum_id = request_var('f', 0);
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$draft_id = request_var('d', 0);
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$lastclick = request_var('lastclick', 0);
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
2003-09-04 18:30:20 +00:00
|
|
|
|
$submit = (isset($_POST['post'])) ? TRUE : FALSE;
|
|
|
|
|
$preview = (isset($_POST['preview'])) ? TRUE : FALSE;
|
|
|
|
|
$save = (isset($_POST['save'])) ? TRUE : FALSE;
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$load = (isset($_POST['load'])) ? TRUE : FALSE;
|
2003-09-04 18:30:20 +00:00
|
|
|
|
$cancel = (isset($_POST['cancel'])) ? TRUE : FALSE;
|
|
|
|
|
$confirm = (isset($_POST['confirm'])) ? TRUE : FALSE;
|
|
|
|
|
$delete = (isset($_POST['delete'])) ? TRUE : FALSE;
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['edit_comment']) || isset($_POST['cancel_unglobalise']) || $save || $load;
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
|
|
if ($delete && !$preview && !$refresh && $submit)
|
2003-03-10 19:39:50 +00:00
|
|
|
|
{
|
|
|
|
|
$mode = 'delete';
|
|
|
|
|
}
|
2003-02-26 19:53:10 +00:00
|
|
|
|
|
2003-06-24 16:46:30 +00:00
|
|
|
|
$error = array();
|
2003-10-21 13:05:15 +00:00
|
|
|
|
$current_time = time();
|
2003-06-24 16:46:30 +00:00
|
|
|
|
|
|
|
|
|
|
2002-10-20 19:19:07 +00:00
|
|
|
|
// Was cancel pressed? If so then redirect to the appropriate page
|
2003-10-22 20:41:00 +00:00
|
|
|
|
if ($cancel || $current_time - $lastclick < 2)
|
2001-09-06 00:29:07 +00:00
|
|
|
|
{
|
2003-06-17 19:34:17 +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
|
|
|
|
}
|
|
|
|
|
|
2003-09-24 19:41:14 +00:00
|
|
|
|
if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$forum_id)
|
2003-08-30 12:21:31 +00:00
|
|
|
|
{
|
2003-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('NO_FORUM');
|
2003-08-30 12:21:31 +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-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-06-17 19:34:17 +00:00
|
|
|
|
$sql = 'SELECT *
|
|
|
|
|
FROM ' . FORUMS_TABLE . "
|
|
|
|
|
WHERE forum_id = $forum_id";
|
2002-10-04 13:09:10 +00:00
|
|
|
|
break;
|
2002-10-30 00:57:27 +00:00
|
|
|
|
|
2003-10-19 15:36:45 +00:00
|
|
|
|
case 'bump':
|
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-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('NO_TOPIC');
|
2002-03-21 01:03:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
$sql = 'SELECT t.*, f.*
|
|
|
|
|
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
|
|
|
|
WHERE t.topic_id = $topic_id
|
2003-07-07 23:43:57 +00:00
|
|
|
|
AND (f.forum_id = t.forum_id
|
|
|
|
|
OR f.forum_id = $forum_id)";
|
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-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('NO_POST');
|
2002-10-04 13:09:10 +00:00
|
|
|
|
}
|
2001-09-06 00:29:07 +00:00
|
|
|
|
|
2003-06-24 16:46:30 +00:00
|
|
|
|
$sql = 'SELECT p.*, t.*, f.*, u.username, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield
|
2003-06-17 19:34:17 +00:00
|
|
|
|
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u
|
|
|
|
|
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-07-07 23:43:57 +00:00
|
|
|
|
AND (f.forum_id = t.forum_id
|
|
|
|
|
OR f.forum_id = $forum_id)";
|
2003-02-28 12:57:10 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-10-30 18:59:09 +00:00
|
|
|
|
case 'smilies':
|
2003-10-10 12:11:18 +00:00
|
|
|
|
generate_smilies('window', $forum_id);
|
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-06-24 16:46:30 +00:00
|
|
|
|
$sql = '';
|
2003-10-19 15:36:45 +00:00
|
|
|
|
trigger_error('NO_POST_MODE');
|
2002-02-18 12:34:38 +00:00
|
|
|
|
}
|
2001-07-06 01:09:42 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$censors = array();
|
|
|
|
|
obtain_word_list($censors);
|
2003-09-09 07:02:57 +00:00
|
|
|
|
|
2003-10-21 13:05:15 +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-10-21 13:05:15 +00:00
|
|
|
|
extract($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-08-30 12:21:31 +00:00
|
|
|
|
$quote_username = (!empty($username)) ? $username : ((isset($post_username)) ? $post_username : '');
|
2003-04-23 22:00:32 +00:00
|
|
|
|
|
2003-08-30 12:21:31 +00:00
|
|
|
|
$forum_id = (int) $forum_id;
|
|
|
|
|
$topic_id = (int) $topic_id;
|
|
|
|
|
$post_id = (int) $post_id;
|
2003-03-12 16:34:40 +00:00
|
|
|
|
|
2003-08-30 12:21:31 +00:00
|
|
|
|
$post_edit_locked = (int) $post_edit_locked;
|
2003-05-08 01:14:14 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$user->setup(FALSE, $forum_style);
|
2003-08-30 12:21:31 +00:00
|
|
|
|
|
|
|
|
|
if ($forum_password)
|
2003-05-03 23:58:45 +00:00
|
|
|
|
{
|
2003-11-22 12:44:01 +00:00
|
|
|
|
$forum_data = array('forum_id' => $forum_id, 'forum_password' => $forum_password);
|
|
|
|
|
login_forum_box($forum_data);
|
2003-05-03 23:58:45 +00:00
|
|
|
|
}
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
2003-08-30 12:21:31 +00:00
|
|
|
|
$post_subject = (in_array($mode, array('quote', 'edit', 'delete'))) ? $post_subject : $topic_title;
|
2003-03-12 16:34:40 +00:00
|
|
|
|
|
2003-10-21 13:05:15 +00:00
|
|
|
|
$topic_time_limit = ($topic_time_limit) ? $topic_time_limit / 86400 : $topic_time_limit;
|
|
|
|
|
$poll_length = ($poll_length) ? $poll_length / 86400 : $poll_length;
|
2003-03-10 19:39:50 +00:00
|
|
|
|
$poll_options = array();
|
|
|
|
|
|
|
|
|
|
// Get Poll Data
|
|
|
|
|
if ($poll_start)
|
|
|
|
|
{
|
2003-06-17 19:34:17 +00:00
|
|
|
|
$sql = 'SELECT poll_option_text
|
|
|
|
|
FROM ' . POLL_OPTIONS_TABLE . "
|
|
|
|
|
WHERE topic_id = $topic_id
|
2003-03-20 13:21:58 +00:00
|
|
|
|
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-10-28 21:23:49 +00:00
|
|
|
|
$message_parser = new parse_message(0);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
|
|
|
|
|
2003-10-12 09:18:56 +00:00
|
|
|
|
$message_parser->filename_data['filecomment'] = preg_replace('#&(\#[0-9]+;)#', '&\1', request_var('filecomment', ''));
|
2003-05-25 14:32:20 +00:00
|
|
|
|
$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-08-29 18:06:56 +00:00
|
|
|
|
|
2003-09-04 18:30:20 +00:00
|
|
|
|
//
|
2003-10-09 14:48:55 +00:00
|
|
|
|
foreach ($message_parser->attachment_data as $pos => $var_ary)
|
2003-08-29 18:06:56 +00:00
|
|
|
|
{
|
2003-10-09 14:48:55 +00:00
|
|
|
|
prepare_data($message_parser->attachment_data[$pos]['physical_filename'], TRUE);
|
2003-09-15 21:05:30 +00:00
|
|
|
|
prepare_data($message_parser->attachment_data[$pos]['comment'], TRUE);
|
2003-10-09 14:48:55 +00:00
|
|
|
|
prepare_data($message_parser->attachment_data[$pos]['real_filename'], TRUE);
|
|
|
|
|
prepare_data($message_parser->attachment_data[$pos]['extension'], TRUE);
|
|
|
|
|
prepare_data($message_parser->attachment_data[$pos]['mimetype'], TRUE);
|
2003-10-12 11:59:23 +00:00
|
|
|
|
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$message_parser->attachment_data[$pos]['filesize'] = (int) $message_parser->attachment_data[$pos]['filesize'];
|
|
|
|
|
$message_parser->attachment_data[$pos]['filetime'] = (int) $message_parser->attachment_data[$pos]['filetime'];
|
|
|
|
|
$message_parser->attachment_data[$pos]['attach_id'] = (int) $message_parser->attachment_data[$pos]['attach_id'];
|
|
|
|
|
$message_parser->attachment_data[$pos]['thumbnail'] = (int) $message_parser->attachment_data[$pos]['thumbnail'];
|
2003-08-29 18:06:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
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-11-04 22:12:52 +00:00
|
|
|
|
$sql = 'SELECT attach_id, physical_filename, comment, real_filename, extension, mimetype, filesize, filetime, thumbnail
|
|
|
|
|
FROM ' . ATTACHMENTS_TABLE . "
|
|
|
|
|
WHERE post_id = $post_id
|
|
|
|
|
ORDER BY 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-06-23 14:00:57 +00:00
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
|
if ($poster_id == ANONYMOUS || !$poster_id)
|
2003-02-28 12:57:10 +00:00
|
|
|
|
{
|
2003-08-30 12:21:31 +00:00
|
|
|
|
$username = (in_array($mode, array('quote', 'edit', 'delete'))) ? trim($post_username) : '';
|
2003-02-28 12:57:10 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-08-30 12:21:31 +00:00
|
|
|
|
$username = (in_array($mode, array('quote', 'edit', 'delete'))) ? trim($username) : '';
|
2003-02-28 12:57:10 +00:00
|
|
|
|
}
|
2002-10-30 00:57:27 +00:00
|
|
|
|
|
2003-03-12 16:34:40 +00:00
|
|
|
|
$enable_urls = $enable_magic_url;
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-08-30 12:21:31 +00:00
|
|
|
|
if (!in_array($mode, array('quote', 'edit', 'delete')))
|
2003-03-12 16:34:40 +00:00
|
|
|
|
{
|
2003-10-07 17:29:53 +00:00
|
|
|
|
$enable_sig = ($config['allow_sig'] && $user->optionget('attachsig')) ? TRUE : FALSE;
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$enable_smilies = ($config['allow_smilies'] && $user->optionget('smile')) ? TRUE : FALSE;
|
|
|
|
|
$enable_bbcode = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? TRUE : FALSE;
|
2003-09-04 18:30:20 +00:00
|
|
|
|
$enable_urls = TRUE;
|
2003-03-12 16:34:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-04 18:30:20 +00:00
|
|
|
|
$enable_magic_url = $drafts = FALSE;
|
2003-02-27 23:37:02 +00:00
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
// User own some drafts?
|
2003-11-22 12:44:01 +00:00
|
|
|
|
if ($user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts') && $mode != 'delete')
|
2003-09-04 18:30:20 +00:00
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT draft_id
|
|
|
|
|
FROM ' . DRAFTS_TABLE . '
|
2003-11-16 21:53:56 +00:00
|
|
|
|
WHERE (forum_id = ' . $forum_id . (($topic_id) ? " OR topic_id = $topic_id" : '') . ')
|
|
|
|
|
AND user_id = ' . $user->data['user_id'] .
|
|
|
|
|
(($draft_id) ? " AND draft_id <> $draft_id" : '');
|
2003-09-04 18:30:20 +00:00
|
|
|
|
$result = $db->sql_query_limit($sql, 1);
|
2003-11-16 21:53:56 +00:00
|
|
|
|
|
2003-10-12 09:18:56 +00:00
|
|
|
|
if ($db->sql_fetchrow($result))
|
2003-09-04 18:30:20 +00:00
|
|
|
|
{
|
|
|
|
|
$drafts = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-06-23 14:00:57 +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
|
|
|
|
{
|
2003-06-17 19:34:17 +00:00
|
|
|
|
$sql = 'SELECT topic_id
|
|
|
|
|
FROM ' . TOPICS_WATCH_TABLE . '
|
|
|
|
|
WHERE topic_id = ' . $topic_id . '
|
|
|
|
|
AND user_id = ' . $user->data['user_id'];
|
2003-10-28 21:23:49 +00:00
|
|
|
|
$result = $db->sql_query_limit($sql, 1);
|
2003-06-06 19:05:21 +00:00
|
|
|
|
$notify_set = ($db->sql_fetchrow($result)) ? 1 : 0;
|
2002-10-30 00:57:27 +00:00
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
}
|
2003-06-06 19:05:21 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2003-10-28 21:23:49 +00:00
|
|
|
|
$notify_set = 0;
|
2003-06-06 19:05:21 +00:00
|
|
|
|
}
|
2002-10-30 00:57:27 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +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-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('USER_CANNOT_' . strtoupper($mode));
|
2002-10-28 00:08:18 +00:00
|
|
|
|
}
|
2001-05-27 03:11:27 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2002-11-01 12:23:08 +00:00
|
|
|
|
// Forum/Topic locked?
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if (($forum_status == ITEM_LOCKED || $topic_status == ITEM_LOCKED) && !$auth->acl_get('m_edit', $forum_id))
|
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';
|
2003-10-12 09:18:56 +00:00
|
|
|
|
trigger_error($message);
|
2002-11-01 12:23:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-30 00:57:27 +00:00
|
|
|
|
// Can we edit this post?
|
2003-10-22 20:41:00 +00:00
|
|
|
|
if (($mode == 'edit' || $mode == 'delete') && !$auth->acl_get('m_edit', $forum_id) && $config['edit_time'] && $post_time < $current_time - $config['edit_time'])
|
2002-10-28 00:08:18 +00:00
|
|
|
|
{
|
2003-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('CANNOT_EDIT_TIME');
|
2002-10-04 13:09:10 +00:00
|
|
|
|
}
|
2001-05-26 00:25:50 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-02-26 19:53:10 +00:00
|
|
|
|
// Do we want to edit our post ?
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id) && $user->data['user_id'] != $poster_id)
|
2003-02-26 19:53:10 +00:00
|
|
|
|
{
|
2003-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('USER_CANNOT_EDIT');
|
2003-02-26 19:53:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-23 14:00:57 +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
|
|
|
|
{
|
2003-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('CANNOT_EDIT_POST_LOCKED');
|
2003-04-12 14:30:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-04-16 21:16:57 +00:00
|
|
|
|
if ($mode == 'edit')
|
|
|
|
|
{
|
2003-09-08 07:05:29 +00:00
|
|
|
|
$message_parser->bbcode_uid = $bbcode_uid;
|
2003-04-16 21:16:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-03-02 13:32:53 +00:00
|
|
|
|
// Delete triggered ?
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if ($mode == 'delete' && (($poster_id == $user->data['user_id'] && $user->data['user_id'] != ANONYMOUS && $auth->acl_get('f_delete', $forum_id) && $post_id == $topic_last_post_id) || $auth->acl_get('m_delete', $forum_id)))
|
2003-03-02 13:32:53 +00:00
|
|
|
|
{
|
|
|
|
|
// Do we need to confirm ?
|
|
|
|
|
if ($confirm)
|
|
|
|
|
{
|
2003-09-07 15:49:03 +00:00
|
|
|
|
$data = array(
|
|
|
|
|
'topic_first_post_id' => $topic_first_post_id,
|
|
|
|
|
'topic_last_post_id' => $topic_last_post_id,
|
|
|
|
|
'topic_approved' => $topic_approved,
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'topic_type' => $topic_type,
|
2003-09-07 15:49:03 +00:00
|
|
|
|
'post_approved' => $post_approved,
|
|
|
|
|
'post_time' => $post_time,
|
|
|
|
|
'poster_id' => $poster_id
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$next_post_id = delete_post($mode, $post_id, $topic_id, $forum_id, $data);
|
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
if ($topic_first_post_id == $topic_last_post_id)
|
2003-04-18 13:07:19 +00:00
|
|
|
|
{
|
2003-05-05 22:48:17 +00:00
|
|
|
|
$meta_info = "viewforum.$phpEx$SID&f=$forum_id";
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$message = $user->lang['POST_DELETED'];
|
2003-04-18 13:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-09-07 15:23:55 +00:00
|
|
|
|
$meta_info = "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=$next_post_id#$next_post_id";
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$message = $user->lang['POST_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], "<a href=\"viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=$next_post_id#$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-09-07 15:49:03 +00:00
|
|
|
|
|
2003-03-02 13:32:53 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-06-26 16:46:17 +00:00
|
|
|
|
$s_hidden_fields = '<input type="hidden" name="p" value="' . $post_id . '" /><input type="hidden" name="f" value="' . $forum_id . '" /><input type="hidden" name="mode" value="delete" />';
|
2003-03-02 13:32:53 +00:00
|
|
|
|
|
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'],
|
2003-11-06 15:05:50 +00:00
|
|
|
|
'MESSAGE_TEXT' => $user->lang['CONFIRM_DELETE_POST'],
|
2003-03-02 13:32:53 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
'S_CONFIRM_ACTION' => "posting.$phpEx$SID",
|
2003-05-02 15:50:11 +00:00
|
|
|
|
'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-06-23 14:00:57 +00:00
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if ($mode == 'delete' && $poster_id != $user->data['user_id'] && !$auth->acl_get('f_delete', $forum_id))
|
2003-03-02 13:32:53 +00:00
|
|
|
|
{
|
2003-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('DELETE_OWN_POSTS');
|
2003-03-02 13:32:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if ($mode == 'delete' && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $topic_last_post_id)
|
2003-03-02 13:32:53 +00:00
|
|
|
|
{
|
2003-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('CANNOT_DELETE_REPLIED');
|
2003-03-02 13:32:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($mode == 'delete')
|
|
|
|
|
{
|
|
|
|
|
trigger_error('USER_CANNOT_DELETE');
|
|
|
|
|
}
|
2002-11-07 22:02:49 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-05-22 01:35:48 +00:00
|
|
|
|
// HTML, BBCode, Smilies, Images and Flash status
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$html_status = ($config['allow_html'] && $auth->acl_get('f_html', $forum_id)) ? TRUE : FALSE;
|
|
|
|
|
$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? TRUE : FALSE;
|
|
|
|
|
$smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? TRUE : FALSE;
|
2003-09-24 19:41:14 +00:00
|
|
|
|
$img_status = ($auth->acl_get('f_img', $forum_id)) ? TRUE : FALSE;
|
|
|
|
|
$flash_status = ($auth->acl_get('f_flash', $forum_id)) ? TRUE : FALSE;
|
2003-11-27 23:44:59 +00:00
|
|
|
|
$quote_status = ($auth->acl_get('f_quote', $forum_id)) ? TRUE : FALSE;
|
2003-05-22 01:35:48 +00:00
|
|
|
|
|
2003-10-19 15:36:45 +00:00
|
|
|
|
// Bump Topic
|
2003-11-01 16:10:21 +00:00
|
|
|
|
if ($mode == 'bump' && ($bump_time = bump_topic_allowed($forum_id, $topic_bumped, $topic_last_post_time, $topic_poster, $topic_last_poster_id)))
|
2003-10-19 15:36:45 +00:00
|
|
|
|
{
|
|
|
|
|
$db->sql_transaction();
|
|
|
|
|
|
|
|
|
|
$db->sql_query('UPDATE ' . POSTS_TABLE . "
|
|
|
|
|
SET post_time = $current_time
|
|
|
|
|
WHERE post_id = $topic_last_post_id
|
|
|
|
|
AND topic_id = $topic_id");
|
|
|
|
|
|
|
|
|
|
$db->sql_query('UPDATE ' . TOPICS_TABLE . "
|
2003-11-01 16:10:21 +00:00
|
|
|
|
SET topic_last_post_time = $current_time,
|
|
|
|
|
topic_bumped = 1,
|
|
|
|
|
topic_bumper = " . $user->data['user_id'] . "
|
2003-10-19 15:36:45 +00:00
|
|
|
|
WHERE topic_id = $topic_id");
|
|
|
|
|
|
|
|
|
|
$db->sql_query('UPDATE ' . FORUMS_TABLE . '
|
|
|
|
|
SET ' . implode(', ', update_last_post_information('forum', $forum_id)) . "
|
|
|
|
|
WHERE forum_id = $forum_id");
|
|
|
|
|
|
|
|
|
|
$db->sql_query('UPDATE ' . USERS_TABLE . "
|
|
|
|
|
SET user_lastpost_time = $current_time
|
|
|
|
|
WHERE user_id = " . $user->data['user_id']);
|
|
|
|
|
|
|
|
|
|
$db->sql_transaction('commit');
|
|
|
|
|
|
|
|
|
|
markread('post', $forum_id, $topic_id, $current_time);
|
|
|
|
|
|
2003-11-01 16:10:21 +00:00
|
|
|
|
add_log('mod', $forum_id, $topic_id, sprintf($user->lang['LOGM_BUMP'], $topic_title));
|
2003-10-22 20:41:00 +00:00
|
|
|
|
|
2003-10-19 15:36:45 +00:00
|
|
|
|
meta_refresh(3, "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=$topic_last_post_id#$topic_last_post_id");
|
|
|
|
|
|
|
|
|
|
$message = $user->lang['TOPIC_BUMPED'] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="viewtopic.' . $phpEx . $SID . "&f=$forum_id&t=$topic_id&p=$topic_last_post_id#$topic_last_post_id\">", '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID .'&f=' . $forum_id . '">', '</a>');
|
|
|
|
|
trigger_error($message);
|
|
|
|
|
}
|
2003-11-01 16:10:21 +00:00
|
|
|
|
else if ($mode == 'bump')
|
|
|
|
|
{
|
|
|
|
|
trigger_error('BUMP_ERROR');
|
|
|
|
|
}
|
2003-10-19 15:36:45 +00:00
|
|
|
|
|
2003-09-04 18:30:20 +00:00
|
|
|
|
// Save Draft
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ($save && $user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts'))
|
2003-09-04 18:30:20 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$subject = preg_replace('#&(\#[0-9]+;)#', '&\1', request_var('subject', ''));
|
|
|
|
|
$subject = ($subject == '' && $mode != 'post') ? $topic_title : $subject;
|
|
|
|
|
$message = (isset($_POST['message'])) ? htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message']))) : '';
|
|
|
|
|
$message = preg_replace('#&(\#[0-9]+;)#', '&\1', $message);
|
|
|
|
|
|
|
|
|
|
if ($subject != '' && $message != '')
|
|
|
|
|
{
|
|
|
|
|
$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
|
|
|
|
|
'user_id' => $user->data['user_id'],
|
|
|
|
|
'topic_id' => $topic_id,
|
|
|
|
|
'forum_id' => $forum_id,
|
|
|
|
|
'save_time' => $current_time,
|
|
|
|
|
'draft_subject' => $subject,
|
|
|
|
|
'draft_message' => $message));
|
2003-09-04 18:30:20 +00:00
|
|
|
|
$db->sql_query($sql);
|
2003-11-16 21:53:56 +00:00
|
|
|
|
|
|
|
|
|
if ($mode == 'post')
|
2003-09-04 18:30:20 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$meta_info = "viewforum.$phpEx$SID&f=$forum_id";
|
2003-09-04 18:30:20 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$meta_info = "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id";
|
2003-09-04 18:30:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
meta_refresh(3, $meta_info);
|
|
|
|
|
|
|
|
|
|
$message = $user->lang['DRAFT_SAVED'] . '<br /><br />';
|
|
|
|
|
$message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $meta_info . '">', '</a>') . '<br /><br />' : '';
|
|
|
|
|
$message .= sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>');
|
|
|
|
|
|
|
|
|
|
trigger_error($message);
|
2003-09-04 18:30:20 +00:00
|
|
|
|
}
|
2003-10-09 14:48:55 +00:00
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
unset($subject);
|
|
|
|
|
unset($message);
|
2003-09-04 18:30:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
// Load Draft
|
|
|
|
|
if ($draft_id && $user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts'))
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT draft_subject, draft_message
|
|
|
|
|
FROM ' . DRAFTS_TABLE . "
|
|
|
|
|
WHERE draft_id = $draft_id
|
|
|
|
|
AND user_id = " . $user->data['user_id'];
|
|
|
|
|
$result = $db->sql_query_limit($sql, 1);
|
|
|
|
|
|
|
|
|
|
if ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
|
|
|
|
$_REQUEST['subject'] = $row['draft_subject'];
|
|
|
|
|
$_POST['message'] = $row['draft_message'];
|
|
|
|
|
$refresh = true;
|
|
|
|
|
$template->assign_var('S_DRAFT_LOADED', true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$draft_id = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load Drafts
|
|
|
|
|
if ($load && $drafts)
|
|
|
|
|
{
|
|
|
|
|
load_drafts($topic_id, $forum_id);
|
|
|
|
|
}
|
2003-09-04 18:30:20 +00:00
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
|
if ($submit || $preview || $refresh)
|
2002-10-04 13:09:10 +00:00
|
|
|
|
{
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$topic_cur_post_id = request_var('topic_cur_post_id', 0);
|
|
|
|
|
$subject = request_var('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-10-12 09:18:56 +00:00
|
|
|
|
$subject = preg_replace('#&(\#[0-9]+;)#', '&\1', $subject);
|
|
|
|
|
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
2003-10-11 11:57:03 +00:00
|
|
|
|
$message_parser->message = (isset($_POST['message'])) ? htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message']))) : '';
|
2003-10-12 09:18:56 +00:00
|
|
|
|
$message_parser->message = preg_replace('#&(\#[0-9]+;)#', '&\1', $message_parser->message);
|
2003-09-08 07:05:29 +00:00
|
|
|
|
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$username = (!empty($_POST['username'])) ? request_var('username', '') : ((!empty($username)) ? $username : '');
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$topic_type = (isset($_POST['topic_type'])) ? (int) $_POST['topic_type'] : (($mode != 'post') ? $topic_type : POST_NORMAL);
|
2003-10-10 15:02:48 +00:00
|
|
|
|
$topic_time_limit = (isset($_POST['topic_time_limit'])) ? (int) $_POST['topic_time_limit'] : (($mode != 'post') ? $topic_time_limit : 0);
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$icon_id = request_var('icon', 0);
|
2003-02-27 23:37:02 +00:00
|
|
|
|
|
2003-05-22 01:35:48 +00:00
|
|
|
|
$enable_html = (!$html_status || !empty($_POST['disable_html'])) ? FALSE : TRUE;
|
|
|
|
|
$enable_bbcode = (!$bbcode_status || !empty($_POST['disable_bbcode'])) ? FALSE : TRUE;
|
|
|
|
|
$enable_smilies = (!$smilies_status || !empty($_POST['disable_smilies'])) ? FALSE : TRUE;
|
2003-03-02 13:32:53 +00:00
|
|
|
|
$enable_urls = (isset($_POST['disable_magic_url'])) ? 0 : 1;
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$enable_sig = (!$config['allow_sig']) ? FALSE : ((!empty($_POST['attach_sig']) && $user->data['user_id'] != ANONYMOUS) ? TRUE : FALSE);
|
2003-04-23 22:00:32 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$notify = (!empty($_POST['notify'])) ? TRUE : FALSE;
|
|
|
|
|
$topic_lock = (isset($_POST['lock_topic'])) ? TRUE : FALSE;
|
|
|
|
|
$post_lock = (isset($_POST['lock_post'])) ? TRUE : FALSE;
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$poll_delete = (isset($_POST['poll_delete'])) ? TRUE : FALSE;
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
2003-06-06 19:05:21 +00:00
|
|
|
|
// Faster than crc32
|
2003-08-30 12:21:31 +00:00
|
|
|
|
$check_value = (($preview || $refresh) && isset($_POST['status_switch'])) ? (int) $_POST['status_switch'] : (($enable_html+1) << 16) + (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1);
|
|
|
|
|
$status_switch = (isset($_POST['status_switch']) && (int) $_POST['status_switch'] != $check_value) ? TRUE : FALSE;
|
2003-06-06 19:05:21 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if ($poll_delete && (($mode == 'edit' && !empty($poll_options) && empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id)))
|
2003-03-10 19:39:50 +00:00
|
|
|
|
{
|
2003-04-18 13:07:19 +00:00
|
|
|
|
// Delete Poll
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ', ' . POLL_VOTES_TABLE . "
|
2003-06-17 19:34:17 +00:00
|
|
|
|
WHERE topic_id = $topic_id";
|
2003-04-18 13:07:19 +00:00
|
|
|
|
$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 . '
|
2003-06-17 19:34:17 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$poll_title = request_var('poll_title', '');
|
|
|
|
|
$poll_length = request_var('poll_length', 0);
|
|
|
|
|
$poll_option_text = request_var('poll_option_text', '');
|
|
|
|
|
$poll_max_options = request_var('poll_max_options', 1);
|
2003-03-10 19:39:50 +00:00
|
|
|
|
}
|
2003-02-27 23:37:02 +00:00
|
|
|
|
|
2003-06-24 16:46:30 +00:00
|
|
|
|
|
2002-11-21 01:35:53 +00:00
|
|
|
|
// If replying/quoting and last post id has changed
|
2003-06-06 19:05:21 +00:00
|
|
|
|
// give user option to continue 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-11-16 21:53:56 +00:00
|
|
|
|
if (($mode == 'reply' || $mode == 'quote') && $topic_cur_post_id && $topic_cur_post_id != $topic_last_post_id)
|
2002-11-21 01:35:53 +00:00
|
|
|
|
{
|
2003-10-11 11:46:29 +00:00
|
|
|
|
if (topic_review($topic_id, $forum_id, 'post_review', $topic_cur_post_id))
|
2003-04-20 16:49:26 +00:00
|
|
|
|
{
|
2003-10-09 16:55:56 +00:00
|
|
|
|
$template->assign_var('S_POST_REVIEW', TRUE);
|
2003-04-20 16:49:26 +00:00
|
|
|
|
}
|
|
|
|
|
$submit = FALSE;
|
|
|
|
|
$refresh = TRUE;
|
2002-11-21 01:35:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-24 16:46:30 +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-06-07 16:37:16 +00:00
|
|
|
|
if ($mode != 'edit' || $message_md5 != $post_checksum || $status_switch || $preview)
|
2002-10-04 13:09:10 +00:00
|
|
|
|
{
|
2002-10-28 00:08:18 +00:00
|
|
|
|
// Parse message
|
2003-11-27 23:44:59 +00:00
|
|
|
|
$message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $img_status, $flash_status, $quote_status);
|
2002-10-28 00:08:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-29 10:59:36 +00:00
|
|
|
|
$message_parser->parse_attachments($mode, $post_id, $submit, $preview, $refresh);
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
2003-11-27 23:44:59 +00:00
|
|
|
|
if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id))
|
2002-10-28 00:08:18 +00:00
|
|
|
|
{
|
|
|
|
|
// Flood check
|
2003-11-30 17:45:13 +00:00
|
|
|
|
$last_post_time = 0;
|
|
|
|
|
|
2003-10-12 09:18:56 +00:00
|
|
|
|
if ($user->data['user_id'] != ANONYMOUS)
|
|
|
|
|
{
|
2003-11-30 17:45:13 +00:00
|
|
|
|
$last_post_time = $user->data['user_lastpost_time'];
|
2003-10-12 09:18:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-11-27 23:44:59 +00:00
|
|
|
|
$sql = 'SELECT post_time AS last_post_time
|
|
|
|
|
FROM ' . POSTS_TABLE . "
|
|
|
|
|
WHERE poster_ip = '" . $user->ip . "'
|
|
|
|
|
AND post_time > " . ($current_time - $config['flood_interval']);
|
2003-11-30 17:45:13 +00:00
|
|
|
|
$result = $db->sql_query_limit($sql, 1);
|
|
|
|
|
if ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
|
|
|
|
$last_post_time = $row['last_post_time'];
|
|
|
|
|
}
|
2003-10-12 09:18:56 +00:00
|
|
|
|
}
|
2002-10-28 00:08:18 +00:00
|
|
|
|
|
2003-11-30 17:45:13 +00:00
|
|
|
|
if ($last_post_time)
|
2002-10-28 00:08:18 +00:00
|
|
|
|
{
|
2003-11-30 17:45:13 +00:00
|
|
|
|
if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval']))
|
2002-10-28 00:08:18 +00:00
|
|
|
|
{
|
2003-06-23 14:00:57 +00:00
|
|
|
|
$error[] = $user->lang['FLOOD_ERROR'];
|
2002-10-28 00:08:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-12 09:18:56 +00:00
|
|
|
|
$db->sql_freeresult($result);
|
2002-10-28 00:08:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate username
|
2003-06-23 14:00:57 +00:00
|
|
|
|
// TODO
|
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);
|
2002-10-28 00:08:18 +00:00
|
|
|
|
$username = strip_tags(htmlspecialchars($username));
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
if (($result = validate_username($username)) != FALSE)
|
2002-10-28 00:08:18 +00:00
|
|
|
|
{
|
2003-06-23 14:00:57 +00:00
|
|
|
|
$error[] = $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-06-23 14:00:57 +00:00
|
|
|
|
$error[] = $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-06-29 10:59:36 +00:00
|
|
|
|
$message_parser->parse_poll($poll, $poll_data);
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
|
|
|
|
$poll_options = $poll['poll_options'];
|
|
|
|
|
$poll_title = $poll['poll_title'];
|
2002-10-30 00:57:27 +00:00
|
|
|
|
|
|
|
|
|
// Check topic type
|
2003-10-28 21:23:49 +00:00
|
|
|
|
if ($topic_type != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $topic_first_post_id == $post_id)))
|
2002-10-30 00:57:27 +00:00
|
|
|
|
{
|
|
|
|
|
switch ($topic_type)
|
|
|
|
|
{
|
2003-05-05 22:48:17 +00:00
|
|
|
|
case POST_GLOBAL:
|
2003-02-26 19:53:10 +00:00
|
|
|
|
case POST_ANNOUNCE:
|
2003-06-23 14:00:57 +00:00
|
|
|
|
$auth_option = 'f_announce';
|
2002-10-30 00:57:27 +00:00
|
|
|
|
break;
|
2003-02-26 19:53:10 +00:00
|
|
|
|
case POST_STICKY:
|
2003-06-23 14:00:57 +00:00
|
|
|
|
$auth_option = 'f_sticky';
|
2002-10-30 00:57:27 +00:00
|
|
|
|
break;
|
2003-06-23 14:00:57 +00:00
|
|
|
|
default:
|
|
|
|
|
$auth_option = '';
|
2002-10-30 00:57:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
if (!$auth->acl_get($auth_option, $forum_id))
|
2002-10-30 00:57:27 +00:00
|
|
|
|
{
|
2003-10-28 21:23:49 +00:00
|
|
|
|
$error[] = $user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))];
|
2002-10-30 00:57:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-29 10:59:36 +00:00
|
|
|
|
if (sizeof($message_parser->warn_msg))
|
|
|
|
|
{
|
|
|
|
|
$error[] = implode('<br />', $message_parser->warn_msg);
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-28 20:39:06 +00:00
|
|
|
|
// Store message, sync counters
|
2003-06-23 14:00:57 +00:00
|
|
|
|
if (!sizeof($error) && $submit)
|
2002-10-28 00:08:18 +00:00
|
|
|
|
{
|
2003-08-30 12:21:31 +00:00
|
|
|
|
// Check if we want to de-globalize the topic... and ask for new forum
|
|
|
|
|
if ($topic_type != POST_GLOBAL)
|
2003-04-12 14:30:21 +00:00
|
|
|
|
{
|
2003-08-30 12:59:29 +00:00
|
|
|
|
$sql = 'SELECT topic_type, forum_id
|
2003-08-30 12:21:31 +00:00
|
|
|
|
FROM ' . TOPICS_TABLE . "
|
|
|
|
|
WHERE topic_id = $topic_id";
|
|
|
|
|
$result = $db->sql_query_limit($sql, 1);
|
2003-04-12 14:30:21 +00:00
|
|
|
|
|
2003-08-30 12:21:31 +00:00
|
|
|
|
$row = $db->sql_fetchrow($result);
|
2003-04-12 14:30:21 +00:00
|
|
|
|
|
2003-08-30 12:59:29 +00:00
|
|
|
|
if ($row && (int)$row['forum_id'] == 0 && $row['topic_type'] == POST_GLOBAL)
|
2003-08-30 12:21:31 +00:00
|
|
|
|
{
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$to_forum_id = request_var('to_forum_id', 0);
|
2003-08-30 12:21:31 +00:00
|
|
|
|
|
|
|
|
|
if (!$to_forum_id)
|
|
|
|
|
{
|
|
|
|
|
$template->assign_vars(array(
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_FORUM_SELECT' => make_forum_select(FALSE, FALSE, FALSE, TRUE, TRUE),
|
2003-08-30 12:21:31 +00:00
|
|
|
|
'S_UNGLOBALISE' => TRUE)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$submit = FALSE;
|
|
|
|
|
$refresh = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$forum_id = $to_forum_id;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-12 14:30:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-30 12:21:31 +00:00
|
|
|
|
if ($submit)
|
2003-04-12 14:30:21 +00:00
|
|
|
|
{
|
2003-08-30 12:21:31 +00:00
|
|
|
|
// Lock/Unlock Topic
|
|
|
|
|
$change_topic_status = $topic_status;
|
2003-11-04 22:05:38 +00:00
|
|
|
|
$perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['user_id'] != ANONYMOUS && $user->data['user_id'] == $topic_poster)) ? TRUE : FALSE;
|
2003-04-12 14:30:21 +00:00
|
|
|
|
|
2003-10-12 09:18:56 +00:00
|
|
|
|
if ($topic_status == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock)
|
2003-08-30 12:21:31 +00:00
|
|
|
|
{
|
|
|
|
|
$change_topic_status = ITEM_UNLOCKED;
|
|
|
|
|
}
|
2003-10-12 09:18:56 +00:00
|
|
|
|
else if ($topic_status == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock)
|
2003-08-30 12:21:31 +00:00
|
|
|
|
{
|
|
|
|
|
$change_topic_status = ITEM_LOCKED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($change_topic_status != $topic_status)
|
|
|
|
|
{
|
|
|
|
|
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
|
|
|
SET topic_status = $change_topic_status
|
|
|
|
|
WHERE topic_id = $topic_id
|
|
|
|
|
AND topic_moved_id = 0";
|
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['user_id'] != ANONYMOUS && $user->data['user_id'] == $topic_poster) ? 'USER_' : '';
|
|
|
|
|
add_log('mod', $forum_id, $topic_id, sprintf($user->lang['LOGM_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK')], '<a href="' . generate_board_url() . "/viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id" . '" class="gen" target="_blank">' . $topic_title . '</a>'));
|
2003-08-30 12:21:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Lock/Unlock Post Edit
|
|
|
|
|
if ($mode == 'edit' && $post_edit_locked == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id))
|
|
|
|
|
{
|
|
|
|
|
$post_edit_locked = ITEM_UNLOCKED;
|
|
|
|
|
}
|
|
|
|
|
else if ($mode == 'edit' && $post_edit_locked == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id))
|
|
|
|
|
{
|
|
|
|
|
$post_edit_locked = ITEM_LOCKED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$post_data = array(
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'topic_title' => (empty($topic_title)) ? $subject : $topic_title,
|
2003-10-10 15:02:48 +00:00
|
|
|
|
'topic_first_post_id' => (int) $topic_first_post_id,
|
|
|
|
|
'topic_last_post_id' => (int) $topic_last_post_id,
|
|
|
|
|
'topic_time_limit' => (int) $topic_time_limit,
|
|
|
|
|
'post_id' => (int) $post_id,
|
|
|
|
|
'topic_id' => (int) $topic_id,
|
|
|
|
|
'forum_id' => (int) $forum_id,
|
|
|
|
|
'icon_id' => (int) $icon_id,
|
|
|
|
|
'poster_id' => (int) $poster_id,
|
|
|
|
|
'enable_sig' => (bool) $enable_sig,
|
|
|
|
|
'enable_bbcode' => (bool) $enable_bbcode,
|
|
|
|
|
'enable_html' => (bool) $enable_html,
|
|
|
|
|
'enable_smilies' => (bool) $enable_smilies,
|
|
|
|
|
'enable_urls' => (bool) $enable_urls,
|
2003-11-16 21:53:56 +00:00
|
|
|
|
'enable_indexing' => (bool) $enable_indexing,
|
2003-10-10 15:02:48 +00:00
|
|
|
|
'message_md5' => (int) $message_md5,
|
|
|
|
|
'post_checksum' => (int) $post_checksum,
|
2003-08-30 12:21:31 +00:00
|
|
|
|
'forum_parents' => $forum_parents,
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'forum_name' => $forum_name,
|
2003-08-30 12:21:31 +00:00
|
|
|
|
'notify' => $notify,
|
|
|
|
|
'notify_set' => $notify_set,
|
2003-10-10 15:02:48 +00:00
|
|
|
|
'poster_ip' => (int) $poster_ip,
|
|
|
|
|
'post_edit_locked' => (int) $post_edit_locked,
|
|
|
|
|
'bbcode_bitfield' => (int) $message_parser->bbcode_bitfield
|
2003-08-30 12:21:31 +00:00
|
|
|
|
);
|
2003-11-16 21:53:56 +00:00
|
|
|
|
|
2003-08-30 12:21:31 +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-10-09 16:55:56 +00:00
|
|
|
|
$post_subject = stripslashes($subject);
|
2003-02-27 23:37:02 +00:00
|
|
|
|
}
|
2002-10-28 00:08:18 +00:00
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
// Preview
|
2003-06-23 14:00:57 +00:00
|
|
|
|
if (!sizeof($error) && $preview)
|
2003-02-27 23:37:02 +00:00
|
|
|
|
{
|
2003-06-24 16:46:30 +00:00
|
|
|
|
$post_time = ($mode == 'edit') ? $post_time : $current_time;
|
2003-04-11 00:19:29 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$preview_subject = (sizeof($censors['match'])) ? preg_replace($censors['match'], $censors['replace'], $subject) : $subject;
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-06-24 16:46:30 +00:00
|
|
|
|
$preview_signature = ($mode == 'edit') ? $user_sig : $user->data['user_sig'];
|
|
|
|
|
$preview_signature_uid = ($mode == 'edit') ? $user_sig_bbcode_uid : $user->data['user_sig_bbcode_uid'];
|
|
|
|
|
$preview_signature_bitfield = ($mode == 'edit') ? $user_sig_bbcode_bitfield : $user->data['user_sig_bbcode_bitfield'];
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-06-24 16:46:30 +00:00
|
|
|
|
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
|
|
|
|
$bbcode = new bbcode($message_parser->bbcode_bitfield | $preview_signature_bitfield);
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
2003-06-24 16:46:30 +00:00
|
|
|
|
$preview_message = $message_parser->message;
|
|
|
|
|
format_display($preview_message, $preview_signature, $message_parser->bbcode_uid, $preview_signature_uid, $enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $enable_sig);
|
2003-09-07 18:11:37 +00:00
|
|
|
|
|
2003-03-10 19:39:50 +00:00
|
|
|
|
// Poll Preview
|
2003-06-23 14:00:57 +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);
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$preview_poll_title = format_display($poll_title, $null, $message_parser->bbcode_uid, FALSE, $enable_html, $enable_bbcode, $enable_urls, $enable_smilies, FALSE, FALSE);
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'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-09-15 21:05:30 +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-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
|
|
// Attachment Preview
|
|
|
|
|
if (sizeof($message_parser->attachment_data))
|
|
|
|
|
{
|
|
|
|
|
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
|
|
$extensions = $update_count = array();
|
|
|
|
|
|
2003-11-06 17:13:35 +00:00
|
|
|
|
$template->assign_var('S_HAS_ATTACHMENTS', TRUE);
|
2003-11-05 14:57:29 +00:00
|
|
|
|
display_attachments('attachment', $message_parser->attachment_data, $update_count, TRUE);
|
2003-06-17 19:34:17 +00:00
|
|
|
|
}
|
2003-02-26 19:53:10 +00:00
|
|
|
|
}
|
2001-12-16 18:13:34 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-03-10 19:39:50 +00:00
|
|
|
|
// Decode text for message display
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$bbcode_uid = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $bbcode_uid : $message_parser->bbcode_uid;
|
2003-04-17 23:47:26 +00:00
|
|
|
|
|
|
|
|
|
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-06-23 14:00:57 +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-06-23 14:00:57 +00:00
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if ($mode == 'quote' && !$preview && !$refresh)
|
2003-02-27 23:37:02 +00:00
|
|
|
|
{
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$post_text = '[quote="' . $quote_username . '"]' . ((sizeof($censors['match'])) ? preg_replace($censors['match'], $censors['replace'], trim($post_text)) : trim($post_text)) . "[/quote]\n";
|
2003-02-27 23:37:02 +00:00
|
|
|
|
}
|
2001-08-10 22:00:12 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if (($mode == 'reply' || $mode == 'quote') && !$preview && !$refresh)
|
2003-03-10 19:39:50 +00:00
|
|
|
|
{
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$post_subject = ((!preg_match('/^Re:/', $post_subject)) ? 'Re: ' : '') . ((sizeof($censors['match'])) ? preg_replace($censors['match'], $censors['replace'], $post_subject) : $post_subject);
|
2003-03-10 19:39:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
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
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-10 12:11:18 +00:00
|
|
|
|
// Generate smilie listing
|
|
|
|
|
generate_smilies('inline', $forum_id);
|
2001-08-10 22:00:12 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-02-27 23:37:02 +00:00
|
|
|
|
// Generate Topic icons
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$s_topic_icons = FALSE;
|
2003-04-18 13:07:19 +00:00
|
|
|
|
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"' : '')
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$s_topic_icons = TRUE;
|
2003-04-18 13:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
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.
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$topic_type_toggle = FALSE;
|
2003-06-17 19:34:17 +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'),
|
2003-06-23 14:00:57 +00:00
|
|
|
|
'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'),
|
|
|
|
|
'global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL')
|
2003-02-26 19:53:10 +00:00
|
|
|
|
);
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$topic_type_array = array();
|
|
|
|
|
|
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-08-30 12:21:31 +00:00
|
|
|
|
// Temp - we do not have a special post global announcement permission
|
|
|
|
|
$auth_key = ($auth_key == 'global') ? 'announce' : $auth_key;
|
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if ($auth->acl_get('f_' . $auth_key, $forum_id))
|
2001-06-07 07:56:45 +00:00
|
|
|
|
{
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$topic_type_toggle = TRUE;
|
|
|
|
|
$topic_type_array[] = array(
|
|
|
|
|
'VALUE' => $topic_value['const'],
|
|
|
|
|
'S_CHECKED' => ($topic_type == $topic_value['const'] || ($forum_id == 0 && $topic_value['const'] == POST_GLOBAL)) ? ' checked="checked"' : '',
|
|
|
|
|
'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']]
|
|
|
|
|
);
|
2001-06-07 07:56:45 +00:00
|
|
|
|
}
|
2001-07-04 00:34:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
if ($topic_type_toggle)
|
2001-07-04 00:34:33 +00:00
|
|
|
|
{
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$topic_type_array = array_merge(array(0 => array(
|
|
|
|
|
'VALUE' => POST_NORMAL,
|
|
|
|
|
'S_CHECKED' => ($topic_type == POST_NORMAL) ? ' checked="checked"' : '',
|
|
|
|
|
'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])),
|
|
|
|
|
$topic_type_array
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
foreach ($topic_type_array as $array)
|
|
|
|
|
{
|
|
|
|
|
$template->assign_block_vars('topic_type', $array);
|
|
|
|
|
}
|
2003-10-10 15:02:48 +00:00
|
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
|
'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)) ? TRUE : FALSE,
|
|
|
|
|
'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_get('f_announce', $forum_id)) ? TRUE : FALSE)
|
|
|
|
|
);
|
2001-06-13 17:36:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-04-17 07:14:50 +00:00
|
|
|
|
|
2003-10-12 09:18:56 +00:00
|
|
|
|
$html_checked = (isset($enable_html)) ? !$enable_html : (($config['allow_html']) ? !$user->optionget('html') : 1);
|
|
|
|
|
$bbcode_checked = (isset($enable_bbcode)) ? !$enable_bbcode : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1);
|
|
|
|
|
$smilies_checked = (isset($enable_smilies)) ? !$enable_smilies : (($config['allow_smilies']) ? !$user->optionget('smile') : 1);
|
2003-06-17 19:34:17 +00:00
|
|
|
|
$urls_checked = (isset($enable_urls)) ? !$enable_urls : 0;
|
|
|
|
|
$sig_checked = $enable_sig;
|
2003-10-28 21:23:49 +00:00
|
|
|
|
$notify_checked = (isset($notify)) ? $notify : ((!$notify_set) ? (($user->data['user_id'] != ANONYMOUS) ? $user->data['user_notify'] : 0) : 1);
|
2003-06-17 19:34:17 +00:00
|
|
|
|
$lock_topic_checked = (isset($topic_lock)) ? $topic_lock : (($topic_status == ITEM_LOCKED) ? 1 : 0);
|
|
|
|
|
$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-06-17 19:34:17 +00:00
|
|
|
|
$s_action = "posting.$phpEx?sid=" . $user->session_id . "&mode=$mode&f=$forum_id";
|
|
|
|
|
$s_action .= ($topic_id) ? "&t=$topic_id" : '';
|
|
|
|
|
$s_action .= ($post_id) ? "&p=$post_id" : '';
|
2003-02-28 12:57:10 +00:00
|
|
|
|
|
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-06-17 19:34:17 +00:00
|
|
|
|
'parent_id' => $parent_id,
|
|
|
|
|
'forum_parents' => $forum_parents,
|
|
|
|
|
'forum_name' => $forum_name,
|
|
|
|
|
'forum_id' => $forum_id,
|
|
|
|
|
'forum_desc' => ''
|
2003-02-26 19:53:10 +00:00
|
|
|
|
);
|
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 . '" />' : '';
|
2003-10-22 20:41:00 +00:00
|
|
|
|
$s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . $current_time . '" />';
|
2003-06-06 19:05:21 +00:00
|
|
|
|
$s_hidden_fields .= (isset($check_value)) ? '<input type="hidden" name="status_switch" value="' . $check_value . '" />' : '';
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . ((isset($_REQUEST['draft_loaded'])) ? intval($_REQUEST['draft_loaded']) : $draft_id) . '" />' : '';
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
2003-11-04 22:05:38 +00:00
|
|
|
|
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || @ini_get('file_uploads') == '0' || !$config['allow_attachments'] || !$auth->acl_gets('f_attach', 'u_attach', $forum_id)) ? '' : '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-06-26 16:46:17 +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
|
|
|
|
'MESSAGE' => trim($post_text),
|
2003-06-24 16:46:30 +00:00
|
|
|
|
'PREVIEW_SUBJECT' => ($preview && !sizeof($error)) ? $preview_subject : '',
|
|
|
|
|
'PREVIEW_MESSAGE' => ($preview && !sizeof($error)) ? $preview_message : '',
|
|
|
|
|
'PREVIEW_SIGNATURE' => ($preview && !sizeof($error)) ? $preview_signature : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
|
'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) : '',
|
2003-06-24 16:46:30 +00:00
|
|
|
|
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
|
2003-10-10 15:02:48 +00:00
|
|
|
|
'TOPIC_TIME_LIMIT' => (int) $topic_time_limit,
|
2003-02-27 23:37:02 +00:00
|
|
|
|
|
|
|
|
|
'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=" . $forum_id,
|
2003-06-17 19:34:17 +00:00
|
|
|
|
'U_VIEWTOPIC' => ($mode != 'post') ? "viewtopic.$phpEx$SID&$forum_id&t=$topic_id" : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
'S_DISPLAY_PREVIEW' => ($preview && !sizeof($error)),
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_EDIT_POST' => ($mode == 'edit'),
|
|
|
|
|
'S_DISPLAY_USERNAME' => ($user->data['user_id'] == ANONYMOUS || ($mode == 'edit' && $post_username != '')) ? TRUE : FALSE,
|
2003-02-27 23:37:02 +00:00
|
|
|
|
'S_SHOW_TOPIC_ICONS' => $s_topic_icons,
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $topic_last_post_id && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) ? TRUE : FALSE,
|
2003-02-27 23:37:02 +00:00
|
|
|
|
'S_HTML_ALLOWED' => $html_status,
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_HTML_CHECKED' => ($html_checked) ? ' checked="checked"' : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
|
'S_BBCODE_ALLOWED' => $bbcode_status,
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
|
'S_SMILIES_ALLOWED' => $smilies_status,
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '',
|
2003-11-23 22:25:46 +00:00
|
|
|
|
'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['user_id'] != ANONYMOUS) ? TRUE : FALSE,
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '',
|
|
|
|
|
'S_NOTIFY_ALLOWED' => ($user->data['user_id'] != ANONYMOUS) ? TRUE : FALSE,
|
|
|
|
|
'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '',
|
2003-11-04 22:05:38 +00:00
|
|
|
|
'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['user_id'] != ANONYMOUS && $user->data['user_id'] == $topic_poster))) ? TRUE : FALSE,
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '',
|
|
|
|
|
'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? TRUE : FALSE,
|
|
|
|
|
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '',
|
|
|
|
|
'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '',
|
2003-02-27 23:37:02 +00:00
|
|
|
|
'S_TYPE_TOGGLE' => $topic_type_toggle,
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['user_id'] != ANONYMOUS) ? TRUE : FALSE,
|
|
|
|
|
'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['user_id'] != ANONYMOUS && $drafts) ? 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-06-17 19:34:17 +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-03-10 19:39:50 +00:00
|
|
|
|
{
|
|
|
|
|
$template->assign_vars(array(
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_SHOW_POLL_BOX' => TRUE,
|
|
|
|
|
'S_POLL_DELETE' => ($mode == 'edit' && !empty($poll_options) && ((empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) ? TRUE : FALSE,
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
|
|
|
|
'L_POLL_OPTIONS_EXPLAIN'=> sprintf($user->lang['POLL_OPTIONS_EXPLAIN'], $config['max_poll_options']),
|
|
|
|
|
|
2003-06-17 19:34:17 +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-06-29 10:59:36 +00:00
|
|
|
|
else if ($mode == 'edit' && !empty($poll_last_vote) && ($auth->acl_get('f_poll', $forum_id) || $auth->acl_get('m_edit', $forum_id)))
|
|
|
|
|
{
|
|
|
|
|
$template->assign_vars(array(
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_POLL_DELETE' => ($mode == 'edit' && !empty($poll_options) && ($auth->acl_get('f_delete', $forum_id) || $auth->acl_get('m_delete', $forum_id))) ? TRUE : FALSE)
|
2003-06-29 10:59:36 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
2003-03-10 19:39:50 +00:00
|
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
|
// Attachment entry
|
2003-11-04 22:05:38 +00:00
|
|
|
|
if ($auth->acl_gets('f_attach', 'u_attach', $forum_id) && $config['allow_attachments'] && $form_enctype != '')
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
|
|
|
|
$template->assign_vars(array(
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_SHOW_ATTACH_BOX' => TRUE)
|
2003-03-22 15:48:46 +00:00
|
|
|
|
);
|
|
|
|
|
|
2003-09-04 18:30:20 +00:00
|
|
|
|
if (sizeof($message_parser->attachment_data))
|
2003-03-22 15:48:46 +00:00
|
|
|
|
{
|
|
|
|
|
$template->assign_vars(array(
|
2003-09-15 21:05:30 +00:00
|
|
|
|
'S_HAS_ATTACHMENTS' => TRUE)
|
2003-03-22 15:48:46 +00:00
|
|
|
|
);
|
|
|
|
|
|
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
|
|
|
|
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$download_link = (!$attach_row['attach_id']) ? $config['upload_dir'] . '/' . $attach_row['physical_filename'] : $phpbb_root_path . "download.$phpEx$SID&id=" . intval($attach_row['attach_id']);
|
2003-05-01 18:24:18 +00:00
|
|
|
|
|
2003-03-22 15:48:46 +00:00
|
|
|
|
$template->assign_block_vars('attach_row', array(
|
2003-06-17 19:34:17 +00:00
|
|
|
|
'FILENAME' => $attach_row['real_filename'],
|
|
|
|
|
'ATTACH_FILENAME' => $attach_row['physical_filename'],
|
2003-09-04 18:30:20 +00:00
|
|
|
|
'FILE_COMMENT' => $attach_row['comment'],
|
2003-06-17 19:34:17 +00:00
|
|
|
|
'ATTACH_ID' => $attach_row['attach_id'],
|
|
|
|
|
'ASSOC_INDEX' => $count,
|
2003-03-22 15:48:46 +00:00
|
|
|
|
|
|
|
|
|
'U_VIEW_ATTACHMENT' => $download_link,
|
2003-06-17 19:34:17 +00:00
|
|
|
|
'S_HIDDEN' => $hidden)
|
2003-03-22 15:48:46 +00:00
|
|
|
|
);
|
2003-05-01 18:24:18 +00:00
|
|
|
|
|
|
|
|
|
$count++;
|
2003-03-22 15:48:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2003-09-04 18:30:20 +00:00
|
|
|
|
'FILE_COMMENT' => $message_parser->filename_data['filecomment'],
|
2003-06-17 19:34:17 +00:00
|
|
|
|
'FILESIZE' => $config['max_filesize'],
|
|
|
|
|
'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')
|
|
|
|
|
{
|
2003-10-11 11:46:29 +00:00
|
|
|
|
if (topic_review($topic_id, $forum_id))
|
2003-10-09 16:55:56 +00:00
|
|
|
|
{
|
|
|
|
|
$template->assign_var('S_DISPLAY_REVIEW', TRUE);
|
|
|
|
|
}
|
2003-02-28 12:57:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-03 23:58:45 +00:00
|
|
|
|
page_footer();
|
2001-06-13 17:36:58 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
|
|
|
|
// ---------
|
2003-04-18 13:07:19 +00:00
|
|
|
|
// FUNCTIONS
|
2003-06-23 14:00:57 +00:00
|
|
|
|
//
|
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
|
|
|
|
|
// User Notification
|
2003-10-07 17:29:53 +00:00
|
|
|
|
function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id)
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
global $db, $user, $censors, $config, $phpbb_root_path, $phpEx, $auth;
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$topic_notification = ($mode == 'reply' || $mode == 'quote') ? TRUE : FALSE;
|
2003-10-07 17:29:53 +00:00
|
|
|
|
$forum_notification = ($mode == 'post') ? TRUE : FALSE;
|
|
|
|
|
|
|
|
|
|
if (!$topic_notification && !$forum_notification)
|
|
|
|
|
{
|
|
|
|
|
trigger_error('WRONG_NOTIFICATION_MODE');
|
|
|
|
|
}
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
if (empty($censors))
|
|
|
|
|
{
|
|
|
|
|
$censors = array();
|
|
|
|
|
obtain_word_list($censors);
|
|
|
|
|
}
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$topic_title = ($topic_notification) ? $topic_title : $subject;
|
2003-10-07 17:29:53 +00:00
|
|
|
|
decode_text($topic_title);
|
|
|
|
|
$topic_title = (sizeof($censors['match'])) ? preg_replace($censors['match'], $censors['replace'], $topic_title) : $topic_title;
|
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
// Get banned User ID's
|
|
|
|
|
$sql = 'SELECT ban_userid
|
|
|
|
|
FROM ' . BANLIST_TABLE;
|
|
|
|
|
$result = $db->sql_query($sql);
|
2003-06-26 16:46:17 +00:00
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
$sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id'];
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-09-07 15:23:55 +00:00
|
|
|
|
if (isset($row['ban_userid']))
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-09-07 15:23:55 +00:00
|
|
|
|
$sql_ignore_users .= ', ' . $row['ban_userid'];
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
2003-10-07 17:29:53 +00:00
|
|
|
|
$db->sql_freeresult($result);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-07 17:29:53 +00:00
|
|
|
|
$notify_rows = array();
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-07 17:29:53 +00:00
|
|
|
|
// -- get forum_userids || topic_userids
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
|
2003-10-07 17:29:53 +00:00
|
|
|
|
FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u
|
|
|
|
|
WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . "
|
|
|
|
|
AND w.user_id NOT IN ($sql_ignore_users)
|
|
|
|
|
AND w.notify_status = 0
|
|
|
|
|
AND u.user_id = w.user_id";
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$result = $db->sql_query($sql);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-07 17:29:53 +00:00
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-10-07 17:29:53 +00:00
|
|
|
|
$notify_rows[$row['user_id']] = array(
|
|
|
|
|
'user_id' => $row['user_id'],
|
|
|
|
|
'username' => $row['username'],
|
|
|
|
|
'user_email' => $row['user_email'],
|
2003-10-12 11:59:23 +00:00
|
|
|
|
'user_jabber' => $row['user_jabber'],
|
|
|
|
|
'user_lang' => $row['user_lang'],
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'notify_type' => ($topic_notification) ? 'topic' : 'forum',
|
|
|
|
|
'template' => ($topic_notification) ? 'topic_notify' : 'newtopic_notify',
|
2003-10-12 11:59:23 +00:00
|
|
|
|
'method' => $row['user_notify_type'],
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'allowed' => false
|
|
|
|
|
);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
$db->sql_freeresult($result);
|
2003-10-07 17:29:53 +00:00
|
|
|
|
|
|
|
|
|
// forum notification is sent to those not receiving post notification
|
|
|
|
|
if ($topic_notification)
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-10-07 17:29:53 +00:00
|
|
|
|
if (sizeof($notify_rows))
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-10-07 17:29:53 +00:00
|
|
|
|
$sql_ignore_users .= ', ' . implode(', ', array_keys($notify_rows));
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
|
2003-10-07 17:29:53 +00:00
|
|
|
|
FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u
|
|
|
|
|
WHERE fw.forum_id = $forum_id
|
|
|
|
|
AND fw.user_id NOT IN ($sql_ignore_users)
|
|
|
|
|
AND fw.notify_status = 0
|
|
|
|
|
AND u.user_id = fw.user_id";
|
2003-09-07 15:23:55 +00:00
|
|
|
|
$result = $db->sql_query($sql);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
2003-10-07 17:29:53 +00:00
|
|
|
|
$notify_rows[$row['user_id']] = array(
|
|
|
|
|
'user_id' => $row['user_id'],
|
|
|
|
|
'username' => $row['username'],
|
|
|
|
|
'user_email' => $row['user_email'],
|
2003-10-12 11:59:23 +00:00
|
|
|
|
'user_jabber' => $row['user_jabber'],
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'user_lang' => $row['user_lang'],
|
|
|
|
|
'notify_type' => 'forum',
|
|
|
|
|
'template' => 'forum_notify',
|
2003-10-12 11:59:23 +00:00
|
|
|
|
'method' => $row['user_notify_type'],
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'allowed' => false
|
|
|
|
|
);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
$db->sql_freeresult($result);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
2003-10-07 17:29:53 +00:00
|
|
|
|
|
|
|
|
|
if (!sizeof($notify_rows))
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-09-07 15:23:55 +00:00
|
|
|
|
return;
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
foreach ($auth->acl_get_list(array_keys($notify_rows), 'f_read', $forum_id) as $forum_id => $forum_ary)
|
2003-10-07 17:29:53 +00:00
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
foreach ($forum_ary as $auth_option => $user_ary)
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
foreach ($user_ary as $user_id)
|
2003-10-12 11:59:23 +00:00
|
|
|
|
{
|
2003-10-12 14:56:53 +00:00
|
|
|
|
$notify_rows[$user_id]['allowed'] = true;
|
2003-10-12 11:59:23 +00:00
|
|
|
|
}
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-23 22:25:46 +00:00
|
|
|
|
|
2003-10-12 11:59:23 +00:00
|
|
|
|
|
2003-10-07 17:29:53 +00:00
|
|
|
|
// Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;)
|
|
|
|
|
$email_users = $delete_ids = $update_notification = array();
|
|
|
|
|
foreach ($notify_rows as $user_id => $row)
|
2003-11-23 22:25:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (!$row['allowed'] || !trim($row['user_email']))
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-10-07 17:29:53 +00:00
|
|
|
|
$delete_ids[$row['notify_type']][] = $row['user_id'];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$msg_users[] = $row;
|
2003-10-07 17:29:53 +00:00
|
|
|
|
$update_notification[$row['notify_type']][] = $row['user_id'];
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-07 17:29:53 +00:00
|
|
|
|
unset($notify_rows);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-07 17:29:53 +00:00
|
|
|
|
// Now, we are able to really send out notifications
|
2003-10-12 11:59:23 +00:00
|
|
|
|
if (sizeof($msg_users))
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-10-12 11:59:23 +00:00
|
|
|
|
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
|
|
|
|
|
$messenger = new messenger();
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$msg_list_ary = array();
|
|
|
|
|
foreach ($msg_users as $row)
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$pos = sizeof($msg_list_ary[$row['template']]);
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$msg_list_ary[$row['template']][$pos]['method'] = $row['method'];
|
|
|
|
|
$msg_list_ary[$row['template']][$pos]['email'] = $row['user_email'];
|
|
|
|
|
$msg_list_ary[$row['template']][$pos]['jabber'] = $row['user_jabber'];
|
|
|
|
|
$msg_list_ary[$row['template']][$pos]['name'] = $row['username'];
|
|
|
|
|
$msg_list_ary[$row['template']][$pos]['lang'] = $row['user_lang'];
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
|
|
|
|
unset($email_users);
|
|
|
|
|
|
2003-10-12 11:59:23 +00:00
|
|
|
|
foreach ($msg_list_ary as $email_template => $email_list)
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
|
|
|
|
foreach ($email_list as $addr)
|
|
|
|
|
{
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$messenger->template($email_template, $addr['lang']);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$messenger->replyto($config['board_email']);
|
|
|
|
|
$messenger->to($addr['email'], $addr['name']);
|
2003-10-12 15:29:18 +00:00
|
|
|
|
$messenger->im($addr['jabber'], $addr['name']);
|
2003-06-23 14:00:57 +00:00
|
|
|
|
|
2003-10-12 11:59:23 +00:00
|
|
|
|
$messenger->assign_vars(array(
|
|
|
|
|
'EMAIL_SIG' => $email_sig,
|
2003-06-23 14:00:57 +00:00
|
|
|
|
'SITENAME' => $config['sitename'],
|
2003-10-12 11:59:23 +00:00
|
|
|
|
'TOPIC_TITLE' => $topic_title,
|
|
|
|
|
'FORUM_NAME' => $forum_name,
|
|
|
|
|
|
|
|
|
|
'U_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&e=1",
|
|
|
|
|
'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&e=1",
|
|
|
|
|
'U_NEWEST_POST' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&p=$post_id&e=1#$post_id",
|
|
|
|
|
'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&unwatch=topic",
|
|
|
|
|
'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&unwatch=forum",
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
$messenger->send($addr['method']);
|
|
|
|
|
$messenger->reset();
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-07 17:29:53 +00:00
|
|
|
|
unset($email_list_ary);
|
2003-10-12 15:14:05 +00:00
|
|
|
|
|
2003-10-28 21:23:49 +00:00
|
|
|
|
if (!empty($messenger->queue))
|
|
|
|
|
{
|
|
|
|
|
$messenger->queue->save();
|
|
|
|
|
}
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
2003-10-07 17:29:53 +00:00
|
|
|
|
|
2003-10-12 11:59:23 +00:00
|
|
|
|
// Handle the DB updates
|
2003-10-09 14:48:55 +00:00
|
|
|
|
$db->sql_transaction();
|
|
|
|
|
|
2003-10-10 15:02:48 +00:00
|
|
|
|
if (sizeof($update_notification['topic']))
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . "
|
2003-10-10 15:02:48 +00:00
|
|
|
|
SET notify_status = 1
|
2003-08-13 16:58:48 +00:00
|
|
|
|
WHERE topic_id = $topic_id
|
2003-10-19 15:36:45 +00:00
|
|
|
|
AND user_id IN (" . implode(', ', $update_notification['topic']) . ")");
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-10 15:02:48 +00:00
|
|
|
|
if (sizeof($update_notification['forum']))
|
2003-06-23 14:00:57 +00:00
|
|
|
|
{
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$db->sql_query('UPDATE ' . FORUMS_WATCH_TABLE . "
|
2003-10-10 15:02:48 +00:00
|
|
|
|
SET notify_status = 1
|
2003-08-13 16:58:48 +00:00
|
|
|
|
WHERE forum_id = $forum_id
|
2003-10-19 15:36:45 +00:00
|
|
|
|
AND user_id IN (" . implode(', ', $update_notification['forum']) . ")");
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
2003-08-13 16:58:48 +00:00
|
|
|
|
|
2003-10-10 15:02:48 +00:00
|
|
|
|
// Now delete the user_ids not authorized to receive notifications on this topic/forum
|
|
|
|
|
if (sizeof($delete_ids['topic']))
|
2003-08-13 16:58:48 +00:00
|
|
|
|
{
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . "
|
2003-08-13 16:58:48 +00:00
|
|
|
|
WHERE topic_id = $topic_id
|
2003-10-19 15:36:45 +00:00
|
|
|
|
AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")");
|
2003-10-07 17:29:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-10 15:02:48 +00:00
|
|
|
|
if (sizeof($delete_ids['forum']))
|
2003-10-07 17:29:53 +00:00
|
|
|
|
{
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$db->sql_query('DELETE FROM ' . FORUMS_WATCH_TABLE . "
|
2003-10-07 17:29:53 +00:00
|
|
|
|
WHERE forum_id = $forum_id
|
2003-10-19 15:36:45 +00:00
|
|
|
|
AND user_id IN (" . implode(', ', $delete_ids['forum']) . ")");
|
2003-08-13 16:58:48 +00:00
|
|
|
|
}
|
2003-10-09 14:48:55 +00:00
|
|
|
|
|
|
|
|
|
$db->sql_transaction('commit');
|
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
}
|
2003-04-18 13:07:19 +00:00
|
|
|
|
|
|
|
|
|
// Topic Review
|
2003-10-11 11:46:29 +00:00
|
|
|
|
function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0)
|
2003-04-18 13:07:19 +00:00
|
|
|
|
{
|
2003-09-24 19:41:14 +00:00
|
|
|
|
global $user, $auth, $db, $template, $bbcode, $template;
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Go ahead and pull all data for this topic
|
2003-10-09 16:55:56 +00:00
|
|
|
|
$sql = 'SELECT u.username, u.user_id, u.user_karma, p.post_id, p.post_username, p.post_subject, p.post_text, p.enable_smilies, p.bbcode_uid, p.bbcode_bitfield, p.post_time
|
2003-05-22 01:35:48 +00:00
|
|
|
|
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
|
2003-04-18 13:07:19 +00:00
|
|
|
|
WHERE p.topic_id = $topic_id
|
|
|
|
|
AND p.poster_id = u.user_id
|
2003-05-22 01:35:48 +00:00
|
|
|
|
" . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . '
|
2003-10-09 16:55:56 +00:00
|
|
|
|
' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . '
|
2003-05-22 01:35:48 +00:00
|
|
|
|
ORDER BY p.post_time DESC';
|
2003-04-18 13:07:19 +00:00
|
|
|
|
$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 ...
|
2003-05-22 01:35:48 +00:00
|
|
|
|
if (!$row = $db->sql_fetchrow($result))
|
2003-04-18 13:07:19 +00:00
|
|
|
|
{
|
2003-10-09 16:55:56 +00:00
|
|
|
|
return FALSE;
|
2003-05-22 01:35:48 +00:00
|
|
|
|
}
|
2003-04-18 13:07:19 +00:00
|
|
|
|
|
2003-05-22 01:35:48 +00:00
|
|
|
|
$bbcode_bitfield = 0;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
$rowset[] = $row;
|
|
|
|
|
$bbcode_bitfield |= $row['bbcode_bitfield'];
|
|
|
|
|
}
|
|
|
|
|
while ($row = $db->sql_fetchrow($result));
|
|
|
|
|
$db->sql_freeresult($result);
|
2003-04-18 13:07:19 +00:00
|
|
|
|
|
2003-05-22 01:35:48 +00:00
|
|
|
|
// Instantiate BBCode class
|
|
|
|
|
if (!isset($bbcode) && $bbcode_bitfield)
|
|
|
|
|
{
|
|
|
|
|
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
|
|
|
|
|
$bbcode = new bbcode($bbcode_bitfield);
|
|
|
|
|
}
|
2003-04-18 13:07:19 +00:00
|
|
|
|
|
2003-05-22 01:35:48 +00:00
|
|
|
|
foreach ($rowset as $i => $row)
|
|
|
|
|
{
|
|
|
|
|
$poster_id = $row['user_id'];
|
|
|
|
|
$poster = $row['username'];
|
2003-04-18 13:07:19 +00:00
|
|
|
|
|
2003-05-22 01:35:48 +00:00
|
|
|
|
// Handle anon users posting with usernames
|
|
|
|
|
if ($poster_id == ANONYMOUS && $row['post_username'] != '')
|
|
|
|
|
{
|
|
|
|
|
$poster = $row['post_username'];
|
|
|
|
|
$poster_rank = $user->lang['GUEST'];
|
|
|
|
|
}
|
2003-04-18 13:07:19 +00:00
|
|
|
|
|
2003-05-22 01:35:48 +00:00
|
|
|
|
$post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : '';
|
2003-06-17 19:34:17 +00:00
|
|
|
|
$message = (empty($row['enable_smilies']) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $row['post_text']) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $row['post_text']);
|
2003-04-18 13:07:19 +00:00
|
|
|
|
|
2003-05-22 01:35:48 +00:00
|
|
|
|
if ($row['bbcode_bitfield'])
|
|
|
|
|
{
|
2003-09-07 17:52:53 +00:00
|
|
|
|
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
2003-04-18 13:07:19 +00:00
|
|
|
|
}
|
2003-05-22 01:35:48 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
if (sizeof($censors['match']))
|
2003-05-22 01:35:48 +00:00
|
|
|
|
{
|
|
|
|
|
$post_subject = preg_replace($censors['match'], $censors['replace'], $post_subject);
|
|
|
|
|
$message = preg_replace($censors['match'], $censors['replace'], $message);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-09 16:55:56 +00:00
|
|
|
|
$template->assign_block_vars($mode . '_row', array(
|
|
|
|
|
'KARMA_IMG' => '<img src="images/karma' . $row['user_karma'] . '.gif" alt="' . $user->lang['KARMA_LEVEL'] . ': ' . $user->lang['KARMA'][$row['user_karma']] . '" title="' . $user->lang['KARMA_LEVEL'] . ': ' . $user->lang['KARMA'][$row['user_karma']] . '" />',
|
2003-05-23 16:15:03 +00:00
|
|
|
|
'POSTER_NAME' => $poster,
|
|
|
|
|
'POST_SUBJECT' => $post_subject,
|
2003-10-09 16:55:56 +00:00
|
|
|
|
'MINI_POST_IMG' => $user->img('icon_post', $user->lang['POST']),
|
|
|
|
|
'POST_DATE' => $user->format_date($row['post_time']),
|
2003-05-23 16:15:03 +00:00
|
|
|
|
'MESSAGE' => str_replace("\n", '<br />', $message),
|
|
|
|
|
|
2003-10-09 16:55:56 +00:00
|
|
|
|
'U_POST_ID' => $row['post_id'],
|
|
|
|
|
'U_MINI_POST' => "{$phpbb_root_path}viewtopic.$phpEx$SID&p=" . $row['post_id'] . '#' . $row['post_id'],
|
2003-11-27 23:44:59 +00:00
|
|
|
|
'U_QUOTE' => ($quote_status) ? 'javascript:addquote(' . $row['post_id'] . ", '" . str_replace("'", "\\'", $poster) . "')" : '',
|
2003-05-22 01:35:48 +00:00
|
|
|
|
|
|
|
|
|
'S_ROW_COUNT' => $i)
|
|
|
|
|
);
|
|
|
|
|
unset($rowset[$i]);
|
2003-04-18 13:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-09 16:55:56 +00:00
|
|
|
|
if ($mode == 'topic_review')
|
|
|
|
|
{
|
|
|
|
|
$template->assign_var('QUOTE_IMG', $user->img('btn_quote', $user->lang['QUOTE_POST']));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2003-04-18 13:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-24 19:41:14 +00:00
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
// Temp Function - strtolower - borrowed from php.net
|
2003-04-20 16:49:26 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2003-05-22 01:35:48 +00:00
|
|
|
|
$new_string .= strtolower($string{$i});
|
2003-04-20 16:49:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $new_string;
|
|
|
|
|
}
|
2003-04-18 13:07:19 +00:00
|
|
|
|
|
2003-09-07 15:49:03 +00:00
|
|
|
|
// Delete Post
|
|
|
|
|
function delete_post($mode, $post_id, $topic_id, $forum_id, $data)
|
|
|
|
|
{
|
|
|
|
|
global $db, $user, $config, $auth, $phpEx, $SID;
|
|
|
|
|
|
|
|
|
|
// Specify our post mode
|
|
|
|
|
$post_mode = ($data['topic_first_post_id'] == $data['topic_last_post_id']) ? 'delete_topic' : (($data['topic_first_post_id'] == $post_id) ? 'delete_first_post' : (($data['topic_last_post_id'] == $post_id) ? 'delete_last_post' : 'delete'));
|
2003-10-11 11:46:29 +00:00
|
|
|
|
$sql_data = array();
|
2003-09-07 15:49:03 +00:00
|
|
|
|
$next_post_id = 0;
|
|
|
|
|
|
|
|
|
|
$db->sql_transaction();
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
if (!delete_posts('post_id', array($post_id), FALSE))
|
2003-09-07 15:49:03 +00:00
|
|
|
|
{
|
|
|
|
|
// Try to delete topic, we may had an previous error causing inconsistency
|
|
|
|
|
if ($post_mode = 'delete_topic')
|
|
|
|
|
{
|
2003-09-15 21:05:30 +00:00
|
|
|
|
delete_topics('topic_id', array($topic_id), FALSE);
|
2003-09-07 15:49:03 +00:00
|
|
|
|
}
|
2003-10-12 09:18:56 +00:00
|
|
|
|
trigger_error('ALREADY_DELETED');
|
2003-09-07 15:49:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$db->sql_transaction('commit');
|
|
|
|
|
|
|
|
|
|
// Collect the necessary informations for updating the tables
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE] = '';
|
2003-09-07 15:49:03 +00:00
|
|
|
|
switch ($post_mode)
|
|
|
|
|
{
|
|
|
|
|
case 'delete_topic':
|
2003-09-15 21:05:30 +00:00
|
|
|
|
delete_topics('topic_id', array($topic_id), FALSE);
|
|
|
|
|
set_config('num_topics', $config['num_topics'] - 1, TRUE);
|
|
|
|
|
|
|
|
|
|
if ($data['topic_type'] != POST_GLOBAL)
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE] .= 'forum_posts = forum_posts - 1, forum_topics_real = forum_topics_real - 1';
|
|
|
|
|
$sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_topics = forum_topics - 1' : '';
|
2003-09-15 21:05:30 +00:00
|
|
|
|
}
|
2003-09-07 15:49:03 +00:00
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE] != '') ? ', ' : '';
|
|
|
|
|
$sql_data[FORUMS_TABLE] .= implode(', ', update_last_post_information('forum', $forum_id));
|
|
|
|
|
$sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
|
2003-09-07 15:49:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'delete_first_post':
|
|
|
|
|
$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
|
|
|
|
|
ORDER BY p.post_time ASC";
|
|
|
|
|
$result = $db->sql_query_limit($sql, 1);
|
|
|
|
|
|
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
if ($data['topic_type'] != POST_GLOBAL)
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1';
|
2003-09-15 21:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[TOPICS_TABLE] = 'topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
|
|
|
|
|
$sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
|
2003-09-07 15:49:03 +00:00
|
|
|
|
|
|
|
|
|
$next_post_id = (int) $row['post_id'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'delete_last_post':
|
2003-09-15 21:05:30 +00:00
|
|
|
|
if ($data['topic_type'] != POST_GLOBAL)
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1';
|
2003-09-15 21:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE] != '') ? ', ' : '';
|
|
|
|
|
$sql_data[FORUMS_TABLE] .= implode(', ', update_last_post_information('forum', $forum_id));
|
|
|
|
|
$sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
|
2003-11-22 12:44:01 +00:00
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$update = update_last_post_information('topic', $topic_id);
|
2003-09-07 15:49:03 +00:00
|
|
|
|
if (sizeof($update))
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update);
|
2003-11-22 12:44:01 +00:00
|
|
|
|
$next_post_id = (int) str_replace('topic_last_post_id = ', '', $update[0]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT MAX(post_id) as last_post_id
|
|
|
|
|
FROM ' . POSTS_TABLE . "
|
|
|
|
|
WHERE topic_id = $topic_id " .
|
|
|
|
|
(($auth->acl_get('m_approve')) ? 'AND post_approved = 1' : '');
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
|
|
$next_post_id = (int) $row['last_post_id'];
|
2003-09-07 15:49:03 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'delete':
|
|
|
|
|
$sql = 'SELECT post_id
|
|
|
|
|
FROM ' . POSTS_TABLE . "
|
|
|
|
|
WHERE topic_id = $topic_id " .
|
|
|
|
|
(($auth->acl_get('m_approve')) ? 'AND post_approved = 1' : '') . '
|
|
|
|
|
AND post_time > ' . $data['post_time'] . '
|
|
|
|
|
ORDER BY post_time ASC';
|
|
|
|
|
$result = $db->sql_query_limit($sql, 1);
|
|
|
|
|
|
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
if ($data['topic_type'] != POST_GLOBAL)
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1';
|
2003-09-15 21:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
|
2003-09-07 15:49:03 +00:00
|
|
|
|
$next_post_id = (int) $row['post_id'];
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[USERS_TABLE] = ($auth->acl_get('f_postcount', $forum_id)) ? 'user_posts = user_posts - 1' : '';
|
2003-09-07 15:49:03 +00:00
|
|
|
|
set_config('num_posts', $config['num_posts'] - 1, TRUE);
|
|
|
|
|
|
|
|
|
|
$db->sql_transaction();
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$where_sql = array(FORUMS_TABLE => "forum_id = $forum_id", TOPICS_TABLE => "topic_id = $topic_id", USERS_TABLE => 'user_id = ' . $data['poster_id']);
|
2003-09-07 15:49:03 +00:00
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
foreach ($sql_data as $table => $update_sql)
|
2003-09-07 15:49:03 +00:00
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
if ($update_sql != '')
|
|
|
|
|
{
|
|
|
|
|
$db->sql_query("UPDATE $table SET $update_sql WHERE " . $where_sql[$table]);
|
|
|
|
|
}
|
2003-09-07 15:49:03 +00:00
|
|
|
|
}
|
2003-10-11 11:46:29 +00:00
|
|
|
|
|
2003-09-07 15:49:03 +00:00
|
|
|
|
$db->sql_transaction('commit');
|
|
|
|
|
|
|
|
|
|
return $next_post_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
// Submit Post
|
|
|
|
|
function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $attach_data, $filename_data, $data)
|
|
|
|
|
{
|
|
|
|
|
global $db, $auth, $user, $config, $phpEx, $SID, $template;
|
|
|
|
|
|
|
|
|
|
// We do not handle erasing posts here
|
|
|
|
|
if ($mode == 'delete')
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$current_time = time();
|
|
|
|
|
|
|
|
|
|
if ($mode == 'post')
|
|
|
|
|
{
|
|
|
|
|
$post_mode = 'post';
|
|
|
|
|
}
|
|
|
|
|
else if ($mode != 'edit')
|
|
|
|
|
{
|
|
|
|
|
$post_mode = 'reply';
|
|
|
|
|
}
|
|
|
|
|
else if ($mode == 'edit')
|
|
|
|
|
{
|
|
|
|
|
$post_mode = ($data['topic_first_post_id'] == $data['topic_last_post_id']) ? 'edit_topic' : (($data['topic_first_post_id'] == $data['post_id']) ? 'edit_first_post' : (($data['topic_last_post_id'] == $data['post_id']) ? 'edit_last_post' : 'edit'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Collect some basic informations about which tables and which rows to update/insert
|
|
|
|
|
$sql_data = array();
|
|
|
|
|
$poster_id = ($mode == 'edit') ? $data['poster_id'] : (int) $user->data['user_id'];
|
|
|
|
|
|
|
|
|
|
// Collect Informations
|
|
|
|
|
switch ($post_mode)
|
|
|
|
|
{
|
|
|
|
|
case 'post':
|
|
|
|
|
case 'reply':
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[POSTS_TABLE]['sql'] = array(
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
|
|
|
|
|
'poster_id' => (int) $user->data['user_id'],
|
|
|
|
|
'icon_id' => $data['icon_id'],
|
|
|
|
|
'poster_ip' => $user->ip,
|
|
|
|
|
'post_time' => $current_time,
|
|
|
|
|
'post_approved' => ($auth->acl_get('f_moderate', $data['forum_id'])) ? 0 : 1,
|
|
|
|
|
'enable_bbcode' => $data['enable_bbcode'],
|
|
|
|
|
'enable_html' => $data['enable_html'],
|
|
|
|
|
'enable_smilies' => $data['enable_smilies'],
|
|
|
|
|
'enable_magic_url' => $data['enable_urls'],
|
|
|
|
|
'enable_sig' => $data['enable_sig'],
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'post_username' => ($user->data['user_id'] == ANONYMOUS) ? stripslashes($username) : '',
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'post_subject' => $subject,
|
|
|
|
|
'post_text' => $message,
|
|
|
|
|
'post_checksum' => $data['message_md5'],
|
|
|
|
|
'post_encoding' => $user->lang['ENCODING'],
|
|
|
|
|
'post_attachment' => (sizeof($filename_data['physical_filename'])) ? 1 : 0,
|
|
|
|
|
'bbcode_bitfield' => $data['bbcode_bitfield'],
|
|
|
|
|
'bbcode_uid' => $bbcode_uid,
|
|
|
|
|
'post_edit_locked' => $data['post_edit_locked']
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'edit_first_post':
|
|
|
|
|
case 'edit':
|
2003-09-08 07:05:29 +00:00
|
|
|
|
if (!$auth->acl_gets('m_', 'a_'))
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[POSTS_TABLE]['sql'] = array(
|
2003-09-08 07:05:29 +00:00
|
|
|
|
'post_edit_time' => $current_time
|
|
|
|
|
);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1';
|
2003-09-08 07:05:29 +00:00
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
|
|
|
|
|
case 'edit_topic':
|
|
|
|
|
case 'edit_last_post':
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array(
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
|
|
|
|
|
'poster_id' => $data['poster_id'],
|
|
|
|
|
'icon_id' => $data['icon_id'],
|
|
|
|
|
'post_approved' => ($auth->acl_get('f_moderate', $data['forum_id'])) ? 0 : 1,
|
|
|
|
|
'enable_bbcode' => $data['enable_bbcode'],
|
|
|
|
|
'enable_html' => $data['enable_html'],
|
|
|
|
|
'enable_smilies' => $data['enable_smilies'],
|
|
|
|
|
'enable_magic_url' => $data['enable_urls'],
|
|
|
|
|
'enable_sig' => $data['enable_sig'],
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'post_username' => ($username != '' && $data['poster_id'] == ANONYMOUS) ? stripslashes($username) : '',
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'post_subject' => $subject,
|
|
|
|
|
'post_text' => $message,
|
|
|
|
|
'post_checksum' => $data['message_md5'],
|
|
|
|
|
'post_encoding' => $user->lang['ENCODING'],
|
|
|
|
|
'post_attachment' => (sizeof($filename_data['physical_filename'])) ? 1 : 0,
|
|
|
|
|
'bbcode_bitfield' => $data['bbcode_bitfield'],
|
|
|
|
|
'bbcode_uid' => $bbcode_uid,
|
2003-09-07 17:16:12 +00:00
|
|
|
|
'post_edit_locked' => $data['post_edit_locked'])
|
|
|
|
|
);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// And the topic ladies and gentlemen
|
|
|
|
|
switch ($post_mode)
|
|
|
|
|
{
|
|
|
|
|
case 'post':
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[TOPICS_TABLE]['sql'] = array(
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'topic_poster' => (int) $user->data['user_id'],
|
|
|
|
|
'topic_time' => $current_time,
|
|
|
|
|
'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
|
|
|
|
|
'icon_id' => $data['icon_id'],
|
|
|
|
|
'topic_approved' => ($auth->acl_get('f_moderate', $data['forum_id'])) ? 0 : 1,
|
|
|
|
|
'topic_title' => $subject,
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'topic_first_poster_name' => ($user->data['user_id'] == ANONYMOUS && !empty($username)) ? stripslashes($username) : $user->data['username'],
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'topic_type' => $topic_type,
|
2003-10-10 15:02:48 +00:00
|
|
|
|
'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0,
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'topic_attachment' => (sizeof($filename_data['physical_filename'])) ? 1 : 0
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!empty($poll['poll_options']))
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array(
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'poll_title' => $poll['poll_title'],
|
|
|
|
|
'poll_start' => ($poll['poll_start']) ? $poll['poll_start'] : $current_time,
|
|
|
|
|
'poll_max_options' => $poll['poll_max_options'],
|
2003-09-07 17:16:12 +00:00
|
|
|
|
'poll_length' => $poll['poll_length'] * 86400)
|
2003-09-07 15:23:55 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id'])) ? ', user_posts = user_posts + 1' : '');
|
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; //(!$auth->acl_get('f_moderate', $data['forum_id'])) ? 'forum_posts = forum_posts + 1' : '';
|
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . ((!$auth->acl_get('f_moderate', $data['forum_id'])) ? ', forum_topics = forum_topics + 1' : '');
|
2003-09-07 15:23:55 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'reply':
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies_real = topic_replies_real + 1, topic_bumped = 0, topic_bumper = 0' . ((!$auth->acl_get('f_moderate', $data['forum_id'])) ? ', topic_replies = topic_replies + 1' : '');
|
|
|
|
|
$sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id'])) ? ', user_posts = user_posts + 1' : '');
|
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; //(!$auth->acl_get('f_moderate', $data['forum_id'])) ? 'forum_posts = forum_posts + 1' : '';
|
2003-09-07 15:23:55 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'edit_topic':
|
|
|
|
|
case 'edit_first_post':
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[TOPICS_TABLE]['sql'] = array(
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
|
|
|
|
|
'icon_id' => $data['icon_id'],
|
|
|
|
|
'topic_approved' => ($auth->acl_get('f_moderate', $data['forum_id'])) ? 0 : 1,
|
|
|
|
|
'topic_title' => $subject,
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'topic_first_poster_name' => stripslashes($username),
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'topic_type' => $topic_type,
|
2003-10-10 15:02:48 +00:00
|
|
|
|
'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0,
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'poll_title' => (!empty($poll['poll_options'])) ? $poll['poll_title'] : '',
|
|
|
|
|
'poll_start' => (!empty($poll['poll_options'])) ? (($poll['poll_start']) ? $poll['poll_start'] : $current_time) : 0,
|
|
|
|
|
'poll_max_options' => (!empty($poll['poll_options'])) ? $poll['poll_max_options'] : 1,
|
2003-10-10 15:02:48 +00:00
|
|
|
|
'poll_length' => (!empty($poll['poll_options'])) ? $poll['poll_length'] * 86400 : 0,
|
|
|
|
|
|
|
|
|
|
'topic_attachment' => ($post_mode == 'edit_topic') ? ((sizeof($filename_data['physical_filename'])) ? 1 : 0) : $data['topic_attachment']
|
2003-09-07 15:23:55 +00:00
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-01 16:10:21 +00:00
|
|
|
|
$db->sql_transaction();
|
2003-09-07 15:23:55 +00:00
|
|
|
|
|
|
|
|
|
// Submit new topic
|
|
|
|
|
if ($post_mode == 'post')
|
|
|
|
|
{
|
|
|
|
|
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' .
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
|
|
|
|
|
$data['topic_id'] = $db->sql_nextid();
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array(
|
2003-09-07 17:16:12 +00:00
|
|
|
|
'topic_id' => $data['topic_id'])
|
2003-09-07 15:23:55 +00:00
|
|
|
|
);
|
2003-11-23 22:25:46 +00:00
|
|
|
|
unset($sql_data[TOPICS_TABLE]['sql']);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Submit new post
|
|
|
|
|
if ($post_mode == 'post' || $post_mode == 'reply')
|
|
|
|
|
{
|
|
|
|
|
if ($post_mode == 'reply')
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array(
|
2003-09-07 17:16:12 +00:00
|
|
|
|
'topic_id' => $data['topic_id'])
|
2003-09-07 15:23:55 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sql = 'INSERT INTO ' . POSTS_TABLE . ' ' .
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
$data['post_id'] = $db->sql_nextid();
|
|
|
|
|
|
|
|
|
|
if ($post_mode == 'post')
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[TOPICS_TABLE]['sql'] = array(
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'topic_first_post_id' => $data['post_id'],
|
2003-09-07 15:33:20 +00:00
|
|
|
|
'topic_last_post_id' => $data['post_id'],
|
|
|
|
|
'topic_last_post_time' => $current_time,
|
|
|
|
|
'topic_last_poster_id' => (int) $user->data['user_id'],
|
2003-10-07 17:29:53 +00:00
|
|
|
|
'topic_last_poster_name' => ($user->data['user_id'] == ANONYMOUS && !empty($username)) ? stripslashes($username) : $user->data['username']
|
2003-09-07 15:23:55 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
unset($sql_data[POSTS_TABLE]['sql']);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
$make_global = FALSE;
|
|
|
|
|
|
|
|
|
|
// Are we globalising or unglobalising?
|
|
|
|
|
if ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic')
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT topic_type, topic_replies_real, topic_approved
|
|
|
|
|
FROM ' . TOPICS_TABLE . '
|
|
|
|
|
WHERE topic_id = ' . $data['topic_id'];
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
|
|
|
|
|
|
// globalise
|
|
|
|
|
if ((int)$row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL)
|
|
|
|
|
{
|
|
|
|
|
// Decrement topic/post count
|
|
|
|
|
$make_global = TRUE;
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'] = array();
|
2003-09-15 21:05:30 +00:00
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($row['topic_replies_real'] + 1);
|
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real - 1' . (($row['topic_approved']) ? ', forum_topics = forum_topics - 1' : '');
|
2003-09-15 21:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
// unglobalise
|
|
|
|
|
else if ((int)$row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL)
|
|
|
|
|
{
|
|
|
|
|
// Increment topic/post count
|
|
|
|
|
$make_global = TRUE;
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'] = array();
|
2003-09-15 21:05:30 +00:00
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + ' . ($row['topic_replies_real'] + 1);
|
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($row['topic_approved']) ? ', forum_topics = forum_topics + 1' : '');
|
2003-09-15 21:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
// Update the topics table
|
2003-11-23 22:25:46 +00:00
|
|
|
|
if (isset($sql_data[TOPICS_TABLE]['sql']))
|
2003-09-07 15:23:55 +00:00
|
|
|
|
{
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$db->sql_query('UPDATE ' . TOPICS_TABLE . '
|
2003-11-23 22:25:46 +00:00
|
|
|
|
SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . '
|
2003-10-19 15:36:45 +00:00
|
|
|
|
WHERE topic_id = ' . $data['topic_id']);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the posts table
|
2003-11-23 22:25:46 +00:00
|
|
|
|
if (isset($sql_data[POSTS_TABLE]['sql']))
|
2003-09-07 15:23:55 +00:00
|
|
|
|
{
|
2003-10-19 15:36:45 +00:00
|
|
|
|
$db->sql_query('UPDATE ' . POSTS_TABLE . '
|
2003-11-23 22:25:46 +00:00
|
|
|
|
SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . '
|
2003-10-19 15:36:45 +00:00
|
|
|
|
WHERE post_id = ' . $data['post_id']);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update Poll Tables and Attachment Entries
|
|
|
|
|
if (!empty($poll['poll_options']))
|
|
|
|
|
{
|
|
|
|
|
$cur_poll_options = array();
|
|
|
|
|
|
|
|
|
|
if ($poll['poll_start'] && $mode == 'edit')
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . '
|
|
|
|
|
WHERE topic_id = ' . $data['topic_id'] . '
|
|
|
|
|
ORDER BY poll_option_id';
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
|
|
while ($cur_poll_options[] = $db->sql_fetchrow($result));
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < sizeof($poll['poll_options']); $i++)
|
|
|
|
|
{
|
|
|
|
|
if (trim($poll['poll_options'][$i]))
|
|
|
|
|
{
|
|
|
|
|
if (empty($cur_poll_options[$i]))
|
|
|
|
|
{
|
|
|
|
|
$sql = 'INSERT INTO ' . POLL_OPTIONS_TABLE . " (poll_option_id, topic_id, poll_option_text)
|
|
|
|
|
VALUES ($i, " . $data['topic_id'] . ", '" . $db->sql_escape($poll['poll_options'][$i]) . "')";
|
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
}
|
|
|
|
|
else if ($poll['poll_options'][$i] != $cur_poll_options[$i])
|
|
|
|
|
{
|
|
|
|
|
$sql = "UPDATE " . POLL_OPTIONS_TABLE . "
|
|
|
|
|
SET poll_option_text = '" . $db->sql_escape($poll['poll_options'][$i]) . "'
|
|
|
|
|
WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . "
|
|
|
|
|
AND topic_id = " . $data['topic_id'];
|
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sizeof($poll['poll_options']) < sizeof($cur_poll_options))
|
|
|
|
|
{
|
|
|
|
|
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . '
|
|
|
|
|
WHERE poll_option_id > ' . sizeof($poll['poll_options']) . '
|
|
|
|
|
AND topic_id = ' . $data['topic_id'];
|
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Submit Attachments
|
2003-10-09 14:48:55 +00:00
|
|
|
|
if (count($attach_data) && !empty($data['post_id']) && in_array($mode, array('post', 'reply', 'quote', 'edit')))
|
2003-09-07 15:23:55 +00:00
|
|
|
|
{
|
2003-11-16 21:53:56 +00:00
|
|
|
|
$space_taken = $files_added = 0;
|
2003-09-07 15:23:55 +00:00
|
|
|
|
foreach ($attach_data as $attach_row)
|
|
|
|
|
{
|
2003-10-09 14:48:55 +00:00
|
|
|
|
if ($attach_row['attach_id'])
|
2003-09-07 15:23:55 +00:00
|
|
|
|
{
|
|
|
|
|
// update entry in db if attachment already stored in db and filespace
|
2003-11-04 22:12:52 +00:00
|
|
|
|
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
|
2003-09-07 15:23:55 +00:00
|
|
|
|
SET comment = '" . $db->sql_escape($attach_row['comment']) . "'
|
|
|
|
|
WHERE attach_id = " . (int) $attach_row['attach_id'];
|
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// insert attachment into db
|
|
|
|
|
$attach_sql = array(
|
2003-11-04 22:12:52 +00:00
|
|
|
|
'post_id' => $data['post_id'],
|
|
|
|
|
'topic_id' => $data['topic_id'],
|
|
|
|
|
'poster_id' => $poster_id,
|
2003-09-07 15:23:55 +00:00
|
|
|
|
'physical_filename' => $attach_row['physical_filename'],
|
|
|
|
|
'real_filename' => $attach_row['real_filename'],
|
|
|
|
|
'comment' => $attach_row['comment'],
|
|
|
|
|
'extension' => $attach_row['extension'],
|
|
|
|
|
'mimetype' => $attach_row['mimetype'],
|
|
|
|
|
'filesize' => $attach_row['filesize'],
|
|
|
|
|
'filetime' => $attach_row['filetime'],
|
|
|
|
|
'thumbnail' => $attach_row['thumbnail']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' .
|
|
|
|
|
$db->sql_build_array('INSERT', $attach_sql);
|
|
|
|
|
$db->sql_query($sql);
|
2003-11-16 21:53:56 +00:00
|
|
|
|
|
|
|
|
|
$space_taken += $attach_row['filesize'];
|
|
|
|
|
$files_added++;
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-16 21:53:56 +00:00
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
if (count($attach_data))
|
|
|
|
|
{
|
|
|
|
|
$sql = 'UPDATE ' . POSTS_TABLE . '
|
|
|
|
|
SET post_attachment = 1
|
|
|
|
|
WHERE post_id = ' . $data['post_id'];
|
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
|
|
|
|
|
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
|
|
|
SET topic_attachment = 1
|
|
|
|
|
WHERE topic_id = ' . $data['topic_id'];
|
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
}
|
2003-09-24 19:41:14 +00:00
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, TRUE);
|
|
|
|
|
set_config('num_files', $config['num_files'] + $files_added, TRUE);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-01 16:10:21 +00:00
|
|
|
|
$db->sql_transaction('commit');
|
2003-09-07 15:23:55 +00:00
|
|
|
|
|
|
|
|
|
if ($post_mode == 'post' || $post_mode == 'reply' || $post_mode == 'edit_last_post')
|
|
|
|
|
{
|
|
|
|
|
if ($topic_type != POST_GLOBAL)
|
|
|
|
|
{
|
2003-10-12 09:18:56 +00:00
|
|
|
|
// We get the last post information not for posting or replying, we can assume the correct params here, which is much faster
|
|
|
|
|
if ($post_mode == 'edit_last_post')
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = implode(', ', update_last_post_information('forum', $data['forum_id']));
|
2003-10-12 09:18:56 +00:00
|
|
|
|
}
|
2003-11-22 12:44:01 +00:00
|
|
|
|
else if (!$auth->acl_get('f_moderate', $data['forum_id']))
|
2003-10-12 09:18:56 +00:00
|
|
|
|
{
|
|
|
|
|
$update_sql = 'forum_last_post_id = ' . $data['post_id'];
|
|
|
|
|
$update_sql .= ", forum_last_post_time = $current_time";
|
|
|
|
|
$update_sql .= ', forum_last_poster_id = ' . $user->data['user_id'];
|
|
|
|
|
$update_sql .= ", forum_last_poster_name = '" . (($user->data['user_id'] == ANONYMOUS) ? $db->sql_escape(stripslashes($username)) : $db->sql_escape($user->data['username'])) . "'";
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = $update_sql;
|
2003-10-12 09:18:56 +00:00
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
2003-11-23 22:25:46 +00:00
|
|
|
|
|
|
|
|
|
$update = update_last_post_information('topic', $data['topic_id']);
|
|
|
|
|
if (sizeof($update))
|
|
|
|
|
{
|
|
|
|
|
$sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update);
|
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
if ($make_global)
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$sql_data[FORUMS_TABLE]['stat'][] = implode(', ', update_last_post_information('forum', $data['forum_id']));
|
2003-09-15 21:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
if ($post_mode == 'edit_topic')
|
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$update = update_last_post_information('topic', $data['topic_id']);
|
|
|
|
|
if (sizeof($update))
|
|
|
|
|
{
|
|
|
|
|
$sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update);
|
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
// Update total post count, do not consider moderated posts/topics
|
|
|
|
|
if (!$auth->acl_get('f_moderate', $data['forum_id']))
|
|
|
|
|
{
|
2003-09-07 15:23:55 +00:00
|
|
|
|
if ($post_mode == 'post')
|
|
|
|
|
{
|
2003-09-15 21:05:30 +00:00
|
|
|
|
set_config('num_topics', $config['num_topics'] + 1, TRUE);
|
|
|
|
|
set_config('num_posts', $config['num_posts'] + 1, TRUE);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($post_mode == 'reply')
|
|
|
|
|
{
|
2003-09-15 21:05:30 +00:00
|
|
|
|
set_config('num_posts', $config['num_posts'] + 1, TRUE);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
2003-11-16 21:53:56 +00:00
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
|
|
|
|
|
// Update forum stats
|
|
|
|
|
$db->sql_transaction();
|
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
$where_sql = array(POSTS_TABLE => 'post_id = ' . $data['post_id'], TOPICS_TABLE => 'topic_id = ' . $data['topic_id'], FORUMS_TABLE => 'forum_id = ' . $data['forum_id'], USERS_TABLE => 'user_id = ' . $user->data['user_id']);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
|
2003-11-23 22:25:46 +00:00
|
|
|
|
foreach ($sql_data as $table => $update_ary)
|
2003-09-07 15:23:55 +00:00
|
|
|
|
{
|
2003-11-23 22:25:46 +00:00
|
|
|
|
if (implode('', $update_ary['stat']) != '')
|
|
|
|
|
{
|
|
|
|
|
$db->sql_query("UPDATE $table SET " . implode(', ', $update_ary['stat']) . ' WHERE ' . $where_sql[$table]);
|
|
|
|
|
}
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-30 17:45:13 +00:00
|
|
|
|
// Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement
|
|
|
|
|
if ($make_global)
|
2003-11-27 23:44:59 +00:00
|
|
|
|
{
|
|
|
|
|
$db->sql_query('DELETE FROM ' . TOPICS_TABLE . '
|
|
|
|
|
WHERE topic_moved_id = ' . $data['topic_id']);
|
2003-11-30 17:45:13 +00:00
|
|
|
|
}
|
2003-11-27 23:44:59 +00:00
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
// Fulltext parse
|
2003-11-16 21:53:56 +00:00
|
|
|
|
if ($data['message_md5'] != $data['post_checksum'] && $data['enable_indexing'])
|
2003-09-07 15:23:55 +00:00
|
|
|
|
{
|
|
|
|
|
$search = new fulltext_search();
|
|
|
|
|
$result = $search->add($mode, $data['post_id'], $message, $subject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$db->sql_transaction('commit');
|
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
// Delete draft if post was loaded...
|
|
|
|
|
$draft_id = request_var('draft_loaded', 0);
|
|
|
|
|
if ($draft_id)
|
|
|
|
|
{
|
|
|
|
|
$db->sql_query('DELETE FROM ' . DRAFTS_TABLE . " WHERE draft_id = $draft_id AND user_id = " . $user->data['user_id']);
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-07 15:23:55 +00:00
|
|
|
|
// Topic Notification
|
2003-10-28 21:23:49 +00:00
|
|
|
|
if (!$data['notify_set'] && $data['notify'])
|
2003-09-07 15:23:55 +00:00
|
|
|
|
{
|
|
|
|
|
$sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id)
|
|
|
|
|
VALUES (' . $user->data['user_id'] . ', ' . $data['topic_id'] . ')';
|
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
}
|
2003-10-28 21:23:49 +00:00
|
|
|
|
else if ($data['notify_set'] && !$data['notify'])
|
2003-09-07 15:23:55 +00:00
|
|
|
|
{
|
|
|
|
|
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
|
|
|
|
|
WHERE user_id = ' . $user->data['user_id'] . '
|
|
|
|
|
AND topic_id = ' . $data['topic_id'];
|
|
|
|
|
$db->sql_query($sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mark this topic as read and posted to.
|
|
|
|
|
$mark_mode = ($mode == 'post' || $mode == 'reply' || $mode == 'quote') ? 'post' : 'topic';
|
|
|
|
|
markread($mark_mode, $data['forum_id'], $data['topic_id'], $data['post_time']);
|
|
|
|
|
|
|
|
|
|
// Send Notifications
|
|
|
|
|
if ($mode != 'edit' && $mode != 'delete')
|
|
|
|
|
{
|
2003-10-07 17:29:53 +00:00
|
|
|
|
user_notification($mode, stripslashes($subject), stripslashes($data['topic_title']), stripslashes($data['forum_name']), $data['forum_id'], $data['topic_id'], $data['post_id']);
|
2003-09-07 15:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
meta_refresh(3, "viewtopic.$phpEx$SID&f=" . $data['forum_id'] . '&t=' . $data['topic_id'] . '&p=' . $data['post_id'] . '#' . $data['post_id']);
|
|
|
|
|
|
|
|
|
|
$message = ($auth->acl_get('f_moderate', $data['forum_id'])) ? 'POST_STORED_MOD' : 'POST_STORED';
|
2003-09-07 15:33:20 +00:00
|
|
|
|
$message = $user->lang[$message] . ((!$auth->acl_get('f_moderate', $data['forum_id'])) ? '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="viewtopic.' . $phpEx . $SID .'&f=' . $data['forum_id'] . '&t=' . $data['topic_id'] . '&p=' . $data['post_id'] . '#' . $data['post_id'] . '">', '</a>') : '') . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID .'&f=' . $data['forum_id'] . '">', '</a>');
|
2003-09-07 15:23:55 +00:00
|
|
|
|
trigger_error($message);
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 21:53:56 +00:00
|
|
|
|
// Load Drafts
|
|
|
|
|
function load_drafts($topic_id = 0, $forum_id = 0)
|
|
|
|
|
{
|
|
|
|
|
global $user, $db, $template, $phpEx, $SID, $auth;
|
|
|
|
|
|
|
|
|
|
// Only those fitting into this forum...
|
|
|
|
|
$sql = 'SELECT d.draft_id, d.topic_id, d.forum_id, d.draft_subject, d.save_time, f.forum_name
|
|
|
|
|
FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f
|
|
|
|
|
WHERE d.user_id = ' . $user->data['user_id'] . '
|
|
|
|
|
AND f.forum_id = d.forum_id ' .
|
|
|
|
|
(($forum_id) ? " AND f.forum_id = $forum_id" : '') . '
|
|
|
|
|
ORDER BY save_time DESC';
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
|
|
$draftrows = $topic_ids = array();
|
|
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
|
|
|
|
if ($row['topic_id'])
|
|
|
|
|
{
|
|
|
|
|
$topic_ids[] = (int) $row['topic_id'];
|
|
|
|
|
}
|
|
|
|
|
$draftrows[] = $row;
|
|
|
|
|
}
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
|
|
if (sizeof($topic_ids))
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT topic_id, forum_id, topic_title
|
|
|
|
|
FROM ' . TOPICS_TABLE . '
|
|
|
|
|
WHERE topic_id IN (' . implode(',', array_unique($topic_ids)) . ')';
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
|
|
|
|
$topic_rows[$row['topic_id']] = $row;
|
|
|
|
|
}
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
}
|
|
|
|
|
unset($topic_ids);
|
|
|
|
|
|
|
|
|
|
if (sizeof($draftrows))
|
|
|
|
|
{
|
|
|
|
|
$row_count = 0;
|
|
|
|
|
$template->assign_var('S_SHOW_DRAFTS', true);
|
|
|
|
|
|
|
|
|
|
foreach ($draftrows as $draft)
|
|
|
|
|
{
|
|
|
|
|
$link_topic = $link_forum = 0;
|
|
|
|
|
$insert_url = $view_url = $title = '';
|
|
|
|
|
|
|
|
|
|
if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id']))
|
|
|
|
|
{
|
|
|
|
|
$link_topic = true;
|
|
|
|
|
$view_url = "viewtopic.$phpEx$SID&f=" . $topic_rows[$draft['topic_id']]['forum_id'] . "&t=" . $draft['topic_id'];
|
|
|
|
|
$title = ($draft['topic_id'] == $topic_id && $topic_id) ? $user->lang['CURRENT_TOPIC'] : $topic_rows[$draft['topic_id']]['topic_title'];
|
|
|
|
|
|
|
|
|
|
$insert_url = "posting.$phpEx$SID&f=" . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id'];
|
|
|
|
|
}
|
|
|
|
|
else if ($auth->acl_get('f_read', $draft['forum_id']))
|
|
|
|
|
{
|
|
|
|
|
$link_forum = true;
|
|
|
|
|
$view_url = "viewforum.$phpEx$SID&f=" . $draft['forum_id'];
|
|
|
|
|
$title = $draft['forum_name'];
|
|
|
|
|
|
|
|
|
|
$insert_url = "posting.$phpEx$SID&f=" . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$template->assign_block_vars('draftrow', array(
|
|
|
|
|
'DRAFT_ID' => $draft['draft_id'],
|
|
|
|
|
'DATE' => $user->format_date($draft['save_time']),
|
|
|
|
|
'DRAFT_SUBJECT' => $draft['draft_subject'],
|
|
|
|
|
|
|
|
|
|
'TITLE' => $title,
|
|
|
|
|
'U_VIEW' => $view_url,
|
|
|
|
|
'U_INSERT' => $insert_url,
|
|
|
|
|
|
|
|
|
|
'S_ROW_COUNT' => $row_count++,
|
|
|
|
|
'S_LINK_TOPIC' => $link_topic,
|
|
|
|
|
'S_LINK_FORUM' => $link_forum)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-09 14:48:55 +00:00
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
function prepare_data(&$variable, $change = FALSE)
|
|
|
|
|
{
|
|
|
|
|
if (!$change)
|
|
|
|
|
{
|
2003-10-09 14:48:55 +00:00
|
|
|
|
// return htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $variable)));
|
|
|
|
|
return htmlspecialchars(trim(stripslashes(preg_replace(array("#[ \xFF]{2,}#s", "#[\r\n]{2,}#s"), array(' ', "\n"), $variable))));
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-09 14:48:55 +00:00
|
|
|
|
// $variable = htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $variable)));
|
|
|
|
|
$variable = htmlspecialchars(trim(stripslashes(preg_replace(array("#[ \xFF]{2,}#s", "#[\r\n]{2,}#s"), array(' ', "\n"), $variable))));
|
|
|
|
|
|
2003-09-15 21:05:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-09 14:48:55 +00:00
|
|
|
|
|
2003-06-23 14:00:57 +00:00
|
|
|
|
//
|
|
|
|
|
// FUNCTIONS
|
|
|
|
|
// ---------
|
|
|
|
|
|
2003-01-08 17:00:37 +00:00
|
|
|
|
?>
|