// // ------------------------------------------------------------------------ // // 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, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // // Author: Kazumi Ono (AKA onokazu) // // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // // Project: The XOOPS Project // // ------------------------------------------------------------------------- // if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { exit("Access Denied"); } else { $myts =& MyTextsanitizer::getInstance(); $op = 'list'; if (isset($_GET['op'])) { $op = trim(strip_tags($myts->stripSlashesGPC($_GET['op']))); $id = $moddir = $file = $type = $tplset = null; if (isset($_GET['id'])) { $id = intval($_GET['id']); } if (isset($_GET['moddir'])) { $moddir = trim(strip_tags($myts->stripSlashesGPC($_GET['moddir']))); } if (isset($_GET['file'])) { $file = trim(strip_tags($myts->stripSlashesGPC($_GET['file']))); } if (isset($_GET['type'])) { $type = trim(strip_tags($myts->stripSlashesGPC($_GET['type']))); } if (isset($_GET['tplset'])) { $tplset = trim(strip_tags($myts->stripSlashesGPC($_GET['tplset']))); } } elseif (!empty($_POST['op'])) { $op = trim(strip_tags($myts->stripSlashesGPC($_POST['op']))); } if ($op == 'edittpl_go') { if (isset($_POST['previewtpl'])) { $op = 'previewtpl'; } } switch ($op) { case 'list': $tplset_handler =& xoops_gethandler('tplset'); $tplsets =& $tplset_handler->getObjects(); xoops_cp_header(); echo '

'._MD_TPLMAIN.'

'; $installed = array(); $tpltpl_handler =& xoops_gethandler('tplfile'); $installed_mods = $tpltpl_handler->getModuleTplCount('default'); $tcount = count($tplsets); echo ''; $class = 'even'; for ($i = 0; $i < $tcount; $i++) { $tplsetname = $tplsets[$i]->getVar('tplset_name'); $installed_themes[] = $tplsetname; $class = ($class == 'even') ? 'odd' : 'even'; echo ''; if ($tplsetname == $xoopsConfig['template_set']) { echo ''; } else { echo ''; } echo ''; } echo '
'._MD_THMSETNAME.''._MD_CREATED.''._MD_TEMPLATES.''._MD_ACTION.' 
'.$tplsetname.'

'.$tplsets[$i]->getVar('tplset_desc').'
'.formatTimestamp($tplsets[$i]->getVar('tplset_created'), 's').'
    '; $tplstats = $tpltpl_handler->getModuleTplCount($tplsetname); if (count($tplstats) > 0) { $module_handler =& xoops_gethandler('module'); echo '
      '; foreach ($tplstats as $moddir => $filecount) { $module =& $module_handler->getByDirname($moddir); //HACK start ------------------------------------------------------- if (@is_object($module)) { if ($installed_mods[$moddir] > $filecount) { $filecount = ''.$filecount.''; } if ($tplsetname != 'default') { echo '
    • '.$module->getVar('name').' ['._LIST.' ('.$filecount.')]['._DELETE.']
    • '; } else { echo '
    • '.$module->getVar('name').' ['._LIST.' ('.$filecount.')]
    • '; } } else { echo '
    • unknown ModuleDirname =' . $moddir . '['._DELETE.']
    • '; } //HACK end ------------------------------------------------------- unset($module); } $not_installed = array_diff(array_keys($installed_mods), array_keys($tplstats)); } else { $not_installed =& array_keys($installed_mods); } foreach ($not_installed as $ni) { $module =& $module_handler->getByDirname($ni); echo '
    • '.$module->getVar('name').' ['._LIST.' (0)] ['._MD_GENERATE.']
    • '; } echo '
'; echo '['._MD_DOWNLOAD.']
['._CLONE.']'; if ($tplsetname != 'default' && $tplsetname != $xoopsConfig['template_set']) { echo '
['._DELETE.']'; } echo '
'._MD_DEFAULTTHEME.' 

'; include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $form = new XoopsThemeForm(_MD_UPLOADTAR, 'tplupload_form', 'admin.php'); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new XoopsFormToken(XoopsSingleTokenHandler::quickCreate('tplsets_uploadtar'))); $form->addElement(new XoopsFormFile(_MD_CHOOSETAR.'
'._MD_ONLYTAR.'', 'tpl_upload', 1000000)); $form->addElement(new XoopsFormText(_MD_NTHEMENAME.'
'._MD_ENTERTH.'', 'tplset_name', 20, 50)); $form->addElement(new XoopsFormHidden('op', 'uploadtar_go')); $form->addElement(new XoopsFormHidden('fct', 'tplsets')); $form->addElement(new XoopsFormButton('', 'upload_button', _MD_UPLOAD, 'submit')); $form->display(); unset($form); //---------------- $form = new XoopsThemeForm('template_c files delete', 'deletetemplate_c_form', 'admin.php', 'post', true); $form->addElement(new XoopsFormToken(XoopsSingleTokenHandler::quickCreate('deletetemplate_c_submit'))); $form->addElement(new XoopsFormHidden('op', 'deletetemplate_c')); $form->addElement(new XoopsFormHidden('fct', 'tplsets')); $form->addElement(new XoopsFormButton('', 'deletetemplate_c_button', _DELETE, 'submit')); $form->display(); unset($form); //---------------- $form = new XoopsThemeForm('cache files delete', 'deletecache_form', 'admin.php', 'post', true); $form->addElement(new XoopsFormToken(XoopsSingleTokenHandler::quickCreate('deletecache_submit'))); $form->addElement(new XoopsFormHidden('op', 'deletecache')); $form->addElement(new XoopsFormHidden('fct', 'tplsets')); $form->addElement(new XoopsFormButton('', 'deletecache_button', _DELETE, 'submit')); $form->display(); unset($form); xoops_cp_footer(); break; case 'listtpl': $tplset = trim($_GET['tplset']); if ($tplset == '') { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } if ($moddir == '') { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } xoops_cp_header(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($moddir); $modname = $module->getVar('name'); echo ''. _MD_TPLMAIN .' »» '.$tplset.'

'; $token=&XoopsMultiTokenHandler::quickCreate('tplsets_update'); echo '

'.$modname.'

'; echo $token->getHtml(); if ($tplset != 'default') { echo ''; } else { echo ''; } $tpltpl_handler =& xoops_gethandler('tplfile'); // get files that are already installed $templates =& $tpltpl_handler->find($tplset, 'module', null, $moddir); $inst_files = array(); $tcount = count($templates); for ($i = 0; $i < $tcount; $i++) { if ($i % 2 == 0) { $class = 'even'; } else { $class = 'odd'; } $last_modified = $templates[$i]->getVar('tpl_lastmodified'); $last_imported = $templates[$i]->getVar('tpl_lastimported'); $last_imported_f = ($last_imported > 0) ? formatTimestamp($last_imported, 'l') : ''; echo ''; $filename = $templates[$i]->getVar('tpl_file'); if ($tplset != 'default') { $physical_file = XOOPS_THEME_PATH.'/'.$tplset.'/templates/'.$moddir.'/'.$filename; if (file_exists($physical_file)) { $mtime = filemtime($physical_file); if ($last_imported < $mtime) { if ($mtime > $last_modified) { $bg = '#ff9999'; } elseif($mtime > $last_imported) { $bg = '#99ff99'; } echo ''; } else { echo ''; } echo ''."\n"; $inst_files[] = $filename; } if ($tplset != 'default') { include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; // get difference between already installed files and the files under modules directory. which will be recognized as files that are not installed $notinst_files = array_diff(XoopsLists::getFileListAsArray(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/templates/'), $inst_files); foreach ($notinst_files as $nfile) { //HACK start ------------------------------------------------------- if( $nfile == '..' || $nfile == '.' || $nfile == ".htaccess" || $nfile == "index.html"|| $nfile == "XTAGS"){ continue; } //HACK end ------------------------------------------------------- if ($nfile != 'index.html') { echo ''."\n"; } } } echo '
'._MD_FILENAME.''._MD_LASTMOD.''._MD_LASTIMP.''._MD_ACTION.'
'._MD_ACTION.'
'.$templates[$i]->getVar('tpl_file').'

'.$templates[$i]->getVar('tpl_desc').'
'.formatTimestamp($last_modified, 'l').''.$last_imported_f.' ['._MD_IMPORT.']'; } else { echo ''.$last_imported_f; } } else { echo ''.$last_imported_f; } echo '['._EDIT.'] ['._DELETE.'] ['._MD_DOWNLOAD.']['._MD_VIEW.'] ['._MD_DOWNLOAD.']
'.$nfile.' '; $physical_file = XOOPS_ROOT_PATH.'/templates/'.$tplset.'/'.$moddir.'/'.$nfile; if (file_exists($physical_file)) { echo '['._MD_IMPORT.']'; } else { echo ' '; } echo '['._MD_GENERATE.']

