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

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

function mblock() {
    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("Edition du Bloc Principal");
    echo "</td></tr></table>\n";
    $result = sql_query("select title, content from ".$NPDS_Prefix."mainblock");
    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 :");
          echo "<br /><input class=\"textbox\" type=\"text\" name=\"title\" size=\"40\" maxlength=\"255\" value=\"$title\"><br /><br />";
          echo adm_translate("Contenu :");
          echo "<br /><textarea class=\"textbox\" cols=\"70\" rows=\"35\" name=\"content\">".$content."</textarea><br /><br />";
          echo "<input type=\"hidden\" name=\"op\" value=\"changemblock\">";
          echo "<input class=\"bouton_standard\" type=\"submit\" value=\"".adm_translate("Valider")."\">";
          echo "</form>";
       }
    }
    closetable();
    include("footer.php");
}

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

    $title = stripslashes(FixQuotes($title));
    $content = stripslashes(FixQuotes($content));
    sql_query("update ".$NPDS_Prefix."mainblock set title='$title', content='$content'");
    Header("Location: admin.php?op=adminMain");
}

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

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