From 7035d1190610099bfffc206a662ae599b1db01d8 Mon Sep 17 00:00:00 2001
From: David Anderson
Date: Sun, 9 Jan 2005 21:52:22 +0000
Subject: [PATCH] *** empty log message ***
svn path=/trunk/boinc/; revision=5045
---
checkin_notes | 11 +++++
html/inc/forum.inc | 93 +++++++++++++++++++++-----------------
html/inc/forum_show.inc | 38 +++++++++-------
html/user/forum_thread.php | 7 +--
4 files changed, 88 insertions(+), 61 deletions(-)
diff --git a/checkin_notes b/checkin_notes
index 1097f100f9..d45894a4d6 100755
--- a/checkin_notes
+++ b/checkin_notes
@@ -22439,3 +22439,14 @@ David 9 Jan 2005
html/inc/
forum.inc
profile.inc
+
+David 9 Oct 2005
+ - message board fixes - show thread titles using htmlspecialchars()
+ prevent invisible titles
+
+ html/
+ inc/
+ forum.inc
+ forum_show.inc
+ user/
+ forum_thread.php
diff --git a/html/inc/forum.inc b/html/inc/forum.inc
index 16b3260224..9e177c4b21 100644
--- a/html/inc/forum.inc
+++ b/html/inc/forum.inc
@@ -68,6 +68,14 @@ $post_ratings['0'] = "Neutral";
$post_ratings['-1'] = "Not helpful (-1)";
$post_ratings['-2'] = "Off topic (-2)";
+// process a user-supplied title to remove HTML stuff
+//
+function cleanup_title($title) {
+ $x = trim(htmlspecialchars(strip_tags($title)));
+ if (strlen($x)==0) return "(no title)";
+ else return $x;
+}
+
function getCategories() {
$langID = (!empty($_SESSION['lang']['id']))?$_SESSION['lang']['id']:1;
$sql = "SELECT * FROM category WHERE lang = ".$langID." AND is_helpdesk = 0 ORDER BY orderID ASC";
@@ -226,16 +234,16 @@ function getForumPreferences($user){
$user->jump_to_unread=$prefs->jump_to_unread;
$user->hide_signatures=$prefs->hide_signatures;
$user->rated_posts=$prefs->rated_posts;
- $user->low_rating_threshold=$prefs->low_rating_threshold;
- $user->high_rating_threshold=$prefs->high_rating_threshold;
+ $user->low_rating_threshold=$prefs->low_rating_threshold;
+ $user->high_rating_threshold=$prefs->high_rating_threshold;
$user->ignorelist=$prefs->ignorelist;
$user->forum_preferences=1;
-
- //Set defaults in certain cases:
- if ($user->low_rating_threshold==0 and $user->high_rating_threshold==0){
- $user->low_rating_threshold=DEFAULT_LOW_RATING_THRESHOLD;
- $user->high_rating_threshold=DEFAULT_HIGH_RATING_THRESHOLD;
- }
+
+ //Set defaults in certain cases:
+ if ($user->low_rating_threshold==0 and $user->high_rating_threshold==0){
+ $user->low_rating_threshold=DEFAULT_LOW_RATING_THRESHOLD;
+ $user->high_rating_threshold=DEFAULT_HIGH_RATING_THRESHOLD;
+ }
} else {
mysql_query("insert into forum_preferences set userid='".$user->id."'");
$user->forum_preferences=0;
@@ -272,7 +280,7 @@ function setSortStyle($user,$place,$new_style){
list($forum,$thread,$faq,$answer)=explode("|",$_COOKIE['sorting']);
$$place=$new_style;
setcookie('sorting', implode("|",array($forum,$thread,$faq,$answer)), time()+3600*24*365);
- }
+ }
}
function getThreadLastVisited($user, $thread){
@@ -331,8 +339,9 @@ function createThread($forumID, $ownerID, $title, $content, $add_signature=false
$title = addslashes(sanitize_html($title));
$content = addslashes(sanitize_html(stripslashes($content)));
- $title = trim($title);
- if (strlen(strip_tags($title)) == 0) {
+ $title = strip_tags(trim($title));
+ if (strlen($title) == 0) {
+ echo "empty title\n";
return 0;
}
@@ -399,7 +408,7 @@ function updateThread($threadID, $title) {
$result = mysql_query($sql);
if (!$result) return false;
return true;
-}
+}
/* display functions */
@@ -418,8 +427,7 @@ function show_posts($thread, $sort_style, $filter, $show_controls=true, $do_colo
$posts = getPosts($thread->id, -1, -1, $sort_style);
$logged_in_user = getThreadLastVisited($logged_in_user,$thread);
setThreadLastVisited($logged_in_user,$thread);
-
-
+
$firstPost = getFirstPost($thread->id);
if ($is_helpdesk) {
@@ -440,7 +448,7 @@ function show_posts($thread, $sort_style, $filter, $show_controls=true, $do_colo
}
}
}
-
+
if ($logged_in_user->jump_to_unread){
if ($first_unread_post->id!=""){
echo "";
@@ -451,7 +459,7 @@ function show_posts($thread, $sort_style, $filter, $show_controls=true, $do_colo
}
function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS, $separate=false, $filter=true) {
- global $post_ratings; // <------ Old obsolete rating method (remove someday)
+ global $post_ratings; // <------ Old obsolete rating method (remove someday)
$user = lookup_user_id($post->user);
$user = getForumPreferences($user);
@@ -462,15 +470,14 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS
//If the user that made this post is on the list of people to ignore, change thresholds to be more strict
if (in_array($user->id,explode("|",$logged_in_user->ignorelist))){
- $user_is_on_ignorelist=true;
- $rated_below_threshold = ($logged_in_user->high_rating_threshold>($post->score*$post->votes));
- $rated_above_threshold = ($logged_in_user->high_rating_threshold+abs($logged_in_user->low_rating_threshold)<($post->score*$post->votes));
- } else { //Use normal threshold values
+ $user_is_on_ignorelist=true;
+ $rated_below_threshold = ($logged_in_user->high_rating_threshold>($post->score*$post->votes));
+ $rated_above_threshold = ($logged_in_user->high_rating_threshold+abs($logged_in_user->low_rating_threshold)<($post->score*$post->votes));
+ } else { //Use normal threshold values
$rated_below_threshold = ($logged_in_user->low_rating_threshold>($post->score*$post->votes));
- $rated_above_threshold = ($logged_in_user->high_rating_threshold<($post->score*$post->votes));
+ $rated_above_threshold = ($logged_in_user->high_rating_threshold<($post->score*$post->votes));
}
-
$can_edit = $logged_in_user && $user->id == $logged_in_user->id;
echo "
@@ -480,7 +487,7 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS
";
echo user_links($user, URL_BASE);
-
+
if ($user->special_user) { //If this user is somehow special
if ($user->special_user==1) $fstatus=ST_ADMIN; //this is displayed in the forums
if ($user->special_user==2) $fstatus=ST_MODERATOR; //so that people know who they are
@@ -498,14 +505,15 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS
echo "
", $user->id, ""; // Try and circumvent various forms of
// of identity spoofing by displaying the
- // user id of the poster, its cheep, easy,
+ // user id of the poster, its cheep, easy,
// and doesn't require any additional database
// calls.
if (!$filter || !$rated_below_threshold){
echo "";
- if ($user->has_avatar and $logged_in_user->hide_avatars!=1)
- echo "avatar."\" alt=\"Avatar\">
";
- echo "Joined: ", gmdate('M j, Y', $user->create_time), "
Posts: ", $user->posts, "
";
+ if ($user->has_avatar and $logged_in_user->hide_avatars!=1) {
+ echo "avatar."\" alt=\"Avatar\">
";
+ }
+ echo "Joined: ", gmdate('M j, Y', $user->create_time), "
Posts: ", $user->posts, "
";
}
echo "
@@ -515,7 +523,7 @@ function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS
if ($controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS) {
echo "