<?php

######################################################################
# Modulo Splatt Forum per PHP-NUKE ver.5.X
#-------------------------
# Versione: 3.1
#
# Copyright (c) 2002 by:
#
# Giorgio Ciranni (~Splatt~)
# (http://www.splatt.it)
# (webmaster@splatt.it)
#
# Supporto tecnico disponibile sul Forum di www.splatt.it 
######################################################################
# PHP-NUKE Add-On 2.0 :
# =====================
#
#              PHPBB Integration 1.0.BETA
#        Brought to you by PHPNuke Add-On Team
#
# Copyright (c) 2000 by Richard Tirtadji AKA King Richard (rtirtadji@hotmail.com)
#                       Hutdik Hermawan AKA hotFix (hutdik76@hotmail.com)
# http://www.phpnuke.web.id
#
#
######################################################################
# PHPBB
#
# Copyright (C) 2000 by James Atkinson (james@totalgeek.org)
# http://www.phpbb.com
#
#
######################################################################
# 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;


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

$module_name = "$name";

include("config.php");
include("modules/$module_name/functions.php");
include("modules/$module_name/auth.php");
include("header.php");


	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."</b><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();
//setlocale("LC_TIME", $locale);
	//	echo "<center><b>"._TODAYIS." ".strftime(_WEEKDAYDATETIME)."<br> ";
		echo "..."._LASTVISIT.convertiData($userdata[lastvisit])."";
Closetable();
		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}_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 BGCOLOR=\"$bgcolor2\" ALIGN=\"LEFT\">";
        echo"<TD BGCOLOR=\"$bgcolor2\" ALIGN=\"CENTER\" VALIGN=\"MIDDLE\">&nbsp;</TD>";
        echo"<TD><FONT SIZE=\"1\" COLOR=\"$textcolor1\"><B>"._FORUM."</B></font></TD>";
        echo"<TD ALIGN=\"CENTER\"><FONT SIZE=\"1\" COLOR=\"$textcolor1\"><B>"._FTOPICS."</B></font></TD>";
        echo"<TD ALIGN=\"CENTER\"><FONT SIZE=\"1\" COLOR=\"$textcolor1\"><B>"._FPOSTS."</B></font></TD>";
        echo"<TD ALIGN=\"CENTER\"><FONT SIZE=\"1\" COLOR=\"$textcolor1\"><B>"._FLPOSTS."</B></font></TD>";
        echo"<TD ALIGN=\"CENTER\"><FONT SIZE=\"1\" COLOR=\"$textcolor1\"><B>"._FFMOD."</B></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, ".$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=\"TOP\"><TD COLSPAN=6 BGCOLOR=\"silver\"><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>";
                        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\" alt=\"Go!\"></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)) {

$ri = mysql_query("select user_avatar from ${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>";

                                        $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>
</TABLE></TD></TR>
</TABLE>
<TABLE ALIGN="CENTER" BORDER="0" WIDTH="95%"><TR><TD>
<font size="1"><?php echo _FNOTA; ?><br><br></a>
<FONT FACE="<?php echo $FontFace?>" SIZE=1 COLOR="<?php echo $textcolor2?>">
<b><?php echo _FLEGEN; ?>:</b><br><br>
<IMG SRC="images/forum/icons/status_del.gif"> = <?php echo _NPO; ?>
<BR><IMG SRC="images/forum/icons/status_del1.gif"> = <?php echo _NNPO; ?>
</FONT></TD></TR></TABLE>
<br>
<br>

<!-- 
<?php
$a = 1;

$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)) 

{
    $title2 = ereg_replace("_", " ", $topic_title);
	$title3 = substr("$title2", 0,35);
    $content1 .= "<strong><big>&middot;</big></strong>&nbsp;$a:&nbsp; <a href=\"modules.php?op=modload&name=$module_name&file=viewtopic&topic=$topic_id&forum=$forum_id \">$title2</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   ($topic_views)<br>";

$a++;
   
}
$contenuto = "<i><b><center>I 10 messaggi pił letti.</b></i></center><br> $content1<br>";
Opentable2();
echo"$contenuto";
Closetable();
?>
 -->




<!-- Don't touch the lines above please! --> 
<p align="center"><font size="1">Splatt Forum By: <a href="http://www.splatt.it">Splatt.it</a><br>Versione: 3.1</font></p>
<br>
<?php
$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");
?>