<?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(); }
include ("publication.php");
global $pdst; $pdst="0";

$result = mysql_query("select radminarticle, radminsuper from authors where aid='$aid'");
list($radminarticle, $radminsuper) = mysql_fetch_row($result);
if (($radminarticle!=1) and ($radminsuper!=1)) {
   Access_Error();
}

function puthome($ihome) {
    echo "<br /><b>".adm_translate("Publier dans la racine ?")."</b>&nbsp;&nbsp;";
    $sel1 = "checked";
    $sel2 = "";
    if ($ihome == 1) {
        $sel1 = "";
        $sel2 = "checked";
    }
    echo "<input type=\"radio\" name=\"ihome\" value=\"0\" $sel1>".adm_translate("Oui")."&nbsp;";
    echo "<input type=\"radio\" name=\"ihome\" value=\"1\" $sel2>".adm_translate("Non");
    echo "&nbsp;&nbsp; <span class=\"NOIR\">[ ".adm_translate("Ne s'applique que si la catégorie : <b>'Articles'</b> n'est pas sélectionnée.")." ]</span><br /><br />";

    $sel1 = "";
    $sel2 = "checked";
    echo "<span class=\"ROUGE\"><b>".adm_translate("Seulement aux membres")."</b></span> :";
    if ($ihome<0) {
       $sel1 = "checked";
       $sel2 = "";
    }
    if (($ihome>1) and ($ihome<=127)) {
       $Mmembers=$ihome;
       $sel1 = "checked";
       $sel2 = "";
    }
    echo "<input type=\"radio\" name=\"members\" value=\"1\" $sel1>".adm_translate("Oui")."&nbsp; /
    ".adm_translate("Groupe")." : ";
    // ---- Groupes
    $mX=liste_group();
    $tmp_groupe="";
    while (list($groupe_id, $groupe_name)=each($mX)) {
       if ($groupe_id=="0") {$groupe_id="";}
       if ($Mmembers==$groupe_id) {$sel3="selected";} else {$sel3="";}
       $tmp_groupe.="<option value=\"$groupe_id\" $sel3>$groupe_name</option>\n";
      $nbg++;
    }
    echo "<select class=\"TEXTBOX_STANDARD\" name=\"Mmembers\">".$tmp_groupe."</select>&nbsp;";
    // ---- Groupes
    echo "<input type=\"radio\" name=\"members\" value=\"0\" $sel2>".adm_translate("Non");
}

function SelectCategory($cat) {
    $selcat = mysql_query("select catid, title from stories_cat");
    echo " <b>".adm_translate("Catégorie")."</b> ";
    echo "<select class=\"TEXTBOX_STANDARD\" name=\"catid\">";
    if ($cat == 0) {
       $sel = "selected";
    } else {
       $sel = "";
    }
    echo "<option name=\"catid\" value=\"0\" $sel>".adm_translate("Articles")."</option>";
    while(list($catidX, $title) = mysql_fetch_row($selcat)) {
       if ($catidX==$cat) {
          $sel = "selected";
       } else {
          $sel = "";
       }
       echo "<option name=\"catid\" value=\"$catidX\" $sel>".aff_langue($title)."</option>";
    }
    echo "</select> [ <a href=\"admin.php?op=AddCategory\" class=\"NOIR\">".adm_translate("Ajouter")."</a> | <a href=\"admin.php?op=EditCategory\" class=\"NOIR\">".adm_translate("Editer")."</a> | <a href=\"admin.php?op=DelCategory\" class=\"ROUGE\">".adm_translate("Effacer")."</a> ]";
}

// CATEGORIES
function AddCategory () {
    include ("header.php");
    GraphicAdmin("");
    OpenTable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Ajouter une nouvelle Catégorie");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\">";
    echo "<b>".adm_translate("Nom : ")."</b> ";
    echo "<input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"title\" size=\"50\" maxlength=\"255\"> - ";
    echo "<input type=\"hidden\" name=\"op\" value=\"SaveCategory\">";
    echo "<input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Sauver les modifications")."\">";
    echo "</form>";
    CloseTable();
    include("footer.php");
}
function SaveCategory($title) {
    $title = ereg_replace("\"","",$title);
    $check = mysql_num_rows(mysql_query("select catid from stories_cat where title='$title'"));
    if ($check) {
        $what1 = adm_translate("Cette Catégorie existe déjà !");
        $what2 = "[ <a href=\"javascript:history.go(-1)\" class=\"NOIR\">".adm_translate("Retour en arrière, pour changer le Nom")."</a> ]";
    } else {
        $what1 = adm_translate("Nouvelle Catégorie ajoutée");
        $what2 = "[ <a href=\"admin.php\" class=\"NOIR\">".adm_translate("Retour à l'index d'administration")."</a> ]";
        $result = mysql_query("insert into stories_cat values (NULL, '$title', '0')");
    }
    include ("header.php");
    GraphicAdmin("");
    OpenTable();
    echo "<p align=\"center\"><b>$what1</b><br /><br />";
    echo "$what2</p><br />";
    CloseTable();
    include("footer.php");
}

function EditCategory($catid) {
    include ("header.php");
    GraphicAdmin("");
    OpenTable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo "".adm_translate("Edition des Catégories")."";
    echo "</td></tr></table>\n";
    $result = mysql_query("select title from stories_cat where catid='$catid'");
    list($title) = mysql_fetch_row($result);
    if (!$catid) {
        $selcat = mysql_query("select catid, title from stories_cat");
        echo "<form action=\"admin.php\" method=\"post\"><b>";
        echo adm_translate("Sélectionner une Catégorie")." : </b>";
        echo "<select class=\"TEXTBOX_STANDARD\" name=\"catid\">";
        echo "<option name=\"catid\" value=\"0\" $sel>".adm_translate("Articles")."</option>";
        while(list($catid, $title) = mysql_fetch_row($selcat)) {
            echo "<option name=\"catid\" value=\"$catid\" $sel>".aff_langue($title)."</option>";
        }
        echo "</select>";
        echo "<input type=\"hidden\" name=\"op\" value=\"EditCategory\">";
        echo " - <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Editer")."\">";
        echo "</form>";
    } else {
        echo "<form action=\"admin.php\" method=\"post\">";
        echo "<b>".adm_translate("Nom : ")."</b> ";
        echo "<input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"title\" size=\"50\" maxlength=\"255\" value=\"$title\"> ";
        echo "<input type=\"hidden\" name=\"catid\" value=\"$catid\">";
        echo "<input type=\"hidden\" name=\"op\" value=\"SaveEditCategory\">";
        echo " - <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Sauver les modifications")."\">";
        echo "</form>";
    }
    CloseTable();
    include("footer.php");
}
function SaveEditCategory($catid, $title) {
    $title = ereg_replace("\"","",$title);
    $check = mysql_num_rows(mysql_query("select catid from stories_cat where title='$title'"));
    if ($check) {
        $what1 = adm_translate("Cette Catégorie existe déjà !");
        $what2 = "[ <a href=\"javascript:history.go(-2)\" class=\"NOIR\">".adm_translate("Retour en arrière, pour changer le Nom")."</a> ]";
    } else {
        $what1 = adm_translate("Catégorie sauvegardée");
        $what2 = "[ <a href=\"admin.php\" class=\"NOIR\">".adm_translate("Retour à l'index d'administration")."</a> ]";
        $result = mysql_query("update stories_cat set title='$title' where catid='$catid'");
        global $aid; Ecr_Log("security", "SaveEditCategory($catid, $title) by AID : $aid", "");
    }
    include ("header.php");
    GraphicAdmin("");
    OpenTable();
    echo "<p align=\"center\"><b>$what1</b><br /><br />";
    echo "$what2</p><br />";
    CloseTable();
    include("footer.php");
}

