<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System .                                 */
/* ===========================                                          */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2005 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.       */
/************************************************************************/
/*
   Script for NPDS by Alexandre Pirard
   alexandre@pascalex.net / www.pascalex.net 
*/
if (!function_exists("Mysql_Connexion")) {include ("mainfile.php");}

function mapsections() {
    $result=mysql_query("select rubid, rubname from rubriques where enligne='1' and rubname<>'Divers' and rubname<>'Presse-papiers' order by ordre");
    echo "<h3>",translate("Sections"),"</h3>";
    if (mysql_num_rows($result) > 0) {
       while (list($rubid, $rubname) = mysql_fetch_array($result)) {
          if ($rubname!="")
             echo "<ul><li><h4>".aff_langue($rubname)."</h4>";
          $result2 = mysql_query("SELECT secid, secname, image, userlevel, intro FROM sections WHERE rubid='$rubid' and (userlevel='0' or userlevel='') order by ordre");
          if (mysql_num_rows($result2) > 0) {
             while (list($secid, $secname, $userlevel) = mysql_fetch_row($result2)) {
                if (autorisation($userlevel)) {
                   echo "<ul><li>",aff_langue($secname);
                   $result3 = mysql_query("select artid, title from seccont where secid='$secid'");
                   while (list($artid, $title) = mysql_fetch_row($result3)) {
                      echo "<ul><li><a href=\"sections.php?op=viewarticle&amp;artid=$artid\" class=\"NOIR\">", aff_langue($title),"</a></li></ul>\n";
                   }
                   echo "</li></ul><br />";
                }
             }
          }
          echo "</li></ul>\n";
       }
    }
    @mysql_free_result($result);
    @mysql_free_result($result2);
    @mysql_free_result($result3);
}

function mapforum() {
    echo "<h3>",translate("Forums!"),"</h3><ul>";
    echo RecentForumPosts_fab("", 10, 0, false, 50, false, "<li>", false);
    echo "</ul><br />\n";
}

function maptopics() {
    echo "<h3>",translate("Topics"),"</h3><ul>";
    $result = mysql_query("select topicid, topictext from topics order by topicname");
    while (list($topicid, $topictext) = mysql_fetch_row($result)) {
       $result2 = mysql_query("select sid from stories where topic='$topicid'");
       $nb_article = mysql_num_rows($result2);
       echo "<li><a href=\"search.php?query=&amp;topic=$topicid\">",aff_langue($topictext),"</a>&nbsp;(",$nb_article,")</li>\n";
    }
    echo "</ul><br />\n";
    @mysql_free_result($result);
    @mysql_free_result($result2);
}

// Proposé par Jireck
function mapcategories() {
    echo "<h3>",translate("Categories"),"</h3><ul>";
    $result = mysql_query("SELECT catid, title FROM stories_cat ORDER BY title");
    while (list($catid, $title) = mysql_fetch_row($result)) {
       $result2 = mysql_query("select sid from stories where catid='$catid'");
       $nb_article = mysql_num_rows($result2);
       echo "<li><a href=\"index.php?op=newindex&amp;catid=$catid\">",aff_langue($title),"</a> (",$nb_article,") </li>\n";
    }
    echo "</ul><br />\n";
    @mysql_free_result($result);
    @mysql_free_result($result2);
}

function mapfaq() {
    echo "<h3>",translate("FAQ (Frequently Ask Question)"),"</h3><ul>";
    $result = mysql_query("select id_cat, categories from faqcategories ORDER BY id_cat ASC");
    while (list($id_cat, $categories) = mysql_fetch_row($result)) {
       $catname = aff_langue($categories);
       echo "<li><a href=\"faq.php?id_cat=$id_cat&amp;myfaq=yes&amp;categories=",urlencode($catname),"\">",$catname,"</a></li>\n";
    }
    echo "</ul><br />\n";
    @mysql_free_result($result);
}

include ('header.php');
// Include cache manager classe
global $SuperCache;
if ($SuperCache) {
    $cache_obj = new cacheManager();
    $CACHE_TIMINGS['map.php'] = 3600;
    $CACHE_QUERYS['map.php'] = "^";
    $cache_obj->startCachingPage();
}
if (($cache_obj->genereting_output==1) or ($cache_obj->genereting_output==-1) or (!$SuperCache)) {
    OpenTable();
    echo "<h2><span>".translate("Site map")."</span></h2>";

    // Vous pouvez enlever certaines parties en mettant // devant les lignes ci-dessous
    mapsections();
    mapforum();
    maptopics();
    mapcategories();
    mapfaq();

    if (file_exists("modules/include/user.inc")) {
       opentable();
       include ("modules/include/user.inc");
       closetable();
    }

    CloseTable();
}
if ($SuperCache) {
   $cache_obj->endCachingPage();
}
include "footer.php";
?>