<?php
/************************************************************************/
/* DUNE by NPDS                                                         */
/* ===========================                                          */
/*                                                                      */
/* Based on PhpNuke 4.x source code                                     */
/*                                                                      */
/* NPDS Copyright (c) 2002-2012 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 (!stristr($_SERVER['PHP_SELF'],"admin.php")) { Access_Error(); }

global $language;
$hlpfile = "manuels/$language/adminblock.html";
$result = sql_query("select radminsuper from ".$NPDS_Prefix."authors where aid='$aid'");
list($radminsuper) = sql_fetch_row($result);
if ($radminsuper!=1) {
   Access_Error();
}

function ablock() {
   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("Editer le Bloc Administration");
   echo "</td></tr></table>\n";
   echo "<br />";
   $result = sql_query("select title, content from ".$NPDS_Prefix."adminblock");
   if (sql_num_rows($result) > 0) {
      while (list($title, $content) = sql_fetch_row($result)) {
         echo "<form action=\"admin.php\" method=\"post\">";
         echo adm_translate("Titre :")." <input class=\"textbox_standard\" type=\"text\" name=\"title\" size=\"70\" maxlength=\"250\" value=\"$title\"/><br /><br />";
         echo adm_translate("Contenu :");
         echo "<br /><textarea class=\"textbox\" cols=\"70\" rows=\"25\" name=\"content\" style=\"width: 95%;\">$content</textarea><br /><br />";
         echo "<input type=\"hidden\" name=\"op\" value=\"changeablock\" />";
         echo "<input class=\"bouton_standard\" type=\"submit\" value=\"".adm_translate("Valider")."\" />";
         echo "</form>";
      }
   }
   closetable();
   include("footer.php");
}

function changeablock($title, $content) {
   global $NPDS_Prefix;

   $title = stripslashes(FixQuotes($title));
   $content = stripslashes(FixQuotes($content));
   sql_query("update ".$NPDS_Prefix."adminblock set title='$title', content='$content'");
   global $aid; Ecr_Log("security", "ChangeAdminBlock() by AID : $aid", "");
   Header("Location: admin.php?op=adminMain");
}

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

   case "changeablock":
        changeablock($title, $content);
        break;
}
?>