<?php
######################################################################
# Modulo Splatt Forum per PHP-NUKE ver.5.6
#-------------------------
# Versione: 3.2
#
# Copyright (c) 2002 by:
#
# Giorgio Ciranni (~Splatt~)
# (http://www.splatt.it)
# (webmaster@splatt.it)
#
# Supporto tecnico disponibile sul Forum di www.splatt.it 
######################################################################
# Splatt Forum is free software. You can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
# Splatt Forum is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
# 02111-1307  USA
######################################################################

$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

######################################################################
$avatarmod = 0; // set 1 if you want moderator avatar in index.page
######################################################################
$collapse = 1; //set 1 only if you have modified theme for this
######################################################################

if (!eregi("modules.php", $PHP_SELF)) {
	die ("Youn can't access this file directly...");
    }

$module_name = "$name";
include("config.php");
require_once("modules/$module_name/functions.php");
$pagetitle = " - Splatt Forum $forumver - >>Index<< -";
include("modules/$module_name/auth.php");
include("header.php");
include ("modules/Forums/class.overlib.php"); 
$ol = new Overlib();

	echo"<table width=\"100%\"><tr><td align=\"left\">"
		."<img src=\"images/forum/forumlogo11.gif\" width=\"168\" height=\"84\" alt=\"Forum\"></td>"
	    ."<td><center><b>"._BENV."$sitename</b><br><br>"
		.""._HEAD1."<br>"
		.""._HEAD2."<br><br>"
		.""._HEAD3."</center><br></td></tr></table>";


	if(!$result = mysql_query("SELECT * FROM ${prefix}_catagories ORDER BY cat_order"))
        die("<font size=+1>"._ERRORE1."</font><hr>"._UNABLETOQUERY."");

Opentable2();

echo "..."._LASTVISIT.convertiData($userdata[lastvisit])."";

Closetable2();

echo"<table align=\"center\" border=\"0\" cellpadding=\"0\" width=\"100%\"><tr><td align=\"center\">"
   ."<table align=\"center\" border=\"0\" cellpadding=\"0\" width=\"100%\" BGCOLOR=\"$bgcolor2\"><tr><td align=\"center\">";

$totale_topics = mysql_num_rows(mysql_query("SELECT * FROM ${prefix}_forumtopics"));

$totale_posts = mysql_num_rows(mysql_query("SELECT * FROM ${prefix}_posts"));

echo "<font size=1>"._FATTACT."</font><font color=\"green\"><b> $totale_topics</b></font><font size=\"1\"> "._DISCTOT."</font><font color=\"green\"><b> $totale_posts </b></font><font size=\"1\"> "._FPOSTS."</font>";

echo"</td></tr></table>"
    ."</td></tr></table>";

$risultato = mysql_query("select index_head from ${prefix}_forum_config");
	list($index_head) = mysql_fetch_row($risultato);
echo "<table width=\"100%\"><tr><td>";

Opentable();

$index_head = stripslashes($index_head);

echo "<center><i>$index_head</i></center>";

Closetable();

echo "</td></tr></table>";
echo"<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"0\" ALIGN=\"CENTER\" VALIGN=\"TOP\" WIDTH=\"100%\"><TR><TD>";
echo"<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\" WIDTH=\"100%\">";
echo"<TR>";
echo"<TD background=\"images/forum/cellpic3.gif\" ALIGN=\"LEFT\" VALIGN=\"MIDDLE\" colspan=\"2\" height=\"38\"><font color=\"#ffffff\">&nbsp;<B>"._FORUM."</B></font></TD>";
echo"<TD background=\"images/forum/cellpic3.gif\" ALIGN=\"CENTER\"><FONT COLOR=\"#ffffff\">&nbsp;<B>"._FTOPICS."</B>&nbsp;</font></TD>";
echo"<TD background=\"images/forum/cellpic3.gif\" ALIGN=\"CENTER\"><FONT SIZE=\"1\" COLOR=\"#ffffff\">&nbsp;<B>"._FPOSTS."</B>&nbsp;</font></TD>";
echo"<TD background=\"images/forum/cellpic3.gif\" ALIGN=\"CENTER\"><FONT SIZE=\"1\" COLOR=\"#ffffff\">&nbsp;<B>"._FLPOSTS."</B>&nbsp;</font></TD>";
echo"<TD background=\"images/forum/cellpic3.gif\" ALIGN=\"CENTER\"><FONT SIZE=\"1\" COLOR=\"#ffffff\">&nbsp;<B>"._FFMOD."</B>&nbsp;</font></TD></TR>";

