<?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)
 *
 */

  /*===================================================
    ShowFormTemplateImport()
  ===================================================*/

  function ShowFormTemplateImport() {

    // vars global configuration
    global $admin_template_path;

    // vars url & form

    // vars messages

    // vars template
    
    DisplayTemplate($admin_template_path . "template_import_form.html");
  }


  /*===================================================
    ProcessFormTemplateImport()
  ===================================================*/

  function ProcessFormTemplateImport() {

    // vars global configuration
    global $admin_template_path, $message, $userfile, $theme_path, $msg, $back;

    // read zip entries
    $zip= new ss_zip('',6);
    $zip->open($userfile);

    // get last entry#
    while($entry=$zip->read()){
      $last_entry = $entry["idx"];
    }
    
    // extract all
    $i=0;
    while($i<$last_entry) {
      $mydata=$zip->extract_file($i,$theme_path);
      $i++;
    }
    
    $message = $msg["20428"];
    $back = "<a href=template_import.php>Back</a>";
    
    DisplayTemplate($admin_template_path . "message.html", "\$message,\$back");
  }


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

  include "../application.php";
  include "../lib/ss_zip.class.php";
  ini_set("max_execution_time", "3600");

  RunPreFilter(__FILE__);

  DisplayTemplate($admin_template_path . "header.html");
  if (empty($pflag)) {
    ShowFormTemplateImport();
  }
  elseif ($pflag == 'import') {
    ProcessFormTemplateImport();
  }
  DisplayTemplate($admin_template_path . "footer.html");

  RunPostFilter(__FILE__);

?>