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

function groupe($groupe) {
   $les_groupes=split(",",$groupe);
   $mX=liste_group();
   $nbg=0; $str="";
   while (list($groupe_id, $groupe_name)=each($mX)) {
      $selectionne=0;
      if ($les_groupes) {
         foreach ($les_groupes as $groupevalue) {
            if (($groupe_id==$groupevalue) and ($groupe_id!=0)) {$selectionne=1;}
         }
      }
      if ($selectionne==1) {
         $str.="<option value=\"$groupe_id\" selected>$groupe_name</option>";
      } else {
         $str.="<option value=\"$groupe_id\">$groupe_name</option>";
      }
      $nbg++;
   }
   if ($nbg>5) {$nbg=5;}
   return ("<select class=\"TEXTBOX_STANDARD\" name=\"Mmember[]\" multiple size=\"$nbg\" style=\"top: -4;\">".$str."</select>");
}

function droits_bloc($member) {
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td align=\"left\" valign=\"top\" width=\"10%\" nowrap=\"nowrap\">";
   echo "<span class=\"ROUGE\">".adm_translate("Administrateurs")."</span> :";
   if ($member==-127) {$checked=" checked";} else {$checked="";}
   echo "<input type=\"radio\" name=\"members\" value=\"-127\"$checked></td><td align=\"center\" valign=\"top\" width=\"10%\" nowrap=\"nowrap\">";
   echo "<span class=\"ROUGE\">".adm_translate("Anonymes")."</span> :";
   if ($member==-1) {$checked=" checked";} else {$checked="";}
   echo "<input type=\"radio\" name=\"members\" value=\"-1\"$checked></td><td align=\"right\" valign=\"top\" width=\"15%\" nowrap=\"nowrap\">";
   echo "<span class=\"ROUGE\">".adm_translate("Membres")."</span> :";
   if ($member>0) {
      echo "<input type=\"radio\" name=\"members\" value=\"1\" checked>&nbsp;&nbsp;<b>=> ".adm_translate("Groupes")." :&nbsp;&nbsp;</b>";
      echo "</td><td align=\"left\" valign=\"top\" width=\"15%\">";
      echo groupe($member);
      echo "</td><td align=\"left\" valign=\"top\" width=\"10%\">";
      echo "<input type=\"radio\" name=\"members\" value=\"0\"><b>".adm_translate("Tous")."</b></td></tr></table>";
   } else {
      if ($member==0) {$checked=" checked";} else {$checked="";}
      echo "<input type=\"radio\" name=\"members\" value=\"1\">&nbsp;&nbsp;<b>=> ".adm_translate("Groupes")." :&nbsp;&nbsp;</b>";
      echo "</td><td align=\"left\" valign=\"top\" width=\"15%\">";
      echo groupe($member);
      echo "</td><td align=\"left\" valign=\"top\" width=\"10%\">";
      echo "<input type=\"radio\" name=\"members\" value=\"0\"$checked><b>".adm_translate("Tous")."</b></td></tr></table>";
   }
}