$row = @mysql_fetch_array($result);

	do {

        $sub_sql = "SELECT f.*, u.uname, m.user_id, m.forum_id FROM ${prefix}_forums f, ".$user_prefix."_users u, ${prefix}_forum_mods m WHERE f.cat_id = '$row[cat_id]' AND m.forum_id = f.forum_id AND m.user_id = u.uid ORDER BY f.forum_id";
      
		if(!$sub_result = mysql_query($sub_sql, $db))
			die("<font size=+1>"._ERRORE1."</font><hr>"._UNABLETOQUERY."");

        if($myrow = mysql_fetch_array($sub_result)) {

        	$title = stripslashes($row[cat_title]);

            echo "<TR ALIGN=\"LEFT\" VALIGN=\"MIDDLE\"><TD background=\"images/forum/cellpic1.gif\" COLSPAN=6 height=\"25\"><FONT SIZE=2 COLOR=\"$textcolor2\">&nbsp;<B>$title</B></FONT></TD></TR>";

// Keledan
            $prevForum = ""; // variabile di controllo, memorizza il forum_id del ciclo precedente

                do {
// Keledan
                     if ($prevForum != $myrow[forum_id])  // fa il ciclo solo se
                     {
	                     $last_post = get_last_post($myrow[forum_id], $db, "forum");
	                     echo "<TR  ALIGN=\"LEFT\" VALIGN=\"TOP\">";
	                     $total_topics = get_total_topics($myrow[forum_id], $db);

                        if(($userdata["lastvisit"] < $last_post[post_time]) && $last_post[post_time] != "No posts") {

                                echo "<TD BGCOLOR=\"$bgcolor1\" ALIGN=\"CENTER\" VALIGN=\"TOP\" WIDTH=5%><IMG SRC=\"images/forum/icons/status_del.gif\"></TD>";

                        }

                        else {
                                echo "<TD BGCOLOR=\"$bgcolor1\" ALIGN=\"CENTER\" VALIGN=\"TOP\" WIDTH=5%><IMG SRC=\"images/forum/icons/status_del1.gif\"></TD>";
                        }

		if($myrow[forum_atch]==1)
						{
							$allegati = ""._FSI."";
						}
						else
							{
								$allegati =""._FNO."";
							}
$foname = stripslashes($myrow[forum_name]);

                        echo "<TD BGCOLOR=\"$bgcolor3\"><FONT SIZE=2 COLOR=\"$textcolor2\"><table width=\"100%\" bgcolor=\"$bgcolor2\"><tr><td><a href=\"modules.php?op=modload&name=$module_name&file=viewforum&forum=$myrow[forum_id]\">$foname </a></font></td></tr></table>\n";

                        $desc = stripslashes($myrow[forum_desc]);

                        echo "<br><FONT SIZE=1 COLOR=\"$textcolor2\">$desc</font><br>";
						echo"<a href=\"modules.php?op=modload&name=".$module_name."&file=newtopic&forum=$myrow[forum_id]\"><img src=\"images/forum/componi.gif\" border=\"0\" ";
$ol->pover(""._HSH1."",""._SFHS."");
						echo"></a>";

                        if ($myrow[forum_access]=="0" && $myrow[forum_type] == "0")
                        echo "<font color=\"FB9260\">["._FACCE.": <i>"._FFA."</i>";

                        if ($myrow[forum_access]=="1" && $myrow[forum_type] == "0")
                        echo "<font color=\"FB9260\">["._FACCE.": <i>"._FREG."</i>";

                        if ($myrow[forum_access]=="2" && $myrow[forum_type] == "0")
                        echo "<font color=\"FB9260\">["._FACCE.": <i>"._FMODS."</i>";

                        if ($myrow[forum_type] == "1")
                        echo "<font color=\"FB9260\">["._FACCE.": <i>"._PASSW."</i>";
						echo "]&nbsp;&nbsp;&nbsp;["._FORUMATCHM.": <i>$allegati</i>]</font></TD>\n";
                        echo "<TD BGCOLOR=\"$bgcolor3\" WIDTH=5% ALIGN=\"CENTER\" VALIGN=\"MIDDLE\"><FONT SIZE=1 COLOR=\"$textcolor2\">$total_topics</font></TD>\n";

                        $total_posts = get_total_posts($myrow[forum_id], $db, "forum");

                        echo "<TD BGCOLOR=\"$bgcolor1\" WIDTH=5% ALIGN=\"CENTER\" VALIGN=\"MIDDLE\"><FONT SIZE=1 COLOR=\"$textcolor2\">$total_posts</font></TD>\n";
                        echo "<TD BGCOLOR=\"$bgcolor3\" WIDTH=15% ALIGN=\"CENTER\" VALIGN=\"MIDDLE\"><FONT SIZE=1 COLOR=\"$textcolor2\">";

			if($last_post[post_time]==""){
				echo""._NONEPOST."";
			}
			else{
					echo"".convertiData($last_post[post_time])." "._BY." <a href=\"modules.php?name=Your_Account&op=userinfo&uname=$last_post[user]\">$last_post[user]</a></font><br><br><a href=\"modules.php?op=modload&name=".$module_name."&file=viewtopic&topic=$last_post[topic_id]&forum=$myrow[forum_id]\"><img src=\"images/forum/icons/icon_ultima.gif\" border=\"0\"";
$ol->pover(""._HSH2."",""._SFHS."");
					echo"></a>";
					echo"</TD>\n";
		}

                        $forum_moderator = $myrow[uname];
                        $moderators = get_moderators($myrow[forum_id], $db);

                        echo "<TD BGCOLOR=\"$bgcolor1\" WIDTH=5% ALIGN=\"CENTER\" VALIGN=\"MIDDLE\"><FONT SIZE=\"1\" COLOR=\"$textcolor2\">";

                        $count = 0;
                        reset ($moderators);
                        while(list($null, $mods) = each($moderators)) {
                                while(list($mod_id, $mod_name) = each($mods)) {
						if($avatarmod== 1){
							$ri = mysql_query("select user_avatar from ${user_prefix}_users where uname = '$mod_name'");

							list($modicon) = mysql_fetch_row($ri);                                      
                                        echo "<BR><a href=\"modules.php?name=Your_Account&op=userinfo&uname=$mod_name\"><IMG SRC=\"images/forum/avatar/$modicon\" BORDER=\"0\" alt=\"$mod_name\"></a><br>";

	}
	else {
		echo "$mod_name<BR><a href=\"modules.php?name=Your_Account&op=userinfo&uname=$mod_name\"><IMG SRC=\"images/forum/subject/icon35.gif\" BORDER=\"0\"></a><br>";

	}
                                   
                                   $count++;
				
                            }
                    }

                        echo "</font></TD></TR>\n";

//                      Keledan
                        $prevForum = $myrow[forum_id];
}
                } while($myrow = mysql_fetch_array($sub_result));
        }
} while($row = mysql_fetch_array($result));

