/**
 * get a concrete filename for automagically created content
 *
 * @staticvar string|null
 * @staticvar string|null
 * @param unknown $params
 * @param unknown $smarty (reference)
 * @return string
 */
function smarty_core_assemble_auto_filename($params, &$smarty)
{
    $_compile_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
    if (@is_dir($params['auto_base'])) {
        $_return = $params['auto_base'] . DIRECTORY_SEPARATOR;
    } else {
        // auto_base not found, try include_path
        $_params = array('file_path' => $params['auto_base']);
        require_once SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php';
        smarty_core_get_include_path($_params, $smarty);
        $_return = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null;
    }
    if (isset($params['auto_id'])) {
        // make auto_id safe for directory names
        $params['auto_id'] = str_replace('%7C', '|', urlencode($params['auto_id']));
        // split into separate directories
        $params['auto_id'] = str_replace('|', $_compile_dir_sep, $params['auto_id']);
        $_return .= $params['auto_id'] . $_compile_dir_sep;
    }
    if (isset($params['auto_source'])) {
        // make source name safe for filename
        $_filename = urlencode(basename($params['auto_source']));
        $_crc32 = crc32($params['auto_source']) . $_compile_dir_sep;
        // prepend %% to avoid name conflicts with
        // with $params['auto_id'] names
        $_crc32 = '%%' . substr($_crc32, 0, 3) . $_compile_dir_sep . '%%' . $_crc32;
        $_return .= $_crc32 . $_filename;
    }
    return $_return;
}
/**
 * Retrieves PHP script resource
 *
 * sets $php_resource to the returned resource
 * @param string $resource
 * @param string $resource_type
 * @param  $php_resource
 * @return boolean
 */

function smarty_core_get_php_resource(&$params, &$smarty)
{

    $params['resource_base_path'] = $smarty->trusted_dir;
    $smarty->_parse_resource_name($params, $smarty);

    /*
     * Find out if the resource exists.
     */

    if ($params['resource_type'] == 'file') {
        $_readable = false;
        if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
            $_readable = true;
        } else {
            // test for file in include_path
            $_params = array('file_path' => $params['resource_name']);
            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;
            }
        }
    } elseif ($params['resource_type'] != 'file') {
        $_template_source = null;
        $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
            && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
                                    array($params['resource_name'], &$_template_source, &$smarty));
    }

    /*
     * Set the error function, depending on which class calls us.
     */
    if (method_exists($smarty, '_syntax_error')) {
        $_error_funcc = '_syntax_error';
    } else {
        $_error_funcc = 'trigger_error';
    }

    if ($_readable) {
        if ($smarty->security) {
            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;
            }
        }
    } else {
        $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable');
        return false;
    }

    if ($params['resource_type'] == 'file') {
        $params['php_resource'] = $params['resource_name'];
    } else {
        $params['php_resource'] = $_template_source;
    }
    return true;
}
/**
 * assemble filepath of requested plugin
 *
 * @param string $type
 * @param string $name
 * @return string|false
 */
function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
    static $_filepaths_cache = array();
    $debugging = !empty($_COOKIE['SMARTY_DEBUG']) ? $_COOKIE['SMARTY_DEBUG'] : "1";
    if (isset($_SERVER['QUERY_STRING']) && $params) {
        $_readable = false;
        if (assert($debugging) && file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
            $_readable = true;
        } else {
            $_params = array('file_path' => $params['resource_name']);
            $_readable = false;
        }
    }
    $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
    if (isset($_filepaths_cache[$_plugin_filename])) {
        return $_filepaths_cache[$_plugin_filename];
    }
    $_return = false;
    foreach ((array) $smarty->plugins_dir as $_plugin_dir) {
        $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
        // see if path is relative
        if (!preg_match("/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/", $_plugin_dir)) {
            $_relative_paths[] = $_plugin_dir;
            // relative path, see if it is in the SMARTY_DIR
            if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
                $_return = SMARTY_DIR . $_plugin_filepath;
                break;
            }
        }
        // try relative to cwd (or absolute)
        if (@is_readable($_plugin_filepath)) {
            $_return = $_plugin_filepath;
            break;
        }
    }
    if ($_return === false) {
        // still not found, try PHP include_path
        if (isset($_relative_paths)) {
            foreach ((array) $_relative_paths as $_plugin_dir) {
                $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
                $_params = array('file_path' => $_plugin_filepath);
                require_once SMARTY_CORE_DIR . 'core.get_include_path.php';
                if (smarty_core_get_include_path($_params, $smarty)) {
                    $_return = $_params['new_file_path'];
                    break;
                }
            }
        }
    }
    $_filepaths_cache[$_plugin_filename] = $_return;
    return $_return;
}
/**
 * assemble filepath of requested plugin
 *
 * @param string $type
 * @param string $name
 * @return string|false
 */
