<?php

/**
 *
 * INDEXU
 * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
 *
 * INDEXU(tm) is protected by Indonesia and International copyright laws.
 * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
 * violators will be prosecuted. To obtain a license for using INDEXU(tm),
 * please register at Nicecoder home page at http://www.nicecoder.com
 *
 * Author:
 *    Dody Rachmat Wicaksono (dody@nicecoder.com)
 *    M. Zuber (zubby@nicecoder.com)
 *
 */

  /*===================================================
    ShowFormPageCaching()
  ===================================================*/

  function ShowFormPageCaching() {

    // vars global configuration
    global $admin_template_path;

    // vars url & form

    // vars messages
    global $msg;

    // vars template
    global $ct_index,$ct_browse,$ct_detail,$ct_new,$ct_hot,$ct_top,$ct_pick;

    $cache_time_arr = explode(';',implode(file('../page_caching.txt'),""));

    $ct_index = $cache_time_arr[0];
    $ct_browse = $cache_time_arr[1];
    $ct_detail = $cache_time_arr[2];
    $ct_new = $cache_time_arr[3];
    $ct_hot = $cache_time_arr[4];
    $ct_top = $cache_time_arr[5];
    $ct_pick = $cache_time_arr[6];

    DisplayTemplate($admin_template_path . "app_page_caching_form.html",
      "\$ct_index,\$ct_browse,\$ct_detail,\$ct_new,\$ct_hot,\$ct_top,\$ct_pick");
  }


  /*===================================================
    ProcessFormPageCaching()
  ===================================================*/

  function ProcessFormPageCaching() {

    // vars global configuration
    global $admin_template_path;

    // vars url & form
    global $ct_index,$ct_browse,$ct_detail,$ct_new,$ct_hot,$ct_top,$ct_pick;

    // vars messages
    global $msg;

    // vars template
    global $message;

    $content = "$ct_index;$ct_browse;$ct_detail;$ct_new;$ct_hot;$ct_top;$ct_pick";

    $fp = fopen('../page_caching.txt','w+');
    fwrite($fp,$content);
    fclose($fp);

    $message = $msg['20471'];

    DisplayTemplate($admin_template_path . "message.html", "\$message");

  }

  /*===================================================
    DeleteCacheFiles()
  ===================================================*/

  function DeleteCacheFiles() {

    // vars global configuration
    global $admin_template_path, $message, $base_path;

    // vars messages
    global $msg;

    @RemoveDir($base_path . 'cache');

    $message = $msg['20472'];

    DisplayTemplate($admin_template_path . "message.html", "\$message");
  }


  /*===================================================
    main
  ===================================================*/

  include "../application.php";
  
  RunPreFilter(__FILE__);

  DisplayTemplate($admin_template_path . "header.html");
  if (empty($pflag)) {
    ShowFormPageCaching();
  }
  elseif ($pflag == 'update' && $val == 'Update cache time') {
    ProcessFormPageCaching();
  }
  elseif ($pflag == 'update' && $val == 'Delete cache files') {
    DeleteCacheFiles();
  }
  DisplayTemplate($admin_template_path . "footer.html");

  RunPostFilter(__FILE__);

?>