'; if ($tplset != 'default') { echo ''; } else { echo ''; } $btemplates =& $tpltpl_handler->find($tplset, 'block', null, $moddir); $binst_files = array(); $btcount = count($btemplates); for ($j = 0; $j < $btcount; $j++) { $last_imported = $btemplates[$j]->getVar('tpl_lastimported'); $last_imported_f = ($last_imported > 0) ? formatTimestamp($last_imported, 'l') : ''; $last_modified = $btemplates[$j]->getVar('tpl_lastmodified'); if ($j % 2 == 0) { $class = 'even'; } else { $class = 'odd'; } echo ''; $filename = $btemplates[$j]->getVar('tpl_file'); $physical_file = XOOPS_ROOT_PATH.'/templates/'.$tplset.'/'.$moddir.'/blocks/'.$filename; if ($tplset != 'default') { if (file_exists($physical_file)) { $mtime = filemtime($physical_file); if ($last_imported < $mtime) { if ($mtime > $last_modified) { $bg = '#ff9999'; } elseif($mtime > $last_imported) { $bg = '#99ff99'; } echo ''; } else { echo ''; } echo ''."\n"; $binst_files[] = $filename; } if ($tplset != 'default') { include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; $bnotinst_files = array_diff(XoopsLists::getFileListAsArray(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/templates/blocks/'), $binst_files); foreach ($bnotinst_files as $nfile) { //HACK start ------------------------------------------------------- if( $nfile == '..' || $nfile == '.' || $nfile == ".htaccess" || $nfile == "index.html"|| $nfile == "XTAGS"){ continue; } //HACK end ------------------------------------------------------- if ($nfile != 'index.html') { echo ''."\n"; } } } echo '
'._MD_FILENAME.''._MD_LASTMOD.''._MD_LASTIMP.''._MD_ACTION.'
'._MD_ACTION.'
'.$btemplates[$j]->getVar('tpl_file').'

'.$btemplates[$j]->getVar('tpl_desc').'
'.formatTimestamp($last_modified, 'l').''.$last_imported_f.' ['._MD_IMPORT.']'; } else { echo ''.$last_imported_f; } } else { echo ''.$last_imported_f; } echo '['._EDIT.'] ['._DELETE.'] ['._MD_DOWNLOAD.']['._MD_VIEW.'] ['._MD_DOWNLOAD.']
'.$nfile.' '; $physical_file = XOOPS_ROOT_PATH.'/templates/'.$tplset.'/'.$moddir.'/blocks/'.$nfile; if (file_exists($physical_file)) { echo '['._MD_IMPORT.']'; } else { echo ' '; } echo '['._MD_GENERATE.']
'; if ($tplset != 'default') { echo '
'; echo '
'; } xoops_cp_footer(); break; case 'edittpl': if (!isset($id) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } if ($id <= 0) { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->get($id, true); if (is_object($tplfile)) { $tplset = $tplfile->getVar('tpl_tplset'); $tform = array('tpl_tplset' => $tplset, 'tpl_id' => $id, 'tpl_file' => $tplfile->getVar('tpl_file'), 'tpl_desc' => $tplfile->getVar('tpl_desc'), 'tpl_lastmodified' => $tplfile->getVar('tpl_lastmodified'), 'tpl_source' => $tplfile->getVar('tpl_source', 'E'), 'tpl_module' => $tplfile->getVar('tpl_module')); include_once XOOPS_ROOT_PATH.'/modules/system/admin/tplsets/tplform.php'; xoops_cp_header(); echo ''. _MD_TPLMAIN .' »» '.$tplset.' »» '._MD_EDITTEMPLATE.'

