PHPCMS2008生成html页面
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-24 16:44:15 浏览: 评论:0
- <?php
- function cachehtml(){
- $head['title'] = '网站地图 - '.$PHPCMS['sitename'];
- $head['keywords'] = $PHPCMS['sitename'];
- ob_start();
- include template('phpcms', 'sitemap');
- $file = PHPCMS_ROOT.'sitemap.html';
- createhtml($file);
- }
- function template($module = 'phpcms', $template = 'index', $istag = 0)
- {
- $compiledtplfile = TPL_CACHEPATH.$module.'_'.$template.'.tpl.php';
- if(TPL_REFRESH &&
- (!file_exists($compiledtplfile) ||
- @filemtime(TPL_ROOT.TPL_NAME.'/'.$module.'/'.$template.'.html') > @filemtime($compiledtplfile) ||
- ))
- {
- template_compile($module, $template, $istag);
- }
- return $compiledtplfile;
- }
- function template_compile($module, $template, $istag = 0)
- {
- $tplfile = TPL_ROOT.TPL_NAME.'/'.$module.'/'.$template.'.html';
- $content = @file_get_contents($tplfile);
- if($content === false) showmessage("$tplfile is not exists!");
- $compiledtplfile = TPL_CACHEPATH.$module.'_'.$template.'.tpl.php';
- $content = ($istag || substr($template, 0, 4) == 'tag_') ? '<?php function _tag_'.$module.'_'.$template.'($data, $number, $rows, $count, $page, $pages, $setting){ global $PHPCMS,$MODULE,$M,$CATEGORY,$TYPE,$AREA,$GROUP,$MODEL,$templateid,<pre class="php" name="code">{1}</pre><br>
- userid,<pre class="php" name="code">{1}</pre><br>
- username;@extract($setting);?>'.template_parse($content, 1).'<?php } ?>' : template_parse($content);$strlen = file_put_contents($compiledtplfile, $content);@chmod($compiledtplfile, 0777);return $strlen;}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\}/","<?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 createhtml($file){$data
- = ob_get_contents();ob_clean();dir_create(dirname($file));$strlen = file_put_contents($file, $data);@chmod($file,0777);return $strlen;}?>
- <pre></pre> //开源软件:phpfensi.com
- <p><br>
- </p>
Tags: PHPCMS生成html PHPCMS生成静态
相关文章
- ·phpcms v9怎么设置静态页面(2014-10-19)
- ·PHPCMS V9静态化HTML生成设置及URL规则优化(2014-10-19)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)