<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System .                                 */
/* ===========================                                          */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2004 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 $pdst; $pdst="1";

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=mysql_query("select email from lnl_outside_users");
    if ($result) {$totalnl = mysql_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=\"ONGL\">".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=\"ONGL\">".translate("Download Stats")."</td></tr>";
    $num_dow=0;
    $result = mysql_query("SELECT dcounter, dfilename FROM downloads");
    while(list($dcounter, $dfilename) = mysql_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 = mysql_query("SELECT * FROM catagories ORDER BY cat_id");
    $row = @mysql_fetch_array($result);
    $num_for=0;
    do {
       $sub_sql = "SELECT f.*, u.uname FROM forums f, users u WHERE f.cat_id = '$row[cat_id]' AND f.forum_moderator = u.uid ORDER BY forum_index,forum_id";
       if (!$sub_result = mysql_query($sub_sql))
          forumerror('0022');
       if ($myrow = mysql_fetch_array($sub_result)) {
          $title = stripslashes($row[cat_title]);
          echo "<tr align=\"left\" valign=\"top\"><td colspan=\"7\"><b>$title</b></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 = mysql_fetch_array($sub_result));
       }
    } while($row = mysql_fetch_array($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");
}
?>