'; $form->display(); xoops_cp_footer(); exit(); } else { $err[] = 'Selected template (ID: $id) does not exist'; } xoops_cp_header(); xoops_error($err); echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'edittpl_go': $id = !empty($_POST['id']) ? intval($_POST['id']) : 0; if ($id <= 0 || !XoopsMultiTokenHandler::quickValidate('tplform')) { redirect_header('admin.php?fct=tplsets'); } //------------------------- if ( !isset($_POST['moddir']) || !isset($_POST['redirect']) || !isset($_POST['html']) || !isset($_POST['submittpl']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->get($id, true); $err = array(); if (!is_object($tplfile)) { $err[] = 'Selected template (ID: $id) does not exist'; } else { if ($tplfile->getVar('tpl_tplset') != 'default') { $tplfile->setVar('tpl_source', $_POST['html']); $tplfile->setVar('tpl_lastmodified', time()); if (!$tpltpl_handler->insert($tplfile)) { $err[] = 'Could not insert template file to the database.'; } else { include_once XOOPS_ROOT_PATH.'/class/template.php'; $xoopsTpl = new XoopsTpl(); if ($xoopsTpl->is_cached('db:'.$tplfile->getVar('tpl_file'))) { if (!$xoopsTpl->clear_cache('db:'.$tplfile->getVar('tpl_file'))) { } } if ($tplfile->getVar('tpl_tplset') == $xoopsConfig['template_set']) { xoops_template_touch($id); } } } else { $err[] = 'Default template files cannot be edited.'; } } if (count($err) == 0) { if (!empty($_POST['moddir'])) { redirect_header('admin.php?fct=tplsets&op=edittpl&id='.$tplfile->getVar('tpl_id'), 2, _MD_AM_DBUPDATED); } elseif (isset($_POST['redirect'])) { redirect_header('admin.php?fct=tplsets&tplset='.$tplfile->getVar('tpl_tplset').'&op='.trim(strip_tags($_POST['redirect'])), 2, _MD_AM_DBUPDATED); } else { redirect_header('admin.php?fct=tplsets', 2, _MD_AM_DBUPDATED); } } xoops_cp_header(); xoops_error($err); echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'deletetpl': if (!isset($id) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } xoops_cp_header(); xoops_confirm(array('id' => $id, 'op' => 'deletetpl_go', 'fct' => 'tplsets'), 'admin.php', _MD_RUSUREDELTPL, _YES); xoops_cp_footer(); break; case 'deletetpl_go': $id = !empty($_POST['id']) ? intval($_POST['id']) : 0; if ($id <= 0 || !xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets', 1); } $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->get($id); $err = array(); if (!is_object($tplfile)) { $err[] = 'Selected template (ID: $id) does not exist'; } else { if ($tplfile->getVar('tpl_tplset') != 'default') { if (!$tpltpl_handler->delete($tplfile)) { $err[] = 'Could not delete '.$tplfile->getVar('tpl_file').' from the database.'; } else { // need to compile default xoops template if ($tplfile->getVar('tpl_tplset') == $xoopsConfig['template_set']) { $defaulttpl =& $tpltpl_handler->find('default', $tplfile->getVar('tpl_type'), $tplfile->getVar('tpl_refid'), null, $tplfile->getVar('tpl_file')); if (count($defaulttpl) > 0) { include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_touch($defaulttpl[0]->getVar('tpl_id'), true); } } } } else { $err[] = 'Default template files cannot be deleted.'; } } if (count($err) == 0) { redirect_header('admin.php?fct=tplsets&op=listtpl&moddir='.$tplfile->getVar('tpl_module').'&tplset='.urlencode($tplfile->getVar('tpl_tplset')), 2, _MD_AM_DBUPDATED); } xoops_cp_header(); xoops_error($err); echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'delete': if (!isset($tplset) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = $myts->htmlSpecialChars($tplset); xoops_cp_header(); xoops_confirm(array('tplset' => $tplset, 'op' => 'delete_go', 'fct' => 'tplsets'), 'admin.php', _MD_RUSUREDELTH, _YES); xoops_cp_footer(); break; case 'delete_go': if(!xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- if ( !isset($_POST['tplset']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = !empty($_POST['tplset']) ? trim(strip_tags($myts->stripSlashesGPC($_POST['tplset']))) : ''; $msgs = array(); if ($tplset != '' && $tplset != 'default' && $tplset != $xoopsConfig['template_set']) { $tpltpl_handler =& xoops_gethandler('tplfile'); $templates =& $tpltpl_handler->getObjects(new Criteria('tpl_tplset', $tplset)); $tcount = count($templates); if ($tcount > 0) { $msgs[] = 'Deleting template files...'; for ($i = 0; $i < $tcount; $i++) { if (!$tpltpl_handler->delete($templates[$i])) { $msgs[] = '  ERROR: Could not delete template '.$templates[$i]->getVar('tpl_file').'. ID: '.$templates[$i]->getVar('tpl_id').''; } else { $msgs[] = '  Template '.$templates[$i]->getVar('tpl_file').' deleted. ID: '.$templates[$i]->getVar('tpl_id').''; } } } /* $image_handler =& xoops_gethandler('imagesetimg'); $imagefiles =& $image_handler->getObjects(new Criteria('tplset_name', $tplset)); $icount = count($imagefiles); if ($icount > 0) { $msgs[] = 'Deleting image files...'; for ($i = 0; $i < $icount; $i++) { if (!$image_handler->delete($imagefiles[$i])) { $msgs[] = '  ERROR: Could not remove file '.$imagefiles[$i]->getVar('imgsetimg_file').' from the database (ID: '.$imagefiles[$i]->getVar('imgsetimg_id').')'; } else { $msgs[] = '  File '.$imagefiles[$i]->getVar('imgsetimg_file').' deleted from the database (ID: '.$imagefiles[$i]->getVar('imgsetimg_id').')'; } } } $imageset_handler =& xoops_gethandler('imageset'); $imagesets =& $imageset_handler->getObjects(new Criteria('tplset_name', $tplset)); $scount = count($imagesets); if ($scount > 0) { $msgs[] = 'Deleting image set data...'; for ($i = 0; $i < $scount; $i++) { if (!$imageset_handler->unlinktplset($imagesets[$i]->getVar('imgset_id'), $tplset)) { $msgs[] = '  ERROR: Could not remove link between '.$imagesets[$i]->getVar('imgset_name').' (ID: '.$imagesets[$i]->getVar('imgset_id').') and '.$tplset.' from the database.'; } else { $msgs[] = '  Link between '.$imagesets[$i]->getVar('imgset_name').' (ID: '.$imagesets[$i]->getVar('imgset_id').') and '.$tplset.' removed from the database.'; } if (!$imageset_handler->delete($imagesets[$i])) { $msgs[] = '  ERROR: Could not delete image set '.$imagesets[$i]->getVar('imgset_name').' (ID: '.$imagesets[$i]->getVar('imgset_id').') from the database.'; } else { $msgs[] = '  Image set '.$imagesets[$i]->getVar('imgset_name').' (ID: '.$imagesets[$i]->getVar('imgset_id').') removed from the database.'; } } } */ $tplset_handler =& xoops_gethandler('tplset'); $tplsets =& $tplset_handler->getObjects(new Criteria('tplset_name', $tplset)); if (count($tplsets) > 0 && is_object($tplsets[0])) { $msgs[] = 'Deleting template set data...'; if (!$tplset_handler->delete($tplsets[0])) { $msgs[] = '  ERROR: Template set '.$tplset.' could not be deleted.'; } else { $msgs[] = '  Template set data removed from the database.'; } } } else { $msgs[] = 'ERROR: Default template files cannot be deleted'; } xoops_cp_header(); foreach ($msgs as $msg) { echo ''.$msg.'
'; } echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'clone': if (!isset($tplset) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $form = new XoopsThemeForm(_MD_CLONETHEME, 'template_form', 'admin.php'); $form->addElement(new XoopsFormToken(XoopsSingleTokenHandler::quickCreate('tplsets_clone'))); $form->addElement(new XoopsFormLabel(_MD_THEMENAME, $tplset)); $form->addElement(new XoopsFormText(_MD_NEWNAME, 'newtheme', 30, 50), true); $form->addElement(new XoopsFormHidden('tplset', $tplset)); $form->addElement(new XoopsFormHidden('op', 'clone_go')); $form->addElement(new XoopsFormHidden('fct', 'tplsets')); $form->addElement(new XoopsFormButton('', 'tpl_button', _SUBMIT, 'submit')); xoops_cp_header(); echo ''. _MD_TPLMAIN .' »» '._MD_CLONETHEME.'

'; $form->display(); xoops_cp_footer(); break; case 'clone_go': //------------------------- if ( !isset($_POST['tplset']) || !isset($_POST['newtheme']) || !isset($_POST['tpl_button']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = ($_POST['tplset'])? trim(strip_tags($myts->stripSlashesGPC($_POST['tplset']))) : null; $newtheme = ($_POST['newtheme'])? trim(strip_tags($myts->stripSlashesGPC($_POST['newtheme']))) : null; //------------------------- $msgs = array(); $tplset = !empty($_POST['tplset']) ? trim($_POST['tplset']) : ''; $newtheme = !empty($_POST['newtheme']) ? trim($_POST['newtheme']) : ''; if ($tplset == '' || $newtheme == '') { redirect_header('admin.php?fct=tplsets',3,'Invalid Template Set Name'); } $tpltpl_handler =& xoops_gethandler('tplfile'); xoops_cp_header(); if(!XoopsSingleTokenHandler::quickValidate('tplsets_clone')) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } elseif ($tplset == $newtheme) { xoops_error('Template set name must be a different name.'); } elseif ($tpltpl_handler->getCount(new Criteria('tpl_tplset', $newtheme)) > 0) { xoops_error('Template set '.$newtheme.' already exists.'); } else { $tplset_handler =& xoops_gethandler('tplset'); $tplsetobj =& $tplset_handler->create(); $tplsetobj->setVar('tplset_name', $newtheme); $tplsetobj->setVar('tplset_created', time()); if (!$tplset_handler->insert($tplsetobj)) { $msgs[] = 'ERROR: Could not create template set '.$newtheme.'.
'; } else { $tplsetid = $tplsetobj->getVar('tplset_id'); $templates =& $tpltpl_handler->getObjects(new Criteria('tpl_tplset', $tplset), true); $tcount = count($templates); if ($tcount > 0) { $msgs[] = 'Copying template files...'; for ($i = 0; $i < $tcount; $i++) { $newtpl =& $templates[$i]->xoopsClone(); $newtpl->setVar('tpl_tplset', $newtheme); $newtpl->setVar('tpl_id', 0); $newtpl->setVar('tpl_lastimported', 0); $newtpl->setVar('tpl_lastmodified', time()); if (!$tpltpl_handler->insert($newtpl)) { $msgs[] = '  ERROR: Failed copying template '.$templates[$i]->getVar('tpl_file').'. ID: '.$templates[$i]->getVar('tpl_id').''; } else { $msgs[] = '  Template '.$templates[$i]->getVar('tpl_file').' copied. ID: '.$newtpl->getVar('tpl_id').''; } unset($newtpl); } /* $imageset_handler =& xoops_gethandler('imageset'); $orig_imgset =& $imageset_handler->getObjects(new Criteria('tplset_name', $tplset)); $msgs[] = 'Copying image files...'; $imgsetcount = count($orig_imgset); for ($i = 0; $i < $imgsetcount; $i++) { if ($orig_imgset[$i]->getVar('imgset_refid') == 0) { $new_imgset =& $orig_imgset[$i]->xoopsClone(); $new_imgset->setVar('imgset_id', 0); $new_imgset->setVar('imgset_name', $newtheme); if (!$imageset_handler->insert($new_imgset)) { $msgs[] = '  ERROR: Failed copying template image set data.'; } else { $new_imgsetid = $new_imgset->getVar('imgset_id'); $msgs[] = '  Template image set data copied. (Name: '.$newtheme.' ID: '.$new_imgsetid.')'; $image_handler = xoops_gethandler('imagesetimg'); $orig_images =& $image_handler->getByImageset($orig_imgset[$i]->getVar('imgset_id')); $imgcount = count($orig_images); for ($j = 0; $j < $imgcount; $j++) { $new_image =& $orig_images[$j]->xoopsClone(); $new_image->setVar('imgsetimg_id', 0); $new_image->setVar('imgsetimg_imgset', $new_imgsetid); if (!$image_handler->insert($new_image)) { $msgs[] = '  ERROR: Failed copying data for image file '.$orig_images[$j]->getVar('imgsetimg_file').'.'; } else { $thisimage = $orig_images[$j]->getVar('imgsetimg_file'); $msgs[] = '  Data for image file '.$thisimage.' copied.'; } } if (!$imageset_handler->linktplset($new_imgsetid, $newtheme)) { $msgs[] = '  ERROR: Failed creating link between template image set (ID : '.$new_imgsetid.') and template set '.$newtheme.'.'; } else { $msgs[] = '  Template image set (ID: '.$new_imgsetid.') and template set '.$newtheme.' linked.'; } } } else { // module image set, so just create another link to the new template set if (!$imageset_handler->linktplset($orig_imgset[$i]->getVar('imgset_id'), $newtheme)) { $msgs[] = '  ERROR: Failed creating link between module image set '.$orig_imgset[$i]->getVar('imgset_name').' (ID '.$orig_imgset[$i]->getVar('imgset_id').') and template set '.$newtheme.'.'; } else { $msgs[] = '  Module image set '.$orig_imgset[$i]->getVar('imgset_name').' (ID '.$orig_imgset[$i]->getVar('imgset_id').') and template set '.$newtheme.' linked.'; } } } */ $msgs[] = 'Template set '.$newtheme.' created. (ID: '.$tplsetid.')
'; } else { $msgs[] = 'ERROR: Template files for '.$theme.' do not exist'; } } } foreach ($msgs as $msg) { echo ''.$msg.'
'; } echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; /* case 'editimage': xoops_cp_header(); echo ''. _MD_TPLMAIN .' »» '._MD_EDITSKINIMG.' ('.$tplset.')

'; include XOOPS_ROOT_PATH.'/modules/system/admin/tplsets/tplimgform.php'; xoops_cp_footer(); break; case 'updateimage': $tplset = trim($tplset); $err = array(); if ($tplset != 'default') { include_once XOOPS_ROOT_PATH.'/class/uploader.php'; $mimetypes = array('image/gif', "image/pjpeg", "image/jpeg", "image/jpeg", "image/jpeg", "image/png", 'image/x-png', "application/x-shockwave-flash", "image/tiff", "image/tiff", 'image/bmp'); if ($tplset == $xoopsConfig['template_set']) { //directly upload to cache to reduce one step ;-) $uploader = new XoopsMediaUploader(XOOPS_CACHE_PATH, $mimetypes, 500000); } else { $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $mimetypes, 500000); } $uploader->setAllowedExtensions(array('gif', 'jpeg', 'jpg', 'png', 'bmp', 'tiff', 'tif', 'swf')); $image_handler =& xoops_gethandler('imagesetimg'); foreach ($imgids as $id) { if (isset($imgfiles[$id]) && trim($imgfiles[$id]) != '') { if ($uploader->fetchMedia('imgfiles', $id)) { $image =& $image_handler->get($id); $uploader->setTargetFileName($image->getVar('imgsetimg_file')); if (!$uploader->upload()) { $err[] = $uploader->getErrors(); } else { $fp = @fopen($uploader->getSavedDestination(), 'rb'); $image->setVar('imgsetimg_body', @fread($fp, filesize($uploader->getSavedDestination())), true); @fclose($fp); if ($tplset != $xoopsConfig['template_set']) { @unlink($uploader->getSavedDestination()); } if (!$image_handler->insert($image)) { $err[] = 'Could not save '.$image->getVar('imgsetimg_file'); } } } else { $err[] = $uploader->getErrors(); } } elseif (!empty($imgdelete[$id])) { $image =& $image_handler->get($id); if (!$image_handler->delete($image)) { $err[] = 'Could not remove image file '.$image->getVar('imgsetimg_file'); } else { if ($tplset == $xoopsConfig['template_set']) { @unlink(XOOPS_CACHE_PATH.'/'.$image->getVar('imgsetimg_file')); } } } } } else { $err[] = 'Cannot change XOOPS system default theme set images'; } // delete image set if no more images $current_imgs =& $image_handler->getByImageset($imgset); if (count($current_imgs) == 0) { $imageset_handler =& xoops_gethandler('imageset'); $imgset =& $imageset_handler->get($imgset); if (!$imageset_handler->delete($imgset)) { $err[] = 'Could not remove image set '.$imgset->getVar('imgset_name'); } } if (count($err) > 0) { xoops_cp_header(); xoops_error($err); xoops_cp_footer(); } else { redirect_header('admin.php?fct=tplsets&op=editimage&tplset='.$tplset, 2, _MD_AM_DBUPDATED); } break; case 'addimage': $tplset = trim($tplset); $err = array(); if ($tplset != 'default') { include_once XOOPS_ROOT_PATH.'/class/uploader.php'; $mimetypes = array('image/gif', "image/pjpeg", "image/jpeg", "image/jpeg", "image/jpeg", "image/png", 'image/x-png', "application/x-shockwave-flash", "image/tiff", "image/tiff", 'image/bmp'); if ($tplset == $xoopsConfig['template_set']) { //directly upload to cache to reduce one step ;-) $uploader = new XoopsMediaUploader(XOOPS_CACHE_PATH, $mimetypes, 500000); } else { $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $mimetypes, 500000); } $uploader->setAllowedExtensions(array('gif', 'jpeg', 'jpg', 'png', 'bmp', 'tiff', 'tif', 'swf')); $image_handler =& xoops_gethandler('imagesetimg'); if ($uploader->fetchMedia('imgfile')) { if (!empty($imgset)) { //check if an image with the same name exists if ($image_handler->imageExists($uploader->getMediaName(), $imgset)) { $err[] = 'Image file '.$uploader->getMediaName().' already exists'; } } if (empty($err)) { $image =& $image_handler->create(); if (!$uploader->upload()) { $err[] = $uploader->getErrors(); } else { if (!$fp = @fopen($uploader->getSavedDestination(), 'rb')) { $err[] = 'Could not read '.$uploader->getSavedFileName(); } else { $image->setVar('imgsetimg_body', @fread($fp, filesize($uploader->getSavedDestination())), true); @fclose($fp); if ($tplset != $xoopsConfig['template_set']) { @unlink($uploader->getSavedDestination()); } $image->setVar('imgsetimg_file', $uploader->getSavedFileName()); if (!empty($imgset)) { $image->setVar('imgsetimg_imgset', $imgset); } else { $imageset_handler =& xoops_gethandler('imageset'); $imgset =& $imageset_handler->create(); $imgset->setVar('imgset_name', $tplset); $imgset->setVar('imgset_refid', 0); if (!$imageset_handler->insert($imgset)) { $err[] = 'Could not create image set.'; } else { $newimgsetid = $imgset->getVar('imgset_id'); $image->setVar('imgsetimg_imgset', $newimgsetid); if (!$imageset_handler->linktplset($newimgsetid, $tplset)) { $err[] = 'Failed linking image set to template set '.$tplset; } } } if (count($err) == 0) { if (!$image_handler->insert($image)) { $err[] = 'Could not save '.$image->getVar('imgsetimg_file'); } } } } } } else { $err[] = $uploader->getErrors(); } } if (count($err) > 0) { xoops_cp_header(); xoops_error($err); xoops_cp_footer(); } else { redirect_header('admin.php?fct=tplsets&op=editimage&tplset='.$tplset, 2, _MD_AM_DBUPDATED); } break; case 'showimage': $image_id = isset($_GET['id']) ? intval($_GET['id']) : 0; if (empty($image_id)) { header('Content-type: image/gif'); readfile(XOOPS_UPLOAD_PATH.'/blank.gif'); exit(); } $image_handler =& xoops_gethandler('imagesetimg'); $image =& $image_handler->getObjects(new Criteria('imgsetimg_id', $image_id)); if (count($image) > 0) { $mimetypes = array('gif' => 'image/gif', "jpe"=>"image/jpeg", "jpeg"=>"image/jpeg", "jpg"=>"image/jpeg", "png"=>"image/png", "swf"=>"application/x-shockwave-flash", "tif"=>"image/tiff", "tiff"=>"image/tiff", "bmp" => 'image/bmp'); $ext = substr(strtolower(strrchr($image[0]->getVar('imgsetimg_file'), '.')), 1); if (in_array($ext, array_keys($mimetypes))) { header('Content-type: '.$mimetypes[$ext]); } header('Cache-control: max-age=31536000'); header('Expires: '.gmdate("D, d M Y H:i:s",time()+31536000).'GMT'); header('Content-disposition: filename='.$image[0]->getVar('imgsetimg_file')); header('Content-Length: '.strlen($image[0]->getVar('imgsetimg_body'))); header('Last-Modified: '.gmdate("D, d M Y H:i:s", time()).'GMT'); echo $image[0]->getVar('imgsetimg_body'); } else { header('Content-type: image/gif'); readfile(XOOPS_UPLOAD_PATH.'/blank.gif'); } break; */ case 'viewdefault': if (!isset($id) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } //------------------------- if ($id <= 0) { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->get($id); $default =& $tpltpl_handler->find('default', $tplfile->getVar('tpl_type'), $tplfile->getVar('tpl_refid'), null, $tplfile->getVar('tpl_file')); echo ""; echo ' '.htmlspecialchars($xoopsConfig['sitename']).' Administration '; if (is_object($default[0])) { $tpltpl_handler->loadSource($default[0]); $last_modified = $default[0]->getVar('tpl_lastmodified'); $last_imported = $default[0]->getVar('tpl_lastimported'); if ($default[0]->getVar('tpl_type') == 'block') { $path = XOOPS_ROOT_PATH.'/modules/'.$default[0]->getVar('tpl_module').'/blocks/'.$default[0]->getVar('tpl_file'); } else { $path = XOOPS_ROOT_PATH.'/modules/'.$default[0]->getVar('tpl_module').'/'.$default[0]->getVar('tpl_file'); } $colorchange = ''; if (!file_exists($path)) { $filemodified_date = _MD_NOFILE; $lastimported_date = _MD_NOFILE; } else { $tpl_modified = filemtime($path); $filemodified_date = formatTimestamp($tpl_modified, 'l'); if ($tpl_modified > $last_imported) { $colorchange = ' bgcolor="#ffCC99"'; } $lastimported_date = formatTimestamp($last_imported, 'l'); } include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $form = new XoopsThemeForm(_MD_VIEWDEFAULT, 'template_form', 'admin.php'); $form->addElement(new XoopsFormTextArea(_MD_FILEHTML, 'html', $default[0]->getVar('tpl_source'), 25)); $form->display(); } else { echo 'Selected file does not exist'; } echo '
['._CLOSE.']
'; break; case 'downloadtpl': if (!isset($id) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } //------------------------- if ($id <= 0) { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } xoops_cp_header(); xoops_confirm(array('id' => $id, 'op' => 'downloadtpl_go', 'fct' => 'tplsets') , 'admin.php', _MD_PLZGENERATE, _MD_GENERATE); xoops_cp_footer(); break; case 'downloadtpl_go': if(!xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- // confirmed, so delete $id = ($_POST['id'])? intval($_POST['id']) : 0; //------------------------- if ($id <= 0) { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tpltpl_handler =& xoops_gethandler('tplfile'); $tpl =& $tpltpl_handler->get($id, true); if (is_object($tpl)) { $output = $tpl->getVar('tpl_source'); strlen($output); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-Type: application/force-download'); if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { header('Content-Disposition: filename='.$tpl->getVar('tpl_file')); } else { header('Content-Disposition: attachment; filename='.$tpl->getVar('tpl_file')); } header('Content-length: '.strlen($output)); echo $output; } break; case 'uploadtpl': //------------------------- if (!isset($id) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } //------------------------- if ($id <= 0) { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } //------------------------- $tpltpl_handler =& xoops_gethandler('tplfile'); $tpl =& $tpltpl_handler->get($id); xoops_cp_header(); echo ''. _MD_TPLMAIN .' »» '.$tpl->getVar('tpl_tplset').' »» '._MD_UPLOAD.'

'; if (is_object($tpl)) { include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $form = new XoopsThemeForm(_MD_UPLOAD, 'tplupload_form', 'admin.php'); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new XoopsFormToken(XoopsSingleTokenHandler::quickCreate('uploadtpl'))); $form->addElement(new XoopsFormLabel(_MD_FILENAME, $tpl->getVar('tpl_file').' ('.$tpl->getVar('tpl_tplset').')')); $form->addElement(new XoopsFormFile(_MD_CHOOSEFILE.'
'._MD_UPWILLREPLACE.'', 'tpl_upload', 200000), true); $form->addElement(new XoopsFormHidden('tpl_id', $id)); $form->addElement(new XoopsFormHidden('op', 'uploadtpl_go')); $form->addElement(new XoopsFormHidden('fct', 'tplsets')); $form->addElement(new XoopsFormButton('', 'upload_button', _MD_UPLOAD, 'submit')); $form->display(); xoops_cp_footer(); exit(); } else { echo 'Selected template does not exist'; } xoops_cp_footer(); break; case 'uploadtpl_go': if(!XoopsSingleTokenHandler::quickValidate('uploadtpl')) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- $tpl_id = !empty($_POST['id']) ? $_POST['id'] : 0; if ($tpl_id <= 0) { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } //------------------------- $tpltpl_handler =& xoops_gethandler('tplfile'); $tpl =& $tpltpl_handler->get($tpl_id); if (is_object($tpl)) { include_once XOOPS_ROOT_PATH.'/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('text/html', 'application/x-cdf', 'text/plain'), 200000); $uploader->setAllowedExtensions(array('html', 'htm')); $uploader->setPrefix('tmp'); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if (!$uploader->upload()) { $err = $uploader->getErrors(); } else { $tpl->setVar('tpl_lastmodified', time()); $fp = @fopen($uploader->getSavedDestination(), 'r'); $fsource = @fread($fp, filesize($uploader->getSavedDestination())); @fclose($fp); $tpl->setVar('tpl_source', $fsource, true); @unlink($uploader->getSavedDestination()); if (!$tpltpl_handler->insert($tpl)) { $err = 'Failed inserting data to database'; } else { if ($tpl->getVar('tpl_tplset') == $xoopsConfig['template_set']) { include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_touch($tpl_id, true); } } } } else { $err = 'Failed uploading file'; } if (isset($err)) { xoops_cp_header(false); xoops_error($err); xoops_cp_footer(); exit(); } redirect_header('admin.php?fct=tplsets&op=listtpl&moddir='.$tpl->getVar('tpl_module').'&tplset='.urlencode($tpl->getVar('tpl_tplset')), 2, _MD_AM_DBUPDATED); } break; // upload new file case 'uploadtpl2': if (!isset($tplset) || !isset($moddir) || !isset($file) || !isset($type) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = $myts->htmlSpecialChars($tplset); $moddir = $myts->htmlSpecialChars($moddir); $file = $myts->htmlSpecialChars($file); $type = $myts->htmlSpecialChars($type); xoops_cp_header(); $tplset = htmlspecialchars($tplset); $moddir = htmlspecialchars($moddir); echo ''. _MD_TPLMAIN .' »» '.$tplset.' »» '._MD_UPLOAD.'

