<?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/overload.html";
$result = sql_query("select radminsuper from ".$NPDS_Prefix."authors where aid='$aid'");
list($radminsuper) = sql_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 .= "# DUNE by NPDS : Net Portal Dynamic System\n";
    $content .= "#         Based on PhpNuke 4.x source code \n";
    $content .= "# ===================================================\n";
    $content .= "#\n";
    $content .= "# This version name NPDS Copyright (c) 2001-2007 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;
}
?>