<?PHP
/************************************************************************/
/* DUNE by NPDS                                                         */
/* ===========================                                          */
/*                                                                      */
/* Based on PhpNuke 4.x source code                                     */
/* Based on Parts of phpBB                                              */
/*                                                                      */
/* Major changes from ALAT 2004-2005                                    */
/* NPDS Copyright (c) 2002-2008 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.       */
/************************************************************************/
function Access_Error() {
  include("admin/die.php");
}

if (!strstr($PHP_SELF,"admin.php")) { Access_Error(); }

global $language;
$hlpfile = "manuels/$language/forumcat.html";
$result = sql_query("select radminforum, radminsuper from ".$NPDS_Prefix."authors where aid='$aid'");
list($radminforum, $radminsuper) = sql_fetch_row($result);
if (($radminforum!=1) and ($radminsuper!=1)) {
   Access_Error();
} else {
   include ("auth.php");
   include ("functions.php");
}

function ForumAdmin() {
    global $hlpfile;
    global $NPDS_Prefix;

    include ("header.php");
    GraphicAdmin($hlpfile);
    opentable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo adm_translate("Catégories de Forum");
    echo "</td></tr></table><br />\n";
    echo "<form action=\"admin.php\" method=\"post\">
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr>\n
    <td class=\"ongl\" align=\"left\">".adm_translate("Index")."</td>
    <td class=\"ongl\" align=\"left\">".adm_translate("Catégories")."</td>
    <td class=\"ongl\" align=\"center\">".adm_translate("Nombre de Forum(s)")."</td>
    <td class=\"ongl\" align=\"center\">".adm_translate("Fonctions")."</td></tr>";
    $result = sql_query("select cat_id, cat_title from ".$NPDS_Prefix."catagories order by cat_id");
    while (list($cat_id, $cat_title) = sql_fetch_row($result)) {
       $gets = sql_query("select count(*) as total from ".$NPDS_Prefix."forums where cat_id='$cat_id'");
       $numbers= sql_fetch_assoc($gets);
       $rowcolor = tablos();
       echo "<tr $rowcolor><td align=\"left\">$cat_id</td>
       <td align=\"left\">".StripSlashes($cat_title)."</td>
       <td align=\"center\">$numbers[total]</td>
       <td align=\"right\">[ <a href=\"admin.php?op=ForumGo&amp;cat_id=$cat_id\" class=\"noir\">".adm_translate("Editer les forums")."</a> | <a href=\"admin.php?op=ForumCatEdit&amp;cat_id=$cat_id\" class=\"noir\">".adm_translate("Editer")."</a> | <a href=\"admin.php?op=ForumCatDel&amp;cat_id=$cat_id&amp;ok=0\" class=\"rouge\">".adm_translate("Effacer")."</a> ]</td><tr>";
    }
    echo "</table></form><br />";
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo adm_translate("Ajouter des Catégories");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">
    ".adm_translate("Catégories :")." <input class=\"textbox_standard\" type=\"text\" name=\"catagories\" size=\"31\"> -
    <input type=\"hidden\" name=\"op\" value=\"ForumCatAdd\">
    <input class=\"bouton_standard\" type=\"submit\" value=".adm_translate("Ajouter").">
    </form>";
    closetable();
    include("footer.php");
}

