<?php
/************************************************************************/
/* DUNE by NPDS                                                         */
/* ===========================                                          */
/*                                                                      */
/* NPDS Copyright (c) 2002-2012 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 (!stristr($_SERVER['PHP_SELF'],"admin.php")) { 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_article, $xt_sections, $xt_faq, $xt_links, $xt_forum, $xt_memberlist, $xt_modules) {
    $line = "/************************************************************************/\n";
    $content = "<?php\n";
    $content .= "$line";
    $content .= "/* DUNE by NPDS / SUPER-CACHE engine                                    */\n";
    $content .= "/*                                                                      */\n";
    $content .= "/* NPDS Copyright (c) 2002-2012 by Philippe Brunier                     */\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 .= "#\$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['leprog.php']  = \"^opc=(visite|modification|commentaire)\"\;\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_article;\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=\"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=\"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['article.php']=="") or (!isset($CACHE_TIMINGS['article.php'])))         {$CACHE_TIMINGS['article.php']=60;}
      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%\">article.php</td><td><input class=\"textbox_standard\" type=\"text\" name=\"xt_article\" value=\"".$CACHE_TIMINGS['article.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_article, $xt_sections, $xt_faq, $xt_links, $xt_forum, $xt_memberlist, $xt_modules);
      }
      global $aid; Ecr_Log("security", "ChangeSuperCache($xsupercache, $xt_index, $xt_article, $xt_sections, $xt_faq, $xt_links, $xt_forum, $xt_memberlist, $xt_modules) by AID : $aid", "");
      Header("Location: admin.php?op=supercache");
      break;

   case "supercache_empty":
      SC_clean();
      global $aid; Ecr_Log("security", "EmptySuperCache() by AID : $aid", "");
      Header("Location: admin.php?op=supercache");
      break;

   default:
      main();
      break;
}
?>