<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System .                                 */
/* ===========================                                          */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2005 by Philippe Brunier   */
/*                                                                      */
/* Manage Overload and Cache MODE for NPDS                              */
/*                                                                      */
/* 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/overload.html";
$result = mysql_query("select radminsuper from authors where aid='$aid'");
list($radminsuper) = mysql_fetch_row($result);

function save_supercache($xsupercache, $xt_index, $xt_sections, $xt_faq, $xt_links, $xt_forum, $xt_memberlist, $xt_modules) {
    $line = "######################################################################\n";
    $content = "<?PHP\n";
    $content .= "$line";
    $content .= "# NPDS V : Net Portal Dynamic System\n";
    $content .= "#          Based on PHP-NUKE Web Portal System\n";
    $content .= "# ===================================================\n";
    $content .= "#\n";
    $content .= "# This version name NPDS Copyright (c) 2001-2005 by Philippe Brunier\n";
    $content .= "#\n";
    $content .= "# This module is to configure the SuperCache Mode for your site\n";
    $content .= "#\n";
    $content .= "# Original Autor: Francisco Echarte [patxi@eslomas.com]\n";
    $content .= "# Fecha: 2001-08-23\n";
    $content .= "# Version: 0.2\n";
    $content .= "#\n";
    $content .= "# This program is free software. You can redistribute it and/or modify\n";
    $content .= "# it under the terms of the GNU General Public License as published by\n";
    $content .= "# the Free Software Foundation; either version 2 of the License.\n";
    $content .= "$line";
    $content .= "\n";
    $content .= "#\$CACHE_TIMINGS['index.php'] = 300;  // 5 minutes\n";
    $content .= "#\$CACHE_QUERYS['index.php']  = \"^\";  // Query_String for this page : \"\" = All\n";
    $content .= "\n";
    $content .= "#\$CACHE_QUERYS['lasmas.php']  = \"^lmopc=(visitadas|modificadas|valoradas|comentadas)\"\;\n";
    $content .= "#\$CACHE_QUERYS['section.php'] = \"^offset=(10|20|30)&cat=[0-9]{1,2}\"\;\n";
    $content .= "#\$CACHE_QUERYS['news.php']    = \"^idn=[0-9]{1,2}\"\;\n";
    $content .= "\n";
    $content .= "\$SuperCache = $xsupercache;\n";
    $content .= "\n";
    $content .= "\$CACHE_TIMINGS['index.php'] = $xt_index;\n";
    $content .= "\$CACHE_QUERYS['index.php'] = \"^\";\n";
    $content .= "\n";
    $content .= "\$CACHE_TIMINGS['article.php'] = $xt_index;\n";
    $content .= "\$CACHE_QUERYS['article.php'] = \"^\";\n";
    $content .= "\n";
    $content .= "\$CACHE_TIMINGS['sections.php'] = $xt_sections;\n";
    $content .= "\$CACHE_QUERYS['sections.php'] = \"^op\";\n";
    $content .= "\n";
    $content .= "\$CACHE_TIMINGS['faq.php'] = $xt_faq;\n";
    $content .= "\$CACHE_QUERYS['faq.php'] = \"^myfaq\";\n";
    $content .= "\n";
    $content .= "\$CACHE_TIMINGS['links.php'] = $xt_links;\n";
    $content .= "\$CACHE_QUERYS['links.php'] = \"^\";\n";
    $content .= "\n";
    $content .= "\$CACHE_TIMINGS['forum.php'] = $xt_forum;\n";
    $content .= "\$CACHE_QUERYS['forum.php'] = \"^\";\n";
    $content .= "\n";
    $content .= "\$CACHE_TIMINGS['memberslist.php'] = $xt_memberlist;\n";
    $content .= "\$CACHE_QUERYS['memberslist.php'] = \"^\";\n";
    $content .= "\n";
    $content .= "\$CACHE_TIMINGS['modules.php'] = $xt_modules;\n";
    $content .= "\$CACHE_QUERYS['modules.php'] = \"^\";\n";
    $content .= "\n";
    $content .= "?>";
    $file = fopen("cache.timings.php", "w");
    fwrite($file, $content);
    fclose($file);
}

function main() {
   global $hlpfile, $radminsuper;
   include("header.php");
   GraphicAdmin($hlpfile);
   Opentable();
   echo "<form action=\"admin.php\" method=\"post\">";
   echo "<table width=\"100%\" cellspaccing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td CLASS=\"HEADER\">\n";
   echo "SuperCache - Administration</td><td>";
   echo "<input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Vider le répertoire cache")."\">";
   echo "<input type=\"hidden\" name=\"op\" value=\"supercache_empty\">";
   echo "</td></tr></table>\n";
   echo "</form>";

   if ($radminsuper==1) {
      include("cache.timings.php");
      echo "<form action=\"admin.php\" method=\"post\">";
      echo "<table width=\"100%\" cellspaccing=\"0\" cellpadding=\"2\" border=\"0\">";
      $rowcolor=tablos();
      echo "<tr $rowcolor>";
      echo "<td width=\"40%\">SuperCache</td><td>";
      if ($SuperCache==true) {
         echo "<input type=\"radio\" name=\"xsupercache\" value=\"true\" checked>".adm_translate("Oui")."&nbsp;
         <input type=\"radio\" name=\"xsupercache\" value=\"false\">".adm_translate("Non");
      } else {
         echo "<input type=\"radio\" name=\"xsupercache\" value=\"true\">".adm_translate("Oui")."&nbsp;
         <input type=\"radio\" name=\"xsupercache\" value=\"false\" checked>".adm_translate("Non");
      }
      echo "</td></tr>";
      if (($CACHE_TIMINGS['index.php']=="") or (!isset($CACHE_TIMINGS['index.php'])))             {$CACHE_TIMINGS['index.php']=300;}
      if (($CACHE_TIMINGS['sections.php']=="") or (!isset($CACHE_TIMINGS['sections.php'])))       {$CACHE_TIMINGS['sections.php']=300;}
      if (($CACHE_TIMINGS['faq.php']=="") or (!isset($CACHE_TIMINGS['faq.php'])))                 {$CACHE_TIMINGS['faq.php']=86400;}
      if (($CACHE_TIMINGS['links.php']=="") or (!isset($CACHE_TIMINGS['links.php'])))             {$CACHE_TIMINGS['links.php']=28800;}
      if (($CACHE_TIMINGS['forum.php']=="") or (!isset($CACHE_TIMINGS['forum.php'])))             {$CACHE_TIMINGS['forum.php']=3600;}
      if (($CACHE_TIMINGS['memberslist.php']=="") or (!isset($CACHE_TIMINGS['memberslist.php']))) {$CACHE_TIMINGS['memberslist.php']=1800;}
      if (($CACHE_TIMINGS['modules.php']=="") or (!isset($CACHE_TIMINGS['modules.php'])))         {$CACHE_TIMINGS['modules.php']=3600;}

      $rowcolor=tablos();
      echo "<tr $rowcolor>";
      echo "<td width=\"40%\">index.php</td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"xt_index\" value=\"".$CACHE_TIMINGS['index.php']."\" size=\"7\" maxlength=\"6\"><span style=\"font-size: 10px;\"> ".adm_translate("rétention en secondes")." - Def : <b>300</b></span></td></tr>";
      $rowcolor=tablos();
      echo "<tr $rowcolor>";
      echo "<td width=\"40%\">sections.php</td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"xt_sections\" value=\"".$CACHE_TIMINGS['sections.php']."\" size=\"7\" maxlength=\"6\"><span style=\"font-size: 10px;\"> ".adm_translate("rétention en secondes")." - Def : <b>300</b></span></td></tr>";
      $rowcolor=tablos();
      echo "<tr $rowcolor>";
      echo "<td width=\"40%\">faq.php</td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"xt_faq\" value=\"".$CACHE_TIMINGS['faq.php']."\" size=\"7\" maxlength=\"6\"><span style=\"font-size: 10px;\"> ".adm_translate("rétention en secondes")." - Def : <b>86400</b></span></td></tr>";
      $rowcolor=tablos();
      echo "<tr $rowcolor>";
      echo "<td width=\"40%\">links.php</td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"xt_links\" value=\"".$CACHE_TIMINGS['links.php']."\" size=\"7\" maxlength=\"6\"><span style=\"font-size: 10px;\"> ".adm_translate("rétention en secondes")." - Def : <b>28800</b></span></td></tr>";
      $rowcolor=tablos();
      echo "<tr $rowcolor>";
      echo "<td width=\"40%\">forum.php</td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"xt_forum\" value=\"".$CACHE_TIMINGS['forum.php']."\" size=\"7\" maxlength=\"6\"><span style=\"font-size: 10px;\"> ".adm_translate("rétention en secondes")." - Def : <b>3600</b></span></td></tr>";
      $rowcolor=tablos();
      echo "<tr $rowcolor>";
      echo "<td width=\"40%\">memberlist.php</td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"xt_memberlist\" value=\"".$CACHE_TIMINGS['memberslist.php']."\" size=\"7\" maxlength=\"6\"><span style=\"font-size: 10px;\"> ".adm_translate("rétention en secondes")." - Def : <b>1800</b></span></td></tr>";
      $rowcolor=tablos();
      echo "<tr $rowcolor>";
      echo "<td width=\"40%\">modules.php</td><td><input class=\"TEXTBOX_STANDARD\" type=\"text\" name=\"xt_modules\" value=\"".$CACHE_TIMINGS['modules.php']."\" size=\"7\" maxlength=\"6\"><span style=\"font-size: 10px;\"> ".adm_translate("rétention en secondes")." - Def : <b>3600</b></span></td></tr>";
      echo "</table><br />";
      echo "<input class=\"BOUTON_STANDARD\" type=\"submit\" value=\"".adm_translate("Valider")."\">";
      echo "<input type=\"hidden\" name=\"op\" value=\"supercache_save\">";
      echo "</form>";
   }
   closetable();
   include("footer.php");
}

switch ($op) {
   case "supercache_save":
      if ($radminsuper==1) {
        save_supercache($xsupercache, $xt_index, $xt_sections, $xt_faq, $xt_links, $xt_forum, $xt_memberlist, $xt_modules);
      }
      Header("Location: admin.php?op=supercache");
      break;

   case "supercache_empty":
      SC_clean();
      Header("Location: admin.php?op=supercache");
      break;

   default:
      main();
      break;
}
?>