function ForumGo($cat_id) {
    global $hlpfile;
    global $NPDS_Prefix;

    include ("header.php");
    GraphicAdmin($hlpfile);
    opentable();
    $result = sql_query("select cat_title from ".$NPDS_Prefix."catagories where cat_id='$cat_id'");
    list($cat_title) = sql_fetch_row($result);
    $ctg=StripSlashes($cat_title);
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo adm_translate("Forum classé en")." $ctg";
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr>\n
    <td class=\"ongl\">".adm_translate("Index")."</td>
    <td class=\"ongl\">".adm_translate("Nom du forum")."</td>
    <td class=\"ongl\" align=\"center\">".adm_translate("Modérateur(s)")."</td>
    <td class=\"ongl\" align=\"center\">".adm_translate("Accès")."</td>
    <td class=\"ongl\" align=\"center\">".adm_translate("Type")."</td>
    <td class=\"ongl\" align=\"center\">".adm_translate("Mode")."</td>
    <td class=\"ongl\" align=\"center\">".adm_translate("Attachement")."</td>
    <td class=\"ongl\" align=\"center\">".adm_translate("Fonctions")."</td></tr>";
    $result = sql_query("select forum_id, forum_name, forum_access, forum_moderator, forum_type, arbre, attachement, forum_index from ".$NPDS_Prefix."forums where cat_id='$cat_id' order by forum_index,forum_id");
    while(list($forum_id, $forum_name, $forum_access, $forum_moderator, $forum_type, $arbre, $attachement, $forum_index) = sql_fetch_row($result)) {
        $moderator=str_replace(" ",", ",get_moderator($forum_moderator));
        $rowcolor = tablos();
        echo "<tr $rowcolor>
        <td>$forum_index</td>
        <td>$forum_name</td>
        <td align=\"center\" style=\"font-size: 10px;\">$moderator</td>";
        switch($forum_access) {
        case (0):
           echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Publication Anonyme autorisée")."</td>";
           break;
        case (1):
           echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Utilisateur enregistré")."</td>";
           break;
        case (2):
           echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Modérateurs")."</td>";
           break;
        case (9):
           echo "<td align=\"center\" style=\"font-size: 10px;\">Forum ".adm_translate("Fermé")."</td>";
           break;
        }
        if ($forum_type==0) {
        echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Public")."</td>";
        } elseif ($forum_type==1) {
        echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Privé")."</td>";
        } elseif ($forum_type==5) {
        echo "<td align=\"center\" style=\"font-size: 10px;\">PHP + ".adm_translate("Groupe")."</td>";
        } elseif ($forum_type==6) {
        echo "<td align=\"center\" style=\"font-size: 10px;\">PHP</td>";
        } elseif ($forum_type==7) {
        echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Groupe")."</td>";
        } elseif ($forum_type==8) {
        echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Texte étendu")."</td>";
        } else {
        echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Caché")."</td>";
        }

        if ($arbre)
           echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Arbre")."</td>";
        else
           echo "<td align=\"center\" style=\"font-size: 10px;\">".adm_translate("Standard")."</td>";

        if ($attachement)
           echo "<td align=\"center\" style=\"font-size: 10px;\" class=\"rouge\">".adm_translate("Oui")."</td>";
        else
           echo "<td align=\"center\" style=\"font-size: 10px;\"".adm_translate("Non")."</td>";

        echo "<td align=\"center\" nowrap=\"nowrap\"><a href=\"admin.php?op=ForumGoEdit&amp;forum_id=$forum_id&amp;ctg=".urlencode($ctg)."\" class=\"noir\">".adm_translate("Editer")."</a> | <a href=\"admin.php?op=ForumGoDel&amp;forum_id=$forum_id&amp;ok=0\" class=\"rouge\">".adm_translate("Effacer")."</a></td></tr>";
    }
    echo "</table></form><br />";
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo adm_translate("Ajouter plus de Forum pour")." $ctg";
    echo "</td></tr></table>\n";

    echo "<form action=\"admin.php\" method=\"post\">
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">
    <tr><td>".adm_translate("Index")." :</td><td><input class=\"textbox_standard\" type=\"text\" name=\"forum_index\" size=\"5\" maxlength=\"4\"></td></tr>
    <tr><td>".adm_translate("Nom du forum")." :</td><td><input class=\"textbox\" type=\"text\" name=\"forum_name\" size=\"31\"><br />".adm_translate("(Redirection sur un forum externe : <.a href...)")."</td></tr>
    <tr><td>".adm_translate("Description")." :</td><td><textarea class=\"textbox\" name=\"forum_desc\" cols=\"40\" rows=\"5\"></textarea></td></tr>
    <tr><td> ".adm_translate("Modérateur(s)")." :</td>
    <td><input class=\"textbox\" type=\"text\" name=\"forum_mod\" size=\"40\">
    </td></tr>";
    echo "<tr><td>".adm_translate("Niveau d'accès")." :</td>
    <td><select class=\"textbox_standard\" name=\"forum_access\">
        <option value=\"0\">".adm_translate("Publication Anonyme autorisée")."</option>
        <option value=\"1\">".adm_translate("Utilisateur enregistré uniquement")."</option>
        <option value=\"2\">".adm_translate("Modérateurs uniquement")."</option>
        <option value=\"9\">".adm_translate("Fermé")."</option>
        </select>
    </td></tr>
    <tr><td>".adm_translate("Type :")." </td>
    <td><select class=\"textbox_standard\" name=\"forum_type\">
        <option value=\"0\">".adm_translate("Public")."</option>
        <option value=\"1\">".adm_translate("Privé")."</option>
        <option value=\"5\">PHP Script + ".adm_translate("Groupe")."</option>
        <option value=\"6\">PHP Script</option>
        <option value=\"7\">".adm_translate("Groupe")."</option>
        <option value=\"8\">".adm_translate("Texte étendu")."</option>
        <option value=\"9\">".adm_translate("Caché")."</option>
        </select>
    </td></tr>
    <tr><td>".adm_translate("Mode")." :</td>
    <td><select class=\"textbox_standard\" name=\"arbre\">
        <option value=\"0\">".adm_translate("Standard")."</option>
        <option value=\"1\">".adm_translate("Arbre")."</option>
        </select>
    </td></tr>
    <tr><td>".adm_translate("Attachement")." :</td>
    <td><select class=\"textbox_standard\" name=\"attachement\">
        <option value=\"0\">".adm_translate("Non")."</option>
        <option value=\"1\">".adm_translate("Oui")."</option>
        </select>
    </td></tr>
    <tr><td colspan=\"2\"><hr width=\"100%\" noshade class=\"ongl\"></td></tr>
    <tr><td nowrap=\"nowrap\">".adm_translate("- Mot de Passe (si Privé)<br />- Le nom du fichier de formulaire (si Texte étendu)<br /><span style=\"font-size: 10px;\">&nbsp;&nbsp;=> modules/sform/forum</span><br />- Les Groupes ID (si Groupe)")."</td><td><input class=\"textbox\" type=\"text\" name=\"forum_pass\" size=\"31\"></td></tr>
    </table><br />
    <input type=\"hidden\" name=\"ctg\" value=\"$ctg\">
    <input type=\"hidden\" name=\"cat_id\" value=\"$cat_id\">
    <input type=\"hidden\" name=\"op\" value=\"ForumGoAdd\">
    <input class=\"bouton_standard\" type=\"submit\" value=".adm_translate("Ajouter").">
    </form>";
    closetable();
    include("footer.php");
}

