让万能标签get 支持嵌套查询,小改动
来源:互联网 发布:.cn域名能用于商业吗? 编辑:程序博客网 时间:2024/06/05 12:45
位置template.func.php
function template_parse($str, $istag = 0)
{
$str = preg_replace ( "/([/n/r]+)/t+/s", "//1", $str );
$str = preg_replace ( "//</!/-/-/{(.+?)/}/-/-/>/s", "{//1}", $str );
$str = preg_replace ( "//{template/s+(.+)/}/", "<?php include template(//1); ?>", $str );
$str = preg_replace ( "//{include/s+(.+)/}/", "<?php include //1; ?>", $str );
$str = preg_replace ( "//{php/s+(.+)/}/", "<?php //1?>", $str );
$str = preg_replace ( "//{if/s+(.+?)/}/", "<?php if(//1) { ?>", $str );
$str = preg_replace ( "//{else/}/", "<?php } else { ?>", $str );
$str = preg_replace ( "//{elseif/s+(.+?)/}/", "<?php } elseif (//1) { ?>", $str );
$str = preg_replace ( "//{//if/}/", "<?php } ?>", $str );
$str = preg_replace ( "//{loop/s+(/S+)/s+(/S+)/}/", "<?php if(is_array(//1)) foreach(//1 AS //2) { ?>", $str );
$str = preg_replace ( "//{loop/s+(/S+)/s+(/S+)/s+(/S+)/}/", "<?php if(is_array(//1)) foreach(//1 AS //2 => //3) { ?>", $str );
$str = preg_replace ( "//{//loop/}/", "<?php } ?>", $str );
$str = preg_replace ( "//{//get/s+dr=/"([^/"/}]+)/"/s+/}/", "<?php } unset(/$//1); ?>", $str );
$str = preg_replace ( "//{//get/}/", "<?php } unset(/$DATA); ?>", $str );
$str = preg_replace ( "//{tag_([^}]+)/}/e", "get_tag('//1')", $str );
$str = preg_replace ( "//{get/s+([^}]+)/}/e", "get_parse('//1')", $str );
$str = preg_replace ( "//{([a-zA-Z_/x7f-/xff][a-zA-Z0-9_/x7f-/xff:]*/(([^{}]*)/))/}/", "<?php echo //1;?>", $str );
$str = preg_replace ( "//{//$([a-zA-Z_/x7f-/xff][a-zA-Z0-9_/x7f-/xff:]*/(([^{}]*)/))/}/", "<?php echo //1;?>", $str );
$str = preg_replace ( "//{(//$[a-zA-Z_/x7f-/xff][a-zA-Z0-9_/x7f-/xff]*)/}/", "<?php echo //1;?>", $str );
$str = preg_replace ( "//{(//$[a-zA-Z0-9_/[/]/'/"/$/x7f-/xff]+)/}/es", "addquote('<?php echo //1;?>')", $str );
$str = preg_replace ( "//{([A-Z_/x7f-/xff][A-Z0-9_/x7f-/xff]*)/}/s", "<?php echo //1;?>", $str );
if (! $istag)
$str = "<?php defined('IN_PHPCMS') or exit('Access Denied'); ?>" . $str;
return $str;
}
function get_parse($str)
{
preg_match_all ( "/([a-z]+)/=/"([^/"]+)/"/i", stripslashes ( $str ), $matches, PREG_SET_ORDER );
foreach ( $matches as $v )
{
$r [$v [1]] = $v [2];
}
extract ( $r );
if (! isset ( $dbsource ))
$dbsource = '';
if (! isset ( $dbname ))
$dbname = '';
if (! isset ( $sql ))
$sql = '';
if (! isset ( $rows ))
$rows = 0;
if (! isset ( $urlrule ))
$urlrule = '';
if (! isset ( $catid ))
$catid = 0;
if (! isset ( $distinctfield ))
$distinctfield = '';
if (! isset ( $return ) || ! preg_match ( "/^/w+$/i", $return ))
$return = 'r';
if (! isset ( $dr ))
$dr = 'DATA';
if (! isset ( $sn ))
$sn = 'n';
if (isset ( $page ))
{
$str = "<?php /$ARRAY = get(/"$sql/", $rows, $page, /"$dbname/", /"$dbsource/", /"$urlrule/",/"$distinctfield/",/"$catid/");/${$dr}=/$ARRAY['data'];/$total=/$ARRAY['total'];/$count=/$ARRAY['count'];/$pages=/$ARRAY['pages'];unset(/$ARRAY);foreach(/${$dr} AS /${$sn}=>/${$return}){/${$sn}++;?>";
}
else
{
$str = substr ( $str, - 1 ) == '/' ? "<?php /${$return} = get(/"$sql/", -1, 0, /"$dbname/", /"$dbsource/");?>" : "<?php /${$dr} = get(/"$sql/", $rows, 0, /"$dbname/", /"$dbsource/");foreach(/${$dr} AS /${$sn} => /${$return}) { /${$sn}++;?>";
}
return $str;
}
http://bbs.phpcms.cn/thread-137360-2-1.html
function template_parse($str, $istag = 0)
{
$str = preg_replace("/([/n/r]+)/t+/s","//1",$str);
$str = preg_replace("//</!/-/-/{(.+?)/}/-/-/>/s", "{//1}",$str);
$str = preg_replace("//{template/s+(.+)/}/","<?php include template(//1); ?>",$str);
$str = preg_replace("//{include/s+(.+)/}/","<?php include //1; ?>",$str);
$str = preg_replace("//{php/s+(.+)/}/","<?php //1?>",$str);
$str = preg_replace("//{if/s+(.+?)/}/","<?php if(//1) { ?>",$str);
$str = preg_replace("//{else/}/","<?php } else { ?>",$str);
$str = preg_replace("//{elseif/s+(.+?)/}/","<?php } elseif (//1) { ?>",$str);
$str = preg_replace("//{//if/}/","<?php } ?>",$str);
$str = preg_replace("//{loop/s+(/S+)/s+(/S+)/}/","<?php if(is_array(//1)) foreach(//1 AS //2) { ?>",$str);
$str = preg_replace("//{loop/s+(/S+)/s+(/S+)/s+(/S+)/}/","<?php if(is_array(//1)) foreach(//1 AS //2 => //3) { ?>",$str);
$str = preg_replace("//{//loop/}/","<?php } ?>",$str);
$str = preg_replace("//{//get/s+dr=/"([^/"/}]+)/"/s+/}/","<?php } unset(/$//1); ?>",$str);
$str = preg_replace("//{//get/}/","<?php } unset(/$DATA); ?>",$str);
$str = preg_replace("//{tag_([^}]+)/}/e", "get_tag('//1')", $str);
$str = preg_replace("//{get/s+([^}]+)/}/e", "get_parse('//1')", $str);
$str = preg_replace("//{([a-zA-Z_/x7f-/xff][a-zA-Z0-9_/x7f-/xff:]*/(([^{}]*)/))/}/","<?php echo //1;?>",$str);
$str = preg_replace("//{//$([a-zA-Z_/x7f-/xff][a-zA-Z0-9_/x7f-/xff:]*/(([^{}]*)/))/}/","<?php echo //1;?>",$str);
$str = preg_replace("//{(//$[a-zA-Z_/x7f-/xff][a-zA-Z0-9_/x7f-/xff]*)/}/","<?php echo //1;?>",$str);
$str = preg_replace("//{(//$[a-zA-Z0-9_/[/]/'/"/$/x7f-/xff]+)/}/es", "addquote('<?php echo //1;?>')",$str);
$str = preg_replace("//{([A-Z_/x7f-/xff][A-Z0-9_/x7f-/xff]*)/}/s", "<?php echo //1;?>",$str);
if(!$istag) $str = "<?php defined('IN_PHPCMS') or exit('Access Denied'); ?>".$str;
return $str;
}
function get_parse($str)
{
preg_match_all("/([a-z]+)/=/"([^/"]+)/"/i", stripslashes($str), $matches, PREG_SET_ORDER);
foreach($matches as $v)
{
$r[$v[1]] = $v[2];
}
extract($r);
if(!isset($dbsource)) $dbsource = '';
if(!isset($dbname)) $dbname = '';
if(!isset($sql)) $sql = '';
if(!isset($rows)) $rows = 0;
if(!isset($urlrule)) $urlrule = '';
if(!isset($catid)) $catid = 0;
if(!isset($distinctfield)) $distinctfield = '';
if(!isset($return) || !preg_match("/^/w+$/i", $return)) $return = 'r';
if(!isset($dr)) $dr = 'DATA';
if(!isset($sn)) $sn = 'n';
if(isset($page))
{
$str = "<?php /$ARRAY = get(/"$sql/", $rows, $page, /"$dbname/", /"$dbsource/", /"$urlrule/",/"$distinctfield/",/"$catid/");/${$dr}=/$ARRAY['data'];/$total=/$ARRAY['total'];/$count=/$ARRAY['count'];/$pages=/$ARRAY['pages'];unset(/$ARRAY);foreach(/${$dr} AS /${$sn}=>/${$return}){/${$sn}++;?>";
}
else
{
$str = substr($str, -1) == '/' ? "<?php /${$return} = get(/"$sql/", -1, 0, /"$dbname/", /"$dbsource/");?>" : "<?php /${$dr} = get(/"$sql/", $rows, 0, /"$dbname/", /"$dbsource/");foreach(/${$dr} AS /${$sn} => /${$return}) { /${$sn}++;?>";
}
return $str;
}
- 让万能标签get 支持嵌套查询,小改动
- 让万能标签get 支持嵌套查询,小改动
- 只改动CSS让IE6支持透明PNG
- phpcms get万能标签实现phpcm…
- 让DreamWeaver支持JSTL标签
- 让ie支持html5标签
- 让apache支持html页面嵌套
- 建立字典嵌套,使用get()查询.
- 让Mysql 支持中文查询
- 让Mysql 支持中文查询
- 让mysql查询支持中文
- 帝国cms搜索模板支持灵动标签和万能标签(支持到7.2)
- Web_PHP_DedeCMS_{dede:php}标签嵌套查询使用;
- 让webservice测试页面支持Get方法
- 让WebService支持Post和Get方法
- html5标签改动
- 相关嵌套查询的一个小例子
- html5】让ie支持html5标签
- 简单工厂模式vs工厂方法模式vs抽象工厂模式
- 第五届MobileDev Day
- 大家好
- 大家好
- C# 创建windows服务
- 让万能标签get 支持嵌套查询,小改动
- 学会使用Web Service
- 内存泄露的排查
- linux下字符驱动模块的一般性步骤
- 主流浏览器内核概览
- 喜剧否?
- CImage显示透明PNG
- java判断IP是否在某个网段中
- PHP 多语言网站解决方案