- fix compatibility for PHP version < 5.6

This commit is contained in:
Uwe Tews
2018-04-24 11:33:47 +02:00
parent 8d21f38dc3
commit c95d3f3a4d

View File

@@ -1042,10 +1042,16 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function _realpath($path, $realpath = null)
{
static $nds = array('/' => '\\', '\\' => '/');
static $sepDotsep = DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR;
static $sepDot = DIRECTORY_SEPARATOR . '.';
static $sepSep = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
static $nds = null;
static $sepDotsep = null;
static $sepDot = null;
static $sepSep =null;
if (!isset($nds)) {
$nds = array('/' => '\\', '\\' => '/');
$sepDotsep = DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR;
$sepDot = DIRECTORY_SEPARATOR . '.';
$sepSep = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
}
// normalize DIRECTORY_SEPARATOR
$path = str_replace(array($nds[DIRECTORY_SEPARATOR], $sepDotsep), DIRECTORY_SEPARATOR, $path);
if (strpos($path,$sepDot) === false && (($realpath === false && $path[0] === '.') || $realpath === null) && $path[0] !== '\\') {