예제 #1
0
 /**
  * Assigns template filename for handle.
  */
 function set_filename($handle, $filename, $xs_include = false, $quiet = false)
 {
     global $config;
     $can_cache = $this->use_cache;
     if (strpos($filename, '..') !== false) {
         $can_cache = false;
     }
     $this->files[$handle] = $this->make_filename($filename, $xs_include);
     $this->files_cache[$handle] = '';
     $this->files_cache2[$handle] = '';
     // check if we are in admin control panel and override extreme styles mod controls if needed
     if (defined('XS_ADMIN_OVERRIDE') && XS_ADMIN_OVERRIDE === true && @function_exists('xs_admin_override')) {
         xs_admin_override();
     }
     // checking if we have valid filename
     if (!$this->files[$handle]) {
         if ($this->files[$handle] === false || $xs_include || $quiet) {
             return false;
         } else {
             die("Template->make_filename(): Error - invalid template {$filename}");
         }
     }
     // creating cache filename
     if ($can_cache) {
         $this->files_cache2[$handle] = $this->make_filename_cache($this->files[$handle]);
         if (@file_exists($this->files_cache2[$handle])) {
             $this->files_cache[$handle] = $this->files_cache2[$handle];
         }
     }
     // checking if tpl and/or php file exists
     if (empty($this->files_cache[$handle]) && !@file_exists($this->files[$handle])) {
         // trying to load alternative filename (usually default)
         if (!empty($this->tpldef) && !empty($this->tpl) && $this->tpldef !== $this->tpl) {
             $this->files[$handle] = '';
             // save old configuration
             $root = $this->root;
             $tpl_name = $this->tpl;
             // set temporary configuration
             $this->root = $this->tpldir . $this->tpldef;
             $this->tpl = $this->tpldef;
             // recursively run set_filename
             $res = $this->set_filename($handle, $filename, $xs_include, $quiet);
             // restore old configuration
             $this->root = $root;
             $this->tpl = $tpl_name;
             return $res;
         }
         if ($quiet) {
             return false;
         }
         if ($xs_include) {
             if ($config['xs_warn_includes']) {
                 //die('Template->make_filename(): Error - included template file not found: ' . $this->tpl . $filename);
                 die('Template->make_filename(): Error - included template file not found: ' . $filename);
             }
             return false;
         } else {
             //die('Template->make_filename(): Error - template file not found: ' . $this->tpl . $filename);
             die('Template->make_filename(): Error - template file not found: ' . $filename);
         }
     }
     // checking if we should recompile cache
     if (!empty($this->files_cache[$handle]) && !empty($config['xs_auto_recompile'])) {
         $cache_time = @filemtime($this->files_cache[$handle]);
         if (@filemtime($this->files[$handle] > $cache_time) || $config['xs_template_time'] > $cache_time) {
             // file was changed. don't use cache file (will be recompled if configuration allowes it)
             $this->files_cache[$handle] = '';
         }
     }
     return true;
 }