function ForumGoEdit($forum_id, $ctg) {
    global $hlpfile;
    global $NPDS_Prefix;

    include ("header.php");
    GraphicAdmin($hlpfile);
    $result = sql_query("select forum_id, forum_name, forum_desc, forum_access, forum_moderator, cat_id, forum_type, forum_pass, arbre, attachement, forum_index from ".$NPDS_Prefix."forums where forum_id='$forum_id'");
    list($forum_id, $forum_name, $forum_desc, $forum_access, $forum_mod, $cat_id_1, $forum_type, $forum_pass, $arbre, $attachement, $forum_index) = sql_fetch_row($result);
    opentable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo adm_translate("Editer")." : $forum_name";
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">
    <input type=\"hidden\" name=\"forum_id\" value=\"$forum_id\">
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr>\n<td>
    <tr><td>".adm_translate("Index")." :</td><td><input class=\"textbox_standard\" type=\"text\" name=\"forum_index\" size=\"5\" maxlength=\"4\" value=\"$forum_index\"></td></tr>
    <tr><td>".adm_translate("Nom du forum")." :</td><td><input class=\"textbox\" type=\"text\" name=\"forum_name\" size=\"30\" value=\"$forum_name\"><br /><span style=\"font-size: 10px;\">".adm_translate("(Redirection sur un forum externe : <.a href...)")."</span></td></tr>
    <tr><td>".adm_translate("Description")." :</td><td><textarea class=\"textbox\" name=\"forum_desc\" cols=\"40\" rows=\"5\">$forum_desc</textarea></td></tr>
    <tr><td> ".adm_translate("Modérateur(s)")." :</td>";
    $moderator=str_replace(" ",",",get_moderator($forum_mod));
    echo "<td><input class=\"textbox\" type=\"text\" name=\"forum_mod\" value=\"$moderator\" size=\"40\">";
    echo "</td><tr>
    <tr><td>".adm_translate("Niveau d'accès")." :</td>
    <td><select class=\"textbox_standard\" name=\"forum_access\">";
    if ($forum_access == 0) { $sel0=" selected"; }
    if ($forum_access == 1) { $sel1=" selected"; }
    if ($forum_access == 2) { $sel2=" selected"; }
    if ($forum_access == 9) { $sel9=" selected"; }
    echo"<option value=\"0\"$sel0>".adm_translate("Publication Anonyme autorisée")."</option>
        <option value=\"1\"$sel1>".adm_translate("Utilisateur enregistré uniquement")."</option>
        <option value=\"2\"$sel2>".adm_translate("Modérateurs uniquement")."</option>
        <option value=\"9\"$sel9>".adm_translate("Fermé")."</option>
        </select>
    </td></tr>
    <tr><td>".adm_translate("Changer les Catégories : ")." </td>
    <td><select class=\"textbox_standard\" name=\"cat_id\">";
    $result = sql_query("select cat_id, cat_title from ".$NPDS_Prefix."catagories");
    while(list($cat_id, $cat_title) = sql_fetch_row($result)) {
        if ($cat_id == $cat_id_1) {
           echo "<option value=\"$cat_id\" selected>".StripSlashes($cat_title)."</option>";
        } else {
           echo "<option value=\"$cat_id\">".StripSlashes($cat_title)."</option>";
        }
    }
    echo "</select>
    </td></tr>
    <tr><td>".adm_translate("Type :")." </td>
    <td><select class=\"textbox_standard\" name=\"forum_type\">";
    if ($forum_type == 0) $sel0=" selected"; else $sel0="";
    if ($forum_type == 1) $sel1=" selected"; else $sel1="";
    if ($forum_type == 5) $sel5=" selected"; else $sel5="";
    if ($forum_type == 6) $sel6=" selected"; else $sel6="";
    if ($forum_type == 7) $sel7=" selected"; else $sel7="";
    if ($forum_type == 8) $sel8=" selected"; else $sel8="";
    if ($forum_type == 9) $sel9=" selected"; else $sel9="";

    echo "<option value=\"0\"$sel0>".adm_translate("Public")."</option>
          <option value=\"1\"$sel1>".adm_translate("Privé")."</option>
          <option value=\"5\"$sel5>PHP Script + ".adm_translate("Groupe")."</option>
          <option value=\"6\"$sel6>PHP Script</option>
          <option value=\"7\"$sel7>".adm_translate("Groupe")."</option>
          <option value=\"8\"$sel8>".adm_translate("Texte étendu")."</option>
          <option value=\"9\"$sel9>".adm_translate("Caché")."</option>
    </select>
    </td></tr>
    <tr><td>".adm_translate("Mode")." :</td>
    <td><select class=\"textbox_standard\" name=\"arbre\">";
    if ($arbre)
        echo "<option value=\"0\">".adm_translate("Standard")."</option><option value=\"1\" selected>".adm_translate("Arbre")."</option>";
    else
        echo "<option value=\"0\" selected>".adm_translate("Standard")."</option><option value=\"1\">".adm_translate("Arbre")."</option>";

    echo "</select>
    </td></tr>
    <tr><td>".adm_translate("Attachement")." :</td>
    <td><select class=\"textbox_standard\" name=\"attachement\">";
    if ($attachement)
        echo "<option value=\"0\">".adm_translate("Non")."</option><option value=\"1\" selected>".adm_translate("Oui")."</option>";
    else
        echo "<option value=\"0\" selected>".adm_translate("Non")."</option><option value=\"1\">".adm_translate("Oui")."</option>";

    echo "</select>
    </td></tr>
    <tr><td colspan=\"2\"><hr width=\"100%\" noshade class=\"ongl\"></td></tr>
    <tr><td nowrap=\"nowrap\">".adm_translate("- Mot de Passe (si Privé)<br />- Le nom du fichier de formulaire (si Texte étendu)<br /><span style=\"font-size: 10px;\">&nbsp;&nbsp;=> modules/sform/forum</span><br />- Les Groupes ID (si Groupe)")."</td><td><input class=\"textbox\" type=\"text\" name=\"forum_pass\" size=\"40\" value=\"$forum_pass\"></td></tr>
    </table><br />
    <input type=\"hidden\" name=\"ctg\" value=\"".StripSlashes($ctg)."\">
    <input type=\"hidden\" name=\"op\" value=\"ForumGoSave\">
    <input class=\"bouton_standard\" type=\"submit\" value=\"".adm_translate("Sauver les modifications")."\">
    </form>";
    closetable();
    include("footer.php");
}

