<?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   */
/*                                                                      */
/* 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 (!eregi("admin.php", $PHP_SELF)) { Access_Error(); }
global $pdst; $pdst="0";

global $language;
$hlpfile = "manuels/$language/faqs.html";
$result = mysql_query("select radminfaq, radminsuper from authors where aid='$aid'");
list($radminfaq, $radminsuper) = mysql_fetch_row($result);
if (($radminfaq!=1) and ($radminsuper!=1)) {
   Access_Error();
}

function FaqAdmin() {
    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("Faq");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr>
        <td class=\"ONGL\">".adm_translate("ID")."</td>
        <td class=\"ONGL\">".adm_translate("Catégories")."</td><td class=\"ONGL\">&nbsp</td></tr>";
    $result = mysql_query("select id_cat, categories from faqcategories order by id_cat ASC");
    while(list($id_cat, $categories) = mysql_fetch_row($result)) {
        $rowcolor = tablos();
        echo "<tr $rowcolor>
        <td>$id_cat</td>
        <td>".aff_langue($categories)."</td>
        <td align=\"right\"><a href=\"admin.php?op=FaqCatGo&amp;id_cat=$id_cat\" class=\"NOIR\">".adm_translate("Questions & Réponses")."</a> | <a href=\"admin.php?op=FaqCatEdit&amp;id_cat=$id_cat\" class=\"NOIR\">".adm_translate("Editer")."</a> | <a href=\"admin.php?op=FaqCatDel&amp;id_cat=$id_cat&amp;ok=0\" class=\"ROUGE\">".adm_translate("Effacer")."</a></td><tr>";
    }
    echo "</table>";
    echo "</form>";
    echo "<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
    <form action=\"admin.php\" method=\"post\">
    ".adm_translate("Catégories :")." <input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"categories\" size=\"65\" maxlength=\"255\">
    <input type=\"hidden\" name=\"op\" value=\"FaqCatAdd\">
     - <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Ajouter")."\">
    </form>";
    closetable();
    include("footer.php");
}

function FaqCatGo($id_cat) {
    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("Ajouter une question");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\" name=\"adminForm\">
    <b>".adm_translate("Question : ")."</b><br /><input class=\"textbox\" type=\"text\" name=\"question\" size=\"70\" maxlength=\"255\"><br /><br />
    <b>".adm_translate("Réponse : ")."</b><br /><textarea class=\"textbox\" name=\"answer\" cols=\"70\" rows=\"15\" style=\"width: 100%;\"></textarea>";
    echo aff_editeur("answer","false");
    echo "<br /><br />";
    echo "<input type=\"hidden\" name=\"id_cat\" value=\"$id_cat\">
    <input type=\"hidden\" name=\"op\" value=\"FaqCatGoAdd\">
    <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Ajouter")."\">&nbsp;&nbsp;[ <a href=\"admin.php?op=FaqAdmin\" class=\"noir\">".adm_translate("Retour en arrière")."</a> ]
    </form>";

    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Questions & Réponses");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr>
    <td class=\"ONGL\">".adm_translate("Question : ")." </td><td class=\"ONGL\">&nbsp</td></tr>";
    $result = mysql_query("select id, question, answer from faqanswer where id_cat='$id_cat' order by id");
    while(list($id, $question, $answer) = mysql_fetch_row($result)) {
        $rowcolor = tablos();
        echo "<tr $rowcolor><td>".aff_langue($question)."</td><td width=\"10%\" rowspan=\"2\" align=\"center\"><a href=\"admin.php?op=FaqCatGoEdit&amp;id=$id\" class=\"NOIR\">".adm_translate("Editer")."</a><br /><a href=\"admin.php?op=FaqCatGoDel&amp;id=$id&amp;ok=0\" class=\"ROUGE\">".adm_translate("Effacer")."</a></td></tr>
        <tr $rowcolor><td class=\"NOIR\">";
        $answer=aff_code(aff_langue($answer));
        echo meta_lang($answer);
        echo "</td></tr>";
    }
    echo "</table></form>";
    closetable();
    include("footer.php");
}

function FaqCatEdit($id_cat) {
    global $hlpfile;
    include ("header.php");
    GraphicAdmin($hlpfile);
    $result = mysql_query("select categories from faqcategories where id_cat='$id_cat'");
    list($categories) = 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_id_cat\" value=\"$id_cat\">
    ID : <input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"id_cat\" value=\"$id_cat\" size=\"4\">&nbsp;&nbsp;
    ".adm_translate("Catégories :")." <input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"categories\" size=\"65\" value=\"$categories\">\n";
    echo " - <input type=\"hidden\" name=\"op\" value=\"FaqCatSave\">
    <input class=\"BOUTON_STANDARD\" type=\"submit\" value=".adm_translate("Sauver les modifications").">";
    echo "</form>";
    closetable();
    include("footer.php");
}

function FaqCatGoEdit($id) {
    global $hlpfile;
    include ("header.php");
    GraphicAdmin($hlpfile);
    $result = mysql_query("select question, answer, id_cat from faqanswer where id='$id'");
    list($question, $answer, $id_cat) = mysql_fetch_row($result);
    OpenTable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Editer Question & Réponse");
    echo "</td></tr></table>\n";

    $rowcolor = tablos();
    echo "<p align=\"center\"><table border=\"0\" width=\"90%\" cellpadding=\"0\" cellspacing=\"1\"><tr $rowcolor><td>";
    $rowcolor = tablos();
    echo "<table width=\"100%\" border=\"0\" cellpadding=\"8\" cellspacing=\"0\">";
    echo "<tr $rowcolor><td valign=\"top\">".aff_local_langue("<b>".adm_translate("Langue de Prévisualisation")."</b> : ","","local_user_language")."</td></tr>";
    global $local_user_language;
    echo "<tr class=\"LIGNB\"><td><b class=\"HEADER\">&nbsp;".preview_local_langue($local_user_language, $question)."&nbsp;</b><p align=\"justify\">";
    $answer=aff_code($answer);
    echo meta_lang(preview_local_langue($local_user_language, $answer))."</p>";
    echo "</td></tr></table></td></tr></table></p><br />";

    echo "<form action=\"admin.php\" method=\"post\" name=\"adminForm\">
    <input type=\"hidden\" name=\"id\" value=\"$id\">";
    echo "<b>".adm_translate("Question : ")."</b><br /><input class=\"textbox\" type=\"text\" name=\"question\" size=\"70\"  maxlength=\"255\" value=\"$question\"><br /><br />
    <b>".adm_translate("Réponse : ")."</b><br /><textarea class=\"textbox\" name=\"answer\" cols=\"70\" rows=\"15\" style=\"width: 100%;\">$answer</textarea>";
    echo aff_editeur("answer","false");
    echo "<br /><br />";
    echo "<input type=\"hidden\" name=\"op\" value=\"FaqCatGoSave\">
    <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Sauver les modifications")."\">&nbsp;&nbsp;[ <a href=\"admin.php?op=FaqCatGo&amp;id_cat=$id_cat\" class=\"noir\">".adm_translate("Retour en arrière")."</a> ]
    </form>";
    closetable();
    include("footer.php");
}

function FaqCatSave($old_id_cat, $id_cat, $categories) {
    $categories = stripslashes(FixQuotes($categories));
    if ($old_id_cat!=$id_cat) {
       mysql_query("update faqanswer set id_cat='$id_cat' where id_cat='$old_id_cat'");
    }
    mysql_query("update faqcategories set id_cat='$id_cat', categories='$categories' where id_cat='$old_id_cat'");
    Header("Location: admin.php?op=FaqAdmin");
}

function FaqCatGoSave($id, $question, $answer) {
    $question = stripslashes(FixQuotes($question));
    $answer = stripslashes(FixQuotes($answer));
    mysql_query("update faqanswer set question='$question', answer='$answer' where id='$id'");
    Header("Location: admin.php?op=FaqCatGoEdit&id=$id");
}

function FaqCatAdd($categories) {
    $categories = stripslashes(FixQuotes($categories));
    mysql_query("insert into faqcategories values (NULL, '$categories')");
    Header("Location: admin.php?op=FaqAdmin");
}

function FaqCatGoAdd($id_cat, $question, $answer) {
    $question = stripslashes(FixQuotes($question));
    $answer = stripslashes(FixQuotes($answer));
    mysql_query("insert into faqanswer values (NULL, '$id_cat', '$question', '$answer')");
    Header("Location: admin.php?op=FaqCatGo&id_cat=$id_cat");
}

function FaqCatDel($id_cat, $ok=0) {
    if($ok==1) {
        mysql_query("delete from faqcategories where id_cat='$id_cat'");
        mysql_query("delete from faqanswer where id_cat='$id_cat'");
        Header("Location: admin.php?op=FaqAdmin");
    } else {
        global $hlpfile;
        include("header.php");
        GraphicAdmin($hlpfile);
        OpenTable();
        echo "<p align=\"center\"><br />";
        echo "<span class=\"ROUGE\"><b>".adm_translate("ATTENTION : êtes-vous sûr de vouloir effacer cette FAQ et toutes ses questions ?")."</b></span><br /><br />";
    }
    echo "[ <a href=\"admin.php?op=FaqCatDel&amp;id_cat=$id_cat&amp;ok=1\" class=\"ROUGE\">".adm_translate("Oui")."</a> | <a href=\"admin.php?op=FaqAdmin\" class=\"NOIR\">".adm_translate("Non")."</a> ]<br /><br /></p>";
    closetable();
    include("footer.php");
}

function FaqCatGoDel($id, $ok=0) {
    if($ok==1) {
        mysql_query("delete from faqanswer where id='$id'");
        Header("Location: admin.php?op=FaqAdmin");
    } else {
        global $hlpfile;
        include("header.php");
        GraphicAdmin($hlpfile);
        OpenTable();
        echo "<p align=\"center\"><br />";
        echo "<span class=\"ROUGE\"><b>".adm_translate("ATTENTION : êtes-vous sûr de vouloir effacer cette question ?")."</b></span><br /><br />";
    }
    echo "[ <a href=\"admin.php?op=FaqCatGoDel&amp;id=$id&amp;ok=1\" class=\"ROUGE\">".adm_translate("Oui")."</a> | <a href=\"admin.php?op=FaqAdmin\" class=\"NOIR\">".adm_translate("Non")."</a> ]<br /><br /></p>";
    closetable();
    include("footer.php");
}
?>