only minor changes, some notes, played around with the code... nothing special.

git-svn-id: file:///svn/phpbb/trunk@3543 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-02-26 13:17:45 +00:00
parent e295cab304
commit d95588823a
11 changed files with 82 additions and 92 deletions

View file

@ -263,61 +263,51 @@ function make_post($new_topic_id, $forum_id, $user_id, $post_username, $text, $m
$post_message = prepare_message($text, $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, bbcode_uid, enable_bbcode, enable_html, enable_smilies, enable_sig)
VALUES ($new_topic_id, $forum_id, $user_id, '$post_username', $current_time, '$user_ip', '$bbcode_uid', $bbcode_on, $html_on, $smilies_on, $attach_sig)";
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, attach_id, icon_id, post_username, post_time, poster_ip, post_approved, bbcode_uid, enable_bbcode, enable_html, enable_smilies, enable_sig, post_subject, post_text)
VALUES ($new_topic_id, $forum_id, $user_id, 0, 0, '$post_username', $current_time, '$user_ip', 1, '$bbcode_uid', $bbcode_on, $html_on, $smilies_on, $attach_sig, '$post_subject', '$post_message')";
$result = $db->sql_query($sql);
if($result)
if ($result)
{
$new_post_id = $db->sql_nextid();
$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, post_text)
VALUES ($new_post_id, '$post_subject', '$post_message')";
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_last_post_id = $new_post_id";
if($mode == "reply")
{
$sql .= ", topic_replies = topic_replies + 1 ";
}
$sql .= " WHERE topic_id = $new_topic_id";
if($db->sql_query($sql))
{
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_last_post_id = $new_post_id";
if($mode == "reply")
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_last_post_id = $new_post_id, forum_posts = forum_posts + 1";
if($mode == "newtopic")
{
$sql .= ", topic_replies = topic_replies + 1 ";
$sql .= ", forum_topics = forum_topics + 1";
}
$sql .= " WHERE topic_id = $new_topic_id";
$sql .= " WHERE forum_id = $forum_id";
if($db->sql_query($sql))
{
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_last_post_id = $new_post_id, forum_posts = forum_posts + 1";
if($mode == "newtopic")
{
$sql .= ", forum_topics = forum_topics + 1";
}
$sql .= " WHERE forum_id = $forum_id";
$sql = "UPDATE " . USERS_TABLE . "
SET user_posts = user_posts + 1
WHERE user_id = " . $user_id;
if($db->sql_query($sql))
if($db->sql_query($sql, END_TRANSACTION))
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_posts = user_posts + 1
WHERE user_id = " . $user_id;
if($db->sql_query($sql, END_TRANSACTION))
{
// SUCCESS.
return true;
}
else
{
message_die(GENERAL_ERROR, "Error updating users table", "", __LINE__, __FILE__, $sql);
}
// SUCCESS.
return true;
}
else
{
message_die(GENERAL_ERROR, "Error updating forums table", "", __LINE__, __FILE__, $sql);
message_die(GENERAL_ERROR, "Error updating users table", "", __LINE__, __FILE__, $sql);
}
}
else
{
message_die(GENERAL_ERROR, "Error updating topics table", "", __LINE__, __FILE__, $sql);
message_die(GENERAL_ERROR, "Error updating forums table", "", __LINE__, __FILE__, $sql);
}
}
else
@ -329,14 +319,13 @@ function make_post($new_topic_id, $forum_id, $user_id, $post_username, $text, $m
WHERE post_id = $new_post_id";
$db->sql_query($sql);
}
message_die(GENERAL_ERROR, "Error inserting data into posts text table", "", __LINE__, __FILE__, $sql);
message_die(GENERAL_ERROR, "Error updating topics table", "", __LINE__, __FILE__, $sql);
}
}
else
{
message_die(GENERAL_ERROR, "Error inserting data into posts table", "", __LINE__, __FILE__, $sql);
}
}
@ -470,8 +459,4 @@ function make_user($username)
}
?>
?>

View file

