<?php
/************************************************************************/
/* DUNE by NPDS                                                         */
/* ===========================                                          */
/*                                                                      */
/* Based on PhpNuke 4.x source code                                     */
/*                                                                      */
/* NPDS Copyright (c) 2002-2010 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/ephem.html";
$result = sql_query("select radminephem, radminsuper from ".$NPDS_Prefix."authors where aid='$aid'");
list($radminephem, $radminsuper) = sql_fetch_row($result);
if (($radminephem!=1) and ($radminsuper!=1)) {
   Access_Error();
}

function Ephemerids() {
    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("Ephémérides")." - ".adm_translate("Ajouter un Epheméride : ");
    echo "</td></tr></table>\n";
    echo "<br /><form action=\"admin.php\" method=\"post\">";
    $nday = "1";
    echo adm_translate("Jour : ")." <select class=\"textbox_standard\" name=\"did\">";
    while ($nday<=31) {
       echo "<option name=\"did\">$nday</option>";
       $nday++;
    }
    echo "</select>";
    $nmonth = "1";
    echo " ".adm_translate("Mois : ")." <select class=\"textbox_standard\" name=\"mid\">";
    while ($nmonth<=12) {
       echo "<option name=\"mid\">$nmonth</option>";
       $nmonth++;
    }
    echo "</select> ".adm_translate("Année : ")." <input class=\"textbox_standard\" type=\"text\" name=\"yid\" maxlength=\"4\" size=\"5\" /><br /><br />
    ".adm_translate("Description de l'Ephéméride : ")."<br />
    <textarea name=\"content\" class=\"textbox\" cols=\"55\" rows=\"10\"></textarea><br /><br />
    <input type=\"hidden\" name=\"op\" value=\"Ephemeridsadd\" />
    <input class=\"bouton_standard\" type=\"submit\" value=\"".adm_translate("Envoyer")."\" />
    </form><br />";
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo adm_translate("Maintenance des Ephémérides (Editer/Effacer)");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">";
    $nday = "1";
    echo adm_translate("Jour : ")." <select class=\"textbox_standard\" name=\"did\">";
    while ($nday<=31) {
       echo "<option name=\"did\">$nday</option>";
       $nday++;
    }
    echo "</select>";
    $nmonth = "1";
    echo "&nbsp;".adm_translate("Mois : ")." <select class=\"textbox_standard\" name=\"mid\">";
    while ($nmonth<=12) {
       echo "<option name=\"mid\">$nmonth</option>";
       $nmonth++;
    }
    echo "</select>";
    echo " - <input type=\"hidden\" name=\"op\" value=\"Ephemeridsmaintenance\" />
    <input class=\"bouton_standard\" type=\"submit\" value=\"".adm_translate("Editer")."\" />
    </form>";
    closetable();
    include ("footer.php");
}

function Ephemeridsadd($did, $mid, $yid, $content) {
    global $NPDS_Prefix;

    $content = stripslashes(FixQuotes($content)."");
    sql_query("insert into ".$NPDS_Prefix."ephem values (NULL, '$did', '$mid', '$yid', '$content')");
    Header("Location: admin.php?op=Ephemerids");
}

function Ephemeridsmaintenance($did, $mid) {
    global $hlpfile;
    global $NPDS_Prefix;

    $resultX=sql_query("select eid, did, mid, yid, content from ".$NPDS_Prefix."ephem where did='$did' AND mid='$mid' ORDER BY yid ASC");
    if (!sql_num_rows($resultX))
       header("location: admin.php?op=Ephemerids");
    include ("header.php");
    GraphicAdmin($hlpfile);
    opentable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo adm_translate("Maintenance des Ephémérides");
    echo "</td></tr></table>\n";
    echo "<br /><table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">";
    while(list($eid, $did, $mid, $yid, $content) = sql_fetch_row($resultX)) {
       $rowcolor = tablos();
       echo "<tr $rowcolor>
       <td>$yid</td><td>".aff_langue($content)."</td>
       <td align=\"right\">[ <a href=\"admin.php?op=Ephemeridsedit&amp;eid=$eid&amp;did=$did&amp;mid=$mid\" class=\"noir\">".adm_translate("Editer")."</a> | <a href=\"admin.php?op=Ephemeridsdel&amp;eid=$eid&amp;did=$did&amp;mid=$mid\" class=\"rouge\">".adm_translate("Effacer")."</a> ]<br />
       </tr>";
    }
    echo "</table>";
    closetable();
    include ('footer.php');
}

function Ephemeridsdel($eid, $did, $mid) {
    global $NPDS_Prefix;

    sql_query("delete from ".$NPDS_Prefix."ephem where eid='$eid'");
    Header("Location: admin.php?op=Ephemeridsmaintenance&did=$did&mid=$mid");
}

function Ephemeridsedit($eid, $did, $mid) {
    global $hlpfile;
    global $NPDS_Prefix;

    include ("header.php");
    GraphicAdmin($hlpfile);
    $result=sql_query("select yid, content from ".$NPDS_Prefix."ephem where eid='$eid'");
    list($yid, $content) = sql_fetch_row($result);
    opentable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"header\">\n";
    echo adm_translate("Maintenance des Ephémérides")." - ".adm_translate("Editer Ephéméride : ");
    echo "</td></tr></table>\n";
    echo "<br /><form action=\"admin.php\" method=\"post\">";
    echo adm_translate("Année : ")." <input class=\"textbox_standard\" type=\"text\" name=\"yid\" value=\"$yid\" maxlength=\"4\" size=\"5\" /><br /><br />
    ".adm_translate("Description de l'Ephéméride : ")."<br />
    <textarea name=\"content\" cols=\"55\" class=\"textbox\" rows=\"10\">$content</textarea><br /><br />
    <input type=\"hidden\" name=\"did\" value=\"$did\" />
    <input type=\"hidden\" name=\"mid\" value=\"$mid\" />
    <input type=\"hidden\" name=\"eid\" value=\"$eid\" />
    <input type=\"hidden\" name=\"op\" value=\"Ephemeridschange\" />
    <input class=\"bouton_standard\" type=\"submit\" value=\"".adm_translate("Envoyer")."\" />
    </form>";
    closetable();
    include ('footer.php');
}

function Ephemeridschange($eid, $did, $mid, $yid, $content) {
    global $NPDS_Prefix;

    $content = stripslashes(FixQuotes($content)."");
    sql_query("update ".$NPDS_Prefix."ephem set yid='$yid', content='$content' where eid='$eid'");
    Header("Location: admin.php?op=Ephemeridsmaintenance&did=$did&mid=$mid");
}

switch ($op) {
    case "Ephemeridsedit":
         Ephemeridsedit($eid, $did, $mid);
         break;

    case "Ephemeridschange":
         Ephemeridschange($eid, $did, $mid, $yid, $content);
         break;

    case "Ephemeridsdel":
         Ephemeridsdel($eid, $did, $mid);
         break;

    case "Ephemeridsmaintenance":
         Ephemeridsmaintenance($did, $mid);
         break;

    case "Ephemeridsadd":
         Ephemeridsadd($did, $mid, $yid, $content);
         break;

    case "Ephemerids":
         Ephemerids();
         break;
}
?>