<?PHP
/** LoudMouth Open Source Edition Version 2.4.
  * 09-07-2001
  *
  * Copyright (C) 2000 - 2001 Miro Contruct Pty Ltd
  * Distributed under the terms of the GNU General Public License
  * This software may be used without warranty provided these statements are left intact
  * and the "Powered by LoudMouth" logo appears at the bottom of each page.
  * This code is Available at http://sourceforge.net/projects/mambo
  *
  * Site Name: LoudMouth Open Source Edition Version 2.4.
  * File Name: default.php
  * Developers: Nicole Anderson - nicole@miro.com.au
  *             Danny Younes - danny@miro.com.au
  * Date: 09/07/2001
  * Version #: 2.4.
  * Comments: Last Post Hack (C) Emir Sakic, 2002. <saka@hotmail.com>
  *
 **/
    
include ("../configuration.php");
    require (
"classes/database.php");

    
$database = new database();

    if (
$HTTP_COOKIE_VARS["forumusercookie"]==""){
        if (
$inside!=1){
            if (
$HTTP_COOKIE_VARS["usercookie"]!=""){
                
$cryptsessionID=md5($HTTP_COOKIE_VARS["usercookie"]);
                
$query="select userid from session where session_id='$cryptsessionID'";
                
$result=$database->openConnectionWithReturn($query);
                if (
mysql_num_rows($result)!=0){
                    
setcookie ("forumusercookie""$usercookie");
                    
$forumusercookie=$usercookie;
                    
$HTTP_COOKIE_VARS["forumusercookie"]=$usercookie;
                }
            }else{
                
setcookie("usercookie");
                
$HTTP_COOKIE_VARS["usercookie"]="";
            }
        }else{
            
setcookie("usercookie");
            
$HTTP_COOKIE_VARS["usercookie"]="";
        }
    }

    require (
"classes/javascript.php");?>

    <HTML>
    <HEAD>
    <TITLE><?echo $sitename;?></TITLE>
    <!--
    LoudMouth Open Source Edition Version 2.3.
      09-07-2001

    Copyright (C) 2000 - 2001 Miro Contruct Pty Ltd
    Distributed under the terms of the GNU General Public License
    This software may be used without warranty provided these statements are left intact
    and the "Powered by LoudMouth" logo appears at the bottom of each page.
    This code is Available at http://sourceforge.net/projects/mambo
    //-->
    <link rel="stylesheet" href="./css/ie5.css">
    <?$javascript = new javascript();?>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" LEFTMARGIN="0" MARGINHEIGHT="0" RIGHTMARGIN="0" TOPMARGIN="10">
    <CENTER>
    <TABLE WIDTH=99%>
        <TR>
            <TD WIDTH='100%'>&nbsp;</TD>
        </TR>
        <TR>
            <TD Width='100%'>&nbsp;</TD>
        </TR>
        <TR>
            <TD WIDTH='100%'>
                <TABLE CELLPADDING='3' CELLSPACING='0' BORDER='0' WIDTH=100%>
                    <TR><FORM METHOD='POST' ACTION='searchAll.php' NAME='searches'>
                        <TD WIDTH=290>Search Forums:</TD>
                        <TD WIDTH=100><INPUT TYPE='hidden' NAME='search' VALUE='Search'>
                            <INPUT TYPE='text' NAME='keyword' SIZE='25' STYLE='WIDTH:225px'></TD>
                        <TD WIDTH=50><INPUT TYPE='submit' NAME='search' VALUE='Search';></TD>
                        </FORM>
                        <?if ($HTTP_COOKIE_VARS["forumusercookie"]!=""){
                            
$cryptsessionID=md5($HTTP_COOKIE_VARS["forumusercookie"]);
                            
$query="select userid from session where session_id='$cryptsessionID'";
                            
$result=$database->openConnectionWithReturn($query);
                            if (
mysql_num_rows($result)!=0){?>
                                <TD width=40% align=right valign=top><B>Status: Logged In</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
                                <a href="#" onClick="window.open('login.php?task=editDetails', 'loginwindow', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=500,height=400,directories=no,location=no');">Change User Details</a>
                                &nbsp;&nbsp;&nbsp;&nbsp;<a href="login.php?task=logout">Logout</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                            <?}else{
                                
//echo "<SCRIPT>window.document.location.href='login.php?task=logout';</SCRIPT>";
                                
?><TD width=40% align=right valign=top><a href=# onClick="window.open('login.php', 'loginwindow', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=500,height=400,directories=no,location=no');">Login</A>&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                            <?}?>
                        <?}else{?>
                            <TD width=40% align=right valign=top><a href=# onClick="window.open('login.php', 'loginwindow', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=500,height=400,directories=no,location=no');">Login</A>&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                        <?}?>
                    </TR>
                </TABLE>
            </TD>
        </TR>
        <TR>
            <TD Width='100%'>&nbsp;</TD>
        </TR>
        <TR>
            <TD WIDTH='100%'>
                <TABLE CELLPADDING='3' CELLSPACING='0' BORDER='0' WIDTH='100%' BGCOLOR="#ffffff">
                    <TR>
                        <TD WIDTH='65%' BGCOLOR='#003366' BACKGROUND-COLOR:'#003366' HEIGHT='25'><SPAN CLASS='forumheading'>Forum Name</SPAN></TD>
                        <TD WIDTH='15%' ALIGN='MIDDLE' BGCOLOR='#003366' BACKGROUND-COLOR:'#003366' HEIGHT='25'><SPAN CLASS='forumheading'># of Messages</SPAN></TD>
                        <TD WIDTH="20%" ALIGN="MIDDLE" BGCOLOR="#003366" BACKGROUND-COLOR:"#003366" HEIGHT="25"><SPAN CLASS="forumheading">Last Post</SPAN></TD>
                    </TR>

                    <?$query "SELECT id, forumname, description, moderatorid FROM forum WHERE archive=0 AND published=1 AND usertype='$usertype' order by id desc";
                    
$result $database->openConnectionWithReturn($query);
                    
$color = Array("#FFFFFF""#CCCCCC");
                    
$num mysql_num_rows($result);
                    
$i 0;
                    if (
$num 0){
                        while (
$row mysql_fetch_object($result)){
                            
$id $row->id;
                            
$forumName $row->forumname;
                            
$description $row->description;
                            
$moderatorID $row->moderatorid;

                            
$query3="select username from users where id='$moderatorID'";
                            
$result3=$database->openConnectionWithReturn($query3);
                            list (
$moderatorName)=mysql_fetch_array($result3);

                            
$query2 "SELECT id FROM messages WHERE forumid=$id AND archive=0 AND published=1 AND replytoid=0 AND newmessage=0 AND usertype='$usertype'";
                            
$result2 $database->openConnectionWithReturn($query2);
                            
$messagesNum=mysql_num_rows($result2);

                                
$query3 "SELECT author, date, time FROM messages WHERE forumid=$id AND archive=0 AND published=1 AND newmessage=0 AND usertype='$usertype' ORDER BY date DESC, time DESC";
                                
$result3 $database->openConnectionWithReturn($query3);
                                
$row3 mysql_fetch_object($result3);
                                
$lastauthor $row3->author;
                                
$lastdate $row3->date;
                                
$lasttime $row3->time;
                                
$lasttime explode (":"$lasttime);?>
                                <TR>
                                    <TD WIDTH='65%'><IMG SRC='images/folder.gif' HSPACE='7'><A HREF="mainpage.php?option=viewForum&forumid=<?echo $id;?>&forum=<?echo $forumName;?>&moderatorName=<?echo $moderatorName;?>"><?echo $forumName;?></A>&nbsp;&nbsp;&nbsp;<?echo $description;?></TD>
                                    <TD WIDTH='15%' ALIGN='MIDDLE'><?echo $messagesNum;?></TD>
                                    <? $time_zone_offset 1//offset can be set here
                                    
if ($lastdate == date("Y-m-d"time() + ($time_zone_offset 60 60))) {
                                        echo 
"<TD WIDTH='20%' ALIGN='LEFT'><b>today, $lasttime[0]:$lasttime[1], $lastauthor</b></TD>";
                                    } else {
                                        
$lastdate explode ("-"$lastdate);
                                        echo 
"<TD WIDTH='20%' ALIGN='LEFT'>$lastdate[2]-$lastdate[1]-$lastdate[0], $lastauthor</TD>";
                                    }
?>
                                </TR>
                            <?if ($i == 1){
                                
$i 0;
                            }else {
                                
$i++;
                            }
                        }
                    }else{
?>
                        <TR><TD>There are currently no forums available to view</TD></TR>
                    <?}?>
                </TABLE>
            </TD>
        </TR>
        <TR>
            <TD WIDTH='100%' BGCOLOR='#003366' BACKGROUND-COLOR:'#003366' HEIGHT='25'>&nbsp;</TD>
        </TR>
    </TABLE>
    <div align="center"><img src="images/loudmouth_button.gif" width="150" height="54"></div>
</BODY>
</HTML>