function ForumCatEdit($cat_id) {
    global $hlpfile;
    global $NPDS_Prefix;

    include ("header.php");
    GraphicAdmin($hlpfile);
    $result = sql_query("select cat_id, cat_title from ".$NPDS_Prefix."catagories where cat_id='$cat_id'");
    list($cat_id, $cat_title) = sql_fetch_row($result);
    opentable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo adm_translate("Editer les Catégories");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">
    <input type=\"hidden\" name=\"old_cat_id\" value=\"$cat_id\">
    ".adm_translate("Index")." : <input class=\"textbox_standard\" type=\"text\" name=\"cat_id\" size=\"10\" value=\"$cat_id\">&nbsp;&nbsp;&nbsp;&nbsp;
    ".adm_translate("Catégories :")." <input class=\"textbox_standard\" type=\"text\" name=\"cat_title\" size=\"31\" value=\"".StripSlashes($cat_title)."\"> -
    <input type=\"hidden\" name=\"op\" value=\"ForumCatSave\">
    <input class=\"bouton_standard\" type=\"submit\" value=".adm_translate("Sauver les modifications").">
    </form>";
    closetable();
    include("footer.php");
}

function ForumCatSave($old_catid, $cat_id, $cat_title) {
    global $NPDS_Prefix;

    $return=sql_query("update ".$NPDS_Prefix."catagories set cat_id='$cat_id', cat_title='".AddSlashes($cat_title)."' where cat_id='$old_catid'");
    if ($return) {
       sql_query("update ".$NPDS_Prefix."forums set cat_id='$cat_id' where cat_id='$old_catid'");
    }
    Q_Clean();
    Header("Location: admin.php?op=ForumAdmin");
}