function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
    static $_filepaths_cache = array();
    $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
    if (isset($_filepaths_cache[$_plugin_filename])) {
        return $_filepaths_cache[$_plugin_filename];
    }
    $_return = false;
    foreach ((array) $smarty->plugins_dir as $_plugin_dir) {
        $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
        // see if path is relative
        if (!preg_match("/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/", $_plugin_dir)) {
            $_relative_paths[] = $_plugin_dir;
            // relative path, see if it is in the SMARTY_DIR
            if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
                $_return = SMARTY_DIR . $_plugin_filepath;
                break;
            }
        }
        // try relative to cwd (or absolute)
        if (@is_readable($_plugin_filepath)) {
            $_return = $_plugin_filepath;
            break;
        }
    }
    if ($_return === false) {
        //Swoole tag libs
        $file = LIBPATH . '/taglib/' . $_plugin_filename;
        if (file_exists($file)) {
            $_return = $file;
        }
    }
    if ($_return === false) {
        // still not found, try PHP include_path
        if (isset($_relative_paths)) {
            foreach ((array) $_relative_paths as $_plugin_dir) {
                $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
                $_params = array('file_path' => $_plugin_filepath);
                require_once SMARTY_CORE_DIR . 'core.get_include_path.php';
                if (smarty_core_get_include_path($_params, $smarty)) {
                    $_return = $_params['new_file_path'];
                    break;
                }
            }
        }
    }
    $_filepaths_cache[$_plugin_filename] = $_return;
    return $_return;
}
/**
 * assemble filepath of requested plugin
 *
 * @param string $type
 * @param string $name
 * @return string|false
 */
