login();
$sectionid = -1;
$postid = -1;
$threadid = -1;
// Only if you are logged in
if( $error == 0 )
{
// Verify if we are editing a post
if( isset($_GET['post']) )
{
$post = new post();
$postid = $post->fetch($_GET['post']);
}
}
// Do if logged in or logged out, but not on error
if( $error == 0 || $error == 3 )
{
// Verify if we are in a section
if( isset($_GET['section']) )
{
$sectionid = securize($_GET['section'], true);
settype($sectionid, 'int');
// Get section and display forum header
$sections = sql_query("SELECT * FROM sections WHERE id = '$sectionid'");
// Display appropriate section
if( mysql_num_rows($sections) != 1 )
{
$sectionid = -1;
}
else
{
$row = mysql_fetch_array($sections);
}
}
// Verify if we are in a thread
if( isset($_GET['thread']) )
{
$thread = new thread();
$threadid = $thread->fetch($_GET['thread']);
}
// No section and threads are selected, list sections
if( ($sectionid == -1 && $threadid == -1 && $postid == -1) || ($sectionid != -1 && $threadid != -1) || ($sectionid != -1 && $postid != -1) || ($threadid != -1 && $postid != -1) )
{
page_header("forum", loginallowed($error), $user, "Forum");
forum_sidemenu( $user );
echo "Please select a section:
";
// List categories
$categories = sql_query("SELECT * FROM categories order by ord asc");
while( $category = mysql_fetch_array($categories) )
{
$catid = $category['id'];
$desc = $category['category'];
// List sections
$sections = sql_query("SELECT * FROM sections WHERE categoryid = '$catid' order by ord asc");
$display = false;
while( $forum = mysql_fetch_array($sections) )
{
$fid = $forum['id'];
if( $user->canreadsection($fid) )
{
if( $display == false )
{
$display = true;
?>
";
if( !$thread->islocked() || ($thread->islocked() && $user->canunlock($thread)) )
{
page_reply_box( "reply", $threadid, "New Reply:", "RE: $title", "", "Post Reply" );
}
}
$error = 0;
}
else
{
$error = 11;
}
}
// Edit post
elseif( $postid != -1 )
{
$sectionid = $post->getsectionid();
$threadid = $post->getthreadid();
if( $user->canpost( $sectionid ) && $user->canreadpost( $post ) )
{
$thread = $post->getthread();
$title = $post->gettitle();
$sectionname = $thread->getsection();
page_header("Edit " . $post->gettitle() . " - " . $post->getthreadtitle() . " - " . $post->getsection() . " - Forum", loginallowed($error), $user, "Forum");
forum_sidemenu( $user );
$url = $thread->getposturl();
echo "Cancel and go back to thread
";
page_reply_box( "edit", $postid, "Edit post:", $title, $post->getcontent(), "Edit Post" );
}
else
{
$error = 11;
}
}
if( $error == 0 )
{
// Users online
$limit = time() - 15 * 60;
$users = sql_query("SELECT * FROM accounts WHERE lastlogged > '$limit'");
echo "
";
$display = "Users online right now: ";
$first = true;
while( $row = mysql_fetch_array($users) )
{
if( $first )
{
$first = false;
}
else
{
$display .= ", ";
}
$display .= getforumname( $row['name'], loginallowed($error) );
}
if( !$first )
{
echo "$display. ";
}
// Guests
$guests = sql_query("SELECT * FROM ips WHERE lastconnect > '$limit' AND user=''");
$nbguests = mysql_numrows($guests);
$plural = "";
if( $nbguests > 1 )
{
$plural = "s";
}
if( $nbguests > 0 )
{
echo "$nbguests guest$plural online. ";
}
// Last 24 hours
$limit = time() - 24*60*60;
$last24h = sql_query("SELECT * FROM ips WHERE lastconnect > '$limit'");
$nbvisitors = mysql_numrows($last24h);
$plural = "";
if( $nbvisitors > 1 )
{
$plural = "s";
}
if( $nbvisitors > 0 )
{
echo "$nbvisitors visitor$plural in the last 24 hours.";
}
echo "
";
}
}
if( $error != 0 )
{
page_header("Forum Error", loginallowed($error), $user, "Forums");
forum_sidemenu( $user );
page_error($error);
}
page_footer($user);
close_db();
?>