[xoops-cvslog 1056] CVS update: xoops2jp/html/class/smarty/core

Back to archive index

NobuNobu nobun****@users*****
2005年 11月 20日 (日) 17:05:54 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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -34,11 +34,14 @@
         }
         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 &&
+                if ( ($_cd = realpath($curr_dir)) !== false) {
+                    if( strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
                      $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
-                    return true;
-                }            
+                        return true;
+                    } elseif ($_cd == $_rp) {
+                        return true;
+                    }
+                }
             }
         }
     } else {
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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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;
             }
@@ -55,7 +55,7 @@
         $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']);
         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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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.1.8.1
--- 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	Sun Nov 20 17:05:53 2005
@@ -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);
     }
 


xoops-cvslog メーリングリストの案内
Back to archive index