<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年2月14日
* 标签解析引擎控制器
*/
namespace app\home\controller;
use core\basic\Controller;
use app\home\model\ParserModel;
use core\basic\Url;
class ParserController extends Controller
{
protected $model;
protected $pre = array();
protected $var = array();
public function __construct()
{
$this->model = new ParserModel();
}
public function _empty()
{
error('您访问的地址有误,请核对后重试!');
}
// 解析全局前置公共标签
public function parserBefore($content)
{
// 处理模板中不需要解析的标签
$content = $this->savePreLabel($content);
return $content;
}
// 解析全局后置公共标签
public function parserAfter($content)
{
// 默认页面信息替换
$content = str_replace('{pboot:pagetitle}', '{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = str_replace('{pboot:pagekeywords}', '{pboot:sitekeywords}', $content);
$content = str_replace('{pboot:pagedescription}', '{pboot:sitedescription}', $content);
$content = $this->parserSingleLabel($content); // 单标签解析
$content = $this->parserSiteLabel($content); // 站点标签
$content = $this->parserCompanyLabel($content); // 公司标签
$content = $this->parserUserLabel($content); // 自定义标签
$content = $this->parserNavLabel($content); // 分类列表
$content = $this->parserSelectAllLabel($content); // CMS筛选全部标签解析
$content = $this->parserSelectLabel($content); // CMS筛选标签解析
$content = $this->parserSpecifySortLabel($content); // 指定分类
$content = $this->parserListLabel($content); // 指定列表
$content = $this->parserSpecifyContentLabel($content); // 指定内容
$content = $this->parserContentPicsLabel($content); // 内容多图
$content = $this->parserContentCheckboxLabel($content); // 内容多选调取
$content = $this->parserContentTagsLabel($content); // 内容tags调取
$content = $this->parserSlideLabel($content); // 幻灯片
$content = $this->parserLinkLabel($content); // 友情链接
$content = $this->parserMessageLabel($content); // 留言板
$content = $this->parserFormLabel($content); // 自定义表单
$content = $this->parserSubmitFormLabel($content); // 自定义表单提交
$content = $this->parserQrcodeLabel($content); // 二维码生成
$content = $this->parserPageLabel($content); // CMS分页标签解析(需置后)
$content = $this->parserLoopLabel($content); // LOOP语句(需置后)
$content = $this->parserIfLabel($content); // IF语句(需置最后)
$content = $this->restorePreLabel($content); // 还原不需要解析的内容
$content = $this->parserReplaceKeyword($content); // 页面关键词替换
return $content;
}
// 保存保留内容
public function savePreLabel($content)
{
$pattern = '/\{pboot:pre}([\s\S]*?)\{\/pboot:pre\}/';
if (preg_match_all($pattern, $content, $matches)) {
$count = count($matches[0]);
for ($i = 0; $i < $count; $i ++) {
$this->pre[] = $matches[1][$i];
end($this->pre);
$content = str_replace($matches[0][$i], '#pre:' . key($this->pre) . '#', $content);
}
}
return $content;
}
// 还原保留内容
public function restorePreLabel($content)
{
$pattern = '/\#pre:([0-9]+)\#/';
if (preg_match_all($pattern, $content, $matches)) {
$count = count($matches[0]);
for ($i = 0; $i < $count; $i ++) {
$content = str_replace($matches[0][$i], $this->pre[$matches[1][$i]], $content);
}
}
return $content;
}
// 解析单标签
public function parserSingleLabel($content)
{
$content = str_replace('{pboot:msgaction}', Url::home('home/Index/addMsg'), $content); // 留言提交路径
$content = str_replace('{pboot:scaction}', Url::home('home/Index/search'), $content); // 搜索提交路径
$content = str_replace('{pboot:checkcode}', CORE_DIR . '/code.php', $content); // 验证码路径
$content = str_replace('{pboot:lgpath}', Url::get('home/Do/area'), $content); // 多语言切换前置路径,如{pboot:lgpath}?lg=cn
$content = str_replace('{pboot:appid}', $this->config('api_appid'), $content); // API认证用户
$content = str_replace('{pboot:timestamp}', time(), $content); // 认证时间戳
$content = str_replace('{pboot:signature}', md5(md5($this->config('api_appid') . $this->config('api_secret') . time())), $content); // API认证密钥
$content = str_replace('{pboot:httpurl}', get_http_url(), $content); // 当前访问的域名地址
$content = str_replace('{pboot:pageurl}', get_current_url(), $content); // 当前页面的地址
$content = str_replace('{pboot:keyword}', get('keyword', 'vars'), $content); // 当前搜索的关键字
$content = str_replace('{pboot:checkcodestatus}', $this->config('message_check_code'), $content); // 是否开启验证码
return $content;
}
// 解析站点标签
public function parserSiteLabel($content)
{
$pattern = '/\{pboot:site([\w]+)(\s+[^}]+)?\}/';
if (preg_match_all($pattern, $content, $matches)) {
$data = $this->model->getSite();
$count = count($matches[0]);
for ($i = 0; $i < $count; $i ++) {
$params = $this->parserParam($matches[2][$i]);
switch ($matches[1][$i]) {
case 'index':
$content = str_replace($matches[0][$i], Url::home('home/Index/'), $content);
break;
case 'path':
$content = str_replace($matches[0][$i], SITE_DIR, $content);
break;
case 'logo':
if (isset($data->logo) && $data->logo) {
if (! preg_match('/^http/', $data->logo)) {
$content = str_replace($matches[0][$i], $this->adjustLabelData($params, SITE_DIR . $data->logo), $content);
} else {
$content = str_replace($matches[0][$i], $this->adjustLabelData($params, $data->logo), $content);
}
} else {
$content = str_replace($matches[0][$i], STATIC_DIR . '/images/logo.png', $content);
}
break;
case 'tplpath':
$content = str_replace($matches[0][$i], APP_THEME_DIR, $content);
break;
case 'language':
$content = str_replace($matches[0][$i], get_lg(), $content);
break;
case 'statistical':
if (isset($data->statistical)) {
$content = str_replace($matches[0][$i], decode_string($data->statistical), $content);
} else {
$content = str_replace($matches[0][$i], '', $content);
}
case 'copyright':
if (isset($data->copyright)) {
$content = str_replace($matches[0][$i], decode_string($data->copyright), $content);
} else {
$content = str_replace($matches[0][$i], '', $content);
}
default:
if (isset($data->{$matches
没有合适的资源?快使用搜索试试~ 我知道了~
流量卡系统源码 流量卡官网系统源码 支持最新的PHP7 带文章系统和后台.zip

共1623个文件
png:560个
js:205个
jpg:178个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 131 浏览量
2023-09-19
16:06:15
上传
评论
收藏 67.19MB ZIP 举报
温馨提示
流量卡官网源码有后台带文章系统附带文章系统更好的进行网站SEO的优化及推广 PHP>=5.3,支持最新的PHP7 系统认采用Sqlite数据库,放入PHP(5.3+)环境即可直接使用, 系统独家支持七牛云对接,无论你是否启用七牛云,请把轮播图,栏目大图,定制标签内的部分图片重新上传 可直接保存图片,重新上传一下,否则不会图片可能会不显示(因为那些图片在我们的七牛云内) 为了网站各个页面正常运行,请不要修改URL规则 附带文章系统更好的进行网站SEO的优化及推广
资源推荐
资源详情
资源评论




















收起资源包目录





































































































共 1623 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论


百创科技
- 粉丝: 2235
- 资源: 264

下载权益

C知道特权

VIP文章

课程特权

开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- AI+应用产业布局及商业化路径:赋能游戏、电商、影视等多领域产业升级
- 基于Python的上海二手房数据可视化分析-带源码+文档报告(期末大作业)
- 基于SpringBoot的企业员工薪酬关系系统(源码+数据库+万字文档)318
- 2 MCS-51单片机并行扩展技术2.ppt
- 1+MCS-51单片机并行扩展技术20140407.ppt
- 30012第9章MCS-51单片机IO接口技术20140413.ppt
- MCS-51单片机串行通信20140403.ppt
- ADDA接口技术20140413.ppt
- MCS-51单片机IO接口技术2014.ppt
- MCS-51单片机定时器2014.ppt
- MCS-51单片机的中断系统20140324.ppt
- MCS-51单片机汇编语言程序设计20140318.ppt
- MCS-51单片机指令系统20140217.ppt
- 程序设计20130402.ppt
- MCS-51单片机硬件结构20140213.pptx
- 单片机概述20140213.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