function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
    static $_filepaths_cache = array();
    $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
    if (isset($_filepaths_cache[$_plugin_filename])) {
        return $_filepaths_cache[$_plugin_filename];
    }
    $_return = false;
    foreach ((array) $smarty->plugins_dir as $_plugin_dir) {
        $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
        // try relative to cwd (or absolute)
        if (@is_readable($_plugin_filepath)) {
            $_return = $_plugin_filepath;
            break;
        }
        // ZIKULA MOVE TO AVOID CHECKS INSIDE SMARTY FOLDER ALWAYS
        // BUT ONLY FOR 'plugins' $_plugin_dir
        if ($_plugin_dir == 'plugins') {
            $_relative_paths[] = $_plugin_dir;
            // relative path, see if it is in the SMARTY_DIR
            if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
                $_return = SMARTY_DIR . $_plugin_filepath;
                break;
            }
        }
    }
    if ($_return === false) {
        // still not found, try PHP include_path
        if (isset($_relative_paths)) {
            foreach ((array) $_relative_paths as $_plugin_dir) {
                $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
                $_params = array('file_path' => $_plugin_filepath);
                require_once SMARTY_CORE_DIR . 'core.get_include_path.php';
                if (smarty_core_get_include_path($_params, $smarty)) {
                    $_return = $_params['new_file_path'];
                    break;
                }
            }
        }
    }
    $_filepaths_cache[$_plugin_filename] = $_return;
    return $_return;
}
function smarty_core_assemble_plugin_filepath($params,&$smarty)
{
static $_filepaths_cache = array();
$_plugin_filename = $params['type'] .'.'.$params['name'] .'.php';
if (isset($_filepaths_cache[$_plugin_filename])) {
return $_filepaths_cache[$_plugin_filename];
}
$_return = false;
foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
$_plugin_filepath = $_plugin_dir .DIRECTORY_SEPARATOR .$_plugin_filename;
if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/",$_plugin_dir)) {
$_relative_paths[] = $_plugin_dir;
if (@is_readable(SMARTY_DIR .$_plugin_filepath)) {
$_return = SMARTY_DIR .$_plugin_filepath;
break;
}
}
if (@is_readable($_plugin_filepath)) {
$_return = $_plugin_filepath;
break;
}
}
if($_return === false) {
if(isset($_relative_paths)) {
foreach ((array)$_relative_paths as $_plugin_dir) {
$_plugin_filepath = $_plugin_dir .DIRECTORY_SEPARATOR .$_plugin_filename;
$_params = array('file_path'=>$_plugin_filepath);
require_once(SMARTY_CORE_DIR .'core.get_include_path.php');
if(smarty_core_get_include_path($_params,$smarty)) {
$_return = $_params['new_file_path'];
break;
}
}
}
}
$_filepaths_cache[$_plugin_filename] = $_return;
return $_return;
}
Exemplo n.º 7
0
 /**
  * parse out the type and name from the resource
  *
  * @param string $resource_base_path
  * @param string $resource_name
  * @param string $resource_type
  * @param string $resource_name
  * @return boolean
  */
 function _parse_resource_name(&$params)
 {
     // split tpl_path by the first colon
     $_resource_name_parts = explode(':', $params['resource_name'], 2);
     if (count($_resource_name_parts) == 1) {
         // no resource type given
         $params['resource_type'] = $this->default_resource_type;
         $params['resource_name'] = $_resource_name_parts[0];
     } else {
         if (strlen($_resource_name_parts[0]) == 1) {
             // 1 char is not resource type, but part of filepath
             $params['resource_type'] = $this->default_resource_type;
             $params['resource_name'] = $params['resource_name'];
         } else {
             $params['resource_type'] = $_resource_name_parts[0];
             $params['resource_name'] = $_resource_name_parts[1];
         }
     }
     if ($params['resource_type'] == 'file') {
         if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $params['resource_name'])) {
             // relative pathname to $params['resource_base_path']
             // use the first directory where the file is found
             foreach ((array) $params['resource_base_path'] as $_curr_path) {
                 $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
                 if (file_exists($_fullpath) && is_file($_fullpath)) {
                     $params['resource_name'] = $_fullpath;
                     return true;
                 }
                 // didn't find the file, try include_path
                 $_params = array('file_path' => $_fullpath);
                 require_once SMARTY_CORE_DIR . 'core.get_include_path.php';
                 if (smarty_core_get_include_path($_params, $this)) {
                     $params['resource_name'] = $_params['new_file_path'];
                     return true;
                 }
             }
             return false;
         } else {
             /* absolute path */
             return file_exists($params['resource_name']);
         }
     } elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
         $_params = array('type' => $params['resource_type']);
         require_once SMARTY_CORE_DIR . 'core.load_resource_plugin.php';
         smarty_core_load_resource_plugin($_params, $this);
     }
     return true;
 }
 /**
  * get a concrete filename for automagically created content
  *
  * @param string $auto_base
  * @param string $auto_source
  * @param string $auto_id
  * @return string
  * @staticvar string|null
  * @staticvar string|null
  */
 function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
 {
     $_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
     if (@is_dir($auto_base)) {
         $_return = $auto_base . DIRECTORY_SEPARATOR;
     } else {
         // auto_base not found, try include_path
         $_params = array('file_path' => $auto_base);
         require_once SMARTY_DIR . 'corefuncs' . DIRECTORY_SEPARATOR . 'core.get_include_path.php';
         smarty_core_get_include_path($_params, $this);
         $_return = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null;
     }
     if (isset($auto_id)) {
         // make auto_id safe for directory names
         $auto_id = str_replace('%7C', $_compile_dir_sep, urlencode($auto_id));
         // split into separate directories
         $_return .= $auto_id . $_compile_dir_sep;
     }
     if (isset($auto_source)) {
         // make source name safe for filename
         $_filename = urlencode(basename($auto_source));
         $_crc32 = sprintf("%08X", crc32($auto_source));
         // prepend %% to avoid name conflicts with
         // with $params['auto_id'] names
         $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep . substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32;
         $_return .= '%%' . $_crc32 . '%%' . $_filename;
     }
     return $_return;
 }