function ForumGoSave($forum_id, $forum_name, $forum_desc, $forum_access, $forum_mod, $cat_id, $forum_type, $forum_pass, $arbre, $attachement, $forum_index, $ctg) {
    global $hlpfile;
    global $NPDS_Prefix;

    $moderator=explode(",",$forum_mod);
    $forum_mod="";
    $error_mod="";
    for ($i = 0; $i < count($moderator); $i++) {
       $result = sql_query("select uid from ".$NPDS_Prefix."users where uname='".trim($moderator[$i])."'");
       list($forum_moderator) = sql_fetch_row($result);
       if ($forum_moderator!="") {
          $forum_mod.=$forum_moderator." ";
          sql_query("update ".$NPDS_Prefix."users_status set level='2' where uid='$forum_moderator'");
       } else {
          $error_mod.=$moderator[$i]." ";
       }
    }
    if ($error_mod!="") {
       include ("header.php");
       GraphicAdmin($hlpfile);
       opentable();
       echo "<p align=\"center\">".adm_translate("Le Modérateur sélectionné n'existe pas.")." : $error_mod<br />";
       echo "[ <a href=\"javascript:history.go(-1)\" class=\"noir\">".adm_translate("Retour en arrière")."</a> ]</p>";
       closetable();
       include("footer.php");
    } else {
       $forum_mod=str_replace(" ",",",chop($forum_mod));
       if ($arbre>1) $arbre=1;
       if ($forum_pass) {
          if (($forum_type==7) and ($forum_access==0) ) {$forum_access=1;}
          sql_query("update ".$NPDS_Prefix."forums set forum_name='$forum_name', forum_desc='$forum_desc', forum_access='$forum_access', forum_moderator='$forum_mod', cat_id='$cat_id', forum_type='$forum_type', forum_pass='$forum_pass', arbre='$arbre', attachement='$attachement', forum_index='$forum_index' where forum_id='$forum_id'");
       } else {
          sql_query("update ".$NPDS_Prefix."forums set forum_name='$forum_name', forum_desc='$forum_desc', forum_access='$forum_access', forum_moderator='$forum_mod', cat_id='$cat_id', forum_type='$forum_type', forum_pass='', arbre='$arbre', attachement='$attachement', forum_index='$forum_index' where forum_id='$forum_id'");
       }
       Q_Clean();
       Header("Location: admin.php?op=ForumGo&cat_id=$cat_id");
    }
}

function ForumCatAdd($catagories) {
    global $NPDS_Prefix;

    sql_query("insert into ".$NPDS_Prefix."catagories values (NULL, '$catagories')");
    Header("Location: admin.php?op=ForumAdmin");
}