function DelCategory($cat) {
    include ("header.php");
    GraphicAdmin("");
    OpenTable();
    $result = mysql_query("select title from stories_cat where catid='$cat'");
    list($title) = mysql_fetch_row($result);
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Supprimer une Catégorie");
    echo "</td></tr></table>\n";
    if (!$cat) {
        $selcat = mysql_query("select catid, title from stories_cat");
        echo "<form action=\"admin.php\" method=\"post\">";
        echo "<b>".adm_translate("Sélectionner une Catégorie à supprimer")." : </b>";
        echo "<select class=\"TEXTBOX_STANDARD\" name=\"cat\">";
        while(list($catid, $title) = mysql_fetch_row($selcat)) {
            echo "<option name=\"cat\" value=\"$catid\">".aff_langue($title)."</option>";
        }
        echo "</select>";
        echo "<input type=\"hidden\" name=\"op\" value=\"DelCategory\">";
        echo " - <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Effacer")."\">";
        echo "</form>";
    } else {
        $result2 = mysql_query("select * from stories where catid='$cat'");
        $numrows = mysql_num_rows($result2);
        if ($numrows == 0) {
            mysql_query("delete from stories_cat where catid='$cat'");
            global $aid; Ecr_Log("security", "DelCategory($cat) by AID : $aid", "");
            echo "<p align=\"center\"<br /><b><span class=\"NOIR\">".adm_translate("Suppression effectuée")."</span></b></p><br />";
        } else {
            echo "<span class=\"NOIR\"><br /><b>".adm_translate("Attention : ")."</b> ".adm_translate("la Catégorie")." <b>$title</b> ".adm_translate("a")." <b>$numrows</b> ".adm_translate("Articles !")."<br /><br />";
            echo adm_translate("Vous pouvez supprimer la Catégorie, les Articles et Commentaires")." ";
            echo adm_translate("ou les affecter à une autre Catégorie.")."<br /><br /></span>";
            echo "<p align=\"center\" class=\"NOIR\">".adm_translate("Que voulez-vous faire ?")." - ";
            echo "<b>[ <a href=\"admin.php?op=YesDelCategory&amp;catid=$cat\" class=\"ROUGE\">".adm_translate("Tout supprimer")."</a> | ";
            echo "<a href=\"admin.php?op=NoMoveCategory&amp;catid=$cat\" class=\"NOIR\">".adm_translate("Affecter à une autre Catégorie")."</a> ]</b></p>";
        }
    }
    CloseTable();
    include("footer.php");
}
function YesDelCategory($catid) {
    mysql_query("delete from stories_cat where catid='$catid'");
    $result = mysql_query("select sid from stories where catid='$catid'");
    while(list($sid) = mysql_fetch_row($result)) {
        mysql_query("delete from stories where catid='$catid'");
        mysql_query("delete from comments where sid='$sid'");
    }
    global $aid; Ecr_Log("security", "YesDelCategory($catid) by AID : $aid", "");
    Header("Location: admin.php");
}
function NoMoveCategory($catid, $newcat) {
    include ("header.php");
    GraphicAdmin("");
    OpenTable();
    $result = mysql_query("select title from stories_cat where catid='$catid'");
    list($title) = mysql_fetch_row($result);
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Affectation d'Articles vers une nouvelle Catégorie");
    echo "</td></tr></table>\n";
    if (!$newcat) {
        echo "<br />".adm_translate("Tous les Articles dans")." <b>".aff_langue($title)."</b> ".adm_translate("seront affectés à")."<br /><br />";
        $selcat = mysql_query("select catid, title from stories_cat");
        echo "<form action=\"admin.php\" method=\"post\">";
        echo "<b>".adm_translate("Sélectionner la nouvelle Catégorie : ")."</b> ";
        echo "<select class=\"TEXTBOX_STANDARD\" name=\"newcat\">";
        echo "<option name=\"newcat\" value=\"0\">".adm_translate("Articles")."</option>";
        while(list($newcat, $title) = mysql_fetch_row($selcat)) {
                echo "<option name=\"newcat\" value=\"$newcat\">".aff_langue($title)."</option>";
        }
        echo "</select>";
        echo "<input type=\"hidden\" name=\"catid\" value=\"$catid\">";
        echo "<input type=\"hidden\" name=\"op\" value=\"NoMoveCategory\">";
        echo " - <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Affectation")."\">";
        echo "</form>";
    } else {
        $resultm = mysql_query("select sid from stories where catid='$catid'");
        while(list($sid) = mysql_fetch_row($resultm)) {
            mysql_query("update stories set catid='$newcat' where sid='$sid'");
        }
        mysql_query("delete from stories_cat where catid='$catid'");
        global $aid; Ecr_Log("security", "NoMoveCategory($catid, $newcat) by AID : $aid", "");
        echo "<p align=\"center\"><br /><b class=\"NOIR\">".adm_translate("La ré-affectation est terminée !")."</b></p><br />";
    }
    CloseTable();
    include("footer.php");
}