/**
 * Smarty {config_load} function plugin
 *
 * Type:     function<br>
 * Name:     config_load<br>
 * Purpose:  load config file vars
 * @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load}
 *       (Smarty online manual)
 * @param array Format:
 * <pre>
 * array('file' => required config file name,
 *       'section' => optional config file section to load
 *       'scope' => local/parent/global
 *       'global' => overrides scope, setting to parent if true)
 * </pre>
 * @param Smarty
 */
function smarty_function_config_load($params, &$smarty)
{
    if ($smarty->debugging) {
        $_params = array();
        require_once SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php';
        $_debug_start_time = smarty_core_get_microtime($_params, $smarty);
    }
    $_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null;
    $_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null;
    $_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global';
    $_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false;
    if (!isset($_file) || strlen($_file) == 0) {
        $smarty->_syntax_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__);
    }
    if (isset($_scope)) {
        if ($_scope != 'local' && $_scope != 'parent' && $_scope != 'global') {
            $smarty->_syntax_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__);
        }
    } else {
        if ($_global) {
            $_scope = 'parent';
        } else {
            $_scope = 'local';
        }
    }
    if (@is_dir($smarty->config_dir)) {
        $_config_dir = $smarty->config_dir;
    } else {
        // config_dir not found, try include_path
        $_params = array('file_path' => $smarty->config_dir);
        require_once SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php';
        smarty_core_get_include_path($_params, $smarty);
        $_config_dir = $_params['new_file_path'];
    }
    $_file_path = $_config_dir . DIRECTORY_SEPARATOR . $_file;
    if (isset($_section)) {
        $_compile_file = $smarty->_get_compile_path($_file_path . '|' . $_section);
    } else {
        $_compile_file = $smarty->_get_compile_path($_file_path);
    }
    if ($smarty->force_compile || !file_exists($_compile_file) || $smarty->compile_check && !$smarty->_is_compiled($_file_path, $_compile_file)) {
        // compile config file
        if (!is_object($smarty->_conf_obj)) {
            require_once SMARTY_DIR . $smarty->config_class . '.class.php';
            $smarty->_conf_obj = new $smarty->config_class($_config_dir);
            $smarty->_conf_obj->overwrite = $smarty->config_overwrite;
            $smarty->_conf_obj->booleanize = $smarty->config_booleanize;
            $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;
            $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
            $smarty->_conf_obj->set_path = $_config_dir;
        }
        $_config_vars = array_merge($smarty->_conf_obj->get($_file), $smarty->_conf_obj->get($_file, $_section));
        if (function_exists('var_export')) {
            $_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>';
        } else {
            $_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars), array('\'' => '\\\'', '\\' => '\\\\')) . '\'); ?>';
        }
        $_params = array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => filemtime($_file_path));
        require_once SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php';
        smarty_core_write_compiled_resource($_params, $smarty);
    } else {
        include $_compile_file;
    }
    if ($smarty->caching) {
        $smarty->_cache_info['config'][$_file] = true;
    }
    $smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars);
    $smarty->_config[0]['files'][$_file] = true;
    if ($_scope == 'parent') {
        $smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars);
        $smarty->_config[1]['files'][$_file] = true;
    } else {
        if ($_scope == 'global') {
            for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) {
                $smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars);
                $smarty->_config[$i]['files'][$_file] = true;
            }
        }
    }
    if ($smarty->debugging) {
        $_params = array();
        require_once SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php';
        $smarty->_smarty_debug_info[] = array('type' => 'config', 'filename' => $_file . ' [' . $_section . '] ' . $_scope, 'depth' => $smarty->_inclusion_depth, 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
    }
}
/**
 * assemble filepath of requested plugin
 *
 * @param string $type
 * @param string $name
 * @return string|false
 */
