2003-07-18 21:38:51 +00:00
< ? php
2003-08-13 22:05:36 +00:00
require_once ( '../db.inc' );
2003-07-18 21:38:51 +00:00
2003-08-01 20:27:53 +00:00
define ( 'NO_CONTROLS' , 0 );
define ( 'FORUM_CONTROLS' , 1 );
define ( 'HELPDESK_CONTROLS' , 2 );
2003-08-13 22:05:36 +00:00
define ( 'SOLUTION' , 'This answered my question' );
define ( 'SUFFERER' , 'I also have this question' );
2003-08-01 20:27:53 +00:00
define ( 'OFF_TOPIC' , 'Off-topic' );
2003-08-13 22:05:36 +00:00
$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 [ 'views-most' ] = " Most views first " ;
$forum_sort_styles [ 'replies-most' ] = " Most replies first " ;
$thread_sort_styles [ 'date-old' ] = " Oldest first " ;
$thread_sort_styles [ 'date-new' ] = " Newest first " ;
$thread_sort_styles [ 'rating-high' ] = " Highest rated first " ;
$thread_filter_styles [ '2' ] = " \" Very helpful \" " ;
$thread_filter_styles [ '1' ] = " At least \" helpful \" " ;
$thread_filter_styles [ '0' ] = " At least \" neutral \" " ;
$thread_filter_styles [ '-1' ] = " At least \" unhelpful \" " ;
$thread_filter_styles [ '-2' ] = " All posts " ;
db_init ( '../' );
2003-07-18 21:38:51 +00:00
class Category {
2003-07-24 22:58:38 +00:00
var $id ;
var $name ;
2003-08-13 22:05:36 +00:00
var $is_helpdesk ;
2003-07-24 22:58:38 +00:00
2003-08-13 22:05:36 +00:00
function Category ( $id = - 1 , $name = '' , $is_helpdesk = 0 ) {
2003-07-24 22:58:38 +00:00
$vars = get_class_vars ( 'Category' );
foreach ( $vars as $var => $value )
$this -> $var = $$var ;
}
function getForums () {
$sql = 'SELECT * FROM forum WHERE category = ' . $this -> id . ' ORDER BY orderID ASC' ;
2003-08-13 22:05:36 +00:00
return mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
}
2003-07-18 21:38:51 +00:00
}
class Forum {
2003-07-24 22:58:38 +00:00
var $id ;
var $category ;
var $orderID ;
var $title ;
var $description ;
var $timestamp ;
var $threads ;
var $posts ;
2003-08-01 20:27:53 +00:00
var $is_helpdesk ;
2003-07-24 22:58:38 +00:00
2003-08-01 20:27:53 +00:00
function Forum ( $id = - 1 , $category = - 1 , $orderID = - 1 , $title = '' , $description = '' , $timestamp = 0 , $threads = 0 , $posts = 0 , $is_helpdesk = 0 ) {
2003-07-24 22:58:38 +00:00
$vars = get_class_vars ( 'Forum' );
foreach ( $vars as $var => $value )
$this -> $var = $$var ;
}
2003-07-30 00:50:02 +00:00
// TODO: Make sure sorting still works properly when there are enough threads to span multiple pages.
function getThreads ( $min = - 1 , $nRec = - 1 , $sort_style = 'modified-new' ) {
$sql = 'SELECT * FROM thread WHERE forum = ' . $this -> id ;
switch ( $sort_style ) {
2003-08-01 20:27:53 +00:00
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 ;
2003-08-02 00:48:46 +00:00
case 'help-activity-most' :
$sql = $sql . ' ORDER by activity DESC, sufferers DESC' ;
2003-08-01 20:27:53 +00:00
break ;
}
2003-07-24 22:58:38 +00:00
if ( $min > - 1 ) {
$sql .= ' LIMIT ' . $min ;
if ( $nRec > - 1 )
$sql .= ', ' . $nRec ;
} elseif ( $nRec > - 1 )
$sql .= ' LIMIT ' . $nRec ;
2003-08-13 22:05:36 +00:00
return mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
}
2003-07-18 21:38:51 +00:00
}
class Thread {
2003-07-24 22:58:38 +00:00
var $id ;
var $forum ;
var $owner ;
var $title ;
var $timestamp ;
var $views ;
var $replies ;
2003-08-01 20:27:53 +00:00
var $sufferers ;
2003-07-24 22:58:38 +00:00
2003-08-01 20:27:53 +00:00
function Thread ( $id = - 1 , $forum = - 1 , $owner = - 1 , $title = '' , $timestamp = 0 , $views = 0 , $replies = 0 , $sufferers = 0 ) {
2003-07-24 22:58:38 +00:00
$vars = get_class_vars ( 'Thread' );
foreach ( $vars as $var => $value )
$this -> $var = $$var ;
}
2003-08-13 22:05:36 +00:00
// TODO: Constant for the default sort style.
2003-07-30 00:50:02 +00:00
function getPosts ( $min = - 1 , $nRec = - 1 , $sort_style = " date-old " ) {
$sql = 'SELECT *, (score * votes) AS rating FROM post WHERE thread = ' . $this -> id ;
switch ( $sort_style ) {
case 'date-old' :
$sql = $sql . ' ORDER BY timestamp ASC' ;
break ;
case 'date-new' :
$sql = $sql . ' ORDER BY timestamp DESC' ;
break ;
2003-08-01 20:27:53 +00:00
case 'score-high' :
$sql = $sql . ' ORDER BY score DESC' ;
break ;
2003-07-30 00:50:02 +00:00
case 'rating-high' :
$sql = $sql . ' ORDER BY rating DESC' ;
break ;
}
2003-07-24 22:58:38 +00:00
if ( $min > - 1 ) {
$sql .= ' LIMIT ' . $min ;
if ( $nRec > - 1 )
$sql .= ', ' . $nRec ;
} elseif ( $nRec > - 1 )
$sql .= ' LIMIT ' . $nRec ;
2003-08-13 22:05:36 +00:00
return mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
}
function getRootPostsArray () {
$sql = 'SELECT * FROM post WHERE (thread = ' . $this -> id . ') AND (parent_post IS NULL) ORDER BY id ASC' ;
2003-08-13 22:05:36 +00:00
$result = mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
if ( mysql_num_rows ( $result ) == 0 ) return NULL ;
while ( $obj = mysql_fetch_object ( $result )) {
$posts [] = $obj ;
}
return $posts ;
}
2003-07-26 00:20:05 +00:00
// Returns an array containing all posts in this thread ordered hierarchically.;
2003-07-24 22:58:38 +00:00
2003-07-26 00:20:05 +00:00
function getOrderedPostArray () {
2003-07-24 22:58:38 +00:00
$rootPosts = $this -> getRootPostsArray ();
// Sort $rootPosts by date (most recent first);
foreach ( $rootPosts as $post ) {
$childPosts = $post -> getChildPostArray ();
$orderedPosts = array_merge ( $orderedPosts , $childPosts );
}
return $orderedPosts ;
}
function post ( $content ) {
$title = addslashes ( htmlentities ( $this -> title ));
$content = addslashes ( htmlentities ( $content ));
$sql = " INSERT INTO thread (forum, owner, title, timestamp) VALUES ( " . $this -> forum . " , " . $this -> owner . " , ' " . $title . " ', UNIX_TIMESTAMP()) " ;
2003-08-13 22:05:36 +00:00
$result = mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
if ( ! $result )
return false ;
2003-08-13 22:05:36 +00:00
$this -> id = mysql_insert_id ();
2003-07-24 22:58:38 +00:00
$post = new Post ();
$post -> thread = $this -> id ;
$post -> user = $this -> owner ;
$post -> content = $content ;
$postID = $post -> insert ();
$sql = " UPDATE user SET posts = posts + 1 WHERE id = " . $this -> owner . " LIMIT 1 " ;
2003-08-13 22:05:36 +00:00
mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
$sql = " UPDATE forum SET threads = threads + 1, posts = posts + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $this -> forum . " LIMIT 1 " ;
2003-08-13 22:05:36 +00:00
mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
return $thread -> id ;
}
2003-07-28 22:47:48 +00:00
function reply ( $user = - 1 , $content = " " , $parent_post = NULL ) {
2003-07-24 22:58:38 +00:00
$content = addslashes ( htmlentities ( $content ));
$post = new Post ();
$post -> thread = $this -> id ;
$post -> user = $user ;
$post -> content = $content ;
$post -> parent_post = $parent_post ;
$postID = $post -> insert ();
$sql = " UPDATE user SET posts = posts + 1 WHERE id = " . $user . " LIMIT 1 " ;
2003-08-13 22:05:36 +00:00
mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
$sql = " UPDATE thread SET replies = replies + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $this -> id . " LIMIT 1 " ;
2003-08-13 22:05:36 +00:00
mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
$sql = " UPDATE forum SET posts = posts + 1, timestamp = UNIX_TIMESTAMP() WHERE id = " . $this -> forum . " LIMIT 1 " ;
2003-08-13 22:05:36 +00:00
mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
}
function incView () {
$sql = " UPDATE thread SET views = views + 1 WHERE id = " . $this -> id . " LIMIT 1 " ;
2003-08-13 22:05:36 +00:00
mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
}
2003-07-18 21:38:51 +00:00
}
class Post {
2003-07-24 22:58:38 +00:00
var $id ;
var $thread ;
var $parent_post ;
var $user ;
var $timestamp ;
var $content ;
var $modified ;
2003-07-30 00:50:02 +00:00
var $votes ;
var $score ;
2003-07-24 22:58:38 +00:00
2003-07-30 00:50:02 +00:00
function Post ( $id = - 1 , $thread = - 1 , $user = - 1 , $timestamp = 0 , $content = " " , $modified = NULL , $parent_post = NULL , $votes = NULL , $score = NULL ) {
2003-07-24 22:58:38 +00:00
$vars = get_class_vars ( 'Post' );
foreach ( $vars as $var => $value )
$this -> $var = $$var ;
}
function insert () {
2003-07-29 18:45:19 +00:00
if ( $this -> parent_post ) {
$sql = " INSERT INTO post (thread, user, timestamp, content, parent_post) VALUES ( " . $this -> thread . " , " . $this -> user . " , UNIX_TIMESTAMP(), ' " . $this -> content . " ', " . $this -> parent_post . " ) " ;
} else {
$sql = " INSERT INTO post (thread, user, timestamp, content) VALUES ( " . $this -> thread . " , " . $this -> user . " , UNIX_TIMESTAMP(), ' " . $this -> content . " ') " ;
}
2003-08-13 22:05:36 +00:00
$result = mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
if ( ! $result )
return false ;
2003-08-13 22:05:36 +00:00
return ( $this -> id = mysql_insert_id ());
2003-07-24 22:58:38 +00:00
}
function update ( $content ) {
$sql = " UPDATE post SET content = \" $content\ " , modified = UNIX_TIMESTAMP () WHERE id = " . $this->id ;
2003-08-13 22:05:36 +00:00
$result = mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
if ( ! $result )
return false ;
return true ;
}
function getImmediateChildren () {
$sql = " SELECT * FROM post WHERE parent_post = " . $this -> id . " ORDER BY timestamp DESC " ;
2003-08-13 22:05:36 +00:00
return mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
}
function getChildPostArray () {
$sql = " SELECT * FROM post WHERE parent_id = " . $this -> id ;
2003-08-13 22:05:36 +00:00
$result = mysql_query ( $sql );
2003-07-24 22:58:38 +00:00
// Base case
if ( mysql_num_rows ( $result ) == 0 ) return array ( $this );
while ( $obj = mysql_fetch_object ( $result )) {
$childPosts [] = $obj ;
}
// Add ourselves to the array before our children
$sortedArray [] = $this ;
// Sort $childPosts by date (most recent first);
2003-07-19 00:27:12 +00:00
2003-07-24 22:58:38 +00:00
foreach ( $childPosts as $post ) {
$childArray = $post -> getChildPostArray ();
$sortedArray = array_merge ( $sortedArray , $childArray );
2003-07-19 00:27:12 +00:00
}
2003-07-24 22:58:38 +00:00
return $sortedArray ;
}
2003-07-26 00:20:05 +00:00
2003-07-18 21:38:51 +00:00
}
/* group database functions */
function getCategories () {
2003-08-13 22:05:36 +00:00
$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 );
}
function getForums ( $categoryID ) {
$sql = 'SELECT * FROM forum WHERE category = ' . $categoryID . ' ORDER BY orderID ASC' ;
return mysql_query ( $sql );
2003-07-18 21:38:51 +00:00
}
function getNextCategory ( $result ) {
2003-08-13 22:05:36 +00:00
$category = mysql_fetch_array ( $result );
2003-07-24 22:58:38 +00:00
if ( ! $category )
return false ;
foreach ( $category as $var => $value )
$category [ $var ] = stripslashes ( $value );
2003-08-13 22:05:36 +00:00
return new Category ( $category [ 'id' ], $category [ 'name' ], $category [ 'is_helpdesk' ]);
2003-07-18 21:38:51 +00:00
}
function getNextForum ( $result ) {
2003-08-13 22:05:36 +00:00
$forum = mysql_fetch_array ( $result );
2003-07-24 22:58:38 +00:00
if ( ! $forum )
return false ;
foreach ( $forum as $var => $value )
$forum [ $var ] = stripslashes ( $value );
2003-08-01 20:27:53 +00:00
return new Forum ( $forum [ 'id' ], $forum [ 'category' ], $forum [ 'orderID' ], $forum [ 'title' ], $forum [ 'description' ], $forum [ 'timestamp' ], $forum [ 'threads' ], $forum [ 'posts' ], $forum [ 'is_helpdesk' ]);
2003-07-18 21:38:51 +00:00
}
function getNextThread ( $result ) {
2003-08-13 22:05:36 +00:00
$thread = mysql_fetch_array ( $result );
2003-07-24 22:58:38 +00:00
if ( ! $thread )
return false ;
foreach ( $thread as $var => $value )
$thread [ $var ] = stripslashes ( $value );
2003-08-01 20:27:53 +00:00
return new Thread ( $thread [ 'id' ], $thread [ 'forum' ], $thread [ 'owner' ], $thread [ 'title' ], $thread [ 'timestamp' ], $thread [ 'views' ], $thread [ 'replies' ], $thread [ 'sufferers' ]);
2003-07-18 21:38:51 +00:00
}
function getNextPost ( $result ) {
2003-08-13 22:05:36 +00:00
$post = mysql_fetch_array ( $result );
2003-07-24 22:58:38 +00:00
if ( ! $post )
return false ;
foreach ( $post as $var => $value )
$post [ $var ] = stripslashes ( $value );
2003-07-30 00:50:02 +00:00
return new Post ( $post [ 'id' ], $post [ 'thread' ], $post [ 'user' ], $post [ 'timestamp' ], $post [ 'content' ], $post [ 'modified' ], $post [ 'parent_post' ], $post [ 'votes' ], $post [ 'score' ]);
2003-07-18 21:38:51 +00:00
}
/* specific database functions */
2003-08-13 22:05:36 +00:00
function getCategory ( $categoryID ) {
$sql = " SELECT * FROM category WHERE id = " . $categoryID ;
return getNextCategory ( mysql_query ( $sql ));
}
2003-07-18 21:38:51 +00:00
function getForum ( $forumID ) {
2003-07-24 22:58:38 +00:00
$sql = " SELECT * FROM forum WHERE id = " . $forumID ;
2003-08-13 22:05:36 +00:00
return getNextForum ( mysql_query ( $sql ));
2003-07-18 21:38:51 +00:00
}
function getThread ( $threadID ) {
2003-07-24 22:58:38 +00:00
$sql = " SELECT * FROM thread WHERE id = " . $threadID ;
2003-08-13 22:05:36 +00:00
return getNextThread ( mysql_query ( $sql ));
2003-07-18 21:38:51 +00:00
}
2003-07-18 22:44:17 +00:00
function getPost ( $postID ) {
2003-07-24 22:58:38 +00:00
$sql = " SELECT * FROM post WHERE id = " . $postID ;
2003-08-13 22:05:36 +00:00
return getNextPost ( mysql_query ( $sql ));
2003-07-18 22:44:17 +00:00
}
2003-07-24 22:58:38 +00:00
2003-08-01 20:27:53 +00:00
// 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 );
return mysql_fetch_object ( $result );
}
2003-07-26 00:20:05 +00:00
/* display functions */
2003-08-01 20:27:53 +00:00
function show_posts ( $thread , $sort_style , $filter , $show_controls = true , $do_coloring = true , $is_helpdesk = false ) {
2003-07-26 00:20:05 +00:00
global $logged_in_user ;
$n = 0 ;
2003-08-01 20:27:53 +00:00
if ( $show_controls && ! $is_helpdesk ) {
2003-08-08 00:55:36 +00:00
$controls = FORUM_CONTROLS ;
2003-08-01 20:27:53 +00:00
} else if ( $show_controls && $is_helpdesk ) {
2003-08-08 00:55:36 +00:00
$controls = HELPDESK_CONTROLS ;
2003-08-01 20:27:53 +00:00
} else {
2003-08-08 00:55:36 +00:00
$controls = NO_CONTROLS ;
2003-08-01 20:27:53 +00:00
}
2003-07-30 00:50:02 +00:00
$posts = $thread -> getPosts ( - 1 , - 1 , $sort_style );
2003-08-01 20:27:53 +00:00
$firstPost = getFirstPost ( $thread -> id );
if ( $is_helpdesk ) {
2003-08-08 00:55:36 +00:00
if ( $firstPost ) {
show_post ( $firstPost , $thread , $logged_in_user , $n , $controls , true );
2003-08-01 20:27:53 +00:00
}
}
2003-07-26 00:20:05 +00:00
while ( $post = getNextPost ( $posts )) {
2003-07-30 00:50:02 +00:00
if ( $post -> score >= $filter ) {
2003-08-08 00:55:36 +00:00
if ( ! $is_helpdesk || ( $is_helpdesk && $post -> id != $firstPost -> id )) {
2003-08-01 20:27:53 +00:00
show_post ( $post , $thread , $logged_in_user , $n , $controls , false );
if ( $do_coloring ) $n = ( $n + 1 ) % 2 ;
2003-08-08 00:55:36 +00:00
}
2003-07-30 00:50:02 +00:00
}
2003-07-26 00:20:05 +00:00
}
}
2003-08-01 20:27:53 +00:00
function show_post ( $post , $thread , $logged_in_user , $n , $controls = FORUM_CONTROLS , $separate = false ) {
2003-08-13 22:05:36 +00:00
$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 );
2003-07-26 00:20:05 +00:00
$can_edit = $logged_in_user && $user -> id == $logged_in_user -> id ;
echo "
2003-08-01 20:27:53 +00:00
< tr class = \ " row $n\ " style = \ " vertical-align:top \" >
< td >
< a name = $post -> id ></ a >
< p style = \ " font-weight:bold \" >
" ;
2003-07-26 00:20:05 +00:00
if ( $user -> has_profile ) {
2003-08-13 22:05:36 +00:00
echo " <a href= \" ../view_profile.php?userid= $post->user\ " > " , $user->name , " </ a > " ;
2003-07-26 00:20:05 +00:00
} else {
echo $user -> name ;
}
echo "
</ p >
< p style = \ " font-size:8pt \" >
2003-08-13 22:05:36 +00:00
Joined : " , date('M j, Y', $user->create_time ), " < br > Posts : " , $user->posts , "
2003-07-26 00:20:05 +00:00
</ p >
</ td >
< td >
2003-08-01 20:27:53 +00:00
" ;
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 : " , date('D M j, Y g:i a', $post->timestamp );
2003-07-26 00:20:05 +00:00
if ( $post -> parent_post ) echo " in response to <a href=# $post->parent_post >Message ID $post->parent_post </a>. " ;
2003-08-01 20:27:53 +00:00
if ( $can_edit && $controls != NO_CONTROLS ) echo " <a href= \" edit.php?id= $post->id\ " > [ Edit this post ] </ a > " ;
2003-07-26 00:20:05 +00:00
if ( $post -> modified ) echo " <br>Last Modified: " , date ( 'D M j, Y g:i a' , $post -> modified );
echo "
2003-07-29 01:14:13 +00:00
</ p >
</ td >
2003-07-29 02:01:58 +00:00
" ;
2003-08-01 20:27:53 +00:00
if ( $controls == FORUM_CONTROLS ) {
2003-07-29 02:01:58 +00:00
echo "
2003-07-29 01:14:13 +00:00
< td align = \ " right \" style= \" border:0px \" >Rate this post:
< select name = \ " rating \" >
2003-07-30 00:50:02 +00:00
< option value = \ " 2 \" >Very helpful (+2)</option>
2003-07-29 01:14:13 +00:00
< option value = \ " 1 \" >Helpful (+1)</option>
< option selected value = \ " 0 \" >Neutral</option>
< option value = \ " -1 \" >Unhelpful (-1)</option>
2003-07-30 00:50:02 +00:00
< option value = \ " -2 \" >Off topic (-2)</option>
2003-07-29 01:14:13 +00:00
</ select >
< input type = \ " submit \" value= \" Rate \" >
</ td >
2003-07-29 02:01:58 +00:00
" ;
2003-08-01 20:27:53 +00:00
} 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 >
" ;
2003-07-29 02:01:58 +00:00
}
echo "
2003-08-01 20:27:53 +00:00
</ tr ></ table > " ;
if ( $controls == FORUM_CONTROLS || $controls == HELPDESK_CONTROLS ) {
echo " </form> " ;
}
echo " <p> " , nl2br ( stripslashes ( $post -> content )), " </p> " ;
2003-07-30 00:50:02 +00:00
echo " <table width=100% cellspacing=0 cellpadding=0>
< tr valign = \ " bottom \" >
2003-08-01 20:27:53 +00:00
< 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> " ;
2003-07-26 00:20:05 +00:00
}
2003-08-01 20:27:53 +00:00
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> " ;
}
2003-07-30 00:50:02 +00:00
echo " </tr></table></td></tr> " ;
2003-08-01 20:27:53 +00:00
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 >
" ;
}
2003-07-26 00:20:05 +00:00
}
2003-07-24 22:58:38 +00:00
2003-08-13 22:05:36 +00:00
function start_forum_table ( $headings , $widths , $span = NULL ) {
echo "
< p style = \ " text-align:center \" >
< table class = \ " content \" border=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 " ;
}
function end_forum_table () {
echo " </table></p> \n " ;
}
function show_combo_from_array ( $name , $array , $selection ) {
echo " <select name= \" $name\ " > " ;
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 " ;
}
2003-07-18 21:38:51 +00:00
?>