<?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   */
/*                                                                      */
/************************************************************************/
/*                                                                      */
/* Add-on Copyright (c) 2000 by Jeff Lambert (jeffx@ican.net)           */
/* http://www.qchc.com                                                  */
/*                                                                      */
/* This module is the main administration part for the reviews add-on   */
/*                                                                      */
/************************************************************************/
/*                                                                      */
/* 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/reviews.html";
$result = mysql_query("select radminreviews, radminsuper from authors where aid='$aid'");
list($radminreviews, $radminsuper) = mysql_fetch_row($result);
if (($radminreviews!=1) and ($radminsuper!=1)) {
   Access_Error();
}

function mod_main($title, $description) {
    $title = stripslashes(FixQuotes($title));
    $description = stripslashes(FixQuotes($description));
    mysql_query("update reviews_main set title='$title', description='$description'");
    Header("Location: admin.php?op=reviews");
}

function reviews() {
    global $hlpfile;
    include ("header.php");
    GraphicAdmin($hlpfile);
    $resultrm = mysql_query("select title, description from reviews_main");
    list($title, $description) = mysql_fetch_row($resultrm);
    OpenTable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Titre de la Page des Critiques");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">
          <input type=\"text\" class=\"textbox\" name=\"title\" value=\"$title\" size=\"40\" maxlength=\"100\"><br /><br />
          ".adm_translate("Description de la Page des Critiques : ")."<br />
          <textarea class=\"textbox\" name=\"description\" rows=\"15\" wrap=\"virtual\" cols=\"40\">$description</textarea><br /><br />
          <input type=\"hidden\" name=\"op\" value=\"mod_main\">
          <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Sauver les modifications")."\">
          </form>";

    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Critiques en attente de validation");
    echo "</td></tr></table>\n";
    $result = mysql_query("select * from reviews_add order by id");
    $numrows = mysql_num_rows($result);
    if ($numrows>0) {
        while(list($id, $date, $title, $text, $reviewer, $email, $score, $url, $url_title) = mysql_fetch_row($result)) {
           $title = stripslashes($title);
           $text = stripslashes($text);
           echo "<form action=\"admin.php\" method=\"post\">";
           echo "<table border=\"0\" cellpadding=\"1\" cellspacing=\"2\" width=\"100%\">";
           echo "<tr><td width=\"30%\">".adm_translate("Ajouter la critique N° : ")."</td><td><b>$id</b></td></tr>";
           echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
           echo "<tr><td>".adm_translate("Date :")."</td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"date\" value=\"$date\" size=\"15\" maxlength=\"10\"></td></tr>";
           echo "<tr><td>".adm_translate("Nom du produit :")."</td><td><input class=\"TEXTBOX\" type=\"text\" name=\"title\" value=\"$title\" size=\"25\" maxlength=\"40\"></TD></TR>";
           echo "<tr><td>".adm_translate("Texte : ")."</td><td><textarea class=\"TEXTBOX\" name=\"text\" rows=\"6\" wrap=\"virtual\" cols=\"40\">$text</textarea></TD></TR>";
           echo "<tr><td>".adm_translate("Le critique : ")."</td><td><input class=\"TEXTBOX\" type=\"text\" name=\"reviewer\" value=\"$reviewer\" size=\"25\" maxlength=\"20\"></TD></TR>";
           echo "<tr><td>".adm_translate("E-mail : ")."</td><td><input class=\"TEXTBOX\" type=\"text\" name=\"email\" value=\"$email\" size=\"40\" maxlength=\"30\"></td></TR>";
           echo "<tr><td>".adm_translate("Note : ")."</TD><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"score\" value=\"$score\" size=\"3\" maxlength=\"2\"></TD></TR>";
           if ($url != "") {
              echo "<tr><td>".adm_translate("Liens relatifs : ")."</TD><td><input class=\"TEXTBOX\" type=\"text\" name=\"url\" value=\"$url\" size=\"25\" maxlength=\"100\"></TD></TR>";
              echo "<tr><td>".adm_translate("Titre du lien : ")."</TD><td><input class=\"TEXTBOX\" type=\"text\" name=\"url_title\" value=\"$url_title\" size=\"25\" maxlength=\"50\"></TD></TR>";
           }
           echo "<tr><td>".adm_translate("Image de garde : ")."</TD><td><input class=\"TEXTBOX\" type=\"text\" name=\"cover\" size=\"25\" maxlength=\"100\"><br /><i>150*150 pixel => images/covers</i></TD></TR></TABLE>";
           echo "<input type=\"hidden\" name=\"op\" value=\"add_review\"><input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Ajouter cette critique")."\"> - [ <a href=\"admin.php?op=deleteNotice&amp;id=$id&amp;op_back=reviews\" class=\"ROUGE\">".adm_translate("Supprimer cette Critique")."</a> ]</form><br />";
        }
    } else {
        echo "<br />".adm_translate("Aucune critique à ajouter")."<br />";
    }
    echo "<hr noshade class=\"ONGL\"><p align=\"center\"><a href=\"reviews.php?op=write_review\" class=\"NOIR\">".adm_translate("Cliquer ici pour proposer une Critique.")."</a></p><hr noshade class=\"ONGL\">";
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Effacer / Modifier une Critique");
    echo "</td></tr></table>\n";
    echo "<br />";
    echo adm_translate("Vous pouvez simplement Effacer / Modifier les Critiques en naviguant sur")." <a href=\"reviews.php\" class=\"NOIR\">reviews.php</a> ".adm_translate("en tant qu'Administrateur.")."<br />";
    CloseTable();
    mysql_free_result($result);
    include ("footer.php");
}

function add_review($id, $date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title) {
    $title = stripslashes(FixQuotes($title));
    $text = stripslashes(FixQuotes($text));
    $reviewer = stripslashes(FixQuotes($reviewer));
    $email = stripslashes(FixQuotes($email));
    mysql_query("insert into reviews values (NULL, '$date', '$title', '$text', '$reviewer', '$email', '$score', '$cover', '$url', '$url_title', '1')");
    mysql_query("delete from reviews_add WHERE id = '$id'");
    Header("Location: admin.php?op=reviews");
}

switch ($op){
    case "reviews":
         reviews();
         break;

    case "add_review":
         add_review($id, $date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title);
         break;

    case "mod_main":
         mod_main($title, $description);
         break;
}
?>
