diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index df5d0aeeab..5385b1db9e 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -44,27 +44,27 @@ class parse_message
$message = preg_replace($match, $replace, $message);
// Message length check
- if ( !strlen($message) || ( $config['max_post_chars'] && strlen($message) > intval($config['max_post_chars']) ) )
+ if (!strlen($message) || ($config['max_post_chars'] && strlen($message) > intval($config['max_post_chars'])))
{
$warn_msg .= ( !strlen($message) ) ? $user->lang['Too_few_chars'] . '
' : $user->lang['Too_many_chars'] . '
';
}
// Smiley check
- if ( $config['max_post_smilies'] && $smilies )
+ if (intval($config['max_post_smilies']) && $smilies )
{
$sql = "SELECT code
FROM " . SMILIES_TABLE;
$result = $db->sql_query($sql);
$match = 0;
- while ( $row = $db->sql_fetchrow($result))
+ while ($row = $db->sql_fetchrow($result))
{
- if ( preg_match_all('#('. preg_quote($row['code'], '#') . ')#', $message, $matches) )
+ if (preg_match_all('#('. preg_quote($row['code'], '#') . ')#', $message, $matches))
{
$match++;
}
- if ( $match > intval($config['max_post_smilies']) )
+ if ($match > intval($config['max_post_smilies']))
{
$warn_msg .= $user->lang['Too_many_smilies'] . '
';
break;
@@ -77,13 +77,14 @@ class parse_message
// Specialchars message here ... ?
// $message = htmlspecialchars($message, ENT_COMPAT, $user->lang['ENCODING']);
- if ( $warn_msg )
+ if ($warn_msg)
{
return $warn_msg;
}
$warn_msg .= $this->html($message, $html);
$warn_msg .= $this->bbcode($message, $bbcode, $uid);
+ $warn_msg .= $this->emoticons($message, $smilies);
$warn_msg .= $this->magic_url($message, $url);
$warn_msg .= $this->attach($_FILE);
@@ -156,6 +157,29 @@ class parse_message
}
}
+ function emoticons(&$message, $smile)
+ {
+ global $db, $user;
+
+ $result = $db->sql_query('SELECT * FROM ' . SMILIES_TABLE);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $match = $replace = array();
+ do
+ {
+ $match[] = "#(?<=.\W|\W.|^\W)" . preg_quote($row['code'], '#') . "(?=.\W|\W.|\W$)#";
+ $replace[] = '
';
+ }
+ while ($row = $db->sql_fetchrow($result));
+
+ $message = preg_replace($match, $replace, ' ' . $message . ' ');
+ }
+ $db->sql_freeresult($result);
+
+ return;
+ }
+
// Based off of Acyd Burns Mod
function attach($file_ary)
{
@@ -163,6 +187,16 @@ class parse_message
$allowed_ext = explode(',', $config['attach_ext']);
}
+
+ function smiley_sort($a, $b)
+ {
+ if ( strlen($a['code']) == strlen($b['code']) )
+ {
+ return 0;
+ }
+
+ return ( strlen($a['code']) > strlen($b['code']) ) ? -1 : 1;
+ }
}
// Parses a given message and updates/maintains the fulltext tables
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 3096d6d964..9f6ba8c689 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -427,6 +427,20 @@ if (isset($post))
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
}
+
+ // post counts for index, etc.
+ if ($mode == 'post')
+ {
+ $sql = 'UPDATE ' . CONFIG_TABLE . "
+ SET config_value = '" . ($config['num_topics'] + 1) . "'
+ WHERE config_name = 'num_topics'";
+ $db->sql_query($sql);
+ }
+
+ $sql = 'UPDATE ' . CONFIG_TABLE . "
+ SET config_value = '" . ($config['num_posts'] + 1) . "'
+ WHERE config_name = 'num_posts'";
+ $db->sql_query($sql);
}
// Topic notification
@@ -485,6 +499,7 @@ $match = array(
'#.*?#',
'#.*?#',
'#.*?#',
+ '#
sql_query($sql);
- if ( !($row = $db->sql_fetchrow($result)) )
+ if (!($row = $db->sql_fetchrow($result)))
{
message_die(MESSAGE, 'No_new_posts_last_visit');
}
@@ -104,32 +99,40 @@ if (isset($_GET['view']) && empty($post_id))
$user->start();
// End session management
-if ( $user->data['user_id'] && isset($_POST['rating']) )
+if ($user->data['user_id'] != ANONYMOUS)
{
- $sql = "SELECT rating
- FROM " . TOPICS_RATINGS_TABLE . "
- WHERE topic_id = $topic_id
- AND user_id = " . $user->data['user_id'];
- $result = $db->sql_query($sql);
-
- $rating = ( $row = $db->sql_fetchrow($result) ) ? $row['rating'] : '';
-
- if ( empty($_POST['rating_value']) && $rating != '' )
+ if (isset($_POST['rating']) )
{
+ $sql = "SELECT rating
+ FROM " . TOPICS_RATINGS_TABLE . "
+ WHERE topic_id = $topic_id
+ AND user_id = " . $user->data['user_id'];
+ $result = $db->sql_query($sql);
+
+ $rating = ($row = $db->sql_fetchrow($result)) ? $row['rating'] : '';
+
+ if ( empty($_POST['rating_value']) && $rating != '' )
+ {
+ }
+ else
+ {
+ $new_rating = intval($_POST['rating']);
+
+ $sql = ( $rating != '' ) ? "UPDATE " . TOPICS_RATING_TABLE . " SET rating = $new_rating WHERE user_id = " . $user->data['user_id'] . " AND topic_id = $topic_id" : "INSERT INTO " . TOPICS_RATING_TABLE . " (topic_id, user_id, rating) VALUES ($topic_id, " . $user->data['user_id'] . ", $new_rating)";
+ }
}
- else
+ else if (isset($_POST['castvote']))
{
- $new_rating = intval($_POST['rating']);
-
- $sql = ( $rating != '' ) ? "UPDATE " . TOPICS_RATING_TABLE . " SET rating = $new_rating WHERE user_id = " . $user->data['user_id'] . " AND topic_id = $topic_id" : "INSERT INTO " . TOPICS_RATING_TABLE . " (topic_id, user_id, rating) VALUES ($topic_id, " . $user->data['user_id'] . ", $new_rating)";
+ if (!isset($_POST['vote_id']))
+ {
+ trigger_error($user->lang['No_vote']);
+ }
}
}
-//
// This rather complex gaggle of code handles querying for topics but
// also allows for direct linking to a post (and the calculation of which
// page the post is on and the correct display of viewtopic)
-//
$join_sql_table = ( !$post_id ) ? '' : ', ' . POSTS_TABLE . ' p, ' . POSTS_TABLE . ' p2 ';
$join_sql = ( !$post_id ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND p.post_approved = " . TRUE . " AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_approved = " . TRUE . " AND p2.post_id <= $post_id";
$count_sql = ( !$post_id ) ? '' : ", COUNT(p2.post_id) AS prev_posts";
@@ -144,7 +147,7 @@ $result = $db->sql_query($sql);
if ( !(extract($db->sql_fetchrow($result))) )
{
- message_die(MESSAGE, 'Topic_post_not_exist');
+ trigger_error('Topic_post_not_exist');
}
// Configure style, language, etc.
@@ -152,25 +155,21 @@ $user->setup(false, $forum_style);
$auth->acl($user->data, $forum_id);
// End configure
-//
// Start auth check
-//
-if ( !$auth->acl_get('f_read', $forum_id) )
+if (!$auth->acl_get('f_read', $forum_id))
{
- if ( $user->data['user_id'] )
+ if ($user->data['user_id'] == ANONYMOUS)
{
$redirect = ( isset($post_id) ) ? "p=$post_id" : "t=$topic_id";
$redirect .= ( isset($start) ) ? "&start=$start" : '';
redirect('login.' . $phpEx . $SID . '&redirect=viewtopic.' . $phpEx . '&' . $redirect);
}
- message_die(MESSAGE, $user->lang['Sorry_auth_read']);
+ trigger_error($user->lang['Sorry_auth_read']);
}
-//
// End auth check
-//
-if ( !empty($post_id) )
+if (!empty($post_id))
{
$start = floor(($prev_posts - 1) / $config['posts_per_page']) * $config['posts_per_page'];
}
@@ -179,18 +178,16 @@ $s_watching_topic = '';
$s_watching_topic_img = '';
watch_topic_forum('topic', $s_watching_topic, $s_watching_topic_img, $user->data['user_id'], $topic_id);
-//
// Post ordering options
-//
$previous_days = array(0 => $user->lang['All_Posts'], 1 => $user->lang['1_Day'], 7 => $user->lang['7_Days'], 14 => $user->lang['2_Weeks'], 30 => $user->lang['1_Month'], 90 => $user->lang['3_Months'], 180 => $user->lang['6_Months'], 364 => $user->lang['1_Year']);
$sort_by_text = array('a' => $user->lang['Author'], 't' => $user->lang['Post_time'], 's' => $user->lang['Subject']);
$sort_by = array('a' => 'u.username', 't' => 'p.post_id', 's' => 'pt.post_subject');
-if ( isset($_POST['sort']) )
+if (isset($_POST['sort']))
{
- if ( !empty($_POST['sort_days']) )
+ if (!empty($_POST['sort_days']))
{
- $sort_days = ( !empty($_POST['sort_days']) ) ? intval($_POST['sort_days']) : intval($_GET['sort_days']);
+ $sort_days = (!empty($_POST['sort_days'])) ? intval($_POST['sort_days']) : intval($_GET['sort_days']);
$min_post_time = time() - ( $sort_days * 86400 );
$sql = "SELECT COUNT(post_id) AS num_posts
@@ -225,7 +222,7 @@ else
$sort_order = $sort_by[$sort_key] . ' ' . ( ( $sort_dir == 'd' ) ? 'DESC' : 'ASC' );
$select_sort_days = '';
$select_sort = '