?>

</TD></TR>
<TR ALIGN="RIGHT" >
<TD COLSPAN=6 BGCOLOR="<?php echo $bgcolor2?>" ><font color="<?php echo $textcolor1;?>"><b><?php bbsearchblock()?></b></font></TD></TR>

<?php 

	if($totale_topics != 0){
		$mediarisposte = $totale_posts / $totale_topics;
	}
	else
	{
		$mediarisposte="(dato attualmente non disponibile)";
}

echo"<TR><TD COLSPAN=6 BGCOLOR=\"$bgcolor2\">";

Opentable();

?>

<font color="<?php echo $textcolor1;?>"><b>&nbsp;<?php echo _FLEGEN; ?>:</b><br>&nbsp;<IMG SRC="images/forum/icons/status_del.gif"> = <?php echo _NPO; ?><BR>&nbsp;<IMG SRC="images/forum/icons/status_del1.gif"> = <?php echo _NNPO; ?><br><br>&nbsp;
<?php
echo""._FNOTA." </td></tr>"; 

Closetable();

Opentable();

echo"<tr><TD background=\"images/forum/cellpic1.gif\" height=\"25\">";

echo"<center>--- "._FMEDRI."&nbsp;&nbsp;<b> $mediarisposte </b>&nbsp;&nbsp;  "._FRISPS." ---</center></font></TD></tr>";

Closetable();

echo"</font></center><TD></TR>"
	."</TABLE></TD></TR></TABLE>"
	."<TABLE bgcolor=\"$bgcolor1\" ALIGN=\"CENTER\" BORDER=\"0\" WIDTH=\"100%\">";

$result = mysql_query("SELECT   t1.topic_id,t1.topic_title,t1.topic_time, t1.topic_views,t1.forum_id  FROM ${prefix}_forums t0,${prefix}_forumtopics t1   WHERE t0.forum_type = 0  AND t0.forum_id = t1.forum_id     ORDER BY t1.topic_views  DESC  LIMIT 0, 10");

while(list($topic_id, $topic_title, $topic_time, $topic_views, $forum_id) = mysql_fetch_row($result)) 

{

$res = mysql_query("select image from ".$prefix."_posts where topic_id='$topic_id'");

 list ($image) = mysql_fetch_row($res);

	if($image == "")
	{
		$image= "icon33.gif";
	}

$title2 = ereg_replace("_", " ", $topic_title);
$title3 = substr("$title2", 0,35);

$content1 .= "<table><tr><td width=\"20\"><img src=\"images/forum/subject/$image\" alt=\"$title2 - $topic_time\"></td><td><a href=\"modules.php?op=modload&name=$module_name&file=viewtopic&topic=$topic_id&forum=$forum_id \">$title2</a>&nbsp;   ($topic_views)</td></tr></table>";

}