function ForumGoAdd($forum_name, $forum_desc, $forum_access, $forum_mod, $cat_id, $forum_type, $forum_pass, $arbre, $attachement, $forum_index, $ctg) {
    global $hlpfile;
    global $NPDS_Prefix;

    $moderator=explode(",",$forum_mod);
    $forum_mod="";
    $error_mod="";
    for ($i = 0; $i < count($moderator); $i++) {
       $result = sql_query("select uid from ".$NPDS_Prefix."users where uname='".trim($moderator[$i])."'");
       list($forum_moderator) = sql_fetch_row($result);
       if ($forum_moderator!="") {
          $forum_mod.=$forum_moderator." ";
          sql_query("update ".$NPDS_Prefix."users_status set level='2' where uid='$forum_moderator'");
       } else {
          $error_mod.=$moderator[$i]." ";
       }
    }
    if ($error_mod!="") {
       include ("header.php");
       GraphicAdmin($hlpfile);
       opentable();
       echo "<p align=\"center\">".adm_translate("Le Modérateur sélectionné n'existe pas.")." : $error_mod<br />";
       echo "[ <a href=\"javascript:history.go(-1)\" class=\"noir\">".adm_translate("Retour en arrière")."</a> ]</p>";
       closetable();
       include("footer.php");
    } else {
       if ($arbre>1) $arbre=1;
       $forum_mod=str_replace(" ",",",chop($forum_mod));
       sql_query("insert into ".$NPDS_Prefix."forums values (NULL, '$forum_name', '$forum_desc', '$forum_access', '$forum_mod', '$cat_id', '$forum_type', '$forum_pass', '$arbre', '$attachement', '$forum_index')");
       Q_Clean();
       Header("Location: admin.php?op=ForumGo&cat_id=$cat_id");
    }
}

function ForumCatDel($cat_id, $ok=0) {
    global $hlpfile;
    global $NPDS_Prefix;

    if ($ok==1) {
       $result = sql_query("select forum_id from ".$NPDS_Prefix."forums where cat_id='$cat_id'");
       while(list($forum_id) = sql_fetch_row($result)) {
           sql_query("delete from ".$NPDS_Prefix."forumtopics where forum_id='$forum_id'");
           sql_query("delete from ".$NPDS_Prefix."forum_read where forum_id='$forum_id'");
           control_efface_post("forum_npds","","",$forum_id);
       }
       sql_query("delete from ".$NPDS_Prefix."forums where cat_id='$cat_id'");
       sql_query("delete from ".$NPDS_Prefix."catagories where cat_id='$cat_id'");
       Q_Clean();
       Header("Location: admin.php?op=ForumAdmin");
    } else {
       include("header.php");
       GraphicAdmin($hlpfile);
       opentable();
       echo "<p align=\"center\" class=\"rouge\"><b>".adm_translate("ATTENTION :  êtes-vous sûr de vouloir supprimer cette Catégorie, ses Forums et tous ses Sujets ?")."</b><br /><br />";
    }
    echo "[ <a href=\"admin.php?op=ForumCatDel&amp;cat_id=$cat_id&amp;ok=1 class=\"rouge\">".adm_translate("Oui")."</a> | <a href=\"admin.php?op=ForumAdmin\" class=\"noir\">".adm_translate("Non")."</a> ]<br /><br />";
    closetable();
    include("footer.php");
}

function ForumGoDel($forum_id, $ok=0) {
    global $hlpfile;
    global $NPDS_Prefix;

    if ($ok==1) {
       sql_query("delete from ".$NPDS_Prefix."forumtopics where forum_id='$forum_id'");
       sql_query("delete from ".$NPDS_Prefix."forum_read where forum_id='$forum_id'");
       control_efface_post("forum_npds","","",$forum_id);
       sql_query("delete from ".$NPDS_Prefix."forums where forum_id='$forum_id'");
       Q_Clean();
       Header("Location: admin.php?op=ForumAdmin");
    } else {
       include("header.php");
       GraphicAdmin($hlpfile);
       opentable();
       echo "<p align=\"center\" class=\"rouge\"><b>".adm_translate("ATTENTION :  êtes-vous certain de vouloir effacer ce Forum et tous ses Sujets ?")."</b><br /><br />";
    }
    echo "[ <a href=\"admin.php?op=ForumGoDel&amp;forum_id=$forum_id&amp;ok=1\" class=\"rouge\">".adm_translate("Oui")."</a> | <a href=\"admin.php?op=ForumAdmin\" class=\"noir\">".adm_translate("Non")."</a> ]<br /><br />";
    closetable();
    include("footer.php");
}
?>