@ -33,7 +33,7 @@ $synonym_array = file($phpbb_root_path . "language/lang_english/search_synonyms.
// Fetch a batch of posts_text entries
//
$sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id
FROM ". POSTS_TEXT_TABLE;
FROM ". POSTS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
$error = $db->sql_error();
@ -56,7 +56,7 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
$batchcount++;
$sql = "SELECT *
FROM " . POSTS_TEXT_TABLE . "
FROM " . POSTS_TABLE . "
WHERE post_id
BETWEEN $batchstart
AND $batchend";

View file

@ -16,7 +16,6 @@ function login_db(&$username, &$password)
if ( $row = $db->sql_fetchrow($result) )
{
$db->sql_freeresult($result);
if ( md5($password) == $row['user_password'] && $row['user_active'] )
{
return $row;

View file

@ -232,9 +232,9 @@ function prune($forum_id, $prune_date, $sql_topics = '')
$pruned_posts = $db->sql_affectedrows();
$sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
/* $sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
WHERE post_id IN ($sql_posts)";
$db->sql_query($sql);
$db->sql_query($sql);*/
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id IN ($sql_posts)";

View file

@ -43,7 +43,6 @@ function display_forums($root_data = '', $display_moderators = TRUE)
lr.user_id = " . $user->data['user_id'] . "
AND (f.forum_id = lr.forum_id OR f.forum_id = -lr.forum_id)
AND lr.lastread_time >= f.forum_last_post_time)";
// Temp fix for index
//$where_sql .= ' GROUP BY f.forum_id';
}
@ -154,7 +153,6 @@ function display_forums($root_data = '', $display_moderators = TRUE)
$forum_id = $row['forum_id'];
$unread_topics = ($user->data['user_id'] && $row['lastread_time'] < $row['forum_last_post_time'] ) ? TRUE : FALSE;
$folder_image = ($unread_topics) ? 'forum_new' : 'forum';
$folder_alt = ($unread_topics) ? 'NEW_POSTS' : 'NO_NEW_POSTS';

View file

@ -24,36 +24,36 @@
class parse_message
{
var $bbcode_tpl = null;
var $message_mode = 0; // introduce constant or string ? 'posting'/'pm'
function parse_message($message_type)
{
$this->message_mode = $message_type;
}
function parse(&$message, $html, $bbcode, $uid, $url, $smilies)
{
global $config, $db, $user;
global $config, $db, $user, $_FILE;
$warn_msg = '';
// Do some general 'cleanup' first before processing message,
// e.g. remove excessive newlines(?), smilies(?)
$match = array();
$replace = array();
$match[] = '#sid=[a-z0-9]*?&?#';
$replace[] = '';
$match[] = "#([\r\n][\s]+){3,}#";
$replace[] = "\n\n";
$match = array('#sid=[a-z0-9]*?&?#', "#([\r\n][\s]+){3,}#");
$replace = array('', "\n\n");
$message = trim(preg_replace($match, $replace, $message));
// Message length check
if (!strlen($message) || ($config['max_post_chars'] && strlen($message) > intval($config['max_post_chars'])))
{
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . (!strlen($message)) ? $user->lang['Too_few_chars'] : $user->lang['Too_many_chars'];
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . (!strlen($message)) ? $user->lang['TOO_FEW_CHARS'] : $user->lang['TOO_MANY_CHARS'];
}
// Smiley check
if (intval($config['max_post_smilies']) && $smilies )
{
$sql = "SELECT code
FROM " . SMILIES_TABLE;
$sql = "SELECT code FROM " . SMILIES_TABLE;
$result = $db->sql_query($sql);
$match = 0;
@ -66,7 +66,7 @@ class parse_message
if ($match > intval($config['max_post_smilies']))
{
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $user->lang['Too_many_smilies'];
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $user->lang['TOO_MANY_SMILIES'];
break;
}
}
@ -82,7 +82,7 @@ class parse_message
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->html($message, $html);
$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->magic_url($message, trim($url));
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->attach($_FILE);
return $warn_msg;
@ -154,7 +154,8 @@ class parse_message
{
global $db, $user;
$result = $db->sql_query('SELECT * FROM ' . SMILIES_TABLE);
$sql = "SELECT * FROM " . SMILIES_TABLE;
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
@ -162,7 +163,7 @@ class parse_message
do
{
$match[] = "#(?<=.\W|\W.|^\W)" . preg_quote($row['code'], '#') . "(?=.\W|\W.|\W$)#";
$replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILE_PATH}/' . $row['smile_url'] . '" border="0" alt="' . $row['emoticon'] . '" title="' . $row['emoticon'] . '" /><!-- s' . $row['code'] . ' -->';
$replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILE_PATH}/' . $row['smile_url'] . '" alt="' . $row['smile_url'] . '" border="0" alt="' . $row['emoticon'] . '" title="' . $row['emoticon'] . '" /><!-- s' . $row['code'] . ' -->';
}
while ($row = $db->sql_fetchrow($result));
@ -173,14 +174,10 @@ class parse_message
return;
}
// Based off of Acyd Burns Mod
function attach($file_ary)
{
global $config;
$allowed_ext = explode(',', $config['attach_ext']);
}
}
@ -453,7 +450,7 @@ function generate_smilies($mode)
if ($mode == 'window')
{
$page_title = $user->lang['Review_topic'] . " - $topic_title";
$page_title = $user->lang['TOPIC_REVIEW'] . " - $topic_title";
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(

View file

@ -581,15 +581,15 @@ else
$check_extensions = array();
$suffix = ( (defined('PHP_OS')) && (eregi('win', PHP_OS)) ) ? '.dll' : '.so';
for ($i = 0; $i < count($check_extensions); $i++)
foreach ($check_extensions as $extension)
{
if (!@extension_loaded($check_extensions[$i]))
if (!@extension_loaded($extension))
{
if ( (!@ini_get('safe_mode')) && (@ini_get('enable_dl')) )
{
if (@dl($check_extensions[$i] . $suffix))
if (@dl($extension . $suffix))
{
$load_extensions .= ($load_extensions == '') ? $check_extensions[$i] . $suffix : ',' . $check_extensions[$i] . $suffix;
$load_extensions .= ($load_extensions == '') ? $extension . $suffix : ',' . $extension . $suffix;
}
}
}

View file

@ -302,7 +302,7 @@ $lang = array_merge($lang, array(
'MESSAGE_BODY' => 'Message body',
'MESSAGE_BODY_EXPLAIN' => 'Enter your message here, it may contain no more than <b>%d</b> characters.',
'Topic_review' => 'Topic review',
'TOPIC_REVIEW' => 'Topic review',
'TOPIC_ICON' => 'Topic icon',
'POST_ICON' => 'Post icon',
'No_post_mode' => 'No post mode specified',
@ -320,9 +320,9 @@ $lang = array_merge($lang, array(
'Empty_subject' => 'You must specify a subject when posting a new topic',
'To_long_subject' => 'The subject is too long it must be 60 characters or less',
'EMPTY_MESSAGE' => 'You must enter a message when posting',
'Too_few_chars' => 'Your message contains too few characters',
'Too_many_chars' => 'Your message contains too many characters',
'Too_many_smilies' => 'Your message contains too many emoticons',
'TOO_FEW_CHARS' => 'Your message contains too few characters',
'TOO_MANY_CHARS' => 'Your message contains too many characters',
'TOO_MANY_SMILIES' => 'Your message contains too many emoticons',
'Forum_locked' => 'This forum is locked you cannot post, reply to or edit topics',
'Topic_locked' => 'This topic is locked you cannot edit posts or make replies',
'No_post_id' => 'No post ID was specified',

View file

@ -22,18 +22,22 @@
// TODO for 2.2:
//
// * deletion of posts/polls
// * topic review additions, quoting, etc.?
// * topic review additions -> quoting from previous posts ?
// * post preview (poll preview too?)
// * check for reply since started posting upon submission?
// * check for reply since started posting upon submission and display of 'between-posts' to allow re-defining of post
// * hidden form element containing sid to prevent remote posting - Edwin van Vliet
// * attachments -> Acyd Burns Mod functionality
// * Attachments
// * bbcode parsing -> see functions_posting.php
// * lock topic option within posting
// * multichoice polls
// * permission defined ability for user to add poll options
// * Spellcheck? aspell? or some such?
// * Posting approval
// * Report to Admin Checkbox/Button for Moderation ?
// * After Submit got clicked, disable the button (prevent double-posts), could be solved in a more elegant way
define('IN_PHPBB', true);
if (count($_POST))
{
define('NEED_SID', true);
@ -71,7 +75,7 @@ if (!empty($_REQUEST['cancel']))
switch ($mode)
{
case 'post':
if (empty($forum_id))
if (!$forum_id)
{
trigger_error($user->lang['NO_FORUM']);
}
@ -82,7 +86,7 @@ switch ($mode)
break;
case 'reply':
if (empty($topic_id))
if (!$topic_id)
{
trigger_error($user->lang['NO_TOPIC']);
}
@ -96,7 +100,7 @@ switch ($mode)
case 'quote':
case 'edit':
case 'delete':
if (empty($post_id))
if (!$post_id)
{
trigger_error($user->lang['NO_POST']);
}
@ -109,7 +113,7 @@ switch ($mode)
break;
case 'topicreview':
if (!isset($topic_id))
if (!$topic_id)
{
trigger_error($user->lang['NO_TOPIC']);
}
@ -138,9 +142,9 @@ if ($sql != '')
if ($mode != 'post' && $user->data['user_id'] != ANONYMOUS)
{
$sql = "SELECT topic_id
FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = " . intval($topic_id) . "
AND user_id = " . $user->data['user_id'];
FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = " . intval($topic_id) . "
AND user_id = " . $user->data['user_id'];
$result = $db->sql_query($sql);
$notify_set = ($db->sql_fetchrow($result)) ? true : false;
@ -150,8 +154,8 @@ if ($mode != 'post' && $user->data['user_id'] != ANONYMOUS)
if ($mode == 'edit' && !empty($poll_start))
{
$sql = "SELECT *
FROM phpbb_poll_results
WHERE topic_id = " . intval($topic_id);
FROM phpbb_poll_results
WHERE topic_id = " . intval($topic_id);
$result = $db->sql_query($sql);
$poll_options = array();
@ -198,6 +202,7 @@ if (isset($_REQUEST['post']))
{
// If replying/quoting and last post id has changed
// give user option of continuing submit or return to post
// notify and show user the post made between his request and the final submit
if (($mode == 'reply' || $mode == 'quote') && intval($topic_last_post_id) != intval($topic_cur_post_id))
{
@ -205,7 +210,7 @@ if (isset($_REQUEST['post']))
$err_msg = '';
$current_time = time();
$parse_msg = new parse_message();
$parse_msg = new parse_message(0);
$search = new fulltext_search();
// Grab relevant submitted data
@ -713,6 +718,7 @@ $template->assign_vars(array(
'S_NOTIFY_ALLOWED' => ($user->data['user_id'] != ANONYMOUS) ? true : false,
'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $topic_last_post_id && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', intval($forum_id))) || $auth->acl_gets('m_delete', 'a_', intval($forum_id)))) ? true : false,
'S_TYPE_TOGGLE' => $topic_type_toggle,
'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_gets('m_lock', 'a_', intval($forum_id)))) ? true : false,
'S_DISPLAY_REVIEW' => ($mode == 'reply' || $mode == 'quote') ? true : false,
'S_TOPIC_ID' => intval($topic_id),

View file

@ -586,10 +586,9 @@ if ( $search_keywords != '' || $search_author != '' || $search_id )
{
if ( $show_results == 'posts' )
{
$sql = "SELECT pt.post_text, pt.bbcode_uid, pt.post_subject, p.*, f.forum_id, f.forum_name, t.*, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt
$sql = "SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
WHERE p.post_id IN ($search_results)
AND pt.post_id = p.post_id
AND f.forum_id = p.forum_id
AND p.topic_id = t.topic_id
AND p.poster_id = u.user_id";

View file

@ -194,6 +194,12 @@ function checkForm()
<td class="gen">{L_NOTIFY_REPLY}</td>
</tr>
<!-- ENDIF -->
<!-- IF S_LOCK_TOPIC_ALLOWED -->
<tr>
<td><input type="checkbox" name="lock_topic" /></td>
<td class="gen">{L_LOCK_TOPIC}</td>
</tr>
<!-- ENDIF -->
<!-- IF S_TYPE_TOGGLE -->
<tr>
<td></td>