$result = mysql_query("SELECT   t1.topic_id,t1.topic_title,t1.topic_time,t1.forum_id  FROM ${prefix}_forums t0,${prefix}_forumtopics t1   WHERE t0.forum_type = 0  AND t0.forum_id = t1.forum_id     ORDER BY t1.topic_time  DESC  LIMIT 0, 10");

while(list($topic_id, $topic_title, $topic_time, $forum_id) = mysql_fetch_row($result)) 

{

$res = mysql_query("select image from ".$prefix."_posts where topic_id='$topic_id'");

    list ($image) = mysql_fetch_row($res);

	if($image == "")
	{
		$image= "icon33.gif";
	}

$title2 = ereg_replace("_", " ", $topic_title);
$title2 = stripslashes($title2);
$title3 = substr("$title2", 0,40);

$content2 .= "<table><tr><td width=\"30\"><img src=\"images/forum/subject/$image\" alt=\"$title2 - $topic_time\"></td><td><a href=\"modules.php?op=modload&amp;name=".$module_name."&amp;file=viewtopic&amp;topic=$topic_id&amp;forum=$forum_id \">  $title3</a></td></tr></table>";
 
}

echo"<TR ALIGN=\"CENTER\" >"
    ."<TD height=\"5\" COLSPAN=6 BGCOLOR=\"$bgcolor2\"><TD></TR>"
	."<tr><td height=\"38\" background=\"images/forum/cellpic3.gif\" valign=\"middle\" width=\"40%\" align=\"left\">&nbsp;<img src=\"images/forum/question.gif\"";

$ol->pover(""._HSH5."",""._SFHS."");

echo">&nbsp;&nbsp;<font color=\"white\">&nbsp;&nbsp;<b>"._FMPIUL."</b></font></td>"
	."<td  colspan=\"3\" width=\"20%\" align=\"left\"></td>"
	."<td height=\"38\" background=\"images/forum/cellpic3.gif\" valign=\"middle\" width=\"40%\" align=\"left\">&nbsp;<img src=\"images/forum/question.gif\"";

$ol->pover(""._HSH6."",""._SFHS."");

echo">&nbsp;&nbsp;<font color=\"white\">&nbsp;&nbsp;<b>"._FULTM."</b></font></td></tr>";
echo"<TR ALIGN=\"CENTER\" >"
    ."<TD height=\"5\" COLSPAN=6 BGCOLOR=\"$bgcolor2\"></TD></TR>"
	."<tr><td background=\"images/forum/cellpic1.gif\" valign=\"top\" width=\"40%\" align=\"left\" height=\"25\">$content1</td>"
	."<td  colspan=\"3\" width=\"20%\" align=\"left\"></td>"
	."<td background=\"images/forum/cellpic1.gif\" valign=\"top\" width=\"40%\" align=\"left\" height=\"25\">$content2</td></tr>"
	."<TR ALIGN=\"CENTER\" >"
    ."<TD height=\"5\" COLSPAN=6 BGCOLOR=\"$bgcolor2\"></TD></TR>"
	."<TR><TD background=\"images/forum/cellpic1.gif\" COLSPAN=\"6\">";

	if($collapse == 1){

		if($index == 2){

			echo"<center><font color=\"white\"><a href=\"modules.php?op=modload&amp;name=".$module_name."&amp;file=index&amp;indexut=0\"";
$ol->pover(""._HSH4."",""._SFHS."");
echo">"._FVISBS."</a></font></center></TR></TD>";

		}
	else 
		{
			echo"<center><font color=\"white\"><a href=\"modules.php?op=modload&amp;name=".$module_name."&amp;file=index&amp;indexut=2\"";
$ol->pover(""._HSH3."",""._SFHS."");
echo">"._FNASCBS."</a></font></center></TR></TD>";

		}
}

echo"<TR ALIGN=\"CENTER\" >"
    ."<TD height=\"5\" COLSPAN=6 BGCOLOR=\"$bgcolor2\"></TD></TR></TABLE>";


	if(is_admin($admin))
	{
		echo"<br>";
Opentable2();
		echo"<center><i>Ciao Admin!</i></center><br><img src =\"images/forum/subject/icon4.gif\">&nbsp; -- <a href=\"admin.php?op=SplattForumConfig\">Forum Admin Page</a> -- &nbsp<img src =\"images/forum/subject/icon4.gif\">";
Closetable2();
	}

//<!-- Don't touch the lines below please! --> 

echo"<p align=\"center\">Splatt Forum &copy; By: <a href=\"http://www.splatt.it\" target=\"_blank\">Splatt.it</a><br>Version: $forumver</font></p><br><br>";


$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
printf("<center><font size=-2>Elaboration time:  %f  seconds.</font></center><br>", $totaltime);

include("footer.php");

?>