<?PHP
/************************************************************************/
/* DUNE by NPDS                                                         */
/* ===========================                                          */
/*                                                                      */
/* Based on PhpNuke 4.x                                                 */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-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/leftblocks.html";
$result = sql_query("select radminleft, radminsuper from ".$NPDS_Prefix."authors where aid='$aid'");
list($radminleft, $radminsuper) = sql_fetch_row($result);
if (($radminleft!=1) and ($radminsuper!=1)) {
   Access_Error();
}

function makelblock($title, $content, $members, $Mmember, $Lindex, $Scache, $BLaide, $SHTML) {
   global $NPDS_Prefix;

   if (is_array($Mmember) and ($members==1)) {
      $members=implode(",",$Mmember);
      if ($members==0) $members=1;
   }
   if (empty($Lindex)) {$Lindex=0;}
   $title=stripslashes(FixQuotes($title));
   $content = stripslashes(FixQuotes($content));
   if ($SHTML!="ON")
      $content = strip_tags(str_replace("<br />","\n",$content));
   sql_query("insert INTO ".$NPDS_Prefix."lblocks VALUES (NULL,'$title','$content','$members', '$Lindex', '$Scache', '1', '$BLaide')");
   Header("Location: admin.php?op=blocks");
}

function changelblock($id, $title, $content, $members, $Mmember, $Lindex, $Scache, $Sactif, $BLaide) {
   global $NPDS_Prefix;

   if (is_array($Mmember) and ($members==1)) {
      $members=implode(",",$Mmember);
      if ($members==0) $members=1;
   }
   if (empty($Lindex)) {$Lindex=0;}
   $title=stripslashes(FixQuotes($title));
   if ($Sactif=="ON") {$Sactif=1;} else {$Sactif=0;}
   $content = stripslashes(FixQuotes($content));
   $BLaide = stripslashes(FixQuotes($BLaide));
   sql_query("update ".$NPDS_Prefix."lblocks set title='$title', content='$content', member='$members', Lindex='$Lindex', cache='$Scache', actif='$Sactif', aide='$BLaide' where id='$id'");
   Header("Location: admin.php?op=blocks");
}

function changedroitelblock($id, $title, $content, $members, $Mmember, $Lindex, $Scache, $Sactif, $BLaide) {
   global $NPDS_Prefix;

   if (is_array($Mmember) and ($members==1)) {
      $members=implode(",",$Mmember);
      if ($members==0) $members=1;
   }
   if (empty($Lindex)) {$Lindex=0;}
   $title=stripslashes(FixQuotes($title));
   if ($Sactif=="ON") {$Sactif=1;} else {$Sactif=0;}
   $content = stripslashes(FixQuotes($content));
   $BLaide = stripslashes(FixQuotes($BLaide));
   sql_query("INSERT INTO ".$NPDS_Prefix."rblocks VALUES (NULL,'$title','$content', '$members', '$Lindex', '$Scache', '$Sactif', '$BLaide')");
   sql_query("delete from ".$NPDS_Prefix."lblocks where id='$id'");
   Header("Location: admin.php?op=blocks");
}

function deletelblock($id) {
   global $NPDS_Prefix;

   sql_query("delete from ".$NPDS_Prefix."lblocks where id='$id'");
   Header("Location: admin.php?op=blocks");
}

switch($op) {
   case "makelblock":
        makelblock($title, $xtext, $members, $Mmember, $index, $Scache, $Baide, $SHTML);
        break;

   case "deletelblock":
        deletelblock($id);
        break;

   case "changelblock":
        changelblock($id, $title, $content, $members, $Mmember, $Lindex, $Scache, $Sactif, $BLaide);
        break;

   case "droitelblock":
        changedroitelblock($id, $title, $content, $members, $Mmember, $Lindex, $Scache, $Sactif, $BLaide);
        break;
}
?>