// NEWS
function displayStory ($qid) {
    global $tipath, $hlpfile, $language, $aid, $radminsuper;
    $hlpfile = "manuels/$language/newarticle.html";

    $result = mysql_query("SELECT qid, uid, uname, subject, story, bodytext, topic, date_debval,date_finval,auto_epur FROM queue where qid='$qid'");
    list($qid, $uid, $uname, $subject, $story, $bodytext, $topic, $date_debval,$date_finval,$epur) = mysql_fetch_row($result);
    mysql_free_result($result);
    $subject = stripslashes($subject);
    $story = stripslashes($story);
    $bodytext = stripslashes($bodytext);

    if ($topic<1) {$topic = 1;}
    $affiche=false;
    $result2=mysql_query("select topictext, topicimage, topicadmin from topics where topicid='$topic'");
    list ($topictext, $topicimage, $topicadmin)=mysql_fetch_row($result2);
    if ($radminsuper) {
       $affiche=true;
    } else {
       $topicadminX=explode(",",$topicadmin);
       for ($i = 0; $i < count($topicadminX); $i++) {
          if (trim($topicadminX[$i])==$aid) $affiche=true;
       }
    }
    if (!$affiche) { header("location: admin.php?op=submissions");}

    include ('header.php');
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Prévisualiser l'Article");
    echo "</td></tr></table>\n";
    echo "<form action=\"admin.php\" method=\"post\" name=\"adminForm\">";
    echo "<p align=\"center\">";
    $rowcolor = tablos();
    echo "<table border=\"0\" width=\"85%\" cellpadding=\"0\" cellspacing=\"1\"><tr $rowcolor><td>";
    $rowcolor = tablos();
    echo "<table width=\"100%\" border=\"0\" cellpadding=\"8\" cellspacing=\"1\"><tr $rowcolor>";
    echo "<td valign=\"top\"><b>".adm_translate("Langue de Prévisualisation")."</b> : ".aff_localzone_langue("local_user_language")."<br /><br />";
    $no_img=false;
    if ((file_exists("$tipath$topicimage")) and ($topicimage!="")) {
       echo "<img src=\"$tipath$topicimage\" border=\"0\" align=\"right\" alt=\"\" />";
    } else {
       $no_img=true;
    }
    code_aff($subject, meta_lang($story), meta_lang($bodytext), "");
    if ($no_img) {
       echo "</td><td width=\"10%\" align=\"center\" valign=\"center\"><b>".aff_langue($topictext)."</b>";
    }
    echo "</td></tr></table></td></tr></table></p><br />";
    opentable2();
    echo "<b>".adm_translate("Utilisateur")."</b> : <input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"author\" size=\"50\" value=\"$uname\">&nbsp;";
    if ($ibid=theme_image("forum/icons/posticon.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/forum/icons/posticon.gif";}
    echo "<a href=\"replypmsg.php?send=".urlencode($uname)."\" target=\"_blank\"><img src=\"$imgtmp\" border=\"0\" alt=\"".adm_translate("Diffusion d'un Message Interne")."\" /></a><br /><br />";

    echo "<b>".adm_translate("Titre")."</b>&nbsp;&nbsp;: <input class=\"TEXTBOX\" type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br />";
    echo "<b>".adm_translate("Sujet")."</b> : <select class=\"TEXTBOX_STANDARD\" name=\"topic\">";
    $toplist = mysql_query("select topicid, topictext, topicadmin from topics order by topictext");
    if ($radminsuper) echo "<option value=\"\">".adm_translate("Tous les Sujets")."</option>\n";
    while(list($topicid, $topics, $topicadmin) = mysql_fetch_row($toplist)) {
       $affiche=false;
       if ($radminsuper) {
          $affiche=true;
       } else {
          $topicadminX=explode(",",$topicadmin);
          for ($i = 0; $i < count($topicadminX); $i++) {
             if (trim($topicadminX[$i])==$aid) $affiche=true;
          }
       }
       if ($affiche) {
          if ($topicid==$topic) { $sel = "selected "; }
          echo "<option $sel value=\"$topicid\">".aff_langue($topics)."</option>\n";
          $sel = "";
       }
    }
    echo "</select>";
    SelectCategory($cat);
    echo "<br />";
    puthome($ihome);
    closetable2();

    echo "<br /><b>".adm_translate("Texte d'introduction")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"hometext\" style=\"width: 100%;\">$story</textarea>";
    echo aff_editeur("hometext", "true");
    echo "<br /><b>".adm_translate("Texte étendu")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"bodytext\" style=\"width: 100%;\">$bodytext</textarea>";
    echo aff_editeur("bodytext", "true");
    echo "<br /><b>".adm_translate("Notes")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"7\" name=\"notes\" style=\"width: 100%;\"></textarea>";
    echo aff_editeur("notes", "true");

    $deb_day=substr($date_debval,8,2);
    $deb_month=substr($date_debval,5,2);
    $deb_year=substr($date_debval,0,4);
    $deb_hour=substr($date_debval,11,2);
    $deb_min=substr($date_debval,14,2);
    //
    $fin_day=substr($date_finval,8,2);
    $fin_month=substr($date_finval,5,2);
    $fin_year=substr($date_finval,0,4);
    $fin_hour=substr($date_finval,11,2);
    $fin_min=substr($date_finval,14,2);
    //
    publication($deb_day,$deb_month,$deb_year,$deb_hour,$deb_min, $fin_day,$fin_month,$fin_year,$fin_hour,$fin_min, $epur);
    echo "<br />
    <input type=\"hidden\" name=\"qid\" value=\"$qid\">
    <input type=\"hidden\" name=\"uid\" value=\"$uid\">
    <select class=\"TEXTBOX_STANDARD\" name=\"op\">
    <option value=\"DeleteStory\">".adm_translate(" Effacer l'Article ")."</option>
    <option value=\"PreviewAgain\" SELECTED>".adm_translate(" Re-prévisualiser ")."</option>
    <option value=\"PostStory\">".adm_translate("Poster un Article ")."</option>
    </select>
    <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Ok")."\">
    </form>";
    closetable();
    include ('footer.php');
}

function previewStory($qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $members, $Mmembers, $deb_day,$deb_month,$deb_year,$deb_hour,$deb_min, $fin_day,$fin_month,$fin_year,$fin_hour,$fin_min,  $epur) {
    global $tipath, $hlpfile, $language, $aid, $radminsuper;
    $hlpfile = "manuels/$language/newarticle.html";
    $subject = stripslashes(str_replace("\"","&quot;",$subject));
    $hometext = stripslashes($hometext);
    $bodytext = stripslashes($bodytext);
    $notes = stripslashes($notes);

    if ($topic<1) {$topic = 1;}
    $affiche=false;
    $result2=mysql_query("select topictext, topicimage, topicadmin from topics where topicid='$topic'");
    list ($topictext, $topicimage, $topicadmin)=mysql_fetch_row($result2);
    if ($radminsuper) {
       $affiche=true;
    } else {
       $topicadminX=explode(",",$topicadmin);
       for ($i = 0; $i < count($topicadminX); $i++) {
          if (trim($topicadminX[$i])==$aid) $affiche=true;
       }
    }
    if (!$affiche) { header("location: admin.php?op=submissions");}

    include ('header.php');
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Prévisualiser l'Article");
    echo "</td></tr></table>\n";
    global $local_user_language;
    echo "<form action=\"admin.php\" method=\"post\" name=\"adminForm\">";
    echo "<p align=\"center\">";
    $rowcolor = tablos();
    echo "<table border=\"0\" width=\"85%\" cellpadding=\"0\" cellspacing=\"1\"><tr $rowcolor><td>";
    $rowcolor = tablos();
    echo "<table width=\"100%\" border=\"0\" cellpadding=\"8\" cellspacing=\"1\"><tr $rowcolor>";
    echo "<td valign=\"top\"><b>".adm_translate("Langue de Prévisualisation")."</b> : ".aff_localzone_langue("local_user_language")."<br /><br />";
    $no_img=false;
    if ((file_exists("$tipath$topicimage")) and ($topicimage!="")) {
       echo "<img src=\"$tipath$topicimage\" border=\"0\" align=\"right\" alt=\"\" />";
    } else {
       $no_img=true;
    }
    code_aff($subject, meta_lang($hometext), meta_lang($bodytext), meta_lang($notes));
    if ($no_img) {
       echo "</td><td width=\"10%\" align=\"center\" valign=\"center\"><b>".aff_langue($topictext)."</b>";
    }
    echo "</td></tr></table></td></tr></table></p><br />";
    opentable2();
    echo "<b>".adm_translate("Utilisateur")."</b> : <input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"author\" size=\"50\" value=\"$author\"><br /><br />";
    echo "<b>".adm_translate("Titre")."</b>&nbsp;&nbsp;: <input class=\"TEXTBOX\" type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br />";
    echo "<b>".adm_translate("Sujet")."</b> : <select class=\"TEXTBOX_STANDARD\" name=\"topic\">";
    $toplist = mysql_query("select topicid, topictext, topicadmin from topics order by topictext");
    if ($radminsuper) echo "<option value=\"\">".adm_translate("Tous les Sujets")."</option>\n";
    while(list($topicid, $topics, $topicadmin) = mysql_fetch_row($toplist)) {
       $affiche=false;
       if ($radminsuper) {
          $affiche=true;
       } else {
          $topicadminX=explode(",",$topicadmin);
          for ($i = 0; $i < count($topicadminX); $i++) {
             if (trim($topicadminX[$i])==$aid) $affiche=true;
          }
       }
       if ($affiche) {
          if ($topicid==$topic) { $sel = "selected "; }
          echo "<option $sel value=\"$topicid\">".aff_langue($topics)."</option>\n";
          $sel = "";
       }
    }
    echo "</select>";
    SelectCategory($catid);
    echo "<br />";
    if (($members==1) and ($Mmembers=="")) {$ihome="-127";}
    if (($members==1) and (($Mmembers>1) and ($Mmembers<=127))) {$ihome=$Mmembers;}
    puthome($ihome);
    closetable2();

    echo "<br /><b>".adm_translate("Texte d'introduction")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"hometext\" style=\"width: 100%;\">$hometext</textarea>";
    echo aff_editeur("hometext", "true");
    echo "<br /><b>".adm_translate("Texte étendu")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"bodytext\" style=\"width: 100%;\">$bodytext</textarea>";
    echo aff_editeur("bodytext", "true");
    echo "<br /><b>".adm_translate("Notes")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"7\" name=\"notes\" style=\"width: 100%;\">$notes</textarea>";
    echo aff_editeur("notes", "true");

    publication($deb_day,$deb_month,$deb_year,$deb_hour,$deb_min, $fin_day,$fin_month,$fin_year,$fin_hour,$fin_min, $epur);
    echo "<input type=\"hidden\" name=\"qid\" value=\"$qid\">
    <input type=\"hidden\" name=\"uid\" value=\"$uid\">
    <br /><select class=\"TEXTBOX_STANDARD\" name=\"op\">
    <option value=\"DeleteStory\">".adm_translate(" Effacer l'Article ")."</option>
    <option value=\"PreviewAgain\" SELECTED>".adm_translate(" Re-prévisualiser ")."</option>
    <option value=\"PostStory\">".adm_translate("Poster un Article ")."</option>
    </select>
    <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Ok")."\"></form>";
    closetable();
    include ('footer.php');
}

function postStory($type_pub, $qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $members, $Mmembers, $date_debval,$date_finval,$epur) {
    global $aid, $ultramode;
    if ($uid == 1) $author = "";
    if ($hometext == $bodytext) $bodytext = "";
    $subject = stripslashes(FixQuotes(str_replace("\"","&quot;",$subject)));
    $hometext = stripslashes(FixQuotes($hometext));
    $bodytext = stripslashes(FixQuotes($bodytext));
    $notes = stripslashes(FixQuotes($notes));
    if (($members==1) and ($Mmembers=="")) {$ihome="-127";}
    if (($members==1) and (($Mmembers>1) and ($Mmembers<=127))) {$ihome=$Mmembers;}
    $upload=false;
    include("modules/upload/upload_f.php");
    if ($Xstring=prepa_upload("",$hometext)) {$hometext=$Xstring[0];$Xname=$Xstring[1];$upload=true;}
    if ($Xstring=prepa_upload($Xname,$bodytext)) {$bodytext=$Xstring[0];$Xname=$Xstring[1];$upload=true;}
    if ($Xstring=prepa_upload($Xname,$notes)) {$notes=$Xstring[0];$Xname=$Xstring[1];$upload=true;}
    if ($upload) {
       global $pdst; $pdst="1";
       include ('header.php');
       win_upload($Xname);
       opentable();
       $subject="!urlencode!".urlencode($subject);
       $hometext=urlencode($hometext);
       $bodytext=urlencode($bodytext);
       $notes=urlencode($notes);
       echo "<br /><form action=\"admin.php\" method=\"post\" name=\"adminForm\">";
       echo "<b>".translate("Submission in progress. After Uploading your files, please click on the OK button to finish.")."</b>";
       echo "<input type=\"hidden\" name=\"qid\" value=\"$qid\">";
       echo "<input type=\"hidden\" name=\"uid\" value=\"$uid\">";
       echo "<input type=\"hidden\" name=\"author\" value=\"$author\">";
       echo "<input type=\"hidden\" name=\"subject\" value=\"$subject\">";
       echo "<input type=\"hidden\" name=\"hometext\" value=\"$hometext\">";
       echo "<input type=\"hidden\" name=\"bodytext\" value=\"$bodytext\">";
       echo "<input type=\"hidden\" name=\"topic\" value=\"$topic\">";
       echo "<input type=\"hidden\" name=\"notes\" value=\"$notes\">";
       echo "<input type=\"hidden\" name=\"catid\" value=\"$catid\">";
       echo "<input type=\"hidden\" name=\"ihome\" value=\"$ihome\">";
       echo "<input type=\"hidden\" name=\"members\" value=\"$members\">";
       echo "<input type=\"hidden\" name=\"Mmembers\" value=\"$Mmembers\">";
       echo "<input type=\"hidden\" name=\"date_debval\" value=\"$date_debval\">";
       echo "<input type=\"hidden\" name=\"date_finval\" value=\"$date_finval\">";
       echo "<input type=\"hidden\" name=\"epur\" value=\"$epur\">";
       echo "<input type=\"hidden\" name=\"op\" value=\"PostStory\">";
       echo "<br /><br /><p align=\"center\"><input class=\"BOUTON_STANDARD\" type=\"submit\" name=\"xop\" value=\"Ok\">&nbsp;&nbsp;<a href=\"javascript: history.go(-1)\" class=\"NOIR\">[ ".adm_translate("Retour en arrière")." ]</a></p>";
       echo "</form>";
       closetable();
       include ('footer.php');
    } else {
       if (substr($subject,0,11)=="!urlencode!") {
          $subject=str_replace("!urlencode!","",urldecode($subject));
          $hometext=urldecode($hometext);
          $bodytext=urldecode($bodytext);
          $notes=urldecode($notes);
       }
       if ($type_pub=="pub_immediate") {
          $result = mysql_query("insert into stories values (NULL, '$catid', '$aid', '$subject', now(), '$hometext', '$bodytext', '0', '0', '$topic','$author', '$notes', '$ihome', '0', '$date_finval','$epur')");
       } else {
          $result = mysql_query("insert into autonews values (NULL, '$catid', '$aid', '$subject', now(), '$hometext', '$bodytext', '$topic', '$author', '$notes', '$ihome','$date_debval','$date_finval','$epur')");
       }
       if (($uid!=1) and ($uid!="")) {
          mysql_query("update users set counter=counter+1 where uid='$uid'");
       }
       mysql_query("update authors set counter=counter+1 where aid='$aid'");
       if ($ultramode) {
          ultramode();
       }
       deleteStory($qid);

       if ($type_pub=="pub_immediate") {
          global $subscribe;
          if ($subscribe) {
             subscribe_mail("topic",$topic,"",$subject,"");
          }
          // Cluster Paradise
          if (file_exists("modules/cluster-paradise/cluster-activate.php")) {include ("modules/cluster-paradise/cluster-activate.php");}
          if (file_exists("modules/cluster-paradise/cluster-M.php")) {include ("modules/cluster-paradise/cluster-M.php");}
          // Cluster Paradise
       }
       redirect_url("admin.php?op=submissions");
    }
}

function editStory ($sid) {
    if (($sid=="") or ($sid=="0")) {
       header("location: admin.php");
    }
    global $tipath, $hlpfile, $language, $aid, $radminsuper;
    $hlpfile = "manuels/$language/newarticle.html";

    $result = mysql_query("SELECT catid, title, hometext, bodytext, topic, notes, ihome, date_finval,auto_epur FROM stories where sid='$sid'");
    list($catid, $subject, $hometext, $bodytext, $topic, $notes, $ihome, $date_finval,$epur) = mysql_fetch_row($result);
    $subject = stripslashes($subject);
    $hometext = stripslashes($hometext);
    if ($ibid=theme_image("pick.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/pick.gif";}
    $hometext=str_replace("<img src=\"".$imgtmp."\" border=\"0\" align=\"middle\" alt=\"\" /> :: ","",$hometext);
    $bodytext = stripslashes($bodytext);
    $notes = stripslashes($notes);

    $affiche=false;
    $result2=mysql_query("select topictext, topicimage, topicadmin from topics where topicid='$topic'");
    list ($topictext, $topicimage, $topicadmin)=mysql_fetch_row($result2);
    if ($radminsuper) {
       $affiche=true;
    } else {
       $topicadminX=explode(",",$topicadmin);
       for ($i = 0; $i < count($topicadminX); $i++) {
          if (trim($topicadminX[$i])==$aid) $affiche=true;
       }
    }
    if (!$affiche) { header("location: admin.php");}

    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 un Article");
    echo "</td></tr></table><br />\n";
    $result=mysql_query("select topictext, topicimage from topics where topicid='$topic'");
    list($topictext, $topicimage) = mysql_fetch_row($result);

    echo "<p align=\"center\">";
    $rowcolor = tablos();
    echo "<table border=\"0\" width=\"85%\" cellpadding=\"0\" cellspacing=\"1\"><tr $rowcolor><td>";
    $rowcolor = tablos();
    echo "<table width=\"100%\" border=\"0\" cellpadding=\"8\" cellspacing=\"1\"><tr $rowcolor>";
    echo "<td valign=\"top\"><b>".aff_local_langue("<b>".adm_translate("Langue de Prévisualisation")."</b> : ","","local_user_language");
    $no_img=false;
    if ((file_exists("$tipath$topicimage")) and ($topicimage!="")) {
       echo "<img src=\"$tipath$topicimage\" border=\"0\" align=\"right\" alt=\"\" />";
    } else {
       $no_img=true;
    }
    global $local_user_language;
    code_aff($subject, $hometext, $bodytext, $notes);
    if ($no_img) {
       echo "</td><td width=\"10%\" align=\"center\" valign=\"center\"><b>".aff_langue($topictext)."</b>";
    }
    echo "</td></tr></table></td></tr></table></p><br />";

    echo "<form action=\"admin.php\" method=\"post\" name=\"adminForm\">";
    opentable2();
    echo "<b>".adm_translate("Titre")."</b>&nbsp;&nbsp;: <input class=\"TEXTBOX\" type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br />";
    echo "<b>".adm_translate("Sujet")."</b> : <select class=\"TEXTBOX_STANDARD\" name=\"topic\">";
    $toplist = mysql_query("select topicid, topictext, topicadmin from topics order by topictext");
    if ($radminsuper) echo "<option value=\"\">".adm_translate("Tous les Sujets")."</option>\n";
    while(list($topicid, $topics, $topicadmin) = mysql_fetch_row($toplist)) {
       $affiche=false;
       if ($radminsuper) {
          $affiche=true;
       } else {
          $topicadminX=explode(",",$topicadmin);
          for ($i = 0; $i < count($topicadminX); $i++) {
             if (trim($topicadminX[$i])==$aid) $affiche=true;
          }
       }
       if ($affiche) {
          if ($topicid==$topic) { $sel = "selected "; }
          echo "<option value=\"$topicid\" $sel>".aff_langue($topics)."</option>\n";
          $sel = "";
       }
    }
    echo "</select>";
    SelectCategory($catid);
    echo "<br />";
    puthome($ihome);
    closetable2();

    echo "<br /><b>".adm_translate("Texte d'introduction")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"hometext\" style=\"width: 100%;\">$hometext</textarea>";
    echo aff_editeur("hometext", "true");
    echo "<br /><b>".adm_translate("Texte complet")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"bodytext\" style=\"width: 100%;\">$bodytext</textarea>";
    echo aff_editeur("bodytext", "true");
    echo "<br /><b>".adm_translate("Notes")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"7\" name=\"notes\" style=\"width: 100%;\">$notes</textarea>";
    echo aff_editeur("notes", "true");

    echo "<br /><b>".adm_translate("Changer la date ? : ")."</b> ".adm_translate("Oui")." <input type=\"checkbox\" name=\"Cdate\" value=\"true\"> - ";
    echo "<b>".adm_translate("Remettre cet article en première position ? : ")."</b> ".adm_translate("Oui")." <input type=\"checkbox\" name=\"Csid\" value=\"true\"><br /><br />";

    if ($date_finval!="") {
       $fin_day=substr($date_finval,8,2);
       $fin_month=substr($date_finval,5,2);
       $fin_year=substr($date_finval,0,4);
       $fin_hour=substr($date_finval,11,2);
       $fin_min=substr($date_finval,14,2);
    } else {
       $fin_day="01";
       $fin_month="01";
       $fin_year=date("Y")+99;
       $fin_hour="00";
       $fin_min="00";
    }
    publication(-1,-1,-1,-1,-1, $fin_day,$fin_month,$fin_year,$fin_hour,$fin_min, $epur);
    global $theme;
    echo "<br /><input type=\"hidden\" name=\"sid\" value=\"$sid\">
    <input type=\"hidden\" name=\"op\" value=\"ChangeStory\">
    <input type=\"hidden\" name=\"theme\" value=\"$theme\">
    <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate(" Modifier l'Article")."\">
    </form>";
    closetable();
    include ('footer.php');
}

function deleteStory($qid) {
   $result=mysql_query("delete from queue where qid='$qid'");
   global $aid; Ecr_Log("security", "deleteStory($qid) by AID : $aid", "");
}

function removeStory ($sid, $ok=0) {
    if (($sid=="") or ($sid=="0")) {
       header("location: admin.php");
    }
    global $ultramode, $aid, $radminsuper;
    $result=mysql_query("select topic from stories where sid='$sid'");
    list($topic)=mysql_fetch_row($result);
    $affiche=false;
    $result2=mysql_query("select topicadmin from topics where topicid='$topic'");
    list ($topicadmin, $topicname)=mysql_fetch_row($result2);
    if ($radminsuper) {
       $affiche=true;
    } else {
       $topicadminX=explode(",",$topicadmin);
       for ($i = 0; $i < count($topicadminX); $i++) {
          if (trim($topicadminX[$i])==$aid) $affiche=true;
       }
    }
    if (!$affiche) { header("location: admin.php");}

    if ($ok) {
       mysql_query("DELETE FROM stories where sid='$sid'");
       mysql_query("DELETE FROM comments where sid='$sid'");
       global $aid; Ecr_Log("security", "removeStory ($sid, $ok) by AID : $aid", "");
       if ($ultramode) {
          ultramode();
       }
       Header("Location: admin.php");
    } else {
       global $hlpfile, $language;
       $hlpfile = "manuels/$language/newarticle.html";
       include ('header.php');
       GraphicAdmin($hlpfile);
       opentable();
       echo "<p align=\"center\"><span class=\"ROUGE\">".adm_translate("Etes-vous sûr de vouloir effacer l'Article N°")." $sid ".adm_translate("et tous ses Commentaires ?")."</span>";
       echo "<br /><br />[ <a href=\"admin.php?op=RemoveStory&amp;sid=$sid&amp;ok=1\" class=\"ROUGE\">".adm_translate("Oui")."</a> | <a href=\"admin.php\" class=\"NOIR\">".adm_translate("Non")."</a> ]</p><br />";
       closetable();
       include("footer.php");
    }
}

function changeStory($sid, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $members, $Mmembers, $Cdate, $Csid, $date_finval,$epur,$theme) {
    global $aid, $ultramode;
    $subject = stripslashes(FixQuotes(str_replace("\"","&quot;",$subject)));
    $hometext = stripslashes(FixQuotes($hometext));
    $bodytext = stripslashes(FixQuotes($bodytext));
    $notes = stripslashes(FixQuotes($notes));
    if (($members==1) and ($Mmembers=="")) {$ihome="-127";}
    if (($members==1) and (($Mmembers>1) and ($Mmembers<=127))) {$ihome=$Mmembers;}
    $upload=false;
    include("modules/upload/upload_f.php");
    if ($Xstring=prepa_upload("",$hometext)) {$hometext=$Xstring[0];$Xname=$Xstring[1];$upload=true;}
    if ($Xstring=prepa_upload($Xname,$bodytext)) {$bodytext=$Xstring[0];$Xname=$Xstring[1];$upload=true;}
    if ($Xstring=prepa_upload($Xname,$notes)) {$notes=$Xstring[0];$Xname=$Xstring[1];$upload=true;}
    if ($upload) {
       global $pdst; $pdst="1";
       include ('header.php');
       win_upload($Xname);
       opentable();
       $subject="!urlencode!".urlencode($subject);
       $hometext=urlencode($hometext);
       $bodytext=urlencode($bodytext);
       $notes=urlencode($notes);
       echo "<br /><form action=\"admin.php\" method=\"post\" name=\"adminForm\">";
       echo "<b>".translate("Submission in progress. After Uploading your files, please click on the OK button to finish.")."</b>";
       echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\">";
       echo "<input type=\"hidden\" name=\"subject\" value=\"$subject\">";
       echo "<input type=\"hidden\" name=\"hometext\" value=\"$hometext\">";
       echo "<input type=\"hidden\" name=\"bodytext\" value=\"$bodytext\">";
       echo "<input type=\"hidden\" name=\"topic\" value=\"$topic\">";
       echo "<input type=\"hidden\" name=\"notes\" value=\"$notes\">";
       echo "<input type=\"hidden\" name=\"catid\" value=\"$catid\">";
       echo "<input type=\"hidden\" name=\"ihome\" value=\"$ihome\">";
       echo "<input type=\"hidden\" name=\"members\" value=\"$members\">";
       echo "<input type=\"hidden\" name=\"Mmembers\" value=\"$Mmembers\">";
       echo "<input type=\"hidden\" name=\"Cdate\" value=\"$Cdate\">";
       echo "<input type=\"hidden\" name=\"Csid\" value=\"$Csid\">";
       echo "<input type=\"hidden\" name=\"date_finval\" value=\"$date_finval\">";
       echo "<input type=\"hidden\" name=\"epur\" value=\"$epur\">";
       echo "<input type=\"hidden\" name=\"op\" value=\"ChangeStory\">";
       echo "<br /><br /><p align=\"center\"><input class=\"BOUTON_STANDARD\" type=\"submit\" name=\"xop\" value=\"Ok\">&nbsp;&nbsp;<a href=\"javascript: history.go(-1)\" class=\"NOIR\">[ ".adm_translate("Retour en arrière")." ]</a></p>";
       echo "</form>";
       closetable();
       include ('footer.php');
    } else {
       if (substr($subject,0,11)=="!urlencode!") {
          $subject=str_replace("!urlencode!","",urldecode($subject));
          $hometext=urldecode($hometext);
          $bodytext=urldecode($bodytext);
          $notes=urldecode($notes);
       }
       if ($Cdate) {
          mysql_query("update stories set catid='$catid', title='$subject', hometext='$hometext', bodytext='$bodytext', topic='$topic', notes='$notes', ihome='$ihome',time=now(), date_finval='$date_finval', auto_epur='$epur', archive='0' where sid='$sid'");
       } else {
          mysql_query("update stories set catid='$catid', title='$subject', hometext='$hometext', bodytext='$bodytext', topic='$topic', notes='$notes', ihome='$ihome', date_finval='$date_finval', auto_epur='$epur' where sid='$sid'");
       }
       if ($Csid) {
          if ($ibid=theme_image("pick.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/pick.gif";}
          mysql_query("update stories set hometext='<img src=\"".$imgtmp."\" border=\"0\" align=\"middle\" alt=\"\" /> :: $hometext' where sid='$sid'");
          list($Lsid)=mysql_fetch_row(mysql_query("select sid from stories order by sid Desc"));
          $Lsid++;
          mysql_query("update stories set sid='$Lsid' where sid='$sid'");
          mysql_query("update comments set sid='$Lsid' where sid='$sid'");
          $sid=$Lsid;
       }
       global $aid; Ecr_Log("security", "changeStory($sid, $subject, hometext..., bodytext..., $topic, notes..., $catid, $ihome, $members, $Mmembers, $Cdate, $Csid, $date_finval,$epur,$theme) by AID : $aid", "");
       if ($ultramode) {
          ultramode();
       }
       // Cluster Paradise
       if (file_exists("modules/cluster-paradise/cluster-activate.php")) {include ("modules/cluster-paradise/cluster-activate.php");}
       if (file_exists("modules/cluster-paradise/cluster-M.php")) {include ("modules/cluster-paradise/cluster-M.php");}
       // Cluster Paradise
       redirect_url("admin.php?op=EditStory&sid=$sid");
    }
}

function adminStory() {
    global $hlpfile, $language, $aid, $radminsuper;
    $hlpfile = "manuels/$language/newarticle.html";
    include ('header.php');
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Nouvel Article");
    echo "</td></tr></table>\n";
    echo "<br />";
    echo "<form action=\"admin.php\" method=\"post\" name=\"adminForm\">";
    opentable2();
    echo "<b>".adm_translate("Titre")."</b>&nbsp;&nbsp;: <input class=\"TEXTBOX\" type=\"text\" name=\"subject\" size=\"50\" value=\"\"><br />";
    echo "<b>".adm_translate("Sujet")."</b> : <select class=\"TEXTBOX_STANDARD\" name=\"topic\">";
    $toplist = mysql_query("select topicid, topictext, topicadmin from topics order by topictext");
    if ($radminsuper) echo "<option value=\"\">".adm_translate("Sélectionner un Sujet")."</option>\n";
    while(list($topicid, $topics, $topicadmin) = mysql_fetch_row($toplist)) {
       $affiche=false;
       if ($radminsuper) {
          $affiche=true;
       } else {
          $topicadminX=explode(",",$topicadmin);
          for ($i = 0; $i < count($topicadminX); $i++) {
             if (trim($topicadminX[$i])==$aid) $affiche=true;
          }
       }
       if ($affiche) {
          if ($topicid==$topic) { $sel = "selected "; }
          echo "<option $sel value=\"$topicid\">".aff_langue($topics)."</option>\n";
          $sel = "";
       }
    }
    echo "</select>";
    echo "&nbsp;";
    $cat = 0;
    SelectCategory($cat);
    echo "<br />";
    puthome($ihome);
    closetable2();

    echo "<br /><b>".adm_translate("Texte d'introduction")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"hometext\" style=\"width: 100%;\">$hometext</textarea>";
    echo aff_editeur("hometext", "true");
    echo "<br /><b>".adm_translate("Texte étendu")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"bodytext\" style=\"width: 100%;\">$bodytext</textarea>";
    echo aff_editeur("bodytext", "true");

    publication($deb_day,$deb_month,$deb_year,$deb_hour,$deb_min, $fin_day,$fin_month,$fin_year,$fin_hour,$fin_min, $epur);
    echo "<input type=\"hidden\" name=\"author\" value=\"$aid\">";
    echo "<br /><input type=\"hidden\" name=\"op\" value=\"PreviewAdminStory\">
    <input class=\"BOUTON_STANDARD\" type=\"submit\" name=\"submit\" value=\"".adm_translate("Prévisualiser")."\">
    </form>";
    closetable();
    include ('footer.php');
}

function previewAdminStory($subject, $hometext, $bodytext, $topic, $catid, $ihome, $members, $Mmembers, $deb_day,$deb_month,$deb_year,$deb_hour,$deb_min, $fin_day,$fin_month,$fin_year,$fin_hour,$fin_min,  $epur) {
    global $tipath, $hlpfile, $language, $aid, $radminsuper;
    $hlpfile = "manuels/$language/newarticle.html";
    $subject = stripslashes(str_replace("\"","&quot;",$subject));
    $hometext = stripslashes($hometext);
    $bodytext = stripslashes($bodytext);

    if ($topic<1) {$topic = 1;}
    $affiche=false;
    $result2=mysql_query("select topictext, topicimage, topicadmin from topics where topicid='$topic'");
    list ($topictext, $topicimage, $topicadmin)=mysql_fetch_row($result2);
    if ($radminsuper) {
       $affiche=true;
    } else {
       $topicadminX=explode(",",$topicadmin);
       for ($i = 0; $i < count($topicadminX); $i++) {
          if (trim($topicadminX[$i])==$aid) $affiche=true;
       }
    }
    if (!$affiche) { header("location: admin.php");}

    include ('header.php');
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo adm_translate("Prévisualiser l'Article");
    echo "</td></tr></table><br />\n";
    global $local_user_language;
    echo "<form action=\"admin.php\" method=\"post\" name=\"adminForm\">";
    echo "<p align=\"center\">";
    $rowcolor = tablos();
    echo "<table border=\"0\" width=\"85%\" cellpadding=\"0\" cellspacing=\"1\"><tr $rowcolor><td>";
    $rowcolor = tablos();
    echo "<table width=\"100%\" border=\"0\" cellpadding=\"8\" cellspacing=\"1\"><tr $rowcolor>";
    echo "<td valign=\"top\"><b>".adm_translate("Langue de Prévisualisation")."</b> : ".aff_localzone_langue("local_user_language")."<br /><br />";
    $no_img=false;
    $no_img=false;
    if ((file_exists("$tipath$topicimage")) and ($topicimage!="")) {
       echo "<img src=\"$tipath$topicimage\" border=\"0\" align=\"right\" alt=\"\" />";
    } else {
       $no_img=true;
    }
    code_aff($subject, $hometext, $bodytext, "");
    if ($no_img) {
       echo "</td><td width=\"10%\" align=\"center\" valign=\"center\"><b>".aff_langue($topictext)."</b>";
    }
    echo "</td></tr></table></td></tr></table></p><br />";
    opentable2();
    echo "<b>".adm_translate("Titre")."</b>&nbsp;&nbsp;: <input class=\"TEXTBOX\" type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br />";
    echo "<b>".adm_translate("Sujet")."</b> : <select class=\"TEXTBOX_STANDARD\" name=\"topic\">";
    $toplist = mysql_query("select topicid, topictext, topicadmin from topics order by topictext");
    if ($radminsuper) echo "<option value=\"\">".adm_translate("Tous les Sujets")."</option>\n";
    while(list($topicid, $topics, $topicadmin) = mysql_fetch_row($toplist)) {
       $affiche=false;
       if ($radminsuper) {
          $affiche=true;
       } else {
          $topicadminX=explode(",",$topicadmin);
          for ($i = 0; $i < count($topicadminX); $i++) {
             if (trim($topicadminX[$i])==$aid) $affiche=true;
          }
       }
       if ($affiche) {
          if ($topicid==$topic) { $sel = "selected "; }
          echo "<option $sel value=\"$topicid\">".aff_langue($topics)."</option>\n";
          $sel = "";
       }
    }
    echo "</select>";
    $cat = $catid;
    SelectCategory($catid);
    echo "<br />";
    if (($members==1) and ($Mmembers=="")) {$ihome="-127";}
    if (($members==1) and (($Mmembers>1) and ($Mmembers<=127))) {$ihome=$Mmembers;}
    puthome($ihome);
    closetable2();

    echo "<br /><b>".adm_translate("Texte d'introduction")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"hometext\" style=\"width: 100%;\">$hometext</textarea>";
    echo aff_editeur("hometext", "true");
    echo "<br /><b>".adm_translate("Texte étendu")."</b> :<br />
    <textarea class=\"textbox\" wrap=\"virtual\" cols=\"70\" rows=\"25\" name=\"bodytext\" style=\"width: 100%;\">$bodytext</textarea>";
    echo aff_editeur("bodytext", "true");

    publication($deb_day,$deb_month,$deb_year,$deb_hour,$deb_min, $fin_day,$fin_month,$fin_year,$fin_hour,$fin_min, $epur);
    echo "<input type=\"hidden\" name=\"author\" value=\"$aid\">";
    echo "<br /><select class=\"TEXTBOX_STANDARD\" name=\"op\">
    <option value=\"PreviewAdminStory\" selected>".adm_translate("Prévisualiser")."</option>
    <option value=\"PostStory\">".adm_translate("Poster un Article Admin")."</option>
    </select> -
    <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Ok")."\">";
    closetable();
    include ('footer.php');
}

switch($op) {
   case "EditCategory":
        EditCategory($catid);
        break;
   case "DelCategory":
        DelCategory($cat);
        break;
   case "YesDelCategory":
        YesDelCategory($catid);
        break;
   case "NoMoveCategory":
        NoMoveCategory($catid, $newcat);
        break;
   case "SaveEditCategory":
        SaveEditCategory($catid, $title);
        break;
   case "AddCategory":
        AddCategory();
        break;
   case "SaveCategory":
        SaveCategory($title);
        break;

   case "DisplayStory":
        displayStory($qid);
        break;
   case "PreviewAgain":
        previewStory($qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $members, $Mmembers, $deb_day,$deb_month,$deb_year,$deb_hour,$deb_min, $fin_day,$fin_month,$fin_year,$fin_hour,$fin_min,  $epur);
        break;
   case "PostStory":
        if (!$date_debval) {
           if (strlen($deb_day)==1) {
              $deb_day = "0$deb_day";
           }
           if (strlen($deb_month)==1) {
              $deb_month = "0$deb_month";
           }
           $date_debval = "$deb_year-$deb_month-$deb_day $deb_hour:$deb_min:00";
        }
        if (!$date_finval) {
           if (strlen($fin_day)==1) {
              $fin_day = "0$fin_day";
           }
           if (strlen($fin_month)==1) {
              $fin_month = "0$fin_month";
           }
           $date_finval = "$fin_year-$fin_month-$fin_day $fin_hour:$fin_min:00";
        }
        if ($date_finval<$date_debval) {
           $date_finval = $date_debval;
        }
        $temp_new=mktime(substr($date_debval,11,2), substr($date_debval,14,2),0,substr($date_debval,5,2),substr($date_debval,8,2),substr($date_debval,0,4));
        $temp=time();
        if ($temp>$temp_new) {
           postStory("pub_immediate",$qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $members, $Mmembers, $date_debval,$date_finval,$epur);
        } else {
           postStory("pub_automated",$qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $members, $Mmembers, $date_debval,$date_finval,$epur);
        }
        break;

   case "DeleteStory":
        deleteStory($qid);
        Header("Location: admin.php?op=submissions");
        break;

   case "EditStory":
        editStory($sid);
        break;
   case "ChangeStory":
        if (!$date_finval) {
           if (strlen($fin_day)==1) {
              $fin_day = "0$fin_day";
           }
           if (strlen($fin_month)==1) {
              $fin_month = "0$fin_month";
           }
           $date_finval = "$fin_year-$fin_month-$fin_day $fin_hour:$fin_min:00";
        }
        changeStory($sid, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $members, $Mmembers, $Cdate, $Csid, $date_finval,$epur, $theme);
        break;
   case "RemoveStory":
        removeStory($sid, $ok);
        break;

   case "adminStory":
        adminStory();
        break;
   case "PreviewAdminStory":
        previewAdminStory($subject, $hometext, $bodytext, $topic, $catid, $ihome, $members, $Mmembers, $deb_day,$deb_month,$deb_year,$deb_hour,$deb_min, $fin_day,$fin_month,$fin_year,$fin_hour,$fin_min,  $epur);
        break;
}
?>