function blocks() {
  global $hlpfile, $radminleft, $radminright, $radminsuper;
  include("header.php");
  include_once ("lib/togglediv.class.php");
  GraphicAdmin($hlpfile);
  OpenTable();

  if (($radminleft==1) or ($radminsuper==1)) {
   echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
   echo adm_translate("Edition des Blocs de gauche");
   echo "</td></tr></table>\n";
   $result = mysql_query("select id, title, content, member, Lindex, cache, actif, aide from lblocks order by Lindex ASC");
   $num_row=mysql_num_rows($result);
   $toggle = new ToggleDiv($num_row);
   if ($num_row>0) {
      echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
      echo "<tr><td width=\"65%\" class=\"ONGL\" align=\"left\">".adm_translate("Titre :")."</td><td width=\"10%\" class=\"ONGL\" align=\"right\">".adm_translate("Actif(s)")." :</td><td  width=\"10%\" class=\"ONGL\" align=\"right\">Index :</td><td width=\"10%\" class=\"ONGL\" align=\"right\"><span style=\"font-size: 10px;\">".adm_translate("rétention en secondes")."</span> :</td><td width=\"5%\" class=\"ONGL\" align=\"right\"> ID :</td></tr>";
      while (list($id, $title, $content, $member, $Lindex, $Scache, $Sactif, $BLaide) = mysql_fetch_array($result)) {
         $rowcolor = tablos();
         $funct="";
         if ($title=="") {
            $title=adm_translate("Sans nom");
            $pos_func=strpos($content,"function#");
            $pos_nl=strpos($content,chr(13),$pos_func);
            if ($pos_func!==false) {
               $funct="<span style=\"font-size: 10px;\"> (";
               if ($pos_nl!==false)
                  $funct.=substr($content,$pos_func, $pos_nl-$pos_func);
               else
                  $funct.=substr($content,$pos_func);
               $funct.=")</span>";
            }
         }
         echo "<tr $rowcolor><td align=\"left\">";
         echo $toggle->Img();
         echo aff_langue($title)."".$funct."</td>";
         if ($Sactif)
            echo "<td class=\"NOIR\" align=\"right\">".adm_translate("Oui")."</td>";
         else
            echo "<td class=\"ROUGE\" align=\"right\">".adm_translate("Non")."</td>";
         echo "<td align=\"right\">$Lindex</td><td align=\"right\">$Scache</td>";
         echo "<td align=\"right\">$id</td></tr>";

         echo "<tr><td colspan=\"5\">";
         echo $toggle->Begin();
         echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr $rowcolor><td>
         <table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><form action=\"admin.php\" method=\"post\">\n";
         echo "<tr $rowcolor><td nowrap=\"nowrap\" width=\"65%\">\n";
         echo "<b>".adm_translate("Titre :")."</b><br />";
         echo "<input class=\"textbox\" type=\"text\" name=\"title\" size=\"30\" maxlength=\"255\" value=\"$title\"><br /><b>Index :</b><br />";
         echo "<input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"Lindex\" size=\"5\" maxlength=\"4\" value=\"$Lindex\"></td><td valign=\"top\" rowspan=\"2\"><b>";
         echo adm_translate("rétention en secondes")." :</b><br /><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"Scache\" size=\"6\" maxlength=\"5\" value=\"$Scache\"><br />".adm_translate("Chaque bloc peut utiliser SuperCache.<br />La valeur du délai de rétention <b>0</b> indique que le bloc ne sera <b>pas caché</b> (obligatoire pour le bloc function#adminblock).")."<br /><br />";

         echo "<a href=\"javascript:void(0);\" onclick=\"window.open('admin/docu.php?op=blocs', 'windocu', 'width=720, height=400, resizable=yes,menubar=no,location=no,directories=no,status=no,copyhistory=no,toolbar=no,scrollbars=yes');\" class=\"NOIR\">";
         echo adm_translate("Manuel en ligne")."</a>";
         echo "<br /><br />";

         echo adm_translate("Activer le Bloc")." : <input type=\"checkbox\" name=\"Sactif\" value=\"ON\" ";
         if ($Sactif) echo "checked";
         echo "></td></tr><tr><td>";
         echo "<b>".adm_translate("Contenu :")."</b>";
         echo "<br /><textarea class=\"textbox\" wrap=\"virtual\" cols=\"50\" rows=\"5\" name=\"content\">$content</textarea>";
         echo "<br /><b>".adm_translate("Aide en ligne de ce bloc")." :</b><br /><textarea class=\"textbox\" cols=\"50\" rows=\"2\" name=\"BLaide\">$BLaide</textarea>";
         echo "</td></tr><tr><td colspan=\"2\" align=\"left\" valign=\"top\">";
         echo droits_bloc($member);
         echo "</td></tr>\n<tr><td colspan=\"2\">";
         echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
         echo "<select class=\"TEXTBOX_STANDARD\" name=\"op\">";
         echo "<option value=\"changelblock\" selected>".adm_translate("Modifier un Bloc gauche")."</option>";
         echo "<option value=\"deletelblock\">".adm_translate("Effacer un Bloc gauche")."</option>";
         echo "<option value=\"droitelblock\">".adm_translate("Transférer à Droite")."</option>";
         echo "</select>";
         echo " <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Ok")."\">";
         echo "</td></tr>\n</form></table>
         </td></tr></table><br />";
         echo $toggle->End();
         echo "</td></tr>";
      }
      echo "</table>";
   }

   echo "<br /><br />";
  }
  if (($radminright==1) or ($radminsuper==1)) {
   echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
   echo adm_translate("Edition des Blocs de droite");
   echo "</td></tr></table>\n";
   $result = mysql_query("select id, title, content, member, Rindex, cache, actif, aide from rblocks order by Rindex ASC");
   $num_row=mysql_num_rows($result);
   $toggle = new ToggleDiv($num_row);
   if ($num_row>0) {
      echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
      echo "<tr><td width=\"65%\" class=\"ONGL\" align=\"left\">".adm_translate("Titre :")."</td><td width=\"10%\" class=\"ONGL\" align=\"right\">".adm_translate("Actif(s)")." :</td><td  width=\"10%\" class=\"ONGL\" align=\"right\">Index :</td><td width=\"10%\" class=\"ONGL\" align=\"right\"><span style=\"font-size: 10px;\">".adm_translate("rétention en secondes")."</span> :</td><td width=\"5%\" class=\"ONGL\" align=\"right\"> ID :</td></tr>";
      while (list($id, $title, $content, $member, $Rindex, $Scache, $Sactif, $BRaide) = mysql_fetch_array($result)) {
         $rowcolor = tablos();
         $funct="";
         if ($title=="") {
            $title=adm_translate("Sans nom");
            $pos_func=strpos($content,"function#");
            $pos_nl=strpos($content,chr(13),$pos_func);
            if ($pos_func!==false) {
               $funct="<span style=\"font-size: 10px;\"> (";
               if ($pos_nl!==false)
                  $funct.=substr($content,$pos_func, $pos_nl-$pos_func);
               else
                  $funct.=substr($content,$pos_func);
               $funct.=")</span>";
            }
         }
         echo "<tr $rowcolor><td align=\"left\">";
         echo $toggle->Img();
         echo aff_langue($title)."".$funct."</td>";
         if ($Sactif)
            echo "<td class=\"NOIR\" align=\"right\">".adm_translate("Oui")."</td>";
         else
            echo "<td class=\"ROUGE\" align=\"right\">".adm_translate("Non")."</td>";
         echo "<td align=\"right\">$Rindex</td><td align=\"right\">$Scache</td>";
         echo "<td align=\"right\">$id</td></tr>";

         echo "<tr><td colspan=\"5\">";
         echo $toggle->Begin();
         echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr $rowcolor><td>
         <table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><form action=\"admin.php\" method=\"post\">\n";
         echo "<tr $rowcolor><td nowrap=\"nowrap\" width=\"65%\">\n";
         echo "<b>".adm_translate("Titre :")."</b><br />";
         echo "<input class=\"textbox\" type=\"text\" name=\"title\" size=\"30\" maxlength=\"255\" value=\"$title\"><br /><b>Index :</b><br />";
         echo "<input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"Rindex\" size=\"5\" maxlength=\"4\" value=\"$Rindex\"></td><td valign=\"top\" rowspan=\"2\"><b>";
         echo adm_translate("rétention en secondes")." :</b><br /><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"Scache\" size=\"6\" maxlength=\"5\" value=\"$Scache\"><br />".adm_translate("Chaque bloc peut utiliser SuperCache.<br />La valeur du délai de rétention <b>0</b> indique que le bloc ne sera <b>pas caché</b> (obligatoire pour le bloc function#adminblock).")."<br /><br />";

         echo "<a href=\"javascript:void(0);\" onclick=\"window.open('admin/docu.php?op=blocs', 'windocu', 'width=720, height=400, resizable=yes,menubar=no,location=no,directories=no,status=no,copyhistory=no,toolbar=no,scrollbars=yes');\" class=\"NOIR\">";
         echo adm_translate("Manuel en ligne")."</a>";
         echo "<br /><br />";

         echo adm_translate("Activer le Bloc")." : <input type=\"checkbox\" name=\"Sactif\" value=\"ON\" ";
         if ($Sactif) echo "checked";
         echo "></td></tr><tr><td>";
         echo "<b>".adm_translate("Contenu :")."</b>";
         echo "<br /><textarea class=\"textbox\" wrap=\"virtual\" cols=\"50\" rows=\"5\" name=\"content\">$content</textarea>";
         echo "<br /><b>".adm_translate("Aide en ligne de ce bloc")." :</b><br /><textarea class=\"textbox\" cols=\"50\" rows=\"2\" name=\"BRaide\">$BRaide</textarea>";
         echo "</td></tr><tr><td colspan=\"2\" align=\"left\" valign=\"top\">";
         echo droits_bloc($member);
         echo "</td></tr>\n<tr><td colspan=\"2\">";
         echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
         echo "<select class=\"TEXTBOX_STANDARD\" name=\"op\">";
         echo "<option value=\"changerblock\" selected>".adm_translate("Modifier un Bloc droit")."</option>";
         echo "<option value=\"deleterblock\">".adm_translate("Effacer un Bloc droit")."</option>";
         echo "<option value=\"gaucherblock\">".adm_translate("Transférer à Gauche")."</option>";
         echo "</select>";
         echo " <input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Ok")."\">";
         echo $toggle->End();
         echo "</td></tr>\n</form></table>
         </td></tr></table><br />";
         echo "</td></tr>";
      }
      echo "</table>";
   }
  }
  echo "<br /><hr noshade><table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
  echo adm_translate("Créer un nouveau Bloc");
  echo "</td></tr></table>\n";
  echo "<form action=\"admin.php\" method=\"post\" name=\"adminForm\"><table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\">";
  echo "<tr><td nowrap=\"nowrap\" width=\"70%\"><b>\n";
  echo adm_translate("Titre :");
  echo "</b><br /><input class=\"textbox\" type=\"text\" name=\"title\" size=\"30\" maxlength=\"255\"><br /><br /><b>Index : </b>";
  echo "<input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"index\" size=\"5\" maxlength=\"4\"></td><td valign=\"top\" rowspan=\"2\"><b>";
  echo adm_translate("rétention en secondes")." :</b><br /><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"Scache\" size=\"6\" maxlength=\"5\" value=\"60\"><br />".adm_translate("Chaque bloc peut utiliser SuperCache.<br />La valeur du délai de rétention <b>0</b> indique que le bloc ne sera <b>pas caché</b> (obligatoire pour le bloc function#adminblock).");
  echo "<br /><br />";
  echo "<a href=\"javascript:void(0);\" onclick=\"window.open('admin/docu.php?op=blocs', 'windocu', 'width=720, height=400, resizable=yes,menubar=no,location=no,directories=no,status=no,copyhistory=no,toolbar=no,scrollbars=yes');\" class=\"NOIR\">";
  echo adm_translate("Manuel en ligne")."</a>";
  echo "<br /><br /><b class=\"ROUGE\">HTML :</b> <input type=\"checkbox\" name=\"SHTML\" value=\"ON\">
  </td></tr>\n<tr><td>";
  echo "<b>".adm_translate("Contenu :")."</b><br />";
  echo aff_editeur("xtext", "false");
  echo "<textarea class=\"textbox\"  name=\"xtext\" cols=\"70\" rows=\"10\" style=\"width: 100%;\"></textarea>";
  echo "<br /><b>".adm_translate("Aide en ligne de ce bloc")." :</b><br /><textarea class=\"textbox\" cols=\"70\" rows=\"2\" name=\"Baide\"></textarea>";
  echo "</td></tr>\n<tr><td colspan=\"2\" align=\"left\">";
  echo droits_bloc("0");
  echo "</td></tr>\n<tr><td colspan=\"2\">";
  if (($radminleft==1) or ($radminsuper==1))
     echo "<input type=\"radio\" name=\"op\" value=\"makelblock\" checked>".adm_translate("Créer un Bloc gauche")."&nbsp;&nbsp;";
  if (($radminright==1) or ($radminsuper==1))
     echo "<input type=\"radio\" name=\"op\" value=\"makerblock\" checked>".adm_translate("Créer un Bloc droite")."&nbsp;&nbsp;";
  echo "<input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Valider")."\"></td></tr></table>\n</form><br />";
  closetable();
  include("footer.php");
}

switch($op) {
   case "blocks":
        blocks();
        break;
}
?>
