标签:必须 ash 处理 屏蔽 pos 内容 系统 linux 直接
ecshop系统的模板是基于smarty开发的,所以语法有很多smarty的特性,但是又不尽相同。
/**
* 处理smarty标签中的变量标签
*
* @access public
* @param string $val
*
* @return bool
*/
function get_val($val)
{
if (strrpos($val, ‘[‘) !== false)
{
$val = preg_replace("/\[([^\[\]]*)\]/eis", "‘.‘.str_replace(‘$‘,‘\$‘,‘\\1‘)", $val);
}
if (strrpos($val, ‘|‘) !== false)
{
$moddb = explode(‘|‘, $val);
$val = array_shift($moddb);
}
if (empty($val))
{
return ‘‘;
}
if (strpos($val, ‘.$‘) !== false)
{
$all = explode(‘.$‘, $val);
foreach ($all AS $key => $val)
{
$all[$key] = $key == 0 ? $this->make_var($val) : ‘[‘. $this->make_var($val) . ‘]‘;
}
$p = implode(‘‘, $all);
}
else
{
$p = $this->make_var($val);
}
if (!empty($moddb))
{
foreach ($moddb AS $key => $mod)
{
$s = explode(‘:‘, $mod);
switch ($s[0])
{
case ‘escape‘:
$s[1] = trim($s[1], ‘"‘);
if ($s[1] == ‘html‘)
{
$p = ‘htmlspecialchars(‘ . $p . ‘)‘;
}
elseif ($s[1] == ‘url‘)
{
$p = ‘urlencode(‘ . $p . ‘)‘;
}
elseif ($s[1] == ‘decode_url‘)
{
$p = ‘urldecode(‘ . $p . ‘)‘;
}
elseif ($s[1] == ‘quotes‘)
{
$p = ‘addslashes(‘ . $p . ‘)‘;
}
elseif ($s[1] == ‘u8_url‘)
{
if (EC_CHARSET != ‘utf-8‘)
{
$p = ‘urlencode(ecs_iconv("‘ . EC_CHARSET . ‘", "utf-8",‘ . $p . ‘))‘;
}
else
{
$p = ‘urlencode(‘ . $p . ‘)‘;
}
}
else
{
$p = ‘htmlspecialchars(‘ . $p . ‘)‘;
}
break;
case ‘nl2br‘:
$p = ‘nl2br(‘ . $p . ‘)‘;
break;
case ‘default‘:
$s[1] = $s[1]{0} == ‘$‘ ? $this->get_val(substr($s[1], 1)) : "‘$s[1]‘";
$p = ‘empty(‘ . $p . ‘) ? ‘ . $s[1] . ‘ : ‘ . $p;
break;
case ‘truncate‘:
$p = ‘sub_str(‘ . $p . ",$s[1])";
break;
case ‘strip_tags‘:
$p = ‘strip_tags(‘ . $p . ‘)‘;
break;
case ‘print_r‘:
$p=‘print_r(‘.$p.‘,true)‘;
break;
case ‘var_export‘:
$p=‘var_export(‘.$p.‘,true)‘;
break;
default:
# code...
break;
}
}
}
return $p;
}
ecshop在dwt模板中和lbi中输入数组详情的方法 ecshop模板中输出数组的方法
标签:必须 ash 处理 屏蔽 pos 内容 系统 linux 直接
原文地址:https://www.cnblogs.com/lixiang1/p/11199505.html