<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System .                                 */
/* ===========================                                          */
/*                                                                      */
/* Original Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)   */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2005 by Philippe Brunier   */
/*                                                                      */
/* =========================                                            */
/* Based on Parts of phpBB                                              */
/*                                                                      */
/* 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() {
  if (file_exists("meta/meta.php"))
     include ("meta/meta.php");
  echo "<title>NPDS</title></head><body bgcolor=\"white\"><br /><p align=\"center\"><span style=\"font-size: 14px; font-family: Arial; font-weight: bold; color: red;\">";
  echo "Access Denied / Acc&egrave;s Refus&eacute;";
  if (cur_charset=="utf-8") echo" / &#x901A;&#x5165;&#x88AB;&#x5426;&#x8BA4;";
  echo "</span>";
  echo "<br /><br /><span style=\"font-size: 12px; font-family: Arial; font-weight: bold; color: black;\">NPDS - Portal System";
  echo "</span></p></body></html>";
  die();
}

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

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

function ForumAdmin() {
    global $hlpfile;
    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 = mysql_query("select cat_id, cat_title from catagories order by cat_id");
    while (list($cat_id, $cat_title) = mysql_fetch_row($result)) {
       $gets = mysql_query("select count(*) as total from forums where cat_id='$cat_id'");
       $numbers= mysql_fetch_array($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;
    include ("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    $result = mysql_query("select cat_title from catagories where cat_id='$cat_id'");
    list($cat_title) = mysql_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 = mysql_query("select forum_id, forum_name, forum_access, forum_moderator, forum_type, arbre, attachement, forum_index from 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) = mysql_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=\"3\" maxlength=\"2\"></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;
    include ("header.php");
    GraphicAdmin($hlpfile);
    $result = mysql_query("select forum_id, forum_name, forum_desc, forum_access, forum_moderator, cat_id, forum_type, forum_pass, arbre, attachement, forum_index from 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) = mysql_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=\"3\" maxlength=\"2\" 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 = mysql_query("select cat_id, cat_title from catagories");
    while(list($cat_id, $cat_title) = mysql_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;
    include ("header.php");
    GraphicAdmin($hlpfile);
    $result = mysql_query("select cat_id, cat_title from catagories where cat_id='$cat_id'");
    list($cat_id, $cat_title) = mysql_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) {
    $return=mysql_query("update catagories set cat_id='$cat_id', cat_title='".AddSlashes($cat_title)."' where cat_id='$old_catid'");
    if ($return) {
       mysql_query("update 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;
    $moderator=explode(",",$forum_mod);
    $forum_mod="";
    $error_mod="";
    for ($i = 0; $i < count($moderator); $i++) {
       $result = mysql_query("select uid from users where uname='".trim($moderator[$i])."'");
       list($forum_moderator) = mysql_fetch_row($result);
       if ($forum_moderator!="") {
          $forum_mod.=$forum_moderator." ";
          mysql_query("update 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;}
          mysql_query("update 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 {
          mysql_query("update 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) {
    mysql_query("insert into 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;
    $moderator=explode(",",$forum_mod);
    $forum_mod="";
    $error_mod="";
    for ($i = 0; $i < count($moderator); $i++) {
       $result = mysql_query("select uid from users where uname='".trim($moderator[$i])."'");
       list($forum_moderator) = mysql_fetch_row($result);
       if ($forum_moderator!="") {
          $forum_mod.=$forum_moderator." ";
          mysql_query("update 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));
       mysql_query("insert into 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;
    if ($ok==1) {
       $result = mysql_query("select forum_id from forums where cat_id='$cat_id'");
       while(list($forum_id) = mysql_fetch_row($result)) {
           mysql_query("delete from forumtopics where forum_id='$forum_id'");
           mysql_query("delete from forum_read where forum_id='$forum_id'");
           control_efface_post("forum_npds","","",$forum_id);
       }
       mysql_query("delete from forums where cat_id='$cat_id'");
       mysql_query("delete from 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;
    if ($ok==1) {
       mysql_query("delete from forumtopics where forum_id='$forum_id'");
       mysql_query("delete from forum_read where forum_id='$forum_id'");
       control_efface_post("forum_npds","","",$forum_id);
       mysql_query("delete from 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");
}
?>