'; include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $form = new XoopsThemeForm(_MD_UPLOAD, 'tplupload_form', 'admin.php'); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new XoopsFormToken(XoopsSingleTokenHandler::quickCreate('uploadtpl2'))); $form->addElement(new XoopsFormLabel(_MD_FILENAME, $file)); $form->addElement(new XoopsFormFile(_MD_CHOOSEFILE.'
'._MD_UPWILLREPLACE.'', 'tpl_upload', 200000), true); $form->addElement(new XoopsFormHidden('moddir', $moddir)); $form->addElement(new XoopsFormHidden('tplset', $tplset)); $form->addElement(new XoopsFormHidden('file', $file)); $form->addElement(new XoopsFormHidden('type', $type)); $form->addElement(new XoopsFormHidden('op', 'uploadtpl2_go')); $form->addElement(new XoopsFormHidden('fct', 'tplsets')); $form->addElement(new XoopsFormButton('', 'ploadtarupload_button', _MD_UPLOAD, 'submit')); $form->display(); xoops_cp_footer(); break; case 'uploadtpl2_go': if(!XoopsSingleTokenHandler::quickValidate('uploadtpl2')) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- if ( !isset($_POST['tplset'])|| !isset($_POST['moddir'])|| !isset($_POST['file']) || !isset($_POST['type']) || !isset($_POST['ploadtarupload_button']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = ($_POST['tplset'])? trim(strip_tags($myts->stripSlashesGPC($_POST['tplset']))) : null; $moddir = ($_POST['moddir'])? trim(strip_tags($myts->stripSlashesGPC($_POST['moddir']))) : null; $file = ($_POST['file'])? trim(strip_tags($myts->stripSlashesGPC($_POST['file']))) : null; $type = ($_POST['type'])? trim(strip_tags($myts->stripSlashesGPC($_POST['type']))) : null; //------------------------- include_once XOOPS_ROOT_PATH.'/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('text/html', 'application/x-cdf', 'text/plain'), 200000); $uploader->setAllowedExtensions(array('html', 'htm')); $uploader->setPrefix('tmp'); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if (!$uploader->upload()) { $err = $uploader->getErrors(); } else { $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->find('default', $type, null, $moddir, $file); if (is_array($tplfile)) { $tpl =& $tplfile[0]->xoopsClone(); $tpl->setVar('tpl_id', 0); $tpl->setVar('tpl_tplset', $tplset); $tpl->setVar('tpl_lastmodified', time()); $fp = @fopen($uploader->getSavedDestination(), 'r'); $fsource = @fread($fp, filesize($uploader->getSavedDestination())); @fclose($fp); $tpl->setVar('tpl_source', $fsource, true); @unlink($uploader->getSavedDestination()); if (!$tpltpl_handler->insert($tpl)) { $err = 'Failed inserting data to database'; } else { if ($tplset == $xoopsConfig['template_set']) { include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_touch($tpl->getVar('tpl_id'), true); } } } else { $err = 'This template file does not need to be installed (PHP files using this template file does not exist)'; } } } else { $err = 'Failed uploading file'; } if (isset($err)) { xoops_cp_header(false); xoops_error($err); xoops_cp_footer(); exit(); } redirect_header('admin.php?fct=tplsets&op=listtpl&moddir='.$myts->htmlSpecialChars($moddir).'&tplset='.urlencode($myts->htmlSpecialChars($tplset)), 2, _MD_AM_DBUPDATED); break; case 'download': if (!isset($_GET['tplset'])) { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tar_method = ($_GET['method'])? trim(strip_tags($myts->stripSlashesGPC($_GET['method']))) : 'zip'; $tar_method = $myts->htmlSpecialChars($tar_method); $tplset = $myts->htmlSpecialChars($tplset); xoops_cp_header(); xoops_confirm(array('tplset' => $tplset, 'tar_method' => $tar_method, 'op' => 'download_go', 'fct' => 'tplsets') , 'admin.php', _MD_PLZGENERATE, _MD_GENERATE); xoops_cp_footer(); break; case 'download_go': if(!xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- if ( !isset($_POST['tplset'])|| !isset($_POST['tar_method']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = isset($_POST['tplset']) ? trim(strip_tags($myts->stripSlashesGPC($_POST['tplset']))) : null; $tar_method = ($_POST['tar_method'])? trim(strip_tags($myts->stripSlashesGPC($_POST['tar_method']))) : null; //------------------------- if (isset($tplset)) { if (false != extension_loaded('zlib')) { if (isset($tar_method) && $tar_method == 'tar') { if (@function_exists('gzencode')) { require_once(XOOPS_ROOT_PATH.'/class/tardownloader.php'); $downloader = new XoopsTarDownloader(); } } else { if (@function_exists('gzcompress')) { require_once(XOOPS_ROOT_PATH.'/class/zipdownloader.php'); $downloader = new XoopsZipDownloader(); } } $tplset_handler =& xoops_gethandler('tplset'); $tplsetobj =& $tplset_handler->getByName($tplset); $xml = "<"."?xml version=\"1.0\"?".">\r\n\r\n ".$tplset."\r\n ".$tplsetobj->getVar('tplset_created')."\r\n \r\n".$tplsetobj->getVar('tplset_credits')."\r\n \r\n ".XOOPS_VERSION."\r\n "; $tpltpl_handler =& xoops_gethandler('tplfile'); $files =& $tpltpl_handler->getObjects(new Criteria('tpl_tplset', $tplset), true); $fcount = count($files); if ($fcount > 0) { for ($i = 0; $i < $fcount; $i++) { if ($files[$i]->getVar('tpl_type') == 'block') { $path = $tplset.'/templates/'.$files[$i]->getVar('tpl_module').'/blocks/'.$files[$i]->getVar('tpl_file'); $xml .= "\r\n "; } elseif ($files[$i]->getVar('tpl_type') == 'module') { $path = $tplset.'/templates/'.$files[$i]->getVar('tpl_module').'/'.$files[$i]->getVar('tpl_file'); $xml .= "\r\n "; } $downloader->addFileData($files[$i]->getVar('tpl_source'), $path, $files[$i]->getVar('tpl_lastmodified')); } $xml .= "\r\n "; /* $xml ." "\r\n "; $image_handler =& xoops_gethandler('imagesetimg'); $criteria = new CriteriaCompo(new Criteria('l.tplset_name', $tplset)); $criteria->add(new Criteria('s.imgset_refid', 0)); $ifiles =& $image_handler->getObjects($criteria); $fcount = count($ifiles); for ($i = 0; $i < $fcount; $i++) { $dummyimage = XOOPS_CACHE_PATH.'/_dummyimage'.$i.time(); $fp = @fopen($dummyimage, 'wb'); @fwrite($fp, $ifiles[$i]->getVar('imgsetimg_body')); @fclose($fp); $downloader->addBinaryFile($dummyimage, $tplset.'/images/'.$ifiles[$i]->getVar('imgsetimg_file')); @unlink($dummyimage); $xml .= " \r\n getVar('imgsetimg_file')."\">"; } */ } //$xml .= "\r\n $xml .= "\r\n"; $downloader->addFileData($xml, $tplset.'/tplset.xml', time()); echo $downloader->download($tplset, true); } else { xoops_cp_header(); xoops_error(_MD_NOZLIB); xoops_cp_footer(); } } break; case 'generatetpl': if (!isset($tplset) || !isset($moddir) || !isset($file) || !isset($type) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = $myts->htmlSpecialChars($tplset); $moddir = $myts->htmlSpecialChars($moddir); $file = $myts->htmlSpecialChars($file); $type = $myts->htmlSpecialChars($type); xoops_cp_header(); xoops_confirm(array('tplset' => $tplset, 'moddir' => $moddir, 'file' => $file, 'type' => $type, 'op' => 'generatetpl_go', 'fct' => 'tplsets'), 'admin.php', _MD_PLZGENERATE, _MD_GENERATE); xoops_cp_footer(); break; case 'generatetpl_go': if(!xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- if ( !isset($_POST['tplset'])|| !isset($_POST['moddir']) || !isset($_POST['file']) || !isset($_POST['type']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = ($_POST['tplset'])? trim(strip_tags($myts->stripSlashesGPC($_POST['tplset']))) : null; $moddir = ($_POST['moddir'])? trim(strip_tags($myts->stripSlashesGPC($_POST['moddir']))) : null; $file = ($_POST['file'])? trim(strip_tags($myts->stripSlashesGPC($_POST['file']))) : null; $type = ($_POST['type'])? trim(strip_tags($myts->stripSlashesGPC($_POST['type']))) : null; //------------------------- $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->find('default', $type, null, $moddir, $file, true); if (count($tplfile) > 0) { $newtpl =& $tplfile[0]->xoopsClone(); $newtpl->setVar('tpl_id', 0); $newtpl->setVar('tpl_tplset', $tplset); $newtpl->setVar('tpl_lastmodified', time()); $newtpl->setVar('tpl_lastimported', 0); if (!$tpltpl_handler->insert($newtpl)) { $err = 'ERROR: Could not insert template '.$tplfile[0]->getVar('tpl_file').' to the database.'; } else { if ($tplset == $xoopsConfig['template_set']) { include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_touch($newtpl->getVar('tpl_id')); } } } else { $err = 'Selected file does not exist)'; } if (!isset($err)) { redirect_header('admin.php?fct=tplsets&op=listtpl&moddir='.$newtpl->getVar('tpl_module').'&tplset='.urlencode($newtpl->getVar('tpl_tplset')), 2, _MD_AM_DBUPDATED); } xoops_cp_header(); xoops_error($err); echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'generatemod': if (!isset($tplset) || !isset($moddir) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = $myts->htmlSpecialChars($tplset); $moddir = $myts->htmlSpecialChars($moddir); xoops_cp_header(); xoops_confirm(array('tplset' => $tplset, 'op' => 'generatemod_go', 'fct' => 'tplsets', 'moddir' => $moddir), 'admin.php', _MD_PLZGENERATE, _MD_GENERATE); xoops_cp_footer(); break; case 'generatemod_go': if(!xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- if ( !isset($_POST['tplset'])|| !isset($_POST['moddir']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = ($_POST['tplset'])? trim(strip_tags($myts->stripSlashesGPC($_POST['tplset']))) : null; $moddir = ($_POST['moddir'])? trim(strip_tags($myts->stripSlashesGPC($_POST['moddir']))) : null; //------------------------- $tpltpl_handler =& xoops_gethandler('tplfile'); xoops_cp_header(); echo ''; $tplfiles =& $tpltpl_handler->find('default', 'module', null, $moddir, null, true); $fcount = count($tplfiles); if ($fcount > 0) { echo 'Installing module template files for template set '.$myts->htmlSpecialChars($tplset).'...
'; for ($i = 0; $i < $fcount; $i++) { $newtpl =& $tplfiles[$i]->xoopsClone(); $newtpl->setVar('tpl_id', 0); $newtpl->setVar('tpl_tplset', $tplset); $newtpl->setVar('tpl_lastmodified', time()); $newtpl->setVar('tpl_lastimported', 0); if (!$tpltpl_handler->insert($newtpl)) { echo '  ERROR: Could not insert template '.$tplfiles[$i]->getVar('tpl_file').' to the database.
'; } else { if ($tplset == $xoopsConfig['template_set']) { include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_touch($newtpl->getVar('tpl_id')); } echo '  Template '.$tplfiles[$i]->getVar('tpl_file').' added to the database.
'; } } flush(); unset($newtpl); } unset($tplfiles); $tplfiles =& $tpltpl_handler->find('default', 'block', null, $moddir, null, true); $fcount = count($tplfiles); if ($fcount > 0) { echo '  Installing block template files...
'; for ($i = 0; $i < $fcount; $i++) { $newtpl =& $tplfiles[$i]->xoopsClone(); $newtpl->setVar('tpl_id', 0); $newtpl->setVar('tpl_tplset', $tplset); $newtpl->setVar('tpl_lastmodified', time()); $newtpl->setVar('tpl_lastimported', 0); if (!$tpltpl_handler->insert($newtpl)) { echo '    ERROR: Could not insert block template '.$tplfiles[$i]->getVar('tpl_file').' to the database.
';echo $newtpl->getHtmlErrors(); } else { if ($tplset == $xoopsConfig['template_set']) { include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_touch($newtpl->getVar('tpl_id')); } echo '    Block template '.$tplfiles[$i]->getVar('tpl_file').' added to the database.
'; } } flush(); unset($newtpl); } echo '
Module template files for template set '.$myts->htmlSpecialChars($tplset).' generated and installed.

'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'uploadtar_go': if(!XoopsSingleTokenHandler::quickValidate('tplsets_uploadtar')) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- if ( !isset($_POST['tplset_name']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset_name = $myts->htmlSpecialChars($_POST['tplset_name']); include_once XOOPS_ROOT_PATH.'/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('application/x-gzip', 'application/gzip', 'application/gzip-compressed', 'application/x-gzip-compressed', 'application/x-tar', 'application/x-tar-compressed', 'application/octet-stream'), 1000000); $uploader->setAllowedExtensions(array('tar', 'tar.gz', 'tgz', 'gz')); $uploader->setPrefix('tmp'); xoops_cp_header(); echo ''; if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if (!$uploader->upload()) { xoops_error($uploader->getErrors()); } else { include_once XOOPS_ROOT_PATH.'/class/class.tar.php'; $tar = new tar(); $tar->openTar($uploader->getSavedDestination()); @unlink($uploader->getSavedDestination()); $themefound = false; foreach ($tar->files as $id => $info) { $infoarr = explode('/', str_replace("\\", '/', $info['name'])); if (!isset($tplset_name)) { $tplset_name = trim(strip_tags($infoarr[0])); } else { $tplset_name = trim(strip_tags($tplset_name)); if ($tplset_name == '') { $tplset_name = trim(strip_tags($infoarr[0])); } } if ($tplset_name != '') { break; } } if ($tplset_name == '') { echo 'ERROR: Template file not found
'; } else { $tplset_handler =& xoops_gethandler('tplset'); if ($tplset_handler->getCount(new Criteria('tplset_name', $tplset_name)) > 0) { echo 'ERROR: Template set '.$myts->htmlSpecialChars($tplset_name).' already exists.
'; } else { $tplset =& $tplset_handler->create(); $tplset->setVar('tplset_name', $tplset_name); $tplset->setVar('tplset_created', time()); if (!$tplset_handler->insert($tplset)) { echo 'ERROR: Could not create template set '.$tplset_name.'.
'; } else { $tplsetid = $tplset->getVar('tplset_id'); echo 'Template set '.$myts->htmlSpecialChars($tplset_name).' created. (ID: '.$tplsetid.')
'; $tpltpl_handler = xoops_gethandler('tplfile'); $themeimages = array(); foreach ($tar->files as $id => $info) { $infoarr = explode('/', str_replace("\\", '/', $info['name'])); if (isset($infoarr[3]) && trim($infoarr[3]) == 'blocks') { $default =& $tpltpl_handler->find('default', 'block', null, trim(strip_tags($myts->stripSlashesGPC($infoarr[2]))), trim(strip_tags($myts->stripSlashesGPC($infoarr[4])))); } elseif ((!isset($infoarr[4]) || trim($infoarr[4]) == '') && $infoarr[1] == 'templates') { $default =& $tpltpl_handler->find('default', 'module', null, trim(strip_tags($myts->stripSlashesGPC($infoarr[2]))), trim(strip_tags($myts->stripSlashesGPC($infoarr[3])))); } elseif (isset($infoarr[3]) && trim($infoarr[3]) == 'images') { $infoarr[2] = trim(strip_tags($myts->stripSlashesGPC($infoarr[2]))); if (preg_match("/(.*)\.(gif|jpg|jpeg|png)$/i", $infoarr[2], $match)) { $themeimages[] = array('name' => $infoarr[2], 'content' => $info['file']); } } if (isset($default) && count($default) > 0) { $newtpl =& $default[0]->xoopsClone(); $newtpl->setVar('tpl_id', 0); $newtpl->setVar('tpl_tplset', $tplset_name); $newtpl->setVar('tpl_source', $info['file'], true); $newtpl->setVar('tpl_lastmodified', time()); if (!$tpltpl_handler->insert($newtpl)) { echo '  ERROR: Could not insert '.$myts->htmlSpecialChars($info['name']).' to the database.
'; } else { echo '  '.$myts->htmlSpecialChars($info['name']).' inserted to the database.
'; } unset($default); } unset($info); } $icount = count($themeimages); if ($icount > 0) { $imageset_handler =& xoops_gethandler('imageset'); $imgset =& $imageset_handler->create(); $imgset->setVar('imgset_name', $tplset_name); $imgset->setVar('imgset_refid', 0); if (!$imageset_handler->insert($imgset)) { echo '  ERROR: Could not create image set.
'; } else { $newimgsetid = $imgset->getVar('imgset_id'); echo '  Image set '.$myts->htmlSpecialChars($tplset_name).' created. (ID: '.$myts->htmlSpecialChars($newimgsetid).')
'; if (!$imageset_handler->linktplset($newimgsetid, $tplset_name)) { echo '  ERROR: Failed linking image set to template set '.$myts->htmlSpecialChars($tplset_name).'
'; } $image_handler =& xoops_gethandler('imagesetimg'); for ($i = 0; $i < $icount; $i++) { if (isset($themeimages[$i]['name']) && $themeimages[$i]['name'] != '') { $image =& $image_handler->create(); $image->setVar('imgsetimg_file', $themeimages[$i]['name']); $image->setVar('imgsetimg_imgset', $newimgsetid); $image->setVar('imgsetimg_body', $themeimages[$i]['content'], true); if (!$image_handler->insert($image)) { echo '  ERROR: Failed storing image file data to database.
'; } else { echo '  Image file data stored into database. (ID: '.$image->getVar('imgsetimg_id').')
'; } } } } } } } } } } else { echo 'ERROR: Failed uploading file'; } echo '

'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'previewtpl': $id = !empty($_POST['id']) ? intval($_POST['id']) : 0; if ($id <= 0 || !XoopsMultiTokenHandler::quickValidate('tplform')) { redirect_header('admin.php?fct=tplsets',3); } //------------------------- if ( !isset($_POST['moddir'])|| !isset($_POST['redirect'])|| !isset($_POST['html']) || !isset($_POST['previewtpl']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } if (!isset($_POST['previewtpl'])){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $moddir = $myts->htmlSpecialChars($_POST['moddir']); //------------------------- require_once XOOPS_ROOT_PATH.'/class/template.php'; $myts =& MyTextsanitizer::getInstance(); $html = !empty($_POST['html']) ? $myts->stripSlashesGPC($_POST['html']) : ''; $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->get($id, true); $xoopsTpl = new XoopsTpl(); if (is_object($tplfile)) { // $moddir = $_POST['moddir']; $dummylayout = ''.$myts->htmlSpecialChars($xoopsConfig['sitename']).'<{$content}>'; if ($tplfile->getVar('tpl_type') == 'block') { include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php'; $block = new XoopsBlock($tplfile->getVar('tpl_refid')); $xoopsTpl->assign('block', $block->buildBlock()); } list( $usec , $sec ) = explode( " " , microtime() ) ; // $dummytpl = '_dummytpl_'.time().'.html'; $dummytpl = '_dummytpl_' .time() . md5( $usec . $_SERVER['PATH'] . $sec ) . '.html'; $fp = fopen(XOOPS_CACHE_PATH.'/'.$dummytpl, 'w'); fwrite($fp, $html); fclose($fp); $xoopsTpl->assign('content', $xoopsTpl->fetch('file:'.XOOPS_CACHE_PATH.'/'.$dummytpl)); $xoopsTpl->clear_compiled_tpl('file:'.XOOPS_CACHE_PATH.'/'.$dummytpl); unlink(XOOPS_CACHE_PATH.'/'.$dummytpl); // $dummyfile = '_dummy_'.time().'.html'; $dummyfile = '_dummy_' .time() . md5( $usec . $_SERVER['PATH'] . $sec ) . '.html'; $fp = fopen(XOOPS_CACHE_PATH.'/'.$dummyfile, 'w'); fwrite($fp, $dummylayout); fclose($fp); $tplset= $tplfile->getVar('tpl_tplset'); $tform = array('tpl_tplset' => $tplset, 'tpl_id' => $id, 'tpl_file' => $tplfile->getVar('tpl_file'), 'tpl_desc' => $tplfile->getVar('tpl_desc'), 'tpl_lastmodified' => $tplfile->getVar('tpl_lastmodified'), 'tpl_source' => htmlspecialchars($html, ENT_QUOTES), 'tpl_module' => $moddir); include_once XOOPS_ROOT_PATH.'/modules/system/admin/tplsets/tplform.php'; xoops_cp_header(); echo ''. _MD_TPLMAIN .' »» '.$tplset.' »» '._MD_EDITTEMPLATE.'

'; $form->display(); //HACK by domifara --------------------- $original_level = error_reporting( E_ALL ) ; if ($tplfile->getVar('tpl_type') == 'block') { echo "
".$block->getVar('title')."
".$xoopsTpl->fetch('file:'.XOOPS_CACHE_PATH.'/'.$dummyfile)."
\n" ; } else { $html = preg_replace("/(<\{.*\}>)/" ,$myts->htmlSpecialChars( "$1") , $html ) ; echo "
"."Module Template Preview"."
" . $html . "
\n" ; } // $xoopsTpl->clear_compiled_tpl('file:'.XOOPS_CACHE_PATH.'/'.$dummyfile); // unlink(XOOPS_CACHE_PATH.'/'.$dummyfile); error_reporting( $original_level ) ; //--------------------------------------------- xoops_cp_footer(); echo ''; } break; case 'update': if (!XoopsMultiTokenHandler::quickValidate('tplsets_update')) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } // $tplset = $_POST['tplset']; // $moddir = $_POST['moddir']; //------------------------- if ( !isset($_POST['moddir']) || !isset($_POST['tplset']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $moddir = $myts->htmlSpecialChars($_POST['moddir']); $tplset = $myts->htmlSpecialChars($_POST['tplset']); //------------------------- $old_template = (isset($_POST['old_template']))? $_POST['old_template'] : null ; //------------------------- include_once XOOPS_ROOT_PATH.'/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('text/html', 'application/x-cdf'), 200000); $uploader->setAllowedExtensions(array('html', 'htm')); $uploader->setPrefix('tmp'); $msg = array(); foreach ($_POST['xoops_upload_file'] as $upload_file) { // '.' is converted to '_' when upload $upload_file2 = str_replace('.', '_', $upload_file); if ($uploader->fetchMedia($upload_file2)) { if (!$uploader->upload()) { $msg[] = $uploader->getErrors(); } else { $tpltpl_handler =& xoops_gethandler('tplfile'); if (empty($old_template[$upload_file])) { $tplfile =& $tpltpl_handler->find('default', null, null, $moddir, $upload_file); if (count($tplfile) > 0) { $tpl =& $tplfile[0]->xoopsClone(); $tpl->setVar('tpl_id', 0); $tpl->setVar('tpl_tplset', $tplset); } else { $msg[] = 'Template file '.$myts->htmlSpecialChars($upload_file).' does not need to be installed (PHP files using this template file does not exist)'; continue; } } else { $tpl =& $tpltpl_handler->get(trim(strip_tags($myts->stripSlashesGPC($old_template[$upload_file])))); } $tpl->setVar('tpl_lastmodified', time()); $fp = @fopen($uploader->getSavedDestination(), 'r'); $fsource = @fread($fp, filesize($uploader->getSavedDestination())); @fclose($fp); $tpl->setVar('tpl_source', $fsource, true); @unlink($uploader->getSavedDestination()); if (!$tpltpl_handler->insert($tpl)) { $msg[] = 'Failed inserting data for '.$myts->htmlSpecialChars($upload_file).' to database'; } else { $msg[] = 'Template file '.$myts->htmlSpecialChars($upload_file).' updated.'; if ($tplset == $xoopsConfig['template_set']) { include_once XOOPS_ROOT_PATH.'/class/template.php'; if (xoops_template_touch($tpl->getVar('tpl_id'), true)) { $msg[] = 'Template file '.$myts->htmlSpecialChars($upload_file).' compiled.'; } } } } } else { if ($uploader->getMediaName() == '') { continue; } else { $msg[] = $uploader->getErrors(); } } } xoops_cp_header(); echo ''; foreach ($msg as $m) { echo $m.'
'; } echo '

'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'importtpl': if (!isset($tplset) || !isset($moddir) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = $myts->htmlSpecialChars($tplset); $moddir = $myts->htmlSpecialChars($moddir); xoops_cp_header(); if (!empty($id)) { xoops_confirm(array('tplset' => $tplset, 'moddir' => $moddir, 'id' => $id, 'op' => 'importtpl_go', 'fct' => 'tplsets'), 'admin.php', _MD_RUSUREIMPT, _MD_IMPORT); } elseif (isset($file)) { xoops_confirm(array('tplset' => $tplset, 'moddir' => $moddir, 'file' => $file, 'op' => 'importtpl_go', 'fct' => 'tplsets'), 'admin.php', _MD_RUSUREIMPT, _MD_IMPORT); } xoops_cp_footer(); break; case 'importtpl_go': if(!xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- // $tplset = $_POST['tplset']; // $moddir = $_POST['moddir']; // $id = !empty($_POST['id']) ? intval($_POST['id']) : 0; // $file = !empty($_POST['file']) ? $_POST['file'] : null; //------------------------- if ( !isset($_POST['moddir'])|| !isset($_POST['tplset']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = $myts->htmlSpecialChars($_POST['tplset']); $moddir = $myts->htmlSpecialChars($_POST['moddir']); //------------------------- $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile = ''; if (!empty($id)) { //------------------------- $id = ($_POST['id'])? intval($_POST['id']) : 0; if ($id <= 0) { redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplfile =& $tpltpl_handler->get($id, true); } else { //------------------------- if (empty($_POST['file']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $file = !empty($_POST['file']) ? trim(strip_tags($myts->stripSlashesGPC($_POST['file']))) : null; $tplfiles =& $tpltpl_handler->find('default', null, null, null, $file, true); $tplfile = (count($tplfiles) > 0) ? $tplfiles[0] : ''; } $error = true; if (is_object($tplfile)) { switch ($tplfile->getVar('tpl_type')) { case 'module': $filepath = XOOPS_ROOT_PATH.'/templates/'.$tplset.'/'.$tplfile->getVar('tpl_module').'/'.$tplfile->getVar('tpl_file'); break; case 'block': $filepath = XOOPS_ROOT_PATH.'/templates/'.$tplset.'/'.$tplfile->getVar('tpl_module').'/blocks/'.$tplfile->getVar('tpl_file'); break; default: break; } if (file_exists($filepath)) { if (false != $fp = fopen($filepath, 'r')) { $filesource = fread($fp, filesize($filepath)); fclose($fp); $tplfile->setVar('tpl_source', $filesource, true); $tplfile->setVar('tpl_tplset', $tplset); $tplfile->setVar('tpl_lastmodified', time()); $tplfile->setVar('tpl_lastimported', time()); if (!$tpltpl_handler->insert($tplfile)) { } else { $error = false; } } } } if (false != $error) { xoops_cp_header(); xoops_error('Could not import file '.$filepath); echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); exit(); } redirect_header('admin.php?fct=tplsets&op=listtpl&moddir='.$tplfile->getVar('tpl_module').'&tplset='.urlencode($tplfile->getVar('tpl_tplset')), 2, _MD_AM_DBUPDATED); break; //HACK start ------------------------------------------------------- case 'deletemod': if (!isset($tplset) || !isset($moddir) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = $myts->htmlSpecialChars($tplset); $moddir = $myts->htmlSpecialChars($moddir); xoops_cp_header(); xoops_confirm(array('tplset' => $tplset, 'op' => 'deletemod_go', 'fct' => 'tplsets', 'moddir' => $moddir) , 'admin.php', _MD_RUSUREDELTPL, _DELETE); xoops_cp_footer(); break; case 'deletemod_go': if(!xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- if ( !isset($_POST['moddir'])|| !isset($_POST['tplset']) ){ redirect_header('admin.php?fct=tplsets', 1 , _TAKINGBACK); } $tplset = trim(strip_tags($myts->stripSlashesGPC($_POST['tplset']))); $moddir = trim(strip_tags($myts->stripSlashesGPC($_POST['moddir']))); //------------------------- $msgs = array(); //HACK start ------------------------------------------------------- $module =& $module_handler->getByDirname($moddir); if ($tplset != 'default' || !is_object($module)) { $tpltpl_handler =& xoops_gethandler('tplfile'); $templates =& $tpltpl_handler->find($tplset , null, null, $moddir, null, false); $tcount = count($templates); if ($tcount > 0) { $msgs[] = 'Deleting template files...'; for ($i = 0; $i < $tcount; $i++) { if (!$tpltpl_handler->delete($templates[$i])) { $msgs[] = '  ERROR: Could not delete template '.$templates[$i]->getVar('tpl_file').'. ID: '.$templates[$i]->getVar('tpl_id').''; } else { $msgs[] = '  Template '.$templates[$i]->getVar('tpl_file').' deleted. ID: '.$templates[$i]->getVar('tpl_id').''; } } } } else { $msgs[] = 'ERROR: Default template files cannot be deleted'; } xoops_cp_header(); foreach ($msgs as $msg) { echo ''.$msg.'
'; } echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'deletetemplate_c': if(!XoopsSingleTokenHandler::quickValidate('deletetemplate_c_submit')) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- xoops_cp_header(); xoops_confirm(array('ok' => 1, 'op' => 'deletetemplate_c_go', 'fct' => 'tplsets') , 'admin.php', _MD_RUSUREDELTPL, _DELETE); xoops_cp_footer(); break; case 'deletetemplate_c_go': if(!xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- $msgs = array(); //templates_c $msgs[] = 'Deleting smarty template_c compile cache files...'; if ($handle = opendir(XOOPS_COMPILE_PATH)) { while (false !== ($fdir = readdir($handle))) { if($fdir == '.' || $fdir == '..' ) { continue; } elseif ($fdir == '.htaccess' || $fdir == 'index.html') { $msgs[] = '(Not deleted :'.$fdir . ')'; } elseif (substr( XOOPS_COMPILE_PATH . DIRECTORY_SEPARATOR . $fdir, 0, strlen( XOOPS_COMPILE_PATH )) == XOOPS_COMPILE_PATH ) { unlink(XOOPS_COMPILE_PATH.'/'.$fdir); $msgs[] = 'deleted cache :'.$fdir; } } closedir($handle); } xoops_cp_header(); foreach ($msgs as $msg) { echo ''.$myts->htmlSpecialChars($msg).'
'; } echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; case 'deletecache': if(!XoopsSingleTokenHandler::quickValidate('deletecache_submit')) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- xoops_cp_header(); xoops_confirm(array('op' => 'deletecache_go', 'fct' => 'tplsets') , 'admin.php', _MD_RUSUREDELTPL, _DELETE); xoops_cp_footer(); break; case 'deletecache_go': if(!xoops_confirm_validate()) { redirect_header('admin.php?fct=tplsets',3,'Ticket Error'); } //------------------------- $msgs = array(); //cache $msgs[] = 'Deleting s xoops cache files...'; if ($handle = opendir(XOOPS_CACHE_PATH)) { while (false !== ($fdir = readdir($handle))) { if ($fdir == '.' || $fdir == '..' ) { continue; } elseif ($fdir == '.htaccess' || $fdir == 'index.html' || $fdir == 'adminmenu.php') { $msgs[] = '(Not deleted :'.$fdir . ')'; } elseif (substr( XOOPS_CACHE_PATH . DIRECTORY_SEPARATOR . $fdir, 0, strlen( XOOPS_CACHE_PATH )) == XOOPS_CACHE_PATH ) { unlink(XOOPS_CACHE_PATH.'/'.$fdir); $msgs[] = 'deleted cache :'.$fdir; } } closedir($handle); } xoops_cp_header(); foreach ($msgs as $msg) { echo ''.$myts->htmlSpecialChars($msg).'
'; } echo '
'._MD_AM_BTOTADMIN.''; xoops_cp_footer(); break; //HACK end ------------------------------------------------------- default: break; } } ?>