mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
some posting updates and fixes.
git-svn-id: file:///svn/phpbb/trunk@3631 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
4c4278ac8d
commit
fa005f44ae
7 changed files with 344 additions and 134 deletions
|
@ -167,7 +167,7 @@ function decode_text(&$message)
|
|||
}
|
||||
|
||||
// Quote Text
|
||||
function quote_text($message, $username = '')
|
||||
function quote_text(&$message, $username = '')
|
||||
{
|
||||
$message = ' [quote' . ( (empty($username)) ? ']' : '="' . addslashes(trim($username)) . '"]') . trim($message) . '[/quote] ';
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class parse_message
|
|||
$this->message_mode = $message_type;
|
||||
}
|
||||
|
||||
function parse(&$message, $html, $bbcode, $uid, $url, $smilies)
|
||||
function parse(&$message, $html, $bbcode, $uid, $url, $smilies, $attach = false)
|
||||
{
|
||||
global $config, $db, $user, $_FILE;
|
||||
|
||||
|
@ -84,7 +84,7 @@ class parse_message
|
|||
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->bbcode($message, $bbcode, $uid);
|
||||
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->emoticons($message, $smilies);
|
||||
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->magic_url($message, $url);
|
||||
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->attach($_FILE);
|
||||
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->attach($_FILE, $attach);
|
||||
|
||||
return $warn_msg;
|
||||
}
|
||||
|
@ -176,16 +176,56 @@ class parse_message
|
|||
return;
|
||||
}
|
||||
|
||||
function attach($file_ary)
|
||||
function attach($file_ary, $attach)
|
||||
{
|
||||
global $config;
|
||||
|
||||
}
|
||||
|
||||
// Manage Poll
|
||||
function parse_poll(&$poll, $poll_data)
|
||||
{
|
||||
global $auth, $forum_id, $user, $config;
|
||||
|
||||
// poll_options, poll_options_size
|
||||
$err_msg = '';
|
||||
|
||||
// Process poll options
|
||||
if (!empty($poll_data['poll_option_text']) && (($auth->acl_get('f_poll', $forum_id) && !$poll_data['poll_last_vote']) || $auth->acl_gets('m_edit', 'a_', $forum_id)))
|
||||
{
|
||||
if (($result = $this->parse($poll_data['poll_option_text'], $poll_data['enable_html'], $poll_data['enable_bbcode'], $poll_data['bbcode_uid'], $poll_data['enable_urls'], $poll_data['enable_smilies'], false)) != '')
|
||||
{
|
||||
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result;
|
||||
}
|
||||
|
||||
$poll['poll_options'] = explode("\n", trim($poll_data['poll_option_text']));
|
||||
$poll['poll_options_size'] = sizeof($poll['poll_options']);
|
||||
|
||||
if (sizeof($poll['poll_options']) == 1)
|
||||
{
|
||||
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['TOO_FEW_POLL_OPTIONS'];
|
||||
}
|
||||
else if (sizeof($poll['poll_options']) > intval($config['max_poll_options']))
|
||||
{
|
||||
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['TOO_MANY_POLL_OPTIONS'];
|
||||
}
|
||||
else if (sizeof($poll['poll_options']) < $poll['poll_options_size'])
|
||||
{
|
||||
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['NO_DELETE_POLL_OPTIONS'];
|
||||
}
|
||||
|
||||
$poll['poll_title'] = (!empty($poll_data['poll_title'])) ? trim(htmlspecialchars(strip_tags($poll_data['poll_title']))) : '';
|
||||
$poll['poll_length'] = (!empty($poll_data['poll_length'])) ? intval($poll_data['poll_length']) : 0;
|
||||
}
|
||||
$poll['poll_start'] = $poll_data['poll_start'];
|
||||
|
||||
return ($err_msg);
|
||||
}
|
||||
|
||||
// Format text to be displayed - from viewtopic.php
|
||||
function format_display($message, $html, $bbcode, $uid, $url, $smilies, $sig)
|
||||
{
|
||||
global $auth, $forum_id, $config, $censors;
|
||||
global $auth, $forum_id, $config, $censors, $user;
|
||||
|
||||
// If the board has HTML off but the post has HTML
|
||||
// on then we process it, else leave it alone
|
||||
|
@ -200,7 +240,6 @@ class parse_message
|
|||
// we'll need an appropriate check and preg_replace here
|
||||
$message = (empty($smilies) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message);
|
||||
|
||||
|
||||
// Replace naughty words such as farty pants
|
||||
if (sizeof($censors))
|
||||
{
|
||||
|
@ -209,36 +248,82 @@ class parse_message
|
|||
|
||||
$message = nl2br($message);
|
||||
|
||||
/* Signature
|
||||
$user_sig = ($sig && $signature != '' && $config['allow_sig']) ? $row['user_sig'] : '';
|
||||
|
||||
if ($user_sig != '' && $auth->acl_gets('f_sigs', 'm_', 'a_', $forum_id))
|
||||
// Signature
|
||||
$user_sig = ($sig && $config['allow_sig']) ? trim($user->data['user_sig']) : '';
|
||||
|
||||
if ($user_sig != '' && $auth->acl_gets('f_sigs', 'm_', 'a_', $forum_id))
|
||||
{
|
||||
if (!$auth->acl_get('f_html', $forum_id) && $user->data['user_allowhtml'])
|
||||
{
|
||||
if (!$auth->acl_get('f_html', $forum_id) && $user->data['user_allowhtml'])
|
||||
{
|
||||
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig);
|
||||
}
|
||||
|
||||
$user_cache[$poster_id]['sig'] = (empty($row['user_allowsmile']) || empty($config['enable_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $user_cache[$poster_id]['sig']) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $user_cache[$poster_id]['sig']);
|
||||
|
||||
if (count($censors))
|
||||
{
|
||||
$user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $user_sig . '<'), 1, -1));
|
||||
}
|
||||
|
||||
$user_cache[$poster_id]['sig'] = '<br />_________________<br />' . nl2br($user_cache[$poster_id]['sig']);
|
||||
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig);
|
||||
}
|
||||
else
|
||||
|
||||
$user_sig = (empty($user->data['user_allowsmile']) || empty($config['enable_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $user_sig) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $user_sig);
|
||||
|
||||
if (sizeof($censors))
|
||||
{
|
||||
$user_cache[$poster_id]['sig'] = '';
|
||||
$user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $user_sig . '<'), 1, -1));
|
||||
}
|
||||
*/
|
||||
|
||||
$user_sig = '<br />_________________<br />' . nl2br($user_sig);
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_sig = '';
|
||||
}
|
||||
|
||||
$message = (empty($smilies) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message);
|
||||
|
||||
$message .= $user_sig;
|
||||
|
||||
return($message);
|
||||
}
|
||||
|
||||
// Submit Poll
|
||||
function submit_poll($topic_id, $mode, $poll)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$cur_poll_options = array();
|
||||
if ($poll['poll_start'] && $mode == 'edit')
|
||||
{
|
||||
$sql = "SELECT * FROM " . POLL_OPTIONS_TABLE . "
|
||||
WHERE topic_id = " . $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 . ", " . $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'];
|
||||
$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 = " . $topic_id;
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
// Submit Post
|
||||
function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $post_data)
|
||||
{
|
||||
|
@ -267,7 +352,7 @@ class parse_message
|
|||
{
|
||||
$topic_sql = array_merge($topic_sql, array(
|
||||
'poll_title' => stripslashes($poll['poll_title']),
|
||||
'poll_start' => (!empty($poll['poll_start'])) ? $poll['poll_start'] : $current_time,
|
||||
'poll_start' => ($poll['poll_start']) ? $poll['poll_start'] : $current_time,
|
||||
'poll_length' => $poll['poll_length'] * 3600
|
||||
));
|
||||
}
|
||||
|
@ -289,7 +374,7 @@ class parse_message
|
|||
'post_time' => $current_time,
|
||||
'post_approved' => ($post_data['enable_moderate'] && !$auth->acl_gets('f_ignorequeue', 'm_', 'a_', $post_data['forum_id'])) ? 0 : 1,
|
||||
'post_edit_time' => ($mode == 'edit' && $post_data['poster_id'] == $user->data['user_id']) ? $current_time : 0,
|
||||
'enable_sig' => $post_data['enable_html'],
|
||||
'enable_sig' => $post_data['enable_sig'],
|
||||
'enable_bbcode' => $post_data['enable_bbcode'],
|
||||
'enable_html' => $post_data['enable_html'],
|
||||
'enable_smilies' => $post_data['enable_smilies'],
|
||||
|
@ -313,37 +398,7 @@ class parse_message
|
|||
// poll options
|
||||
if (!empty($poll['poll_options']))
|
||||
{
|
||||
$cur_poll_options = array();
|
||||
if (!empty($poll['poll_start']) && $mode == 'edit')
|
||||
{
|
||||
$sql = "SELECT * FROM " . POLL_OPTIONS_TABLE . "
|
||||
WHERE topic_id = " . $post_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 . " (topic_id, poll_option_text)
|
||||
VALUES (" . $post_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'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->submit_poll($post_data['topic_id'], $mode, $poll);
|
||||
}
|
||||
|
||||
// Fulltext parse
|
||||
|
@ -445,6 +500,30 @@ class parse_message
|
|||
trigger_error($message);
|
||||
}
|
||||
|
||||
// Delete Poll
|
||||
function delete_poll($topic_id)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = "DELETE FROM " . POLL_OPTIONS_TABLE . "
|
||||
WHERE topic_id = " . $topic_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = "DELETE FROM " . POLL_VOTES_TABLE . "
|
||||
WHERE topic_id = " . $topic_id;
|
||||
$db->sql_query($sql);
|
||||
|
||||
$topic_sql = array(
|
||||
'poll_title' => '',
|
||||
'poll_start' => 0,
|
||||
'poll_length' => 0,
|
||||
'poll_last_vote' => 0
|
||||
);
|
||||
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $topic_sql) . ' WHERE topic_id = ' . $topic_id;
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
// Delete Post. Please be sure user have the correct Permissions before calling this function
|
||||
function delete_post($mode, $post_id, $topic_id, $forum_id, $post_data)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,28 @@
|
|||
// * Posting approval
|
||||
// * After Submit got clicked, disable the button (prevent double-posts), could be solved in a more elegant way
|
||||
|
||||
// Temp Function - strtolower (will have a look at iconv later) - borrowed from php.net
|
||||
function phpbb_strtolower($string)
|
||||
{
|
||||
$new_string = '';
|
||||
|
||||
for ($i = 0; $i < strlen($string); $i++)
|
||||
{
|
||||
// Not sure about the offset, where is my ASCII Table ???
|
||||
if (ord(substr($string, $i, 1)) > 0xa0)
|
||||
{
|
||||
$new_string .= strtolower(substr($string, $i, 2));
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_string .= strtolower(substr($string, $i, 1));
|
||||
}
|
||||
}
|
||||
|
||||
return $new_string;
|
||||
}
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
$phpbb_root_path = './';
|
||||
include($phpbb_root_path . 'extension.inc');
|
||||
|
@ -52,15 +74,22 @@ $mode = (!empty($_REQUEST['mode'])) ? strval($_REQUEST['mode']) : '';
|
|||
$post_id = (!empty($_REQUEST['p'])) ? intval($_REQUEST['p']) : false;
|
||||
$topic_id = (!empty($_REQUEST['t'])) ? intval($_REQUEST['t']) : false;
|
||||
$forum_id = (!empty($_REQUEST['f'])) ? intval($_REQUEST['f']) : false;
|
||||
$lastclick = (isset($_POST['lastclick'])) ? intval($_POST['lastclick']) : 0;
|
||||
|
||||
$submit = (isset($_POST['post'])) ? true : false;
|
||||
$preview = (isset($_POST['preview'])) ? true : false;
|
||||
$save = (isset($_POST['save'])) ? true : false;
|
||||
$cancel = (isset($_POST['cancel'])) ? true : false;
|
||||
$confirm = (isset($_POST['confirm'])) ? true : false;
|
||||
$delete = (isset($_POST['delete'])) ? true : false;
|
||||
|
||||
if (($delete) && (!$preview) && ($submit))
|
||||
{
|
||||
$mode = 'delete';
|
||||
}
|
||||
|
||||
// Was cancel pressed? If so then redirect to the appropriate page
|
||||
if ($cancel)
|
||||
if ( ($cancel) || ((time() - $lastclick) < 2) )
|
||||
{
|
||||
$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"));
|
||||
redirect($redirect);
|
||||
|
@ -73,8 +102,8 @@ $topic_validate = false;
|
|||
$post_validate = false;
|
||||
|
||||
$forum_fields = array('f.forum_id', 'f.forum_name', 'f.parent_id', 'f.forum_parents', 'f.forum_status', 'f.forum_postable', 'f.enable_icons', 'f.enable_post_count', 'f.enable_moderate');
|
||||
$topic_fields = array('t.topic_id', 't.topic_status', 't.topic_first_post_id', 't.topic_last_post_id', 't.topic_type', 't.topic_title');
|
||||
$post_fields = array('p.post_id', 'p.post_time', 'p.poster_id', 'p.post_username', 'p.post_text', 'p.post_checksum', 'p.bbcode_uid', 'p.enable_magic_url');
|
||||
$topic_fields = array('t.topic_id', 't.topic_status', 't.topic_first_post_id', 't.topic_last_post_id', 't.topic_type', 't.topic_title', 't.poll_last_vote', 't.poll_start', 't.poll_title', 't.poll_length');
|
||||
$post_fields = array('p.post_id', 'p.post_time', 'p.poster_id', 'p.post_username', 'p.post_text', 'p.post_subject', 'p.post_checksum', 'p.bbcode_uid', 'p.enable_magic_url', 'p.enable_sig', 'p.enable_smilies', 'p.enable_bbcode');
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
|
@ -166,6 +195,27 @@ if ($sql != '')
|
|||
$topic_last_post_id = ($topic_validate) ? intval($topic_last_post_id) : false;
|
||||
$topic_type = ($topic_validate) ? intval($topic_type) : false;
|
||||
$topic_title = ($topic_validate) ? trim($topic_title) : '';
|
||||
$poll_last_vote = ($topic_validate) ? intval($poll_last_vote) : false;
|
||||
$poll_start = ($topic_validate) ? intval($poll_start) : false;
|
||||
$poll_title = ($topic_validate) ? trim($poll_title) : false;
|
||||
$poll_length = ($topic_validate) ? (intval($poll_length)/3600) : false;
|
||||
$poll_options = array();
|
||||
|
||||
// Get Poll Data
|
||||
if ($poll_start)
|
||||
{
|
||||
$sql = "SELECT poll_option_text
|
||||
FROM " . POLL_OPTIONS_TABLE . "
|
||||
WHERE topic_id = " . $topic_id . "
|
||||
ORDER BY poll_option_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$poll_options[] = trim($row['poll_option_text']);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$post_id = intval($post_id);
|
||||
$post_time = ($post_validate) ? intval($post_time) : false;
|
||||
|
@ -182,8 +232,12 @@ if ($sql != '')
|
|||
|
||||
$post_text = ($post_validate) ? trim($post_text) : '';
|
||||
$post_checksum = ($post_validate) ? trim($post_checksum) : '';
|
||||
$post_subject = ($post_validate) ? trim($post_subject) : $topic_title;
|
||||
$bbcode_uid = ($post_validate) ? trim($bbcode_uid) : '';
|
||||
$enable_urls = ($post_validate) ? intval($enable_magic_url) : true;
|
||||
$enable_sig = ($post_validate) ? intval($enable_sig) : ((intval($config['allow_sig']) && $user->data['user_attachsig']) ? true : false);
|
||||
$enable_smilies = ($post_validate) ? intval($enable_smilies) : ((intval($config['allow_smilies']) && $user->data['user_allowsmile']) ? true : false);
|
||||
$enable_bbcode = ($post_validate) ? intval($enable_bbcode) : ((intval($config['allow_bbcode']) && $user->data['user_allowbbcode']) ? true : false);
|
||||
$enable_magic_url = false;
|
||||
}
|
||||
|
||||
|
@ -247,7 +301,7 @@ if ( ($mode == 'edit') && (!$perm['m_edit']) && ($user->data['user_id'] != $post
|
|||
$message_handler = new parse_message(0); // <- TODO: add constant (MSG_POST/MSG_PM)
|
||||
|
||||
// Delete triggered ?
|
||||
if ( ($mode == 'delete') && ((($poster_id == $user->data['user_id']) && ($perm['u_delete']) && ($post_id == $topic_last_post_id)) || ($perm['m_delete'])) )
|
||||
if ( ($mode == 'delete') && ((($poster_id == $user->data['user_id']) && ($user->data['user_id'] != ANONYMOUS) && ($perm['u_delete']) && ($post_id == $topic_last_post_id)) || ($perm['m_delete'])) )
|
||||
{
|
||||
// Do we need to confirm ?
|
||||
if ($confirm)
|
||||
|
@ -309,6 +363,12 @@ if (($submit) || ($preview))
|
|||
{
|
||||
$topic_cur_post_id = (isset($_POST['topic_cur_post_id'])) ? intval($_POST['topic_cur_post_id']) : false;
|
||||
$subject = (!empty($_POST['subject'])) ? trim(htmlspecialchars(strip_tags($_POST['subject']))) : '';
|
||||
|
||||
if ((strcmp($subject, strtoupper($subject)) == 0) && ($subject != ''))
|
||||
{
|
||||
$subject = phpbb_strtolower($subject);
|
||||
}
|
||||
|
||||
$message = (!empty($_POST['message'])) ? trim($_POST['message']) : '';
|
||||
$username = (!empty($_POST['username'])) ? trim($_POST['username']) : '';
|
||||
$topic_type = (!empty($_POST['topic_type'])) ? intval($_POST['topic_type']) : POST_NORMAL;
|
||||
|
@ -318,8 +378,25 @@ if (($submit) || ($preview))
|
|||
$enable_bbcode = (!intval($config['allow_bbcode'])) ? 0 : ((!empty($_POST['disable_bbcode'])) ? 0 : 1);
|
||||
$enable_smilies = (!intval($config['allow_smilies'])) ? 0 : ((!empty($_POST['disable_smilies'])) ? 0 : 1);
|
||||
$enable_urls = (isset($_POST['disable_magic_url'])) ? 0 : 1;
|
||||
$enable_sig = (empty($_POST['attach_sig'])) ? 1 : 0;
|
||||
$notify = (!empty($_POST['notify'])) ? 1 : 0;
|
||||
$enable_sig = (!intval($config['allow_sig'])) ? false : ((!empty($_POST['attach_sig'])) ? true : false);
|
||||
$notify = (!empty($_POST['notify'])) ? true : false;
|
||||
|
||||
$poll_delete = (isset($_POST['poll_delete'])) ? true : false;
|
||||
|
||||
if ( ($poll_delete) && ($mode == 'edit' && !empty($poll_options) && ((empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $perm['u_delete']) || $perm['m_delete'])) )
|
||||
{
|
||||
$message_handler->delete_poll($topic_id);
|
||||
|
||||
$poll_title = '';
|
||||
$poll_length = '';
|
||||
$poll_option_text = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$poll_title = (!empty($_POST['poll_title'])) ? trim($_POST['poll_title']) : '';
|
||||
$poll_length = (!empty($_POST['poll_length'])) ? $_POST['poll_length'] : '';
|
||||
$poll_option_text = (!empty($_POST['poll_option_text'])) ? $_POST['poll_option_text'] : '';
|
||||
}
|
||||
|
||||
$err_msg = '';
|
||||
$current_time = time();
|
||||
|
@ -366,8 +443,9 @@ if (($submit) || ($preview))
|
|||
// Validate username
|
||||
if (($username != '' && $user->data['user_id'] == ANONYMOUS) || ($mode == 'edit' && $post_username != ''))
|
||||
{
|
||||
$userdata = new userdata();
|
||||
$username = strip_tags(htmlspecialchars($username));
|
||||
if (($result = validate_username($username)) != false)
|
||||
if (($result = $userdata->validate_username($username)) != false)
|
||||
{
|
||||
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result;
|
||||
}
|
||||
|
@ -379,8 +457,27 @@ if (($submit) || ($preview))
|
|||
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $user->lang['EMPTY_SUBJECT'];
|
||||
}
|
||||
|
||||
$poll_data = array(
|
||||
'poll_title' => $poll_title,
|
||||
'poll_length' => $poll_length,
|
||||
'poll_option_text' => $poll_option_text,
|
||||
'poll_start' => $poll_start,
|
||||
'poll_last_vote' => $poll_last_vote,
|
||||
'enable_html' => $enable_html,
|
||||
'enable_bbcode' => $enable_bbcode,
|
||||
'bbcode_uid' => $bbcode_uid,
|
||||
'enable_urls' => $enable_urls,
|
||||
'enable_smilies' => $enable_smilies
|
||||
);
|
||||
|
||||
$poll = array();
|
||||
// $poll = $message_handler->parse_poll();
|
||||
if (($result = $message_handler->parse_poll($poll, $poll_data)) != '')
|
||||
{
|
||||
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result;
|
||||
}
|
||||
|
||||
$poll_options = $poll['poll_options'];
|
||||
$poll_title = $poll['poll_title'];
|
||||
|
||||
// Check topic type
|
||||
if ($topic_type != POST_NORMAL)
|
||||
|
@ -416,7 +513,7 @@ if (($submit) || ($preview))
|
|||
'enable_moderate' => $enable_moderate,
|
||||
'icon_id' => $icon_id,
|
||||
'poster_id' => $poster_id,
|
||||
'enable_sig' => $enable_html,
|
||||
'enable_sig' => $enable_sig,
|
||||
'enable_bbcode' => $enable_bbcode,
|
||||
'enable_html' => $enable_html,
|
||||
'enable_smilies' => $enable_smilies,
|
||||
|
@ -428,7 +525,7 @@ if (($submit) || ($preview))
|
|||
'notify' => $notify,
|
||||
'notify_set' => $notify_set
|
||||
);
|
||||
|
||||
|
||||
$message_handler->submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $post_data);
|
||||
}
|
||||
|
||||
|
@ -452,24 +549,47 @@ if ($preview)
|
|||
$post_time = $current_time;
|
||||
$preview_message = $message_handler->format_display(stripslashes($message), $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies, $enable_sig);
|
||||
|
||||
if (sizeof($censors))
|
||||
$preview_subject = (sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], $subject) : $subject;
|
||||
|
||||
// Poll Preview
|
||||
if ((($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && empty($poll_last_vote))) && $auth->acl_get('f_poll', $forum_id)) || $auth->acl_gets('m_edit', 'a_', $forum_id))
|
||||
{
|
||||
$preview_subject = preg_replace($censors['match'], $censors['replace'], $subject);
|
||||
}
|
||||
else
|
||||
{
|
||||
$preview_subject = $subject;
|
||||
decode_text($poll_title);
|
||||
$preview_poll_title = $message_handler->format_display(stripslashes($poll_title), $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies, false, false);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_HAS_POLL_OPTIONS' => (sizeof($poll_options)) ? true : false,
|
||||
'POLL_QUESTION' => $preview_poll_title)
|
||||
);
|
||||
|
||||
foreach ($poll_options as $option)
|
||||
{
|
||||
$template->assign_block_vars('poll_option', array(
|
||||
'POLL_OPTION_CAPTION' => $message_handler->format_display(stripslashes($option), $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies, false, false))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decode text for message display
|
||||
decode_text($post_text);
|
||||
decode_text($subject);
|
||||
|
||||
for ($i = 0; $i < sizeof($poll_options); $i++)
|
||||
{
|
||||
decode_text($poll_options[$i]);
|
||||
}
|
||||
|
||||
if (($mode == 'quote') && (!$preview))
|
||||
{
|
||||
quote_text($post_text, $username);
|
||||
}
|
||||
|
||||
if ( (($mode == 'reply') || ($mode == 'quote')) && (!$preview) )
|
||||
{
|
||||
$post_subject = ( ( !preg_match('/^Re:/', $post_subject) ) ? 'Re: ' : '' ) . $post_subject;
|
||||
}
|
||||
|
||||
// MAIN POSTING PAGE BEGINS HERE
|
||||
|
||||
// Forum moderators?
|
||||
|
@ -522,7 +642,7 @@ $html_checked = (isset($enable_html)) ? !$enable_html : ((intval($config['allow_
|
|||
$bbcode_checked = (isset($enable_bbcode)) ? !$enable_bbcode : ((intval($config['allow_bbcode'])) ? !$user->data['user_allowbbcode'] : 1);
|
||||
$smilies_checked = (isset($enable_smilies)) ? !$enable_smilies : ((intval($config['allow_smilies'])) ? !$user->data['user_allowsmile'] : 1);
|
||||
$urls_checked = (isset($enable_urls)) ? !$enable_urls : 0;
|
||||
$sig_checked = (isset($attach_sig)) ? $attach_sig : ((intval($config['allow_sigs'])) ? $user->data['user_atachsig'] : 0);
|
||||
$sig_checked = $enable_sig;
|
||||
$notify_checked = (isset($notify_set)) ? $notify_set : (($user->data['user_id'] != ANONYMOUS) ? $user->data['user_notify'] : 0);
|
||||
$lock_topic_checked = (isset($topic_lock)) ? $topic_lock : (($topic_status == ITEM_LOCKED) ? 1 : 0);
|
||||
|
||||
|
@ -557,6 +677,10 @@ $forum_data = array(
|
|||
);
|
||||
generate_forum_nav($forum_data);
|
||||
|
||||
$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $topic_last_post_id . '" />' : '';
|
||||
$s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . time() . '" />';
|
||||
|
||||
|
||||
// Start assigning vars for main posting page ...
|
||||
$template->assign_vars(array(
|
||||
'L_POST_A' => $page_title,
|
||||
|
@ -568,7 +692,7 @@ $template->assign_vars(array(
|
|||
'TOPIC_TITLE' => $topic_title,
|
||||
'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : $user->lang['NONE'],
|
||||
'USERNAME' => (((!$preview) && ($mode != 'quote')) || ($preview)) ? stripslashes($username) : '',
|
||||
'SUBJECT' => (!empty($topic_title)) ? $topic_title : $post_subject,
|
||||
'SUBJECT' => $post_subject,
|
||||
'PREVIEW_SUBJECT' => ($preview) ? $preview_subject : '',
|
||||
'MESSAGE' => trim($post_text),
|
||||
'PREVIEW_MESSAGE' => ($preview) ? $preview_message : '',
|
||||
|
@ -596,7 +720,7 @@ $template->assign_vars(array(
|
|||
'S_BBCODE_CHECKED' => ($bbcode_checked) ? 'checked="checked"' : '',
|
||||
'S_SMILIES_ALLOWED' => $smilies_status,
|
||||
'S_SMILIES_CHECKED' => ($smilies_checked) ? 'checked="checked"' : '',
|
||||
'S_SIG_ALLOWED' => ($perm['f_sigs']) ? true : false,
|
||||
'S_SIG_ALLOWED' => ( ($perm['f_sigs']) && ($config['allow_sig']) ) ? true : false,
|
||||
'S_SIGNATURE_CHECKED' => ($sig_checked) ? 'checked="checked"' : '',
|
||||
'S_NOTIFY_ALLOWED' => ($user->data['user_id'] != ANONYMOUS) ? true : false,
|
||||
'S_NOTIFY_CHECKED' => ($notify_checked) ? 'checked="checked"' : '',
|
||||
|
@ -607,9 +731,24 @@ $template->assign_vars(array(
|
|||
'S_SAVE_ALLOWED' => ($perm['f_save']) ? true : false,
|
||||
|
||||
'S_POST_ACTION' => $s_action,
|
||||
'S_HIDDEN_FIELDS' => ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $topic_last_post_id . '" />' : '')
|
||||
'S_HIDDEN_FIELDS' => $s_hidden_fields)
|
||||
);
|
||||
|
||||
// Poll entry
|
||||
if ((($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && empty($poll_last_vote))) && $auth->acl_get('f_poll', $forum_id)) || $auth->acl_gets('m_edit', 'a_', $forum_id))
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_SHOW_POLL_BOX' => true,
|
||||
'S_POLL_DELETE' => ($mode == 'edit' && !empty($poll_options) && ((empty($poll_last_vote) && $poster_id == $user->data['user_id'] && $perm['u_delete']) || $perm['m_delete'])) ? true : false,
|
||||
|
||||
'L_POLL_OPTIONS_EXPLAIN'=> sprintf($user->lang['POLL_OPTIONS_EXPLAIN'], $config['max_poll_options']),
|
||||
|
||||
'POLL_TITLE' => $poll_title,
|
||||
'POLL_OPTIONS' => (!empty($poll_options)) ? implode("\n", $poll_options) : '',
|
||||
'POLL_LENGTH' => $poll_length)
|
||||
);
|
||||
}
|
||||
|
||||
// Output page ...
|
||||
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
||||
|
||||
|
|
|
@ -210,30 +210,7 @@ function checkForm()
|
|||
</table></td>
|
||||
</tr>
|
||||
<!-- IF S_SHOW_POLL_BOX -->
|
||||
<tr>
|
||||
<th colspan="2">{L_ADD_POLL}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row3" colspan="2"><span class="gensmall">{L_ADD_POLL_EXPLAIN}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><b class="gen">{L_POLL_QUESTION}</b></td>
|
||||
<td class="row2"><input class="post" type="text" name="poll_title" size="50" maxlength="255" value="{POLL_TITLE}" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><b class="gen">{L_POLL_OPTIONS}</b><br /><span class="gensmall">{L_POLL_OPTIONS_EXPLAIN}</span></td>
|
||||
<td class="row2"><textarea style="width:450px" name="poll_option_text" rows="5" cols="35">{POLL_OPTIONS}</textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><b class="gen">{L_POLL_FOR}</b></td>
|
||||
<td class="row2"><input class="post" type="text" name="poll_length" size="3" maxlength="3" value="{POLL_LENGTH}" /> <b class="gen">{L_DAYS}</b> <span class="gensmall">{L_POLL_FOR_EXPLAIN}</span></td>
|
||||
</tr>
|
||||
<!-- IF S_POLL_DELETE -->
|
||||
<tr>
|
||||
<td class="row1"><span class="gen"><b>{L_POLL_DELETE}</b></span></td>
|
||||
<td class="row2"><input type="checkbox" name="poll_delete" /></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- INCLUDE posting_poll_body.html -->
|
||||
<!-- ENDIF -->
|
||||
<!-- IF S_SHOW_ATTACH_BOX -->
|
||||
<tr>
|
||||
|
|
|
@ -1,30 +1,25 @@
|
|||
<tr>
|
||||
<th class="thHead" colspan="2">{L_ADD_A_POLL}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1" colspan="2"><span class="gensmall">{L_ADD_POLL_EXPLAIN}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><span class="gen"><b>{L_POLL_QUESTION}</b></span></td>
|
||||
<td class="row2"><span class="genmed"><input type="text" name="poll_title" size="50" maxlength="255" class="post" value="{POLL_TITLE}" /></span></td>
|
||||
</tr>
|
||||
<!-- BEGIN poll_option_rows -->
|
||||
<tr>
|
||||
<td class="row1"><span class="gen"><b>{L_POLL_OPTION}</b></span></td>
|
||||
<td class="row2"><span class="genmed"><input type="text" name="poll_option_text[{poll_option_rows.S_POLL_OPTION_NUM}]" size="50" class="post" maxlength="255" value="{poll_option_rows.POLL_OPTION}" /></span> <input type="submit" name="edit_poll_option" value="{L_UPDATE_OPTION}" class="liteoption" /> <input type="submit" name="del_poll_option[{poll_option_rows.S_POLL_OPTION_NUM}]" value="{L_DELETE_OPTION}" class="liteoption" /></td>
|
||||
</tr>
|
||||
<!-- END poll_option_rows -->
|
||||
<tr>
|
||||
<td class="row1"><span class="gen"><b>{L_POLL_OPTION}</b></span></td>
|
||||
<td class="row2"><span class="genmed"><input type="text" name="add_poll_option_text" size="50" maxlength="255" class="post" value="{ADD_POLL_OPTION}" /></span> <input type="submit" name="add_poll_option" value="{L_ADD_OPTION}" class="liteoption" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><span class="gen"><b>{L_POLL_LENGTH}</b></span></td>
|
||||
<td class="row2"><span class="genmed"><input type="text" name="poll_length" size="3" maxlength="3" class="post" value="{POLL_LENGTH}" /></span> <span class="gen"><b>{L_DAYS}</b></span> <span class="gensmall">{L_POLL_LENGTH_EXPLAIN}</span></td>
|
||||
</tr>
|
||||
<!-- IF S_POLL_DELETE -->
|
||||
<tr>
|
||||
<td class="row1"><span class="gen"><b>{L_POLL_DELETE}</b></span></td>
|
||||
<td class="row2"><input type="checkbox" name="poll_delete" /></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
|
||||
<tr>
|
||||
<th colspan="2">{L_ADD_POLL}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row3" colspan="2"><span class="gensmall">{L_ADD_POLL_EXPLAIN}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><b class="gen">{L_POLL_QUESTION}</b></td>
|
||||
<td class="row2"><input class="post" type="text" name="poll_title" size="50" maxlength="255" value="{POLL_TITLE}" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><b class="gen">{L_POLL_OPTIONS}</b><br /><span class="gensmall">{L_POLL_OPTIONS_EXPLAIN}</span></td>
|
||||
<td class="row2"><textarea style="width:450px" name="poll_option_text" rows="5" cols="35">{POLL_OPTIONS}</textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><b class="gen">{L_POLL_FOR}</b></td>
|
||||
<td class="row2"><input class="post" type="text" name="poll_length" size="3" maxlength="3" value="{POLL_LENGTH}" /> <b class="gen">{L_DAYS}</b> <span class="gensmall">{L_POLL_FOR_EXPLAIN}</span></td>
|
||||
</tr>
|
||||
<!-- IF S_POLL_DELETE -->
|
||||
<tr>
|
||||
<td class="row1"><span class="gen"><b>{L_POLL_DELETE}</b></span></td>
|
||||
<td class="row2"><input type="checkbox" name="poll_delete" /></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
|
|
|
@ -6,6 +6,26 @@
|
|||
<tr>
|
||||
<td class="row1">{MINI_POST_IMG}<span class="postdetails">{L_POSTED}: {POST_DATE} {L_POST_SUBJECT}: {PREVIEW_SUBJECT}</span></td>
|
||||
</tr>
|
||||
<!-- IF S_HAS_POLL_OPTIONS -->
|
||||
<tr>
|
||||
<td class="row2" colspan="2"><br clear="all" />
|
||||
<table cellspacing="0" cellpadding="4" border="0" align="center">
|
||||
<tr>
|
||||
<td align="center"><span class="gen"><b>{POLL_QUESTION}</b></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><table cellspacing="0" cellpadding="2" border="0">
|
||||
<!-- BEGIN poll_option -->
|
||||
<tr>
|
||||
<td><input type="radio" name="vote_id" value="" /> </td>
|
||||
<td><span class="gen">{poll_option.POLL_OPTION_CAPTION}</span></td>
|
||||
</tr>
|
||||
<!-- END poll_option -->
|
||||
</table></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<tr>
|
||||
<td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<td align="center"><input type="submit" name="castvote" value="{L_SUBMIT_VOTE}" class="liteoption" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><span class="gensmall"><b><a href="{U_VIEW_RESULTS}" class="gensmall">{L_VIEW_RESULTS}</a></b></span></td>
|
||||
<td align="center"><span class="gensmall"><b><a href="{U_VIEW_RESULTS}">{L_VIEW_RESULTS}</a></b></span></td>
|
||||
</tr>
|
||||
</table>{S_HIDDEN_FIELDS}</form></td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Reference in a new issue