<?PHP
/************************************************************************/
/* DUNE by NPDS                                                         */
/* ===========================                                          */
/*                                                                      */
/* Based on PhpNuke 4.x source code                                     */
/*                                                                      */
/* NPDS Copyright (c) 2002-2007 by Philippe Brunier                     */
/*                                                                      */
/* This program 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.       */
/************************************************************************/
if (!function_exists("Mysql_Connexion")) {
   include ("mainfile.php");
}
include("functions.php");
include("auth.php");

global $admin;
if ($admin) {
    include ("header.php");
    opentable();

    global $startdate;
    list($membres,$totala,$totalb,$totalc,$totald,$totalz)=req_stat();
    //LNL Email in outside table
    $result=sql_query("select email from ".$NPDS_Prefix."lnl_outside_users");
    if ($result) {$totalnl = sql_num_rows($result);} else {$totalnl = "0";}
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo translate("Administration BlackBoard");
    echo "&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"admin.php\" class=\"heada\">".translate("Administration Tools")."</a>";
    echo "</td></tr></table>\n";
    echo "<br />\n";
    include("abla.log.php");
    $timex=time()-$xdate;
    if ($timex>=3600) {
       $timex=round($timex/3600)." ".translate("Hour(s)");
    } elseif ($timex>=60) {
       $timex=round($timex/60)." ".translate("Minut(s)");
    } else {
       $timex=$timex." ".translate("Second(s)");
    }
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td colspan=\"2\" class=\"header\">".translate("General Stats")." - ".translate("Past Stat")." : $timex </td></tr>";
    echo "<tr class=\"ligna\"><td width=\"70%\">".translate("Nb of Pages")." : </td><td><span class=\"rouge\">$xtotalz</span> - $totalz</td></tr>";
    echo "<tr class=\"lignb\"><td width=\"70%\">".translate("Nb of members")." : </td><td><span class=\"rouge\">$xmembres</span> - $membres</td></tr>";
    echo "<tr class=\"ligna\"><td width=\"70%\">".translate("Nb of articles")." : </td><td><span class=\"rouge\">$xtotala</span> - $totala</td></tr>";
    echo "<tr class=\"lignb\"><td width=\"70%\">".translate("Nb of forums")." : </td><td><span class=\"rouge\">$xtotalc</span> - $totalc</td></tr>";
    echo "<tr class=\"ligna\"><td width=\"70%\">".translate("Nb of topics")." : </td><td><span class=\"rouge\">$xtotald</span> - $totald</td></tr>";
    echo "<tr class=\"lignb\"><td width=\"70%\">".translate("Nb of reviews")." : </td><td><span class=\"rouge\">$xtotalb</span> - $totalb</td></tr>";
    echo "<tr class=\"ligna\"><td width=\"70%\">".translate("Nb Outside Users for LNL")." : </td><td><span class=\"rouge\">$xtotalnl</span> - $totalnl</td></tr>";
    $xfile="<?PHP\n";
    $xfile.="\$xdate = ".time().";\n";
    $xfile.="\$xtotalz = $totalz;\n";
    $xfile.="\$xmembres = $membres;\n";
    $xfile.="\$xtotala = $totala;\n";
    $xfile.="\$xtotalc = $totalc;\n";
    $xfile.="\$xtotald = $totald;\n";
    $xfile.="\$xtotalb = $totalb;\n";
    $xfile.="\$xtotalnl = $totalnl;\n";
    echo "</table><br />\n";

    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td colspan=\"2\" class=\"header\">".translate("Download Stats")."</td></tr>";
    $num_dow=0;
    $result = sql_query("SELECT dcounter, dfilename FROM ".$NPDS_Prefix."downloads");
    while(list($dcounter, $dfilename) = sql_fetch_row($result)) {
       $rowcolor = tablos();
       $num_dow++;
       echo "<tr $rowcolor><td width=\"70%\"><span class=\"rouge\">".$xdownload[$num_dow][1]."</span> -/- $dfilename : </td><td><span class=\"rouge\">".$xdownload[$num_dow][2]."</span> -/- $dcounter</td></tr>";
       $xfile.="\$xdownload[$num_dow][1] = \"$dfilename\";\n";
       $xfile.="\$xdownload[$num_dow][2] = \"$dcounter\";\n";
    }
    echo "</table><br />\n";

    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\">";
    echo "<tr>";
    echo "<td class=\"header\">&nbsp;</td>";
    echo "<td class=\"header\">".translate("Forum")."</td>";
    echo "<td class=\"header\" align=\"center\">".translate("Topics")."</td>";
    echo "<td class=\"header\" align=\"center\">".translate("Posts")."</td>";
    echo "<td class=\"header\" align=\"center\">".translate("Last Posts")."</td></tr>";

    $result = sql_query("SELECT * FROM ".$NPDS_Prefix."catagories ORDER BY cat_id");
    $num_for=0;
    while (list($cat_id, $cat_title) = sql_fetch_row($result)) {
       $sub_sql = "SELECT f.*, u.uname FROM ".$NPDS_Prefix."forums f, ".$NPDS_Prefix."users u WHERE f.cat_id = '$cat_id' AND f.forum_moderator = u.uid ORDER BY forum_index,forum_id";
       if (!$sub_result = sql_query($sub_sql))
          forumerror('0022');
       if ($myrow = sql_fetch_assoc($sub_result)) {
          echo "<tr align=\"left\" valign=\"top\"><td colspan=\"7\">".stripslashes($cat_title)."</td></tr>";
          do {
             $num_for++;
             $last_post = get_last_post($myrow[forum_id], "forum", "infos",true);
             echo "<tr align=\"left\" valign=\"top\">";
             $total_topics = get_total_topics($myrow[forum_id]);
             echo "<td align=\"center\" valign=\"middle\" width=\"5%\"><img src=\"";
             if ($ibid=theme_image("forum/icons/folder.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/forum/icons/folder.gif";}
             echo "$imgtmp\" border=\"\" alt=\"\" /></td>";
             $name = stripslashes($myrow[forum_name]);
             $xfile.="\$xforum[$num_for][1] = \"$name\";\n";
             $xfile.="\$xforum[$num_for][2] = $total_topics;\n";
             echo "<td width=\"30%\"><a href=\"viewforum.php?forum=$myrow[forum_id]\" class=\"noir\"><span class=\"rouge\">".$xforum[$num_for][1]."</span> -/- $name </a>\n";
             $desc = stripslashes($myrow[forum_desc]);
             echo "<br />$desc</td>\n";
             echo "<td align=\"center\" valign=\"middle\" width=\"30%\"><span class=\"rouge\">".$xforum[$num_for][2]."</span> -/- $total_topics</td>\n";
             $total_posts = get_total_posts($myrow[forum_id], "", "forum",false);
             $xfile.="\$xforum[$num_for][3] = $total_posts;\n";
             echo "<td align=\"center\" valign=\"middle\" width=\"15%\"><span class=\"rouge\">".$xforum[$num_for][3]."</span> -/- $total_posts</td>\n";

             echo "<td align=\"center\" valign=\"middle\" width=\"15%\">$last_post</td>\n";
          } while($myrow = sql_fetch_assoc($sub_result));
       }
    }
    echo "</tr></table>";

    $file = fopen("abla.log.php", "w");
    $xfile.="\$memo=\"$memo\";\n";
    $xfile.="?>\n";
    fwrite($file, $xfile);
    fclose($file);

    closetable();
    include ("footer.php");
} else {
    redirect_url("index.php");
}
?>