fix: make_filename for absolute path under windows (c:\)

improvement: you don't have to call assign_block_vars('a' before 
calling assign_block_vars('a.b'

git-svn-id: http://piwigo.org/svn/trunk@1579 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2006-10-27 00:21:15 +00:00
parent 12182ddcfe
commit 5cce84ff1c
+5 -3
View File
@@ -222,7 +222,7 @@ class Template {
for ($i = 0; $i < $blockcount; $i++)
{
$str .= '[\'' . $blocks[$i] . '.\']';
eval('$lastiteration = sizeof(' . $str . ') - 1;');
eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:0;');
$str .= '[' . $lastiteration . ']';
}
// Now we add the block that we're actually assigning to.
@@ -278,8 +278,9 @@ class Template {
function make_filename($filename)
{
// Check if it's an absolute or relative path.
// if (substr($filename, 0, 1) != '/')
if (preg_match('/^[a-z_]/i', $filename))
if (substr($filename, 0, 1) != '/'
and substr($filename, 0, 1) != '\\' //Windows UNC path
and !preg_match('/^[a-z]:\\\/i', $filename) )
{
$filename = $this->root.'/'.$filename;
}
@@ -316,6 +317,7 @@ class Template {
$filename = $this->files[$handle];
$str = implode("", @file($filename));
if (empty($str))
{
die("Template->loadfile(): File $filename for handle $handle is empty");