onokazu
onoka****@users*****
2006年 5月 1日 (月) 11:37:25 JST
Index: xoops2jp/html/class/smarty/core/core.assemble_plugin_filepath.php diff -u xoops2jp/html/class/smarty/core/core.assemble_plugin_filepath.php:1.1 xoops2jp/html/class/smarty/core/core.assemble_plugin_filepath.php:1.2 --- xoops2jp/html/class/smarty/core/core.assemble_plugin_filepath.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.assemble_plugin_filepath.php Mon May 1 11:37:25 2006 @@ -50,7 +50,7 @@ $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; $_params = array('file_path' => $_plugin_filepath); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); + require_once(SMARTY_CORE_DIR . 'core.get_include_path.php'); if(smarty_core_get_include_path($_params, $smarty)) { $_return = $_params['new_file_path']; break; Index: xoops2jp/html/class/smarty/core/core.create_dir_structure.php diff -u xoops2jp/html/class/smarty/core/core.create_dir_structure.php:1.1 xoops2jp/html/class/smarty/core/core.create_dir_structure.php:1.2 --- xoops2jp/html/class/smarty/core/core.create_dir_structure.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.create_dir_structure.php Mon May 1 11:37:25 2006 @@ -22,7 +22,7 @@ /* unix-style paths */ $_dir = $params['dir']; $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY); - $_new_dir = ($_dir{0}=='/') ? '/' : getcwd().'/'; + $_new_dir = (substr($_dir, 0, 1)=='/') ? '/' : getcwd().'/'; if($_use_open_basedir = !empty($_open_basedir_ini)) { $_open_basedirs = explode(':', $_open_basedir_ini); } Index: xoops2jp/html/class/smarty/core/core.display_debug_console.php diff -u xoops2jp/html/class/smarty/core/core.display_debug_console.php:1.1 xoops2jp/html/class/smarty/core/core.display_debug_console.php:1.2 --- xoops2jp/html/class/smarty/core/core.display_debug_console.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.display_debug_console.php Mon May 1 11:37:25 2006 @@ -23,7 +23,7 @@ // set path to debug template from SMARTY_DIR $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl'; if($smarty->security && is_file($smarty->debug_tpl)) { - $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl)); + $smarty->secure_dir[] = realpath($smarty->debug_tpl); } $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl'; } Index: xoops2jp/html/class/smarty/core/core.get_php_resource.php diff -u xoops2jp/html/class/smarty/core/core.get_php_resource.php:1.1 xoops2jp/html/class/smarty/core/core.get_php_resource.php:1.2 --- xoops2jp/html/class/smarty/core/core.get_php_resource.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.get_php_resource.php Mon May 1 11:37:25 2006 @@ -32,7 +32,7 @@ } else { // test for file in include_path $_params = array('file_path' => $params['resource_name']); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); + require_once(SMARTY_CORE_DIR . 'core.get_include_path.php'); if(smarty_core_get_include_path($_params, $smarty)) { $_include_path = $_params['new_file_path']; $_readable = true; @@ -56,7 +56,7 @@ if ($_readable) { if ($smarty->security) { - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_trusted.php'); + require_once(SMARTY_CORE_DIR . 'core.is_trusted.php'); if (!smarty_core_is_trusted($params, $smarty)) { $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); return false; Index: xoops2jp/html/class/smarty/core/core.is_secure.php diff -u xoops2jp/html/class/smarty/core/core.is_secure.php:1.1 xoops2jp/html/class/smarty/core/core.is_secure.php:1.2 --- xoops2jp/html/class/smarty/core/core.is_secure.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.is_secure.php Mon May 1 11:37:25 2006 @@ -27,18 +27,21 @@ foreach ((array)$params['resource_base_path'] as $curr_dir) { if ( ($_cd = realpath($curr_dir)) !== false && strncmp($_rp, $_cd, strlen($_cd)) == 0 && - $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { + substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { return true; } } } if (!empty($smarty->secure_dir)) { foreach ((array)$smarty->secure_dir as $curr_dir) { - if ( ($_cd = realpath($curr_dir)) !== false && - strncmp($_rp, $_cd, strlen($_cd)) == 0 && - $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { - return true; - } + if ( ($_cd = realpath($curr_dir)) !== false) { + if($_cd == $_rp) { + return true; + } elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && + substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) { + return true; + } + } } } } else { Index: xoops2jp/html/class/smarty/core/core.is_trusted.php diff -u xoops2jp/html/class/smarty/core/core.is_trusted.php:1.1 xoops2jp/html/class/smarty/core/core.is_trusted.php:1.2 --- xoops2jp/html/class/smarty/core/core.is_trusted.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.is_trusted.php Mon May 1 11:37:25 2006 @@ -25,7 +25,7 @@ if (!empty($curr_dir) && is_readable ($curr_dir)) { $_cd = realpath($curr_dir); if (strncmp($_rp, $_cd, strlen($_cd)) == 0 - && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { + && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { $_smarty_trusted = true; break; } Index: xoops2jp/html/class/smarty/core/core.process_cached_inserts.php diff -u xoops2jp/html/class/smarty/core/core.process_cached_inserts.php:1.1 xoops2jp/html/class/smarty/core/core.process_cached_inserts.php:1.2 --- xoops2jp/html/class/smarty/core/core.process_cached_inserts.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.process_cached_inserts.php Mon May 1 11:37:25 2006 @@ -20,7 +20,7 @@ for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { if ($smarty->debugging) { $_params = array(); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); $debug_start_time = smarty_core_get_microtime($_params, $smarty); } @@ -29,7 +29,7 @@ if (isset($args['script'])) { $_params = array('resource_name' => $smarty->_dequote($args['script'])); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); + require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); if(!smarty_core_get_php_resource($_params, $smarty)) { return false; } @@ -52,10 +52,10 @@ $replace = ''; } - $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']); + $params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i])); if ($smarty->debugging) { $_params = array(); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); $smarty->_smarty_debug_info[] = array('type' => 'insert', 'filename' => 'insert_'.$name, 'depth' => $smarty->_inclusion_depth, Index: xoops2jp/html/class/smarty/core/core.process_compiled_include.php diff -u xoops2jp/html/class/smarty/core/core.process_compiled_include.php:1.1 xoops2jp/html/class/smarty/core/core.process_compiled_include.php:1.2 --- xoops2jp/html/class/smarty/core/core.process_compiled_include.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.process_compiled_include.php Mon May 1 11:37:25 2006 @@ -20,6 +20,11 @@ $smarty->_cache_including = true; $_return = $params['results']; + + foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { + $smarty->_include($_include_file_path, true); + } + foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) { $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s', array(&$smarty, '_process_compiled_include_callback'), Index: xoops2jp/html/class/smarty/core/core.read_cache_file.php diff -u xoops2jp/html/class/smarty/core/core.read_cache_file.php:1.1 xoops2jp/html/class/smarty/core/core.read_cache_file.php:1.2 --- xoops2jp/html/class/smarty/core/core.read_cache_file.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.read_cache_file.php Mon May 1 11:37:25 2006 @@ -48,10 +48,11 @@ return false; } - $cache_split = explode("\n", $params['results'], 2); - $cache_header = $cache_split[0]; - - $_cache_info = unserialize($cache_header); + $_contents = $params['results']; + $_info_start = strpos($_contents, "\n") + 1; + $_info_len = (int)substr($_contents, 0, $_info_start - 1); + $_cache_info = unserialize(substr($_contents, $_info_start, $_info_len)); + $params['results'] = substr($_contents, $_info_start + $_info_len); if ($smarty->caching == 2 && isset ($_cache_info['expires'])){ // caching by expiration time @@ -89,17 +90,6 @@ } } - foreach ($_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { - if (empty($smarty->_cache_serials[$_include_file_path])) { - $smarty->_include($_include_file_path, true); - } - - if ($smarty->_cache_serials[$_include_file_path] != $_cache_serial) { - /* regenerate */ - return false; - } - } - $params['results'] = $cache_split[1]; $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info); $smarty->_cache_info = $_cache_info; Index: xoops2jp/html/class/smarty/core/core.rm_auto.php diff -u xoops2jp/html/class/smarty/core/core.rm_auto.php:1.1 xoops2jp/html/class/smarty/core/core.rm_auto.php:1.2 --- xoops2jp/html/class/smarty/core/core.rm_auto.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.rm_auto.php Mon May 1 11:37:25 2006 @@ -28,7 +28,7 @@ 'level' => 0, 'exp_time' => $params['exp_time'] ); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); + require_once(SMARTY_CORE_DIR . 'core.rmdir.php'); $_res = smarty_core_rmdir($_params, $smarty); } else { $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); @@ -47,7 +47,7 @@ 'level' => 1, 'exp_time' => $params['exp_time'] ); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); + require_once(SMARTY_CORE_DIR . 'core.rmdir.php'); $_res = smarty_core_rmdir($_params, $smarty); } else { // remove matching file names Index: xoops2jp/html/class/smarty/core/core.rmdir.php diff -u xoops2jp/html/class/smarty/core/core.rmdir.php:1.1 xoops2jp/html/class/smarty/core/core.rmdir.php:1.2 --- xoops2jp/html/class/smarty/core/core.rmdir.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.rmdir.php Mon May 1 11:37:25 2006 @@ -32,7 +32,6 @@ 'level' => $params['level'] + 1, 'exp_time' => $params['exp_time'] ); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); smarty_core_rmdir($_params, $smarty); } else { Index: xoops2jp/html/class/smarty/core/core.run_insert_handler.php diff -u xoops2jp/html/class/smarty/core/core.run_insert_handler.php:1.1 xoops2jp/html/class/smarty/core/core.run_insert_handler.php:1.2 --- xoops2jp/html/class/smarty/core/core.run_insert_handler.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.run_insert_handler.php Mon May 1 11:37:25 2006 @@ -14,7 +14,7 @@ function smarty_core_run_insert_handler($params, &$smarty) { - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); if ($smarty->debugging) { $_params = array(); $_debug_start_time = smarty_core_get_microtime($_params, $smarty); @@ -34,7 +34,7 @@ } else { if (isset($params['args']['script'])) { $_params = array('resource_name' => $smarty->_dequote($params['args']['script'])); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); + require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); if(!smarty_core_get_php_resource($_params, $smarty)) { return false; } @@ -51,7 +51,7 @@ $_content = $_funcname($params['args'], $smarty); if ($smarty->debugging) { $_params = array(); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); $smarty->_smarty_debug_info[] = array('type' => 'insert', 'filename' => 'insert_'.$params['args']['name'], 'depth' => $smarty->_inclusion_depth, Index: xoops2jp/html/class/smarty/core/core.smarty_include_php.php diff -u xoops2jp/html/class/smarty/core/core.smarty_include_php.php:1.1 xoops2jp/html/class/smarty/core/core.smarty_include_php.php:1.2 --- xoops2jp/html/class/smarty/core/core.smarty_include_php.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.smarty_include_php.php Mon May 1 11:37:25 2006 @@ -21,7 +21,7 @@ function smarty_core_smarty_include_php($params, &$smarty) { $_params = array('resource_name' => $params['smarty_file']); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); + require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); smarty_core_get_php_resource($_params, $smarty); $_smarty_resource_type = $_params['resource_type']; $_smarty_php_resource = $_params['php_resource']; Index: xoops2jp/html/class/smarty/core/core.write_cache_file.php diff -u xoops2jp/html/class/smarty/core/core.write_cache_file.php:1.1 xoops2jp/html/class/smarty/core/core.write_cache_file.php:1.2 --- xoops2jp/html/class/smarty/core/core.write_cache_file.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.write_cache_file.php Mon May 1 11:37:25 2006 @@ -31,16 +31,39 @@ $smarty->_cache_info['expires'] = -1; } - // collapse {nocache...}-tags - $params['results'] = preg_replace('!((\{nocache\:([0-9a-f]{32})#(\d+)\})' - .'.*' - .'{/nocache\:\\3#\\4\})!Us' - ,'\\2' - ,$params['results']); + // collapse nocache.../nocache-tags + if (preg_match_all('!\{(/?)nocache\:[0-9a-f]{32}#\d+\}!', $params['results'], $match, PREG_PATTERN_ORDER)) { + // remove everything between every pair of outermost noache.../nocache-tags + // and replace it by a single nocache-tag + // this new nocache-tag will be replaced by dynamic contents in + // smarty_core_process_compiled_includes() on a cache-read + + $match_count = count($match[0]); + $results = preg_split('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!', $params['results'], -1, PREG_SPLIT_DELIM_CAPTURE); + + $level = 0; + $j = 0; + for ($i=0, $results_count = count($results); $i < $results_count && $j < $match_count; $i++) { + if ($results[$i] == $match[0][$j]) { + // nocache tag + if ($match[1][$j]) { // closing tag + $level--; + unset($results[$i]); + } else { // opening tag + if ($level++ > 0) unset($results[$i]); + } + $j++; + } elseif ($level > 0) { + unset($results[$i]); + } + } + $params['results'] = implode('', $results); + } $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials; // prepend the cache header info into cache file - $params['results'] = serialize($smarty->_cache_info)."\n".$params['results']; + $_cache_info = serialize($smarty->_cache_info); + $params['results'] = strlen($_cache_info) . "\n" . $_cache_info . $params['results']; if (!empty($smarty->cache_handler_func)) { // use cache_handler function @@ -62,7 +85,7 @@ $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']); $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id); $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); + require_once(SMARTY_CORE_DIR . 'core.write_file.php'); smarty_core_write_file($_params, $smarty); return true; } Index: xoops2jp/html/class/smarty/core/core.write_compiled_include.php diff -u xoops2jp/html/class/smarty/core/core.write_compiled_include.php:1.1 xoops2jp/html/class/smarty/core/core.write_compiled_include.php:1.2 --- xoops2jp/html/class/smarty/core/core.write_compiled_include.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.write_compiled_include.php Mon May 1 11:37:25 2006 @@ -15,8 +15,8 @@ function smarty_core_write_compiled_include($params, &$smarty) { - $_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}'; - $_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}'; + $_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; \};'; + $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\'; \};'; preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us', $params['compiled_content'], $_match_source, PREG_SET_ORDER); @@ -25,7 +25,8 @@ if (count($_match_source)==0) return; // convert the matched php-code to functions - $_include_compiled = "<?php /* funky header here */\n\n"; + $_include_compiled = "<?php /* Smarty version ".$smarty->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; + $_include_compiled .= " compiled from " . strtr(urlencode($params['resource_name']), array('%2F'=>'/', '%3A'=>':')) . " */\n\n"; $_compile_path = $params['include_file_path']; @@ -42,7 +43,19 @@ if ($this_varname == '_smarty') { /* rename $this to $_smarty in the sourcecode */ $tokens = token_get_all('<?php ' . $_match[4]); - array_shift($tokens); /* remove the opening <.?.php */ + + /* remove trailing <?php */ + $open_tag = ''; + while ($tokens) { + $token = array_shift($tokens); + if (is_array($token)) { + $open_tag .= $token[1]; + } else { + $open_tag .= $token; + } + if ($open_tag == '<?php ') break; + } + for ($i=0, $count = count($tokens); $i < $count; $i++) { if (is_array($tokens[$i])) { if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') { @@ -69,7 +82,7 @@ $_params = array('filename' => $_compile_path, 'contents' => $_include_compiled, 'create_dirs' => true); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); + require_once(SMARTY_CORE_DIR . 'core.write_file.php'); smarty_core_write_file($_params, $smarty); return true; } Index: xoops2jp/html/class/smarty/core/core.write_compiled_resource.php diff -u xoops2jp/html/class/smarty/core/core.write_compiled_resource.php:1.1 xoops2jp/html/class/smarty/core/core.write_compiled_resource.php:1.2 --- xoops2jp/html/class/smarty/core/core.write_compiled_resource.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.write_compiled_resource.php Mon May 1 11:37:25 2006 @@ -25,7 +25,7 @@ } $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); + require_once(SMARTY_CORE_DIR . 'core.write_file.php'); smarty_core_write_file($_params, $smarty); return true; } Index: xoops2jp/html/class/smarty/core/core.write_file.php diff -u xoops2jp/html/class/smarty/core/core.write_file.php:1.1 xoops2jp/html/class/smarty/core/core.write_file.php:1.2 --- xoops2jp/html/class/smarty/core/core.write_file.php:1.1 Fri Mar 18 21:56:02 2005 +++ xoops2jp/html/class/smarty/core/core.write_file.php Mon May 1 11:37:25 2006 @@ -19,7 +19,7 @@ if ($params['create_dirs']) { $_params = array('dir' => $_dirname); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.create_dir_structure.php'); + require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php'); smarty_core_create_dir_structure($_params, $smarty); }