mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
improved include_path resolving
This commit is contained in:
@@ -1277,6 +1277,8 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
}
|
||||
// plugin filename is expected to be: [type].[name].php
|
||||
$_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
|
||||
|
||||
$_stream_resolve_include_path = function_exists('stream_resolve_include_path');
|
||||
|
||||
// loop through plugin dirs and find the plugin
|
||||
foreach($this->getPluginsDir() as $_plugin_dir) {
|
||||
@@ -1291,7 +1293,13 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
}
|
||||
if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
|
||||
// try PHP include_path
|
||||
if (($file = Smarty_Internal_Get_Include_Path::getIncludePath($file)) !== false) {
|
||||
if ($_stream_resolve_include_path) {
|
||||
$file = stream_resolve_include_path($file);
|
||||
} else {
|
||||
$file = Smarty_Internal_Get_Include_Path::getIncludePath($file);
|
||||
}
|
||||
|
||||
if ($file !== false) {
|
||||
require_once($file);
|
||||
return $file;
|
||||
}
|
||||
|
@@ -299,6 +299,8 @@ class Smarty_Internal_Utility {
|
||||
echo "Smarty Installation test...\n";
|
||||
echo "Testing template directory...\n";
|
||||
}
|
||||
|
||||
$_stream_resolve_include_path = function_exists('stream_resolve_include_path');
|
||||
|
||||
// test if all registered template_dir are accessible
|
||||
foreach($smarty->getTemplateDir() as $template_dir) {
|
||||
@@ -308,7 +310,13 @@ class Smarty_Internal_Utility {
|
||||
if (!$template_dir) {
|
||||
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) {
|
||||
// try PHP include_path
|
||||
if (($template_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_template_dir)) !== false) {
|
||||
if ($_stream_resolve_include_path) {
|
||||
$template_dir = stream_resolve_include_path($_template_dir);
|
||||
} else {
|
||||
$template_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_template_dir);
|
||||
}
|
||||
|
||||
if ($template_dir !== false) {
|
||||
if ($errors === null) {
|
||||
echo "$template_dir is OK.\n";
|
||||
}
|
||||
@@ -423,7 +431,13 @@ class Smarty_Internal_Utility {
|
||||
if (!$plugin_dir) {
|
||||
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
|
||||
// try PHP include_path
|
||||
if (($plugin_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_plugin_dir)) !== false) {
|
||||
if ($_stream_resolve_include_path) {
|
||||
$plugin_dir = stream_resolve_include_path($_plugin_dir);
|
||||
} else {
|
||||
$plugin_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_plugin_dir);
|
||||
}
|
||||
|
||||
if ($plugin_dir !== false) {
|
||||
if ($errors === null) {
|
||||
echo "$plugin_dir is OK.\n";
|
||||
}
|
||||
@@ -549,7 +563,13 @@ class Smarty_Internal_Utility {
|
||||
if (!$config_dir) {
|
||||
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) {
|
||||
// try PHP include_path
|
||||
if (($config_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_config_dir)) !== false) {
|
||||
if ($_stream_resolve_include_path) {
|
||||
$config_dir = stream_resolve_include_path($_config_dir);
|
||||
} else {
|
||||
$config_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_config_dir);
|
||||
}
|
||||
|
||||
if ($config_dir !== false) {
|
||||
if ($errors === null) {
|
||||
echo "$config_dir is OK.\n";
|
||||
}
|
||||
|
@@ -254,6 +254,8 @@ abstract class Smarty_Resource {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$_stream_resolve_include_path = function_exists('stream_resolve_include_path');
|
||||
|
||||
// relative file name?
|
||||
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) {
|
||||
@@ -264,7 +266,13 @@ abstract class Smarty_Resource {
|
||||
}
|
||||
if ($source->smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_directory)) {
|
||||
// try PHP include_path
|
||||
if (($_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath)) !== false) {
|
||||
if ($_stream_resolve_include_path) {
|
||||
$_filepath = stream_resolve_include_path($_filepath);
|
||||
} else {
|
||||
$_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath);
|
||||
}
|
||||
|
||||
if ($_filepath !== false) {
|
||||
if ($this->fileExists($source, $_filepath)) {
|
||||
return $_filepath;
|
||||
}
|
||||
|
Reference in New Issue
Block a user