예제 #2
0
        }
    }
    // add menu for style configuration
    foreach ($board_config as $var => $value) {
        if (substr($var, 0, 9) === 'xs_style_') {
            $str = substr($var, 9);
            $module['Template_Config'][$str] = 'xs_frameset.' . $phpEx . '?action=style_config&tpl=' . urlencode($str);
        }
    }
}
if (!empty($setmodules)) {
    if (@function_exists('jr_admin_get_module_list')) {
        $tmp_mod = $module;
        global $module;
        $module = $tmp_mod;
        xs_admin_override(true);
    }
    return;
}
//
// Global defines for eXtreme Styles mod administration panel
//
define('STYLE_HEADER_START', 'xs_style_01<xs>');
define('STYLE_HEADER_END', '</xs>');
define('STYLE_HEADER_VERSION', '1');
define('STYLE_EXTENSION', '.style');
define('TAR_HEADER_PACK', 'a100A8A8A8A12A12A8A1A100A6A2A32A32A8A8a155a12');
define('TAR_HEADER_UNPACK', 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix/a12extra');
define('XS_MAX_ITEMS_PER_STYLE', 32);
define('XS_TEMP_DIR', '../cache/');
define('XS_FTP_LOCAL', 'no_ftp');
예제 #3
0
파일: template.php 프로젝트: Nekrofage/FJR
 /**
  * Assigns template filename for handle.
  */
 function set_filename($handle, $filename, $xs_include = false, $quiet = false)
 {
     global $board_config;
     if (false !== strpos($filename, 'areabb/mods/') && ROOT_STYLE == 'admin') {
         $filename = '../../' . $filename;
     }
     if (false !== strpos($filename, 'areabb/cache/') && ROOT_STYLE == 'page') {
         $filename = '../../' . $filename;
     }
     if (false !== strpos($filename, 'areabb/mods/') && ROOT_STYLE == 'page') {
         $filename = '../../' . $filename;
     }
     if (defined('ROOT_STYLE') && ROOT_STYLE == 'admin') {
         $this->assign_var('ROOT_STYLE', $root_style = '../../../');
     } else {
         if (defined('IN_ADMIN')) {
             $this->assign_var('ROOT_STYLE', $root_style = '../');
         } else {
             $this->assign_var('ROOT_STYLE', $root_style = './');
         }
     }
     $filename = str_replace('{ROOT}', defined('IN_ADMIN') ? '../../templates/' . $this->tpldef . '/' : '', $filename);
     $filename = str_replace('{T_TEMPLATE_NAME}', $this->tpl, $filename);
     $can_cache = $this->use_cache;
     /* V: I think we can work this out ;-).
     		if(strpos($filename, '..') !== false)
     		{
     			$can_cache = false;
     		}*/
     $this->files[$handle] = $this->make_filename($filename, $xs_include);
     $this->files_cache[$handle] = '';
     $this->files_cache2[$handle] = '';
     // check if we are in admin control panel and override extreme styles mod controls if needed
     if (defined('XS_ADMIN_OVERRIDE') && XS_ADMIN_OVERRIDE === true && @function_exists('xs_admin_override')) {
         xs_admin_override();
     }
     // checking if we have valid filename
     if (!$this->files[$handle]) {
         if ($xs_include || $quiet) {
             return false;
         } else {
             die("Template->make_filename(): Error - invalid template {$filename}");
         }
     }
     // creating cache filename
     if ($can_cache) {
         $this->files_cache2[$handle] = $this->make_filename_cache($this->files[$handle]);
         if (@file_exists($this->files_cache2[$handle])) {
             $this->files_cache[$handle] = $this->files_cache2[$handle];
         }
     }
     // checking if tpl and/or php file exists
     if (empty($this->files_cache[$handle]) && !@file_exists($this->files[$handle])) {
         // trying to load alternative filename (usually subSilver)
         if (!empty($this->tpldef) && !empty($this->tpl) && $this->tpldef !== $this->tpl) {
             $this->files[$handle] = '';
             // save old configuration
             $root = $this->root;
             $tpl_name = $this->tpl;
             // set temporary configuration
             $this->root = $this->tpldir . $this->tpldef;
             $this->tpl = $this->tpldef;
             // recursively run set_filename
             $res = $this->set_filename($handle, $filename, $xs_include, $quiet);
             // restore old configuration
             $this->root = $root;
             $this->tpl = $tpl_name;
             return $res;
         }
         if ($quiet) {
             return false;
         }
         if ($xs_include) {
             if ($board_config['xs_warn_includes']) {
                 die('Template->make_filename(): (xs_include) Error - included template file not found: ' . $filename);
             }
             return false;
         } else {
             if (DEBUG) {
                 debug_print_backtrace();
             }
             die('Template->make_filename(): (not include) Error - template file not found: ' . $filename);
         }
     }
     // checking if we should recompile cache
     if (!empty($this->files_cache[$handle]) && !empty($board_config['xs_auto_recompile'])) {
         $cache_time = @filemtime($this->files_cache[$handle]);
         if (@filemtime($this->files[$handle]) > $cache_time || $board_config['xs_template_time'] > $cache_time) {
             // file was changed. don't use cache file (will be recompiled if configuration allowes it)
             $this->files_cache[$handle] = '';
         }
     }
     return true;
 }