##
# Project: PHPDisk
# This is NOT a freeware, use is subject to license terms.
#
# Site: http://www.phpdisk.com
#
# $Id: templates.inc.php 201 2009-03-02 06:57:21Z along $
#
# Copyright (C) 2008-2009 PHPDisk Team. All Rights Reserved.
#
##
if(!defined('IN_PHPDISK') || !defined('IN_ADMINCP')) {
exit('[PHPDisk] Access Denied');
}
phpdisk_admin();
define('SCRIPT_NAME',$item);
require_once lang('adm_'.SCRIPT_NAME);
$lang = array_merge($pub_lang,$lang);
switch($action){
case 'index':
require_once template(SCRIPT_NAME,ADMIN_TPL_NAME);
break;
case 'admin_tpl':
$tpl_dir = PHPDISK_ROOT."./templates/".ADMIN_TPL_NAME;
$tpl_arr = tpl_list($tpl_dir);
sort($tpl_arr);
reset($tpl_arr);
if($task == 'make_all'){
for($i=0;$i template($tpl_arr[$i],ADMIN_TPL_NAME,1);
$sysmsg[] = "[{$tpl_arr[$i]}] ...... {$lang['tpl_each_success']}";
}
$sysmsg[] = $lang['all_tpl_make_success'];
redirect(urr("admincp","item=templates&action=index"),$sysmsg);
}elseif($task == 'make_one'){
$tpl_name = trim(gpc('tpl_name','G',''));
if($tpl_name){
template($tpl_name,ADMIN_TPL_NAME,1);
$sysmsg[] = "[{$tpl_name}] ...... {$lang['tpl_each_success']}";
}else{
$sysmsg[] = $lang['tpl_not_exists'];
}
redirect(urr("admincp","item=templates&action=index"),$sysmsg);
}else{
require_once template(SCRIPT_NAME,ADMIN_TPL_NAME);
}
break;
case 'user_tpl':
$tpl_dir = PHPDISK_ROOT."./templates/".TPL_NAME;
$tpl_arr = tpl_list($tpl_dir);
sort($tpl_arr);
reset($tpl_arr);
if($task == 'make_all'){
for($i=0;$i template($tpl_arr[$i],TPL_NAME,1);
$sysmsg[] = "[{$tpl_arr[$i]}] ...... {$lang['tpl_each_success']}";
}
$sysmsg[] = $lang['all_tpl_make_success'];
redirect(urr("admincp","item=templates&action=index"),$sysmsg);
}elseif($task == 'make_one'){
$tpl_name = trim(gpc('tpl_name','G',''));
if($tpl_name){
template($tpl_name,TPL_NAME,1);
$sysmsg[] = "[{$tpl_name}] ...... {$lang['tpl_each_success']}";
}else{
$sysmsg[] = $lang['tpl_not_exists'];
}
redirect(urr("admincp","item=templates&action=index"),$sysmsg);
}else{
require_once template(SCRIPT_NAME,ADMIN_TPL_NAME);
}
break;
}
function tpl_list($tpl_dir){
$tpl_arr = array();
if ($fp = opendir($tpl_dir)) {
while(($file = readdir($fp)) !== false) {
if(get_extension($file) == 'html'){
if(substr($file,0,1) != '.' && $file != 'images'){
$tpl_arr[] = str_replace('.tpl.html','',$file);
}
}
}
closedir($fp);
}
return $tpl_arr;
}
?>