<?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/headlines.html";
$result = mysql_query("select radminhead, radminsuper from authors where aid='$aid'");
list($radminhead, $radminsuper) = mysql_fetch_row($result);
if (($radminhead!=1) AND ($radminsuper!=1)) {
   Access_Error();
}

function HeadlinesAdmin() {
    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("Grands Titres de sites de News");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr>
        <td class=\"ONGL\">".adm_translate("ID")."</td>
        <td class=\"ONGL\">".adm_translate("Nom du site")."</td>
        <td class=\"ONGL\">".adm_translate("URL")."</td>
        <td class=\"ONGL\" align=center>".adm_translate("Etat")."</td>
        <td class=\"ONGL\" align=center>".adm_translate("Fonctions")."</td></tr>\n";
    $result = mysql_query("select hid, sitename, url, status from headlines order by hid");
    while(list($hid, $sitename, $url, $status) = mysql_fetch_row($result)) {
        $rowcolor = tablos();
        echo "<tr $rowcolor><td>$hid</td>
        <td><a href=\"$url\" target=\"_blank\" class=\"NOIR\">$sitename</a></td>
        <td>$url</td>";
        if($status == 1) {
            $status = "<b><span style=\"color: green;\">".adm_translate("Actif(s)")."</span></b>";
        } else {
            $status = "".adm_translate("Inactif(s)")."";
        }
        echo "
        <td align=\"center\">$status</td>
        <td align=\"center\"><a href=\"admin.php?op=HeadlinesEdit&amp;hid=$hid\" class=\"NOIR\">".adm_translate("Editer")."</a> | <a href=\"admin.php?op=HeadlinesDel&amp;hid=$hid&amp;ok=0\" class=\"ROUGE\">".adm_translate("Effacer")."</a></td></tr>\n";
    }
    echo "</table></form><br />\n";
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Ajouter Grands Titres");
    echo "</td></tr></table>\n";
    echo "<br /><form action=\"admin.php\" method=\"post\">
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td width=\"30%\">
    ".adm_translate("Nom du site : ")." </td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"xsitename\" size=\"35\" maxlength=\"30\"></td></tr><tr><td>
    ".adm_translate("URL : ")." </td><td><input class=\"TEXTBOX\" type=\"text\" name=\"url\" size=\"50\" maxlength=\"100\"></td></tr><tr><td>
    ".adm_translate("URL pour le fichier RDF/XML : ")." </td><td><input class=\"TEXTBOX\" type=\"text\" name=\"headlinesurl\" size=\"50\" maxlength=\"200\"></td></tr><tr><td>
    ".adm_translate("Etat : ")." </td><td><select class=\"TEXTBOX_STANDARD\" name=\"status\">
        <option name=\"status\" value=\"1\">".adm_translate("Actif(s)")."</option>
        <option name=\"status\" value=\"0\" selected>".adm_translate("Inactif(s)")."</option>
        </select></td></tr></table><br />
    <input type=\"hidden\" name=\"op\" value=\"HeadlinesAdd\">
    <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Ajouter")."\">
    </form>";
    closetable();
    include("footer.php");
}

function HeadlinesEdit($hid) {
    global $hlpfile;
    include ("header.php");
    GraphicAdmin($hlpfile);
    $result = mysql_query("select sitename, url, headlinesurl, status from headlines where hid='$hid'");
    list($xsitename, $url, $headlinesurl, $status) = mysql_fetch_row($result);
    OpenTable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Editer paramètres Grand Titre");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">
    <input type=\"hidden\" name=\"hid\" value=\"$hid\">
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td width=\"30%\">
    ".adm_translate("Nom du site : ")." </td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"xsitename\" size=\"35\" maxlength=\"30\" value=\"$xsitename\"></td></tr><tr><td>
    ".adm_translate("URL : ")." </td><td><input class=\"TEXTBOX\" type=\"text\" name=\"url\" size=\"50\" maxlength=\"100\" value=\"$url\"></td></tr><tr><td>
    ".adm_translate("URL pour le fichier RDF/XML : ")." </td><td><input class=\"TEXTBOX\" type=\"text\" name=\"headlinesurl\" size=\"50\" maxlength=\"200\" value=\"$headlinesurl\"></td></tr><tr><td>
    ".adm_translate("Etat : ")." </td><td><select class=\"TEXTBOX_STANDARD\" name=\"status\">";
    if ($status == 1) {
       $sel_a = "selected";
    } else {
       $sel_i = "selected";
    }
    echo "<option name=\"status\" value=\"1\" $sel_a>".adm_translate("Actif(s)")."</option>
          <option name=\"status\" value=\"0\" $sel_i>".adm_translate("Inactif(s)")."</option>
          </select></td></tr></table><br />
          <input type=\"hidden\" name=\"op\" value=\"HeadlinesSave\">
          <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Sauver les modifications")."\">
          </form>";
    closetable();
    include("footer.php");
}

function HeadlinesSave($hid, $xsitename, $url, $headlinesurl, $status) {
    $xsitename = ereg_replace(" ", "", $xsitename);
    mysql_query("update headlines set sitename='$xsitename', url='$url', headlinesurl='$headlinesurl', status='$status' where hid='$hid'");
    Header("Location: admin.php?op=HeadlinesAdmin");
}

function HeadlinesAdd($xsitename, $url, $headlinesurl, $status) {
    $xsitename = ereg_replace(" ", "", $xsitename);
    mysql_query("insert into headlines values (NULL, '$xsitename', '$url', '$headlinesurl', '$status')");
    Header("Location: admin.php?op=HeadlinesAdmin");
}

function HeadlinesDel($hid, $ok=0) {
    if ($ok==1) {
       mysql_query("delete from headlines where hid='$hid'");
       Header("Location: admin.php?op=HeadlinesAdmin");
    } else {
       global $hlpfile;
       include("header.php");
       GraphicAdmin($hlpfile);
       OpenTable();
       echo "<p align=\"center\"><br />";
       echo "<span class=\"ROUGE\">";
       echo "<b>".adm_translate("Etes-vous sûr de vouloir supprimer cette boîte de Titres ?")."</b><br /><br /></span>";
    }
    echo "[ <a href=\"admin.php?op=HeadlinesDel&amp;hid=$hid&amp;ok=1\" class=\"ROUGE\">".adm_translate("Oui")."</a> | <a href=\"admin.php?op=HeadlinesAdmin\" class=\"NOIR\">".adm_translate("Non")."</a> ]<br /><br />";
    closetable();
    include("footer.php");
}

switch($op) {
    case "HeadlinesDel":
         HeadlinesDel($hid, $ok);
         break;

    case "HeadlinesAdd":
         HeadlinesAdd($xsitename, $url, $headlinesurl, $status);
         break;

    case "HeadlinesSave":
         HeadlinesSave($hid, $xsitename, $url, $headlinesurl, $status);
         break;

    case "HeadlinesAdmin":
         HeadlinesAdmin();
         break;

    case "HeadlinesEdit":
         HeadlinesEdit($hid);
         break;
}
?>
