mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
update plugin loading logic, look in SMARTY_DIR, then cwd. If all fail, then retry all with include_path
This commit is contained in:
@@ -1672,25 +1672,36 @@ function _run_insert_handler($args)
|
||||
|
||||
$_plugin_filepath = $_plugin_dir . DIR_SEP . $_plugin_filename;
|
||||
|
||||
if (@is_readable($_plugin_filepath)) {
|
||||
return $_plugin_filepath;
|
||||
}
|
||||
|
||||
// didn't find it, see if path is relative
|
||||
// see if path is relative
|
||||
if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
|
||||
$_relative = true;
|
||||
// relative path, see if it is in the SMARTY_DIR
|
||||
if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
|
||||
return SMARTY_DIR . $_plugin_filepath;
|
||||
}
|
||||
// didn't find it, try include path
|
||||
} else {
|
||||
// absolute path
|
||||
$_relative = false;
|
||||
}
|
||||
// try relative to cwd (or absolute)
|
||||
if (@is_readable($_plugin_filepath)) {
|
||||
return $_plugin_filepath;
|
||||
}
|
||||
}
|
||||
|
||||
// still not found, try PHP include_path
|
||||
if($_relative) {
|
||||
foreach ((array)$this->plugins_dir as $_plugin_dir) {
|
||||
|
||||
$_plugin_filepath = $_plugin_dir . DIR_SEP . $_plugin_filename;
|
||||
|
||||
if ($this->_get_include_path($_plugin_filepath, $_include_filepath)) {
|
||||
return $_include_filepath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -359,9 +359,11 @@ Stock Name: {$ticker_name} Stock Price: {$ticker_price}</programlisting>
|
||||
<para>
|
||||
Do you ever wonder how your E-mail address gets on so many spam mailing
|
||||
lists? One way spammers collect E-mail addresses is from web pages. To
|
||||
help combat this problem, you can make your E-mail address show up in a
|
||||
scrambled looking form in the HTML source, yet it it will look and work
|
||||
correctly in the browser. This is done with the escape modifier.
|
||||
help combat this problem, you can make your E-mail address show up in
|
||||
scrambled javascript in the HTML source, yet it it will look and work
|
||||
correctly in the browser. This is done with the mailto plugin,
|
||||
available from the plugin repository on the Smarty website. Download
|
||||
the plugin and drop it into the plugins directory.
|
||||
</para>
|
||||
<example>
|
||||
<title>Example of Obfuscating an E-mail Address</title>
|
||||
@@ -371,26 +373,15 @@ index.tpl
|
||||
---------
|
||||
|
||||
Send inquiries to
|
||||
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
|
||||
|
||||
OUTPUT:
|
||||
|
||||
Send inquiries to
|
||||
<a
|
||||
href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">&#x62;&#x6f;&#x62;&#x40;&#x6d;&#x65;&#x2e;&#x6e;&#x65;&#x74;</a>
|
||||
{mailto address=$EmailAddress encode="javascript" subject="Hello"}
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Although this looks like a mess in the HTML source, it will render
|
||||
correctly in your browser, and the mailto: hyperlink will go to the correct
|
||||
address.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
This method isn't 100% foolproof. A spammer
|
||||
could conceivably program his e-mail collector to decode these values.
|
||||
This method isn't 100% foolproof. A spammer could conceivably program his
|
||||
e-mail collector to decode these values, but not likely.
|
||||
</para>
|
||||
</note>
|
||||
</sect1>
|
||||
@@ -398,7 +389,7 @@ href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">&#x62;&#x6f;&#x62;&a
|
||||
<chapter id="resources">
|
||||
<title>Resources</title>
|
||||
<para>
|
||||
Smarty's homepage is located at http://www.phpinsider.com/php/code/Smarty/.
|
||||
Smarty's homepage is located at http://smarty.php.net/.
|
||||
You can join the mailing list by sending an e-mail to
|
||||
smarty-general-subscribe@lists.php.net. An archive of the mailing list can be
|
||||
viewed at http://marc.theaimsgroup.com/?l=smarty&r=1&w=2
|
||||
|
@@ -3818,6 +3818,12 @@ OUTPUT:
|
||||
root and supply the relative path to this file as the "src"
|
||||
parameter to popup_init.
|
||||
</para>
|
||||
<example>
|
||||
<title>popup_init</title>
|
||||
<programlisting>
|
||||
{* popup_init must be called once at the top of the page *}
|
||||
{popup_init src="/javascripts/overlib.js"}</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.function.popup">
|
||||
<title>popup</title>
|
||||
|
@@ -153,8 +153,9 @@ debug.tpl
|
||||
|
||||
<para>
|
||||
You can either place these library files within your PHP include_path, or
|
||||
in any directory as long as you define that with the SMARTY_DIR constant.
|
||||
We'll show an example of both.
|
||||
in any directory as long as you define that with the <link
|
||||
linkend="constant.smarty.dir">SMARTY_DIR</link> constant. We'll show an
|
||||
example of both.
|
||||
</para>
|
||||
<para>
|
||||
Here is how you create an instance of Smarty in your PHP scripts:
|
||||
@@ -169,8 +170,9 @@ $smarty = new Smarty;</screen>
|
||||
|
||||
<para>
|
||||
If the library files are outside of your PHP include_path, you must define
|
||||
the absolute path with the SMARTY_DIR constant. SMARTY_DIR must end with a
|
||||
slash. Lets say we place our Smarty library files in
|
||||
the absolute path with the <link
|
||||
linkend="constant.smarty.dir">SMARTY_DIR</link> constant. SMARTY_DIR must
|
||||
end with a slash. Lets say we place our Smarty library files in
|
||||
"/usr/local/lib/php/Smarty/".
|
||||
</para>
|
||||
|
||||
@@ -238,11 +240,11 @@ $smarty = new Smarty;</screen>
|
||||
<example>
|
||||
<title>Example file structure</title>
|
||||
<screen>
|
||||
/php/includes/Smarty/Smarty.class.php
|
||||
/php/includes/Smarty/Smarty_Compiler.class.php
|
||||
/php/includes/Smarty/Config_File.class.php
|
||||
/php/includes/Smarty/debug.tpl
|
||||
/php/includes/Smarty/plugins/*.php
|
||||
/usr/local/lib/php/Smarty/Smarty.class.php
|
||||
/usr/local/lib/php/Smarty/Smarty_Compiler.class.php
|
||||
/usr/local/lib/php/Smarty/Config_File.class.php
|
||||
/usr/local/lib/php/Smarty/debug.tpl
|
||||
/usr/local/lib/php/Smarty/plugins/*.php
|
||||
|
||||
/web/www.mydomain.com/smarty/guestbook/templates/
|
||||
/web/www.mydomain.com/smarty/guestbook/templates_c/
|
||||
@@ -420,27 +422,5 @@ $smarty->display('index.tpl');</screen>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="smarty.constants">
|
||||
<title>Constants</title>
|
||||
<para></para>
|
||||
|
||||
<sect2 id="constant.smarty.dir">
|
||||
<title>SMARTY_DIR</title>
|
||||
<para>
|
||||
This should be the full system path to the location of the Smarty
|
||||
class files. If this is not defined, then Smarty will attempt to
|
||||
determine the appropriate value automatically. If defined, the path
|
||||
must end with a slash.
|
||||
</para>
|
||||
<example>
|
||||
<title>SMARTY_DIR</title>
|
||||
<programlisting>
|
||||
// set path to Smarty directory
|
||||
define("SMARTY_DIR","/usr/local/lib/php/Smarty/");
|
||||
|
||||
require_once(SMARTY_DIR."Smarty.class.php");</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
</sect1>
|
||||
</chapter>
|
||||
</part>
|
||||
|
@@ -1,5 +1,30 @@
|
||||
<part id="smarty.for.programmers">
|
||||
<title>Smarty For Programmers</title>
|
||||
|
||||
|
||||
<chapter id="smarty.constants">
|
||||
<title>Constants</title>
|
||||
<para></para>
|
||||
|
||||
<sect1 id="constant.smarty.dir">
|
||||
<title>SMARTY_DIR</title>
|
||||
<para>
|
||||
This should be the full system path to the location of the Smarty
|
||||
class files. If this is not defined, then Smarty will attempt to
|
||||
determine the appropriate value automatically. If defined, the path
|
||||
must end with a slash.
|
||||
</para>
|
||||
<example>
|
||||
<title>SMARTY_DIR</title>
|
||||
<programlisting>
|
||||
// set path to Smarty directory
|
||||
define("SMARTY_DIR","/usr/local/lib/php/Smarty/");
|
||||
|
||||
require_once(SMARTY_DIR."Smarty.class.php");</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
</chapter>
|
||||
|
||||
<chapter id="api.variables">
|
||||
<title>Variables</title>
|
||||
|
||||
@@ -15,7 +40,7 @@
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
It is not mandatory to put this directory under
|
||||
It is not recommended to put this directory under
|
||||
the web server document root.
|
||||
</para>
|
||||
</note>
|
||||
@@ -39,7 +64,7 @@
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
It is not mandatory to put this directory under
|
||||
It is not recommended to put this directory under
|
||||
the web server document root.
|
||||
</para>
|
||||
</note>
|
||||
@@ -55,7 +80,7 @@
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
It is not mandatory to put this directory under
|
||||
It is not recommended to put this directory under
|
||||
the web server document root.
|
||||
</para>
|
||||
</note>
|
||||
@@ -63,11 +88,20 @@
|
||||
<sect1 id="variable.plugins.dir">
|
||||
<title>$plugins_dir</title>
|
||||
<para>
|
||||
This is the directory where Smarty will look for the plugins that
|
||||
it needs. The directory must be relative to the directory where
|
||||
Smarty itself is installed. Default is "plugins". There can be
|
||||
only one plugins directory.
|
||||
This is the directories where Smarty will look for the plugins that it
|
||||
needs. Default is "plugins" under the SMARTY_DIR. If you supply a
|
||||
relative path, Smarty will first look under the SMARTY_DIR, then
|
||||
relative to the cwd (current working directory), then relative to each
|
||||
entry in your PHP include path.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
For best performance, do not setup your plugins_dir to have to use the
|
||||
PHP include path. Use an absolute pathname, or a path relative to
|
||||
SMARTY_DIR or the cwd.
|
||||
</para>
|
||||
</note>
|
||||
</sect1>
|
||||
<sect1 id="variable.debugging">
|
||||
<title>$debugging</title>
|
||||
@@ -217,7 +251,7 @@ $smarty->autoload_filters = array('pre' => array('trim', 'stamp'),
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
It is not mandatory to put this directory under
|
||||
It is not recommended to put this directory under
|
||||
the web server document root.
|
||||
</para>
|
||||
</note>
|
||||
|
@@ -1672,25 +1672,36 @@ function _run_insert_handler($args)
|
||||
|
||||
$_plugin_filepath = $_plugin_dir . DIR_SEP . $_plugin_filename;
|
||||
|
||||
if (@is_readable($_plugin_filepath)) {
|
||||
return $_plugin_filepath;
|
||||
}
|
||||
|
||||
// didn't find it, see if path is relative
|
||||
// see if path is relative
|
||||
if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
|
||||
$_relative = true;
|
||||
// relative path, see if it is in the SMARTY_DIR
|
||||
if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
|
||||
return SMARTY_DIR . $_plugin_filepath;
|
||||
}
|
||||
// didn't find it, try include path
|
||||
} else {
|
||||
// absolute path
|
||||
$_relative = false;
|
||||
}
|
||||
// try relative to cwd (or absolute)
|
||||
if (@is_readable($_plugin_filepath)) {
|
||||
return $_plugin_filepath;
|
||||
}
|
||||
}
|
||||
|
||||
// still not found, try PHP include_path
|
||||
if($_relative) {
|
||||
foreach ((array)$this->plugins_dir as $_plugin_dir) {
|
||||
|
||||
$_plugin_filepath = $_plugin_dir . DIR_SEP . $_plugin_filename;
|
||||
|
||||
if ($this->_get_include_path($_plugin_filepath, $_include_filepath)) {
|
||||
return $_include_filepath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user