*** empty log message ***

svn path=/trunk/boinc/; revision=2723
This commit is contained in:
David Anderson 2003-11-30 21:05:57 +00:00
parent be893d6aea
commit 844c5c22b2
15 changed files with 526 additions and 412 deletions

View File

@ -7966,3 +7966,36 @@ Karl 2003-11-28
Makefile.am
api/
Makefile.am
David 29 Nov 2003
- top hosts shows 10 hosts, lets you page forward/back
- Various stuff related to message boards (formerly known as Forum)
- don't show blue links on blue background
- terminology in message-board interface
"message boards" describes the message system
"questions/problems" describes the FAQ system
- got rid of hard-wired field widths
- removed "activity" stuff (wasn't being used)
- cleaned up names in the beta-test database
- Yahoo-type hierarchical page titles
- made "sort by" work when step through pages
- added category, forum tables to schema.sql
- added comments on PHP-only tables to schema.sql
db/
schema.sql
html_user/
edit_user_info_action.php
index.php
top_hosts.php
user.inc
util.inc
white.css
forum/
forum.inc
forum.php
help_desk.php
index.php
post.php
reply.php
thread.php

View File

@ -226,6 +226,11 @@ create table workseq (
primary key (id)
);
-- EVERYTHING FROM HERE ON IS USED ONLY FROM PHP,
-- SO NOT IN BOINC_DB.H ETC.
-- represents a language (so can have message boards in different languages)
--
create table lang (
id integer not null auto_increment,
name varchar(254) not null,
@ -233,17 +238,9 @@ create table lang (
primary key (id)
);
create table post (
id integer not null auto_increment,
thread integer not null,
user integer not null,
timestamp integer not null,
content text not null,
modified integer not null,
parent_post integer not null,
primary key (id)
);
-- user profile (description, pictures)
--
create table profile (
userid integer not null auto_increment,
language varchar(254),
@ -256,13 +253,67 @@ create table profile (
primary key (userid)
);
-- message board category
-- help desk is a group of categories that are handled separately
--
create table category (
id integer not null auto_increment,
orderID integer not null,
-- order in which to display
lang integer not null,
name varchar(254) binary,
is_helpdesk smallint not null,
primary key (id)
);
-- message board topic
--
create table forum (
id integer not null auto_increment,
category integer not null,
orderID integer not null,
title varchar(254) not null,
description varchar(254) not null,
timestamp integer not null,
threads integer not null,
posts integer not null,
primary key (id)
);
-- threads in a topic
--
create table thread (
id integer not null auto_increment,
forum integer not null,
owner integer not null,
title varchar(254) not null,
timestamp integer not null,
-- creation time (uh, why not call it that?)
views integer not null,
-- number of times this has been viewed
replies integer not null,
-- number of postings in thread
activity integer not null,
-- not used?? should remove references
sufferers integer not null,
-- in help desk: # people who indicated they had same problem
primary key (id)
);
-- postings in a thread.
-- Each thread has an initial post
--
create table post (
id integer not null auto_increment,
thread integer not null,
user integer not null,
timestamp integer not null,
content text not null,
modified integer not null,
-- when last modified
parent_post integer not null,
score double not null,
votes integer not null,
primary key (id)
);

View File

@ -12,9 +12,9 @@ define ('OFF_TOPIC', 'Off-topic');
$forum_sort_styles['modified-new'] = "Most recent post first";
$forum_sort_styles['modified-old'] = "Least recent post first";
$forum_sort_styles['activity-most'] = "Most recent activity first";
//$forum_sort_styles['activity-most'] = "Most recent activity first";
$forum_sort_styles['views-most'] = "Most views first";
$forum_sort_styles['replies-most'] = "Most replies first";
$forum_sort_styles['replies-most'] = "Most posts first";
$thread_sort_styles['date-old'] = "Oldest first";
$thread_sort_styles['date-new'] = "Newest first";
@ -37,202 +37,199 @@ db_init('../');
/* group database functions */
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";
return mysql_query($sql);
$langID = (!empty($_SESSION['lang']['id']))?$_SESSION['lang']['id']:1;
$sql = "SELECT * FROM category WHERE lang = ".$langID." AND is_helpdesk = 0 ORDER BY orderID ASC";
return mysql_query($sql);
}
function getHelpDeskCategories() {
$sql = "SELECT * FROM category WHERE is_helpdesk = 1 ORDER BY orderID ASC";
return mysql_query($sql);
$sql = "SELECT * FROM category WHERE is_helpdesk = 1 ORDER BY orderID ASC";
return mysql_query($sql);
}
function getForums($categoryID) {
$sql = 'SELECT * FROM forum WHERE category = ' . $categoryID . ' ORDER BY orderID ASC';
$sql = 'SELECT * FROM forum WHERE category = ' . $categoryID . ' ORDER BY orderID ASC';
return mysql_query($sql);
}
function getThreads($forumID, $min = -1, $nRec = -1, $sort_style='modified-new') {
$sql = 'SELECT * FROM thread WHERE forum = ' . $forumID;
switch($sort_style) {
case 'modified-new':
$sql = $sql . ' ORDER BY timestamp DESC';
break;
case 'modified-old':
$sql = $sql . ' ORDER BY timestamp ASC';
break;
case 'views-most':
$sql = $sql . ' ORDER BY views DESC';
break;
case 'replies-most':
$sql = $sql . ' ORDER BY replies DESC';
break;
case 'activity-most':
$sql = $sql . ' ORDER by activity DESC, timestamp DESC';
break;
case 'help-activity-most':
$sql = $sql . ' ORDER by activity DESC, sufferers DESC';
break;
}
if ($min > -1) {
$sql .= ' LIMIT '.$min;
if ($nRec > -1) {
$sql .= ', '.$nRec;
}
} else if ($nRec > -1) {
$sql .= ' LIMIT '.$nRec;
$sql = 'SELECT * FROM thread WHERE forum = ' . $forumID;
switch($sort_style) {
case 'modified-new':
$sql = $sql . ' ORDER BY timestamp DESC';
break;
case 'modified-old':
$sql = $sql . ' ORDER BY timestamp ASC';
break;
case 'views-most':
$sql = $sql . ' ORDER BY views DESC';
break;
case 'replies-most':
$sql = $sql . ' ORDER BY replies DESC';
break;
// case 'activity-most':
// $sql = $sql . ' ORDER by activity DESC, timestamp DESC';
// break;
// case 'help-activity-most':
// $sql = $sql . ' ORDER by activity DESC, sufferers DESC';
// break;
}
if ($min > -1) {
$sql .= ' LIMIT '.$min;
if ($nRec > -1) {
$sql .= ', '.$nRec;
}
} else if ($nRec > -1) {
$sql .= ' LIMIT '.$nRec;
}
return mysql_query($sql);
}
function getPosts($threadID, $min = -1, $nRec = -1, $sort_style="date-old") {
$sql = 'SELECT *, (score * votes) AS rating FROM post WHERE thread = '. $threadID;
switch($sort_style) {
case 'date-old':
$sql = $sql . ' ORDER BY timestamp ASC';
break;
case 'date-new':
$sql = $sql . ' ORDER BY timestamp DESC';
break;
case 'score-high':
$sql = $sql . ' ORDER BY score DESC';
break;
case 'rating-high':
$sql = $sql . ' ORDER BY rating DESC';
break;
$sql = 'SELECT *, (score * votes) AS rating FROM post WHERE thread = '. $threadID;
switch($sort_style) {
case 'date-old':
$sql = $sql . ' ORDER BY timestamp ASC';
break;
case 'date-new':
$sql = $sql . ' ORDER BY timestamp DESC';
break;
case 'score-high':
$sql = $sql . ' ORDER BY score DESC';
break;
case 'rating-high':
$sql = $sql . ' ORDER BY rating DESC';
break;
}
if ($min > -1) {
$sql .= ' LIMIT '.$min;
if ($nRec > -1) {
$sql .= ', '.$nRec;
}
} elseif ($nRec > -1) {
$sql .= ' LIMIT '.$nRec;
}
return mysql_query($sql);
$sql .= ' LIMIT '.$min;
if ($nRec > -1) {
$sql .= ', '.$nRec;
}
} elseif ($nRec > -1) {
$sql .= ' LIMIT '.$nRec;
}
return mysql_query($sql);
}
/* specific database functions */
function getCategory($categoryID) {
$sql = "SELECT * FROM category WHERE id = ".$categoryID;
$result = mysql_query($sql);
if ($result) {
return mysql_fetch_object($result);
} else {
return NULL;
}
$sql = "SELECT * FROM category WHERE id = ".$categoryID;
$result = mysql_query($sql);
if ($result) {
return mysql_fetch_object($result);
} else {
return NULL;
}
}
function getForum($forumID) {
$sql = "SELECT * FROM forum WHERE id = " . $forumID;
$result = mysql_query($sql);
if ($result) {
return mysql_fetch_object($result);
} else {
return NULL;
}
return mysql_fetch_object($result);
} else {
return NULL;
}
}
function getThread($threadID) {
$sql = "SELECT * FROM thread WHERE id = ".$threadID;
$result = mysql_query($sql);
if ($result) {
return mysql_fetch_object($result);
} else {
return NULL;
}
return mysql_fetch_object($result);
} else {
return NULL;
}
}
function getPost($postID) {
$sql = "SELECT * FROM post WHERE id = ".$postID;
$result = mysql_query($sql);
if ($result) {
return mysql_fetch_object($result);
} else {
return NULL;
}
return mysql_fetch_object($result);
} else {
return NULL;
}
}
// Returns the post that started the thread with id = $threadId
function getFirstPost($threadID) {
$sql = "SELECT * FROM post WHERE thread = " . $threadID ." ORDER BY id ASC";
$result = mysql_query($sql);
if ($result) {
return mysql_fetch_object($result);
} else {
return NULL;
}
$sql = "SELECT * FROM post WHERE thread = " . $threadID ." ORDER BY id ASC";
$result = mysql_query($sql);
if ($result) {
return mysql_fetch_object($result);
} else {
return NULL;
}
}
function incThreadViews($threadID) {
$sql = "UPDATE thread SET views = views + 1 WHERE id = " . $threadID . " LIMIT 1";
mysql_query($sql);
$sql = "UPDATE thread SET views = views + 1 WHERE id = " . $threadID . " LIMIT 1";
mysql_query($sql);
}
/* Forum modifying functions. */
function createThread($forumID, $ownerID, $title, $content) {
$title = addslashes(htmlentities($title));
$content = addslashes(htmlentities($content));
$title = addslashes(htmlentities($title));
$content = addslashes(htmlentities($content));
$sql = "INSERT INTO thread (forum, owner, title, timestamp) VALUES (" . $forumID . ", " . $ownerID . ", '" . $title . "', UNIX_TIMESTAMP())";
$result = mysql_query($sql);
if (!$result)
return false;
$threadID = mysql_insert_id();
$sql = "INSERT INTO thread (forum, owner, title, timestamp) VALUES (" . $forumID . ", " . $ownerID . ", '" . $title . "', UNIX_TIMESTAMP())";
$result = mysql_query($sql);
if (!$result) return false;
$threadID = mysql_insert_id();
$postID = addPost($threadID, $ownerID, NULL, $content);
$postID = addPost($threadID, $ownerID, NULL, $content);
$sql = "UPDATE user SET posts = posts + 1 WHERE id = " . $ownerID . " LIMIT 1";
mysql_query($sql);
$sql = "UPDATE user SET posts = posts + 1 WHERE id = " . $ownerID . " LIMIT 1";
mysql_query($sql);
$sql = "UPDATE forum SET threads = threads + 1, posts = posts + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $forumID . " LIMIT 1";
mysql_query($sql);
$sql = "UPDATE forum SET threads = threads + 1, posts = posts + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $forumID . " LIMIT 1";
mysql_query($sql);
return $threadID;
return $threadID;
}
function replyToThread($threadID, $userID, $content, $parent_post=NULL) {
$thread = getThread($threadID);
$thread = getThread($threadID);
$content = addslashes(htmlentities($content));
$content = addslashes(htmlentities($content));
addPost($threadID, $userID, $parent_post, $content);
addPost($threadID, $userID, $parent_post, $content);
$sql = "UPDATE user SET posts = posts + 1 WHERE id = " . $userID . " LIMIT 1";
mysql_query($sql);
$sql = "UPDATE user SET posts = posts + 1 WHERE id = " . $userID . " LIMIT 1";
mysql_query($sql);
$sql = "UPDATE thread SET replies = replies + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $threadID . " LIMIT 1";
mysql_query($sql);
$sql = "UPDATE thread SET replies = replies + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $threadID . " LIMIT 1";
mysql_query($sql);
$sql = "UPDATE forum SET posts = posts + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $thread->forum . " LIMIT 1";
mysql_query($sql);
}
$sql = "UPDATE forum SET posts = posts + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $thread->forum . " LIMIT 1";
mysql_query($sql);
}
function addPost($threadID, $userID, $parentID, $content) {
if ($parentID) {
$sql = "INSERT INTO post (thread, user, timestamp, content, parent_post) VALUES (" . $threadID . ", " . $userID . ", UNIX_TIMESTAMP(), '" . $content . "', " . $parentID . ")";
} else {
$sql = "INSERT INTO post (thread, user, timestamp, content) VALUES (" . $threadID . ", " . $userID . ", UNIX_TIMESTAMP(), '" . $content . "')";
}
$result = mysql_query($sql);
if (!$result)
return false;
//return ($post->id = mysql_insert_id());
mysql_insert_id();
return true;
if ($parentID) {
$sql = "INSERT INTO post (thread, user, timestamp, content, parent_post) VALUES (" . $threadID . ", " . $userID . ", UNIX_TIMESTAMP(), '" . $content . "', " . $parentID . ")";
} else {
$sql = "INSERT INTO post (thread, user, timestamp, content) VALUES (" . $threadID . ", " . $userID . ", UNIX_TIMESTAMP(), '" . $content . "')";
}
$result = mysql_query($sql);
if (!$result) return false;
//return ($post->id = mysql_insert_id());
mysql_insert_id();
return true;
}
function updatePost($postID, $content) {
$sql = "UPDATE post SET content = \"$content\", modified = UNIX_TIMESTAMP() WHERE id = " . $postID;
$result = mysql_query($sql);
if (!$result)
return false;
return true;
$sql = "UPDATE post SET content = \"$content\", modified = UNIX_TIMESTAMP() WHERE id = " . $postID;
$result = mysql_query($sql);
if (!$result) return false;
return true;
}
/* display functions */
@ -255,191 +252,192 @@ function show_posts($thread, $sort_style, $filter, $show_controls=true, $do_colo
if ($is_helpdesk) {
if ($firstPost) {
show_post($firstPost, $thread, $logged_in_user, $n, $controls, true);
}
}
}
while ($post = mysql_fetch_object($posts)) {
if ($post->score >= $filter) {
if (!$is_helpdesk || ($is_helpdesk && $post->id != $firstPost->id)) {
show_post($post, $thread, $logged_in_user, $n, $controls, false);
if ($do_coloring) $n = ($n+1)%2;
show_post($post, $thread, $logged_in_user, $n, $controls, false);
if ($do_coloring) $n = ($n+1)%2;
}
}
}
}
function show_post($post, $thread, $logged_in_user, $n, $controls=FORUM_CONTROLS, $separate=false) {
global $post_ratings;
global $post_ratings;
$user = lookup_user_id($post->user);
$sql = "SELECT * FROM profile WHERE userid = " . $user->id;
$result2 = mysql_query($sql);
$user->has_profile = (mysql_num_rows($result2) > 0);
$user = lookup_user_id($post->user);
$sql = "SELECT * FROM profile WHERE userid = " . $user->id;
$result2 = mysql_query($sql);
$user->has_profile = (mysql_num_rows($result2) > 0);
$can_edit = $logged_in_user && $user->id == $logged_in_user->id;
$can_edit = $logged_in_user && $user->id == $logged_in_user->id;
echo "
<tr class=\"row$n\" style=\"vertical-align:top\">
<td>
<a name= $post->id ></a>
<p style=\"font-weight:bold\">
";
echo "
<tr class=\"row$n\" style=\"vertical-align:top\">
<td>
<a name= $post->id ></a>
<p style=\"font-weight:bold\">
";
if ($user->has_profile) {
echo "<a href=\"../view_profile.php?userid=$post->user\">", $user->name, "</a>";
} else {
echo $user->name;
}
if ($user->has_profile) {
echo "<a href=\"../view_profile.php?userid=$post->user\">", $user->name, "</a>";
} else {
echo $user->name;
}
echo "
</p>
<p style=\"font-size:8pt\">
Joined: ", gmdate('M j, Y', $user->create_time), "<br>Posts: ", $user->posts, "
</p>
</td>
<td>
";
echo "
</p>
<p style=\"font-size:8pt\">
Joined: ", gmdate('M j, Y', $user->create_time), "<br>Posts: ", $user->posts, "
</p>
</td>
<td>
";
if ($controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS) {
echo "<form action=\"rate.php?post=", $post->id, "\" method=\"post\">";
}
echo "
<table width=100% cellspacing=0 cellpadding=0>
<tr valign=\"top\">
<td align=\"left\" style=\"border:0px\"><p style=\"font-size:8pt\">
Posted: ", pretty_time_str($post->timestamp);
;
if ($controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS) {
echo "<form action=\"rate.php?post=", $post->id, "\" method=\"post\">";
}
echo "
<table width=100% cellspacing=0 cellpadding=0>
<tr valign=\"top\">
<td align=\"left\" style=\"border:0px\"><p style=\"font-size:8pt\">
Posted: ", pretty_time_str($post->timestamp);
;
if ($post->parent_post) echo " in response to <a href=#$post->parent_post>Message ID $post->parent_post</a>.";
if ($can_edit && $controls != NO_CONTROLS) echo "&nbsp;<a href=\"edit.php?id=$post->id\">[Edit this post]</a>";
if ($post->modified) echo "<br>Last Modified: ", pretty_time_Str($post->modified);
if ($post->parent_post) echo " in response to <a href=#$post->parent_post>Message ID $post->parent_post</a>.";
if ($can_edit && $controls != NO_CONTROLS) echo "&nbsp;<a href=\"edit.php?id=$post->id\">[Edit this post]</a>";
if ($post->modified) echo "<br>Last modified: ", pretty_time_Str($post->modified);
echo "</p>\n</td>\n";
echo "</p>\n</td>\n";
if ($controls == FORUM_CONTROLS) {
echo "<td align=\"right\" style=\"border:0px\">Rate this post:";
show_combo_from_array("rating", $post_ratings, "0");
echo "<input type=\"submit\" value=\"Rate\"></td>";
} else if ($controls == HELPDESK_CONTROLS && $separate) {
echo "
<td align=\"right\" style=\"border:0px\">
<input type=\"submit\" name=\"submit\" value=\"", SUFFERER, "\">
</td>
";
} else if ($controls == HELPDESK_CONTROLS && !$separate) {
echo "
<td align=\"right\" style=\"border:0px\">
<input type=\"submit\" name=\"submit\" value=\"", SOLUTION, "\">
<input type=\"submit\" name=\"submit\" value=\"", OFF_TOPIC, "\">
</td>
";
}
if ($controls == FORUM_CONTROLS) {
echo "<td align=\"right\" style=\"border:0px\">Rate this post:";
show_combo_from_array("rating", $post_ratings, "0");
echo "<input type=\"submit\" value=\"Rate\"></td>";
} else if ($controls == HELPDESK_CONTROLS && $separate) {
echo "
<td align=\"right\" style=\"border:0px\">
<input type=\"submit\" name=\"submit\" value=\"", SUFFERER, "\">
</td>
";
} else if ($controls == HELPDESK_CONTROLS && !$separate) {
echo "
<td align=\"right\" style=\"border:0px\">
<input type=\"submit\" name=\"submit\" value=\"", SOLUTION, "\">
<input type=\"submit\" name=\"submit\" value=\"", OFF_TOPIC, "\">
</td>
";
}
echo "</tr>\n</table>\n";
echo "</tr>\n</table>\n";
if ($controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS) {
echo "</form>";
}
echo "<p>", nl2br(stripslashes($post->content)), "</p>";
echo "<table width=100% cellspacing=0 cellpadding=0>
<tr valign=\"bottom\">
<td align=\"left\" style=\"border:0px; font-size:7pt\"><i>ID: ", $post->id;
if ($controls == HELPDESK_CONTROLS && $separate) {
echo "</i></td>";
} else if ($controls == HELPDESK_CONTROLS && !$separate) {
echo " / Score: ", ($post->score * $post->votes), "</i></td>";
} else {
echo " / Rating: ", $post->score, "</i></td>";
}
if ($controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS) {
echo "</form>";
}
echo "<p>", nl2br(stripslashes($post->content)), "</p>";
echo "<table width=100% cellspacing=0 cellpadding=0>
<tr valign=\"bottom\">
<td align=\"left\" style=\"border:0px; font-size:7pt\"><i>ID: ", $post->id;
if ($controls == HELPDESK_CONTROLS && $separate) {
echo "</i></td>";
} else if ($controls == HELPDESK_CONTROLS && !$separate) {
echo " / Score: ", ($post->score * $post->votes), "</i></td>";
} else {
echo " / Rating: ", $post->score, "</i></td>";
}
if ($controls == FORUM_CONTROLS) {
echo "<td align=\"right\" style=\"border:0px\">[<a href=\"reply.php?thread=" . $thread->id . "&post=" . $post->id . "#input\">Reply to this post</a>]</td>";
} else if ($controls == HELPDESK_CONTROLS && !$separate) {
echo "<td align=\"right\" style=\"border:0px\">[<a href=\"reply.php?thread=" . $thread->id . "&post=" . $post->id . "&helpdesk=1#input\">Reply to this answer</a>]</td>";
}
if ($controls == FORUM_CONTROLS) {
echo "<td align=\"right\" style=\"border:0px\">[<a href=\"reply.php?thread=" . $thread->id . "&post=" . $post->id . "#input\">Reply to this post</a>]</td>";
} else if ($controls == HELPDESK_CONTROLS && !$separate) {
echo "<td align=\"right\" style=\"border:0px\">[<a href=\"reply.php?thread=" . $thread->id . "&post=" . $post->id . "&helpdesk=1#input\">Reply to this answer</a>]</td>";
}
echo "</tr></table></td></tr>";
echo "</tr></table></td></tr>";
if ($separate) {
echo "
</table>
<br><br>
<table class=\"content\" border=0 cellpadding=5 cellspacing=0 width=100%>
<tr>
<th style=\"width: 150px\">Author</th>
<th>Answers</th>
";
}
if ($separate) {
echo "
</table>
<br><br>
<table class=\"content\" border=0 cellpadding=5 cellspacing=0 width=100%>
<tr>
<th style=\"width: 150px\">Author</th>
<th>Answers</th>
";
}
}
/* utility functions */
function start_forum_table($headings, $widths, $span=NULL) {
echo "
<p style=\"text-align:center\">
<table order=0 cellpadding=5 cellspacing=0 width=100%>
<tr>
";
function start_forum_table($headings, $span=NULL) {
echo "
<p style=\"text-align:center\">
<table order=0 cellpadding=5 cellspacing=0 width=100%>
<tr>
";
for ($i = 0; $i < count($headings); $i++) {
$cell = "<th";
if ($span) {
$cell = $cell . " colspan=$span";
}
if ($widths[$i]) {
$cell = $cell . " style=\"width: " . $widths[$i] . "px\">";
} else {
$cell = $cell . ">";
}
echo $cell, $headings[$i], "</th>\n";
}
echo "</tr>\n";
for ($i = 0; $i < count($headings); $i++) {
$cell = "<th";
if ($span) {
$cell = $cell . " colspan=$span";
}
$cell = $cell . ">";
echo $cell, $headings[$i], "</th>\n";
}
echo "</tr>\n";
}
function end_forum_table() {
echo "</table></p>\n";
echo "</table></p>\n";
}
function show_combo_from_array($name, $array, $selection) {
echo "<select name=\"$name\">";
echo "<select name=\"$name\">";
foreach ($array as $key => $value) {
echo "<option ";
if ($key == $selection) {
echo "selected ";
}
echo "value=\"", $key, "\">", $value, "</option>";
}
echo "</select>";
foreach ($array as $key => $value) {
echo "<option ";
if ($key == $selection) {
echo "selected ";
}
echo "value=\"", $key, "\">", $value, "</option>";
}
echo "</select>";
}
function show_forum_title($forum=NULL, $thread=NULL, $helpdesk=false) {
echo "<p>\n";
if (!$forum && !$thread) {
echo "<p class=\"title\">", PROJECT;
if ($helpdesk) {
echo " Help Desk</p>";
} else {
echo " Forum</p>";
}
} else if ($forum && !$thread) {
echo "<span class=\"title\">", $forum->title, "</span><br>";
if ($helpdesk) {
echo "<a href=\"help_desk.php\">", PROJECT, " Help Desk</a>";
} else {
echo "<a href=\"index.php\">", PROJECT, " Forum</a>";
}
} else if ($forum && $thread) {
echo "<span class=\"title\">", $thread->title, "</span><br>";
if ($helpdesk) {
echo "<a href=\"help_desk.php\">", PROJECT, " Help Desk</a> -> <a href=\"forum.php?id=", $forum->id, "\">", $forum->title, "</a>";
} else {
echo "<a href=\"index.php\">", PROJECT, " Forum</a> -> <a href=\"forum.php?id=", $forum->id, "\">", $forum->title, "</a>";
}
} else {
echo "Invalid input to show_forum_title<br>";
}
echo "</p>\n";
echo "<p>\n";
if (!$forum && !$thread) {
echo "<p class=\"title\">";
if ($helpdesk) {
echo " Help desk</p>";
} else {
echo " Message boards</p>";
}
} else if ($forum && !$thread) {
echo "<span class=title>";
if ($helpdesk) {
echo "<a href=help_desk.php>", " Help Desk</a> : ";
} else {
echo "<a href=index.php>", " Message boards</a> : ";
}
echo $forum->title;
echo "</span><br>";
} else if ($forum && $thread) {
echo "<span class=title>";
if ($helpdesk) {
echo "<a href=help_desk.php>", " Help Desk</a> : ";
} else {
echo "<a href=index.php>", " Messages boards</a> : ";
}
echo "<a href=\"forum.php?id=", $forum->id, "\">", $forum->title, "</a> : ";
echo $thread->title;
echo "</span><br>";
} else {
echo "Invalid input to show_forum_title<br>";
}
echo "</p>\n";
}
?>
?>

View File

@ -10,9 +10,9 @@ define("EXCERPT_LENGTH", "120");
$n = 50;
if (empty($_GET['id'])) {
// TODO: Standard error page
echo "Invalid forum ID.<br>";
exit();
// TODO: Standard error page
echo "Invalid forum ID.<br>";
exit();
}
/* sanitize variable */
@ -20,26 +20,26 @@ $_GET['id'] = stripslashes(strip_tags($_GET['id']));
$_GET['sort'] = stripslashes(strip_tags($_GET['sort']));
if (!array_key_exists('start', $_GET) || $_GET['start'] < 0) {
$_GET['start'] = 0;
$_GET['start'] = 0;
}
$forum = getForum($_GET['id']);
$category = getCategory($forum->category);
if ($category->is_helpdesk) {
page_head('Help Desk');
$sort_style = 'help-activity-most';
page_head('Help Desk');
$sort_style = 'help-activity-most';
} else {
page_head('Forum');
($_GET['sort'] != NULL) ? $sort_style = $_GET['sort'] : $sort_style = 'modified-new';
page_head('Message boards : '.$forum->title);
($_GET['sort'] != NULL) ? $sort_style = $_GET['sort'] : $sort_style = 'modified-new';
}
echo "
<form action=\"forum.php\" method=\"get\">
<input type=\"hidden\" name=\"id\" value=", $forum->id, ">
<table width=100% cellspacing=0 cellpadding=0>
<tr valign=\"bottom\">
<td align=\"left\" style=\"border:0px\">
<form action=\"forum.php\" method=\"get\">
<input type=\"hidden\" name=\"id\" value=", $forum->id, ">
<table width=100% cellspacing=0 cellpadding=0>
<tr valign=\"bottom\">
<td align=\"left\" style=\"border:0px\">
";
show_forum_title($forum, NULL, $category->is_helpdesk);
@ -47,30 +47,31 @@ show_forum_title($forum, NULL, $category->is_helpdesk);
echo "<p>\n<a href=\"post.php?id=", $_GET['id'], "\">";
if ($category->is_helpdesk) {
echo "Post a New Question";
echo "Create a new question";
} else {
echo "Post a New Thread / Question";
echo "Create a new thread";
}
echo "</a>\n</p>\n</td>";
// Only show the sort combo box for normal forums, never for the help desk.
if (!$category->is_helpdesk) {
echo "<td align=\"right\" style=\"border:0px\">";
show_combo_from_array("sort", $forum_sort_styles, $sort_style);
echo "<input type=\"submit\" value=\"Sort\">\n</td>";
echo "<td align=\"right\" style=\"border:0px\">";
show_combo_from_array("sort", $forum_sort_styles, $sort_style);
echo "<input type=\"submit\" value=\"Sort\">\n</td>";
}
echo "</tr>\n</table>\n</form>";
// If there are more than the threshold number of threads on the page, only show the
// first $n and display links to the rest
// If there are more than the threshold number of threads on the page,
// show only the first $n and display links to the rest
//
show_page_nav($forum);
if ($category->is_helpdesk) {
start_forum_table(array("Question", "Answers"), array(NULL, 50));
start_forum_table(array("Question", "Answers"));
} else {
start_forum_table(array("Titles", "Replies", "Author", "Views", "Last Post"), array(NULL, 50, 150, 50, 170));
start_forum_table(array("Threads", "Posts", "Author", "Views", "Last post"));
}
// TODO: Move this into its own function?
@ -79,86 +80,105 @@ $threads = getThreads($forum->id, $_GET['start'], $n, $sort_style);
$n = 0;
while($thread = mysql_fetch_object($threads)) {
$user = lookup_user_id($thread->owner);
$first_post = getFirstPost($thread->id);
$excerpt = sub_sentence($first_post->content, ' ', EXCERPT_LENGTH, true);
echo "
<tr class=\"row$n\" style=\"font-size:8pt; text-align:center\">
<td style=\"font-size:10pt; text-align:left\"><a href=\"thread.php?id=", $thread->id, "\"><b>", stripslashes($thread->title), "</b></a><br>
";
$n = ($n+1)%2;
$user = lookup_user_id($thread->owner);
$first_post = getFirstPost($thread->id);
$excerpt = sub_sentence($first_post->content, ' ', EXCERPT_LENGTH, true);
echo "
<tr class=\"row$n\" style=\"font-size:8pt; text-align:center\">
<td style=\"font-size:10pt; text-align:left\"><a href=\"thread.php?id=", $thread->id, "\"><b>", stripslashes($thread->title), "</b></a><br>
";
$n = ($n+1)%2;
if ($category->is_helpdesk) {
echo "<span style=\"font-size:8pt\">", stripslashes($excerpt), "</span>";
}
if ($category->is_helpdesk) {
echo "<span style=\"font-size:8pt\">", stripslashes($excerpt), "</span>";
}
echo "</td>";
if ($category->is_helpdesk) {
echo "<td>", $thread->replies, "</td>";
} else {
echo "
<td>", $thread->replies, "</td>
<td><a href=\"../show_user.php?userid=", $thread->owner, "\">", $user->name, "</a></td>
<td>", $thread->views, "</td>
<td style=\"text-align:right\">", pretty_time_str($thread->timestamp), "</td>
";
}
echo "</td>";
if ($category->is_helpdesk) {
echo "<td>", $thread->replies, "</td>";
} else {
echo "
<td>", $thread->replies, "</td>
<td><a href=\"../show_user.php?userid=", $thread->owner, "\">", $user->name, "</a></td>
<td>", $thread->views, "</td>
<td style=\"text-align:right\">", pretty_time_str($thread->timestamp), "</td>
";
}
echo "</tr>";
echo "</tr>";
}
end_forum_table();
if ($forum->threads > $n) {
echo $gotoStr;
echo $gotoStr;
}
page_tail();
function show_page_nav($forum) {
global $n;
global $n;
if ($forum->threads > $n) {
$totalPages = floor($forum->threads / $n);
$curPage = floor($_GET['start'] / $n);
if ($forum->threads > $n) {
$totalPages = floor($forum->threads / $n);
$curPage = floor($_GET['start'] / $n);
$pages = array(0, 1, 2);
for ($i = -1 ; $i <= 1 ; $i++)
if ($curPage + $i > 0 && $curPage + $i < $totalPages - 1)
array_push($pages, $curPage + $i);
for ($i = -3 ; $i <= -1 ; $i++)
if ($totalPages + $i > 0)
array_push($pages, $totalPages + $i);
$pages = array_unique($pages);
natsort($pages);
$pages = array_values($pages);
$pages = array(0, 1, 2);
for ($i = -1 ; $i <= 1 ; $i++) {
if ($curPage + $i > 0 && $curPage + $i < $totalPages - 1) {
array_push($pages, $curPage + $i);
}
}
for ($i = -3 ; $i <= -1 ; $i++) {
if ($totalPages + $i > 0) {
array_push($pages, $totalPages + $i);
}
}
$pages = array_unique($pages);
natsort($pages);
$pages = array_values($pages);
$gotoStr = '<p style="text-align:right">Goto page ';
$gotoStr = '<p style="text-align:right">Go to page ';
if ($curPage == 0)
$gotoStr .= '<span style="font-size:larger; font-weight:bold">1</span>';
else
$gotoStr .= '<a href="forum.php?id='.$_GET['id'].'&start='.(($curPage-1)*$n).'">Previous</a> <a href="forum.php?id='.$_GET['id'].'&start=0">1</a>';
if ($curPage == 0) {
$gotoStr .= '<span style="font-size:larger; font-weight:bold">1</span>';
} else {
$gotoStr .= '<a href="forum.php?id='.$_GET['id'];
$gotoStr .= '&start='.(($curPage-1)*$n);
$gotoStr .= '&sort='.$_GET["sort"];
$gotoStr .= '">Previous</a> <a href="forum.php?id='.$_GET['id'].'&start=0">1</a>';
}
for ($i = 1 ; $i < count($pages)-1 ; $i++) {
if ($curPage == $pages[$i]) {
$gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... ';
$gotoStr .= '<span style="font-size:larger; font-weight:bold">'.($pages[$i]+1).'</span>';
} else {
$gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... ';
$gotoStr .= '<a href="forum.php?id='.$_GET['id'].'&start='.($pages[$i]*$n).'">'.($pages[$i]+1).'</a>';
}
}
for ($i = 1 ; $i < count($pages)-1 ; $i++) {
if ($curPage == $pages[$i]) {
$gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... ';
$gotoStr .= '<span style="font-size:larger; font-weight:bold">'.($pages[$i]+1).'</span>';
} else {
$gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... ';
$gotoStr .= '<a href="forum.php?id='.$_GET['id'];
$gotoStr .= '&start='.($pages[$i]*$n);
$gotoStr .= '&sort='.$_GET["sort"];
$gotoStr .= '">'.($pages[$i]+1).'</a>';
}
}
if ($curPage == $totalPages-1)
$gotoStr .= ', <span style="font-size:larger; font-weight:bold">'.$totalPages.'</span>';
else
$gotoStr .= ', <a href="forum.php?id='.$_GET['id'].'&start='.(($totalPages-1)*$n).'">'.$totalPages.'</a> <a href="forum.php?id='.$_GET['id'].'&start='.(($curPage+1)*$n).'">Next</a>';
if ($curPage == $totalPages-1) {
$gotoStr .= ', <span style="font-size:larger; font-weight:bold">'.$totalPages.'</span>';
} else {
$gotoStr .= ', <a href="forum.php?id='.$_GET['id'];
$gotoStr .= '&start='.(($totalPages-1)*$n);
$gotoStr .= '&sort='.$_GET["sort"];
$gotoStr .= '">'.$totalPages.'</a> ';
$gotoStr .= '<a href="forum.php?id='.$_GET['id'];
$gotoStr .= '&start='.(($curPage+1)*$n);
$gotoStr .= '&sort='.$_GET["sort"];
$gotoStr .= '">Next</a>';
}
$gotoStr .= '</p>';
$gotoStr .= '</p>';
echo $gotoStr;
}
echo $gotoStr;
}
}
?>
?>

View File

@ -3,19 +3,19 @@
require_once('forum.inc');
require_once('../util.inc');
page_head('Forum');
page_head('Questions and problems');
show_forum_title(NULL, NULL, true);
echo "<p style=\"text-align:center\">";
start_forum_table(array("Help Desk", "Questions", "Last Answer Posted"), array(NULL, 60, 160));
start_forum_table(array("Topic", "# Questions", "Last answer posted"));
$categories = getHelpDeskCategories();
while ($category = mysql_fetch_object($categories)) {
echo "
<tr class=\"subtitle\">
<td class=\"category\" colspan=\"4\">", $category->name, "</td>
<tr class=subtitle>
<td class=category colspan=4>", $category->name, "</td>
</tr>
";
@ -23,7 +23,7 @@ while ($category = mysql_fetch_object($categories)) {
while ($forum = mysql_fetch_object($forums)) {
echo "
<tr class=\"row1\" style=\"font-size:8pt; text-align:right\">
<td class=\"indent\" style=\"text-align:left\">
<td class=indent style=\"text-align:left\">
<span style=\"font-size:10pt; font-weight:bold\"><a href=\"forum.php?id=", $forum->id, "\">", $forum->title, "</a></span>
<br>", $forum->description, "
</td>
@ -40,4 +40,4 @@ echo "
";
page_tail();
?>
?>

View File

@ -3,13 +3,16 @@
require_once('forum.inc');
require_once('../util.inc');
page_head('Forum', NULL, NULL);
page_head('Message boards', NULL, NULL);
show_forum_title(NULL, NULL, false);
echo "<p>Note: For questions or problems pertaining to the ", PROJECT, " client, server, or website, please visit the <a href=\"help_desk.php\">Help Desk / FAQ</a>.</p>";
echo "<p>Note: For questions or problems about the ".PROJECT."
client, server, or web site, please visit the
<a href=\"help_desk.php\">Help Desk / FAQ</a>.</p>
";
start_forum_table(array("Forum", "Threads", "Posts", "Last Post"), array(NULL, 60, 60, 160));
start_forum_table(array("Topic", "Threads", "Posts", "Last post"));
show_forums();
end_table();
page_tail();
@ -18,17 +21,19 @@ function show_forums() {
$categories = getCategories();
while ($category = mysql_fetch_object($categories)) {
echo "
<tr class=\"subtitle\">
<td class=\"category\" colspan=\"4\">", $category->name, "</td>
<tr class=subtitle>
<td class=category colspan=4>", $category->name, "</td>
</tr>
";
$forums = getForums($category->id);
while ($forum = mysql_fetch_object($forums)) {
echo "
<tr class=\"row1\" style=\"font-size:8pt; text-align:right\">
<td class=\"indent\" style=\"text-align:left\">
<span style=\"font-size:10pt; font-weight:bold\"><a href=\"forum.php?id=", $forum->id, "\">", $forum->title, "</a></span>
<tr class=row1 style=\"font-size:8pt; text-align:right\">
<td class=indent style=\"text-align:left\">
<span style=\"font-size:10pt; font-weight:bold\">
<a href=\"forum.php?id=", $forum->id, "\">", $forum->title,
"</a></span>
<br>", $forum->description, "
</td>
<td>", $forum->threads, "</td>
@ -39,4 +44,4 @@ function show_forums() {
}
}
}
?>
?>

View File

@ -60,7 +60,7 @@ if ($category->is_helpdesk) {
} else {
$cell = "Post a New Thread / Question";
}
start_forum_table(array($cell), array(NULL), 2);
start_forum_table(array($cell), 2);
echo "<tr><td class=fieldname><b>Title</b>";
@ -73,7 +73,7 @@ echo "
<td><input type=\"text\" name=\"title\" size=62></td>
</tr>
<tr>
<td class=fieldname style=\"vertical-align:top\"><b>Message content</b>
<td class=fieldname style=\"vertical-align:top\"><b>Message</b>
";
if ($category->is_helpdesk) {
@ -90,14 +90,9 @@ if ($category->is_helpdesk) {
echo "
<td><textarea name=\"content\" rows=\"12\" cols=\"54\"></textarea></td>
</tr>
<tr>
<td colspan=2 style=\"text-align:center\">
<input name=add_signature value=add_it checked=true type=checkbox>Add my signature to this post
&nbsp;&nbsp;&nbsp;
<input type=\"submit\" value=\"Post message\">
</td>
</tr>
";
row2("", "<input name=add_signature value=add_it checked=true type=checkbox>Add my signature to this post");
row2("", "<input type=submit value=\"Post message\">");
end_forum_table();

View File

@ -57,7 +57,7 @@ if ($helpdesk) {
show_forum_title($forum, $thread, $helpdesk);
start_forum_table(array("Author", "Message"), array(150, NULL));
start_forum_table(array("Author", "Message"));
// TODO: Use the same sorting method that the user had in the thread view.

View File

@ -52,11 +52,11 @@ if ($logged_in_user) {
// TODO: Include this in show_forum_title?
echo "
<form action=\"thread.php\" method=\"get\">
<form action=\"thread.php\" method=\"get\">
<input type=\"hidden\" name=\"id\" value=", $thread->id, ">
<table width=100% cellspacing=0 cellpadding=0>
<tr valign=\"bottom\">
<td align=\"left\" style=\"border:0px\">
<tr valign=\"bottom\">
<td align=\"left\" style=\"border:0px\">
";
show_forum_title($forum, $thread, $category->is_helpdesk);
@ -88,10 +88,10 @@ if ($is_subscribed) {
echo "</td>";
if (!$category->is_helpdesk) {
echo "<td align=\"right\" style=\"border:0px\">Sort / Filter ";
show_combo_from_array("sort", $thread_sort_styles, $sort_style);
show_combo_from_array("filter", $thread_filter_styles, $filter_min);
echo "<input type=\"submit\" value=\"Sort\">\n</td>";
echo "<td align=\"right\" style=\"border:0px\">Sort / Filter ";
show_combo_from_array("sort", $thread_sort_styles, $sort_style);
show_combo_from_array("filter", $thread_filter_styles, $filter_min);
echo "<input type=\"submit\" value=\"Sort\">\n</td>";
}
echo "</tr>\n</table>\n</form>\n";
@ -102,7 +102,7 @@ if ($category->is_helpdesk) {
$headings = array("Author", "Message");
}
start_forum_table($headings, array(150, NULL));
start_forum_table($headings);
show_posts($thread, $sort_style, $filter_min, true, true, $category->is_helpdesk);
end_forum_table();

View File

@ -12,7 +12,7 @@
$postal_code = $HTTP_POST_VARS["postal_code"];
$signature = $HTTP_POST_VARS["signature"];
$result = mysql_query("update user set name='$name', url='$url', country='$country', postal_code='$postal_code' signature='$signature' where id=$user->id");
$result = mysql_query("update user set name='$name', url='$url', country='$country', postal_code='$postal_code', signature='$signature' where id=$user->id");
if ($result) {
Header("Location: home.php");
} else {

View File

@ -35,8 +35,8 @@
<h3>Community</h3>
<ul>
<li><a href=".URL_BASE."profile_menu.php>User profiles</a>
<li><a href=".URL_BASE."forum/>Forum</a>
<li><a href=".URL_BASE."forum/help_desk.php>Help Desk / FAQ</a>
<li><a href=".URL_BASE."forum/>Message boards</a>
<li><a href=".URL_BASE."forum/help_desk.php>Questions and problems</a>
</ul>
<h3><a href=stats.php>Project totals and leader boards</a></h3>
<!-- Deprecated

View File

@ -3,24 +3,33 @@
require_once("util.inc");
require_once("host.inc");
$max_hosts_display = 100;
$n = 10;
$offset = $_GET["offset"];
if (!$offset) $offset=0;
db_init();
page_head("Top computers");
$sort_by = $_GET["sort_by"];
if ($sort_by == "total_credit") {
$sort_by = "total_credit desc, total_credit desc";
$sort_clause = "total_credit desc, total_credit desc";
} else {
$sort_by = "expavg_credit desc, total_credit desc";
$sort_clause = "expavg_credit desc, total_credit desc";
}
$result = mysql_query("select * from host order by $sort_by limit $max_hosts_display");
$result = mysql_query("select * from host order by $sort_clause limit $n offset $offset");
host_table_start("Top computers", false);
$i = 1;
while (($host = mysql_fetch_object($result)) && $max_hosts_display > 0) {
$i = $offset+1;
while ($host = mysql_fetch_object($result)) {
show_host_row($host, $i, false);
$max_hosts_display--;
$i++;
}
mysql_free_result($result);
echo "</table>\n";
if ($offset > 0) {
$new_offset = $offset - $n;
echo "<a href=top_hosts?sort_by=$sort_by&offset=$new_offset>Last $n</a> | ";
}
$new_offset = $offset + $n;
echo "<a href=top_hosts?sort_by=$sort_by&offset=$new_offset>Next $n</a>";
page_tail();
?>

View File

@ -37,6 +37,10 @@ function show_user_profile_private($user) {
row2("URL", "http://$user->url");
row2("Country", $user->country);
row2("Postal code", $user->postal_code);
if ($user->signature) {
$x = "<pre>".htmlspecialchars($user->signature)."</pre>";
row2("Forums signature", $x);
}
row2("", "<a href=edit_user_info_form.php>Edit account info</a>");
row1("Profile");

View File

@ -176,7 +176,7 @@ function time_str($x) {
function pretty_time_str($x) {
if ($x == 0) return "&nbsp;";
return gmdate('D M j, Y g:i a', $x) . " UTC";
return gmdate('D j M Y g:i a', $x) . " UTC";
}
function start_table($extra="") {
@ -198,7 +198,7 @@ function row1($x, $ncols=2) {
function row2($x, $y) {
if ($x=="") $x="<br>";
if ($y=="") $y="<br>";
echo "<tr><td class=fieldname bgcolor=eeeeee width=40% align=right valign=top>$x</td><td valign=top><b>$y</b></td></tr>\n";
echo "<tr><td class=fieldname bgcolor=eeeeee align=right valign=top>$x</td><td valign=top><b>$y</b></td></tr>\n";
}
function row2_init($x, $y) {
echo "<tr><td class=fieldname bgcolor=eeeeee width=40% align=right valign=top>$x</td><td valign=top><b>$y\n";

View File

@ -3,11 +3,11 @@ a:link {
}
a:visited {
color: navy;
color: blue;
}
a:active {
color: red;
color: blue;
}
body , table , input , select {
@ -30,8 +30,7 @@ table.bordered {
th {
border-bottom: 2px solid white;
background-color: navy;
color: gold;
background-color: ffffcc;
font-weight: bold;
}