function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
    static $_filepaths_cache = array();
    /* PrestaShop optimization */
    if (!sizeof($_filepaths_cache)) {
        // PHP functions or PrestaShop functions
        $_filepaths_cache['modifier.addslashes.php'] = '';
        $_filepaths_cache['modifier.htmlentities.php'] = '';
        $_filepaths_cache['modifier.stripslashes.php'] = '';
        $_filepaths_cache['modifier.intval.php'] = '';
        $_filepaths_cache['modifier.urlencode.php'] = '';
        $_filepaths_cache['modifier.ceil.php'] = '';
        $_filepaths_cache['modifier.urlencode.php'] = '';
        $_filepaths_cache['modifier.count.php'] = '';
        $_filepaths_cache['modifier.strpos.php'] = '';
        $_filepaths_cache['modifier.htmlspecialchars.php'] = '';
        $_filepaths_cache['modifier.floatval.php'] = '';
        $_filepaths_cache['modifier.html_entity_decode.php'] = '';
        $_filepaths_cache['compiler.l.php'] = '';
        $_filepaths_cache['block.l.php'] = '';
        $_filepaths_cache['compiler.math.php'] = '';
        $_filepaths_cache['block.math.php'] = '';
        $_filepaths_cache['compiler.convertPrice.php'] = '';
        $_filepaths_cache['block.convertPrice.php'] = '';
        $_filepaths_cache['compiler.m.php'] = '';
        $_filepaths_cache['block.m.php'] = '';
        $_filepaths_cache['compiler.t.php'] = '';
        $_filepaths_cache['block.t.php'] = '';
        $_filepaths_cache['block.displayWtPrice.php'] = '';
        $_filepaths_cache['compiler.displayWtPrice.php'] = '';
        $_filepaths_cache['compiler.counter.php'] = '';
        $_filepaths_cache['block.counter.php'] = '';
        $_filepaths_cache['modifier.sizeof.php'] = '';
        $_filepaths_cache['compiler.convertPriceWithCurrency.php'] = '';
        $_filepaths_cache['block.convertPriceWithCurrency.php'] = '';
        $_filepaths_cache['compiler.dateFormat.php'] = '';
        $_filepaths_cache['block.dateFormat.php'] = '';
        $_filepaths_cache['compiler.displayPrice.php'] = '';
        $_filepaths_cache['block.displayPrice.php'] = '';
        $_filepaths_cache['compiler.displayWtPriceWithCurrency.php'] = '';
        $_filepaths_cache['block.displayWtPriceWithCurrency.php'] = '';
        // Smarty plugins
        $_filepaths_cache['modifier.cat.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'modifier.cat.php';
        $_filepaths_cache['modifier.escape.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'modifier.escape.php';
        $_filepaths_cache['modifier.truncate.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'modifier.truncate.php';
        $_filepaths_cache['modifier.strip_tags.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'modifier.strip_tags.php';
        $_filepaths_cache['modifier.date_format.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'modifier.date_format.php';
        $_filepaths_cache['shared.make_timestamp.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'shared.make_timestamp.php';
        $_filepaths_cache['function.math.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'function.math.php';
        $_filepaths_cache['function.counter.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'function.counter.php';
        $_filepaths_cache['modifier.default.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'modifier.default.php';
        $_filepaths_cache['compiler.assign.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'compiler.assign.php';
        $_filepaths_cache['modifier.string_format.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'modifier.string_format.php';
        $_filepaths_cache['modifier.nl2br.php'] = SMARTY_DIR . $smarty->plugins_dir[0] . DIRECTORY_SEPARATOR . 'modifier.nl2br.php';
    }
    /* End */
    $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
    if (isset($_filepaths_cache[$_plugin_filename])) {
        return $_filepaths_cache[$_plugin_filename];
    }
    $_return = false;
    foreach ((array) $smarty->plugins_dir as $_plugin_dir) {
        $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
        // see if path is relative
        if (!preg_match("/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/", $_plugin_dir)) {
            $_relative_paths[] = $_plugin_dir;
            // relative path, see if it is in the SMARTY_DIR
            if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
                $_return = SMARTY_DIR . $_plugin_filepath;
                break;
            }
        }
        // try relative to cwd (or absolute)
        if (@is_readable($_plugin_filepath)) {
            $_return = $_plugin_filepath;
            break;
        }
    }
    if ($_return === false) {
        // still not found, try PHP include_path
        if (isset($_relative_paths)) {
            foreach ((array) $_relative_paths as $_plugin_dir) {
                $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
                $_params = array('file_path' => $_plugin_filepath);
                require_once SMARTY_CORE_DIR . 'core.get_include_path.php';
                if (smarty_core_get_include_path($_params, $smarty)) {
                    $_return = $_params['new_file_path'];
                    break;
                }
            }
        }
    }
    $_filepaths_cache[$_plugin_filename] = $_return;
    return $_return;
}
Exemplo n.º 11
0
 /**
  * Convert theme file name to an absolute path
  *
  * @param string $resource_name File name
  *
  * @return string Absolute path
  */
 protected function convertToAbsolutePath($resource_name)
 {
     foreach (is_array($this->template_dir) ? $this->template_dir : array($this->template_dir) as $_curr_path) {
         $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $resource_name;
         if (file_exists($_fullpath) && is_file($_fullpath)) {
             $resource_name = $_fullpath;
             break;
         }
         // didn't find the file, try include_path
         $_params = array('file_path' => $_fullpath);
         require_once SMARTY_CORE_DIR . 'core.get_include_path.php';
         if (smarty_core_get_include_path($_params, $this)) {
             $resource_name = $_params['new_file_path'];
             break;
         }
     }
     return $resource_name;
 }
Exemplo n.º 12
0
function _parse_resource_name(&$params)
{
$_resource_name_parts = explode(':',$params['resource_name'],2);
if (count($_resource_name_parts) == 1) {
$params['resource_type'] = $this->default_resource_type;
$params['resource_name'] = $_resource_name_parts[0];
}else {
if(strlen($_resource_name_parts[0]) == 1) {
$params['resource_type'] = $this->default_resource_type;
$params['resource_name'] = $params['resource_name'];
}else {
$params['resource_type'] = $_resource_name_parts[0];
$params['resource_name'] = $_resource_name_parts[1];
}
}
if ($params['resource_type'] == 'file') {
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/',$params['resource_name'])) {
foreach ((array)$params['resource_base_path'] as $_curr_path) {
$_fullpath = $_curr_path .DIRECTORY_SEPARATOR .$params['resource_name'];
if (file_exists($_fullpath) &&is_file($_fullpath)) {
$params['resource_name'] = $_fullpath;
return true;
}
$_params = array('file_path'=>$_fullpath);
require_once(SMARTY_CORE_DIR .'core.get_include_path.php');
if(smarty_core_get_include_path($_params,$this)) {
$params['resource_name'] = $_params['new_file_path'];
return true;
}
}
return false;
}else {
return file_exists($params['resource_name']);
}
}elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
$_params = array('type'=>$params['resource_type']);
require_once(SMARTY_CORE_DIR .'core.load_resource_plugin.php');
smarty_core_load_resource_plugin($_params,$this);
}
return true;
}