初始化提交

This commit is contained in:
shenquanyi
2024-05-28 11:01:13 +08:00
commit 5d96ff2eed
1393 changed files with 325846 additions and 0 deletions

View File

@@ -0,0 +1,151 @@
<?php
/**
* @copyright (C)2020-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2020年06月27日
* 评论控制器
*/
namespace app\home\controller;
use core\basic\Controller;
use app\home\model\ParserModel;
use core\basic\Url;
class CommentController extends Controller
{
protected $parser;
protected $model;
protected $htmldir;
public function __construct()
{
$this->model = new ParserModel();
$this->parser = new ParserController();
$this->htmldir = $this->config('tpl_html_dir') ? $this->config('tpl_html_dir') . '/' : '';
}
// 评论新增
public function add()
{
if ($_POST) {
if ($this->config('comment_status') === '0') {
error('系统已经关闭评论功能,请到后台开启再试!');
}
if (time() - session('lastsub') < 10) {
alert_back('您提交太频繁了,请稍后再试!');
}
if (! session('pboot_uid') && ! $this->config('comment_anonymous')) {
if (! ! $backurl = $_SERVER['HTTP_REFERER']) {
alert_location("请先注册登录后再评论!", Url::home('member/login', null, "backurl=" . urlencode($backurl)));
} else {
alert_location("请先注册登录后再评论!", Url::home('member/login'));
}
}
// 验证码验证
$checkcode = strtolower(post('checkcode', 'var'));
if ($this->config('comment_check_code') !== '0') {
if (! $checkcode) {
alert_back('验证码不能为空!');
}
if ($checkcode != session('checkcode')) {
alert_back('验证码错误!');
}
}
// 接收数据
$status = $this->config('comment_verify') === '0' ? 1 : 0;
if (! $contentid = request('contentid', 'int')) {
alert_back('文章ID未能正常获取请使用POST或URL参数传递');
}
$comment = post('comment');
$data = array(
'pid' => request('pid', 'int') ?: 0,
'contentid' => $contentid,
'comment' => $comment,
'uid' => session('pboot_uid'),
'puid' => request('puid', 'int'),
'likes' => 0,
'oppose' => 0,
'status' => $status,
'user_ip' => ip2long(get_user_ip()),
'user_os' => get_user_os(),
'user_bs' => get_user_bs(),
'create_time' => get_datetime(),
'update_user' => '',
'update_time' => ''
);
if ($this->model->addComment($data)) {
session('lastsub', time()); // 记录最后提交时间
$this->log('文章' . $contentid . '评论提交成功!');
if ($this->config('comment_send_mail') && $this->config('message_send_to')) {
$mail_subject = "" . CMSNAME . "】您有新的文章评论信息,请注意查收!";
$mail_body = '评论内容:' . $comment . '<br>';
$mail_body .= '<br>来自网站 ' . get_http_url() . ' ' . date('Y-m-d H:i:s') . '';
sendmail($this->config(), $this->config('message_send_to'), $mail_subject, $mail_body);
}
if ($status) {
alert_location('评论提交成功!', '-1', 1);
} else {
alert_location('评论提交成功,请等待管理员审核!', '-1', 1);
}
} else {
$this->log('文章评论提交失败!');
alert_back('提交失败!');
}
} else {
alert_back('提交失败请使用POST方式提交');
}
}
// 我的评论
public function my()
{
// 未登录时跳转到用户登录
if (! session('pboot_uid')) {
location(Url::home('member/login'));
}
$content = parent::parser($this->htmldir . 'member/mycomment.html'); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$content = str_replace('{pboot:pagetitle}', '我的评论-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = $this->parser->parserPositionLabel($content, 0, '我的评论', Url::home('comment/my')); // CMS当前位置标签解析
$content = $this->parser->parserSpecialPageSortLabel($content, - 3, '我的评论', Url::home('comment/my')); // 解析分类标签
$content = $this->parser->parserMyCommentLabel($content); // 我的评论
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
echo $content;
exit();
}
// 评论删除
public function del()
{
// 未登录时跳转到用户登录
if (! session('pboot_uid')) {
location(Url::home('member/login'));
}
// 执行删除
if (! ! $id = get('id', 'int')) {
if ($this->model->delComment($id)) {
alert_back('删除成功!', 1);
} else {
alert_back('删除失败!');
}
} else {
alert_back('传递参数有误!');
}
}
}

View File

@@ -0,0 +1,90 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年3月8日
*
*/
namespace app\home\controller;
use core\basic\Controller;
use app\home\model\DoModel;
class DoController extends Controller
{
private $model;
public function __construct()
{
$this->model = new DoModel();
}
// 多语言切换
public function area()
{
$lg = request('lg', 'var');
if ($lg) {
$lgs = $this->config('lgs');
if (isset($lgs[$lg])) {
cookie('lg', $lg);
}
location(SITE_INDEX_DIR . '/');
}
}
// 文章访问量累计
public function visits()
{
if (! ! $id = get('id', 'int')) {
$this->model->addVisits($id);
echo 'var ok;'; // 避免前端浏览器报js错
} else {
echo 'var error;'; // 避免前端浏览器报js错
}
}
// 点赞
public function likes()
{
if (($id = get('id', 'int')) && ! cookie('likes_' . $id)) {
$this->model->addLikes($id);
cookie('likes_' . $id, true, 31536000, null, null, null, null);
}
location('-1');
}
// 获取是否点赞
public function isLikes()
{
if (($id = get('id', 'int')) && cookie('likes_' . $id)) {
return json(1, 'yes');
} else {
return json(0, 'no');
}
}
// 反对
public function oppose()
{
if (($id = get('id', 'int')) && ! cookie('oppose_' . $id)) {
$this->model->addOppose($id);
cookie('oppose_' . $id, true, 31536000, null, null, null, null);
}
location('-1');
}
// 获取是否反对
public function isOppose()
{
if (($id = get('id', 'int')) && cookie('oppose_' . $id)) {
return json(1, 'yes');
} else {
return json(0, 'no');
}
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* @copyright (C)2020-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2020年3月8日
* 个人扩展标签可编写到本类中,升级不会覆盖
*/
namespace app\home\controller;
use core\basic\Controller;
class ExtLabelController
{
protected $content;
/* 必备启动函数 */
public function run($content)
{
// 接收数据
$this->content = $content;
// 执行个人自定义标签函数
$this->test();
// 返回数据
return $this->content;
}
// 测试扩展单个标签
private function test()
{
$this->content = str_replace('{pboot:userip}', get_user_ip(), $this->content);
}
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* @copyright (C)2020-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2020年3月8日
* 表单控制器
*/
namespace app\home\controller;
use core\basic\Controller;
use app\home\model\ParserModel;
class FormController extends Controller
{
protected $model;
public function __construct()
{
$this->model = new ParserModel();
}
// 表单提交
public function index()
{
// 在非兼容模式接受地址第二参数值
if (defined('RVAR')) {
$_GET['fcode'] = RVAR;
}
if ($_POST) {
if ($this->config('form_status') === '0') {
error('系统已经关闭表单功能,请到后台开启再试!');
}
if (time() - session('lastsub') < 10) {
alert_back('您提交太频繁了,请稍后再试!');
}
if (! $fcode = get('fcode', 'var')) {
alert_back('传递的表单编码有误!');
}
if ($fcode == 1) {
alert_back('表单提交地址有误,留言提交请使用留言专用地址!');
}
// 验证码验证
$checkcode = strtolower(post('checkcode', 'var'));
if ($this->config('form_check_code') !== '0') {
if (! $checkcode) {
alert_back('验证码不能为空!');
}
if ($checkcode != session('checkcode')) {
alert_back('验证码错误!');
}
}
// 读取字段
if (! $form = $this->model->getFormField($fcode)) {
alert_back('接收表单不存在任何字段,请核对后重试!');
}
// 接收数据
$mail_body = '';
foreach ($form as $value) {
$field_data = post($value->name);
if (is_array($field_data)) { // 如果是多选等情况时转换
$field_data = implode(',', $field_data);
}
$field_data = preg_replace_r('/pboot:if/i', '', $field_data);
if ($value->required && ! $field_data) {
alert_back($value->description . '不能为空!');
} else {
$data[$value->name] = $field_data;
$mail_body .= $value->description . '' . $field_data . '<br>';
}
}
// 设置创建时间
if ($data) {
$data['create_time'] = get_datetime();
}
// 写入数据
if ($this->model->addForm($value->table_name, $data)) {
session('lastsub', time()); // 记录最后提交时间
$this->log('提交表单数据成功!');
if ($this->config('form_send_mail') && $this->config('message_send_to')) {
$mail_subject = "" . CMSNAME . "】您有新的" . $value->form_name . "信息,请注意查收!";
$mail_body .= '<br>来自网站 ' . get_http_url() . ' ' . date('Y-m-d H:i:s') . '';
sendmail($this->config(), $this->config('message_send_to'), $mail_subject, $mail_body);
}
alert_location('提交成功!', '-1', 1);
} else {
$this->log('提交表单数据失败!');
alert_back('提交失败!');
}
} else {
alert_back('提交失败请使用POST方式提交');
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* @author xsh
* @email hnxsh@foxmail.com
* @date 2021年10月31日
*
*/
namespace app\home\controller;
use core\basic\Controller;
use app\home\model\ParserModel;
use core\basic\Config;
use core\basic\Url;
class GetPageController extends Controller
{
protected $parser;
protected $model;
protected $tplhtmldir;
public function __construct()
{
$this->parser = new ParserController();
$this->model = new ParserModel();
$this->tplhtmldir = $this->config('tpl_html_dir') ? $this->config('tpl_html_dir') . '/' : '';
}
// 首页
protected function getIndexPage()
{
}
// 列表
protected function getListPage($sort)
{
$pagelink = $this->parser->parserLink($sort->type, $sort->urlname, 'list', $sort->scode, $sort->filename, '', '');
}
// 详情页
protected function getContentPage($data)
{
$link = $this->parser->parserLink($data->type, $data->urlname, 'content', $data->scode, $data->sortfilename, $data->id, $data->filename);
}
// 单页
protected function getAboutPage($sort)
{
$link = $this->parser->parserLink($sort->type, $sort->urlname, 'list', $sort->scode, $sort->filename, '', '');
}
// 检查页面权限
}

View File

@@ -0,0 +1,458 @@
<?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\Config;
use core\basic\Url;
class IndexController extends Controller
{
protected $parser;
protected $model;
protected $htmldir;
public function __construct()
{
$this->parser = new ParserController();
$this->model = new ParserModel();
$this->htmldir = $this->config('tpl_html_dir') ? $this->config('tpl_html_dir') . '/' : '';
}
// 空拦截器, 实现文章路由转发
public function _empty()
{
// 地址类型
$url_rule_type = $this->config('url_rule_type') ?: 3;
if (P) { // 采用pathinfo模式及p参数伪静态模式
if ($url_rule_type == 2) { // 禁止伪静态时带index.php 和动态地址访问
if(stripos(URL, 'index.php') !== false){
_404('您访问的内容不存在,请核对后重试!');
}
if(stripos(URL,'?') !== false && stripos(URL,'/?tag=') == false && stripos(URL,'/?page=') == false && stripos(URL,'/?ext_') == false){
_404('您访问的内容不存在,请核对后重试!');
}
}
$path = P;
} elseif ($url_rule_type == 3 && isset($_SERVER["QUERY_STRING"]) && $qs = $_SERVER["QUERY_STRING"]) { // 采用简短传参模式
parse_str($qs, $output);
unset($output['page']); // 去除分页
if ($output && ! current($output)) { // 第一个路径参数不能有值,否则非标准路径参数
$path = key($output); // 第一个参数为路径信息注意PHP数组会自动将key点符号转换下划线
} elseif (get('tag')) { // 对于兼容模式tag需要自动跳转tag独立页面
$tag = new TagController();
$tag->index();
} elseif (get('keyword')) { // 兼容模式搜索处理
$search = new SearchController();
$search->index();
}
}
// 判断是否存在后缀
$url_rule_suffix = substr($this->config('url_rule_suffix'), 1);
$suffix = false;
$slash = false;
if (preg_match('/(.*)(_|\.)' . $url_rule_suffix . '$/', $path, $matchs)) {
$path = $matchs[1];
$suffix = true;
} elseif (preg_match('/^[\w\-\/]+\/$/', $path)) {
$slash = true;
$path = trim($path, '/');
}
$path = escape_string($path);
$path_arr = $path ? explode('/', $path) : array();
// 开始路由
if (isset($path_arr) && count($path_arr) > 0 && preg_match('/^[\w\-\/]+$/', $path)) {
switch (strtolower($path_arr[0])) {
case 'search':
case 'keyword':
$search = new SearchController();
$search->index();
break;
case 'message':
$msg = new MessageController();
$msg->index();
break;
case 'form':
$_GET['fcode'] = $path_arr[1];
$form = new FormController();
$form->index();
break;
case 'sitemap':
case 'sitemap_xml':
$sitemap = new SitemapController();
$sitemap->index();
break;
case 'sitemap_txt':
$sitemap = new SitemapController();
$sitemap->linkTxt();
break;
case 'tag':
$tag = new TagController();
$tag->index();
break;
case 'member':
$member = new MemberController();
$member->{$path_arr[1]}();
break;
case 'comment':
$comment = new CommentController();
$comment->{$path_arr[1]}();
break;
case 'spider':
$spider = new SpiderController();
$spider->index();
break;
default:
$url_break_char = $this->config('url_break_char') ?: '_';
$url_rule_content_path = $this->config('url_rule_content_path') ? true : false;
$err = '';
$iscontent = false;
// 开始进行地址匹配
if (! $suffix && ! ! $sort = $this->model->getSort($path)) {
// 栏目名称,即栏目全路径匹配
} elseif (preg_match('/^([a-zA-Z0-9\-\/]+)' . $url_break_char . '([0-9]+)$/i', $path, $matchs) && ! ! $sort = $this->model->getSort($matchs[1])) {
// 栏目名称_分页栏目分页的情况
define('CMS_PAGE_CUSTOM', true); // 设置走自定义CMS分页
$_GET['page'] = $matchs[2]; // 设置分页参数
} else {
if ($url_rule_content_path && ! ! $data = $this->model->getContent($path)) {
$iscontent = true; // 短路径情况
} elseif (! $url_rule_content_path) {
// 详情页至少是2级对地址进行栏目和内容路径拆分访问详情页
$part1 = dirname($path);
$part2 = basename($path);
while ($part1 != '.') {
if ((! ! $sort = $this->model->getSort($part1)) && ! ! $data = $this->model->getContent($part2)) {
// 栏目名称/内容名称或ID
$iscontent = true;
$scode = $sort->scode;
break;
} elseif (preg_match('/^([a-zA-Z0-9\-\/]+)' . $url_break_char . '([0-9]+)$/i', $part1, $matchs) && ! ! $model = $this->model->checkModelUrlname($matchs[1])) {
// 模型名称_栏目ID/内容名称或ID
$data = $this->model->getContent($part2);
$iscontent = true;
$scode = $matchs[2];
// 限制串模型多路径
if (! ! $data->urlname && $matchs[1] != $data->urlname) {
$err = true;
}
break;
} else {
$part2 = basename($part1) . '/' . $part2;
$part1 = dirname($part1);
}
}
// 限制串栏目多路径
if ($scode != $data->scode) {
$err = true;
}
// 限制串内容ID及名称多路径
if (! ! $data->filename && $part2 != $data->filename) {
$err = true;
}
}
// 执行未配置栏目名称但是配置了模型路径的情况路径匹配
if (! $iscontent) {
preg_match('/^([a-zA-Z0-9\-\/]+)(' . $url_break_char . '([0-9]+))?' . $url_break_char . '([0-9]+)$/i', $path, $matchs);
if ($matchs[2] && $model = $this->model->checkModelUrlname($matchs[1])) {
// 模型名称_栏目ID_分页
define('CMS_PAGE_CUSTOM', false);
$sort = $this->model->getSort($matchs[3]);
$_GET['page'] = $matchs[4]; // 分页
} elseif (! ! $model = $this->model->checkModelUrlname($matchs[1])) {
// 模型名称_栏目ID
$sort = $this->model->getSort($matchs[4]);
}
// 限制串模型和栏目名称多路径,当栏目名称不为空时不允许使用模型路径
if ($sort->filename != '') {
$err = true;
}
// 限制串模型多路径
if (! ! $sort->urlname && $matchs[1] != $sort->urlname) {
$err = true;
}
}
}
if ($iscontent) {
define('CMS_PAGE', false); // 使用普通分页处理模型
if (! ! $data && $suffix && ! $err) {
$this->getContentPage($data);
} else {
_404('您访问的内容不存在,请核对后重试!');
}
} else {
define('CMS_PAGE', true); // 使用cms分页处理模型
if (! ! $sort && ! $suffix && ! $err) {
if ($sort->type == 1) {
$this->getAboutPage($sort);
} else {
$this->getListPage($sort);
}
} else {
_404('您访问的页面不存在,请核对后重试!');
}
}
}
} else {
if(SITE_DIR == ''){
//一级目录
$this->urlJump($url_rule_type,false);
} else {
//二级目录
$this->urlJump($url_rule_type,true);
}
}
}
// 首页
private function getIndexPage()
{
$content = parent::parser($this->htmldir . 'index.html'); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$content = str_replace('{pboot:pagetitle}', $this->config('index_title') ?: '{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = $this->parser->parserPositionLabel($content, - 1, '首页', SITE_INDEX_DIR . '/'); // CMS当前位置标签解析
$content = $this->parser->parserSpecialPageSortLabel($content, 0, '', SITE_INDEX_DIR . '/'); // 解析分类标签
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
$this->cache($content, true);
}
// 列表
private function getListPage($sort)
{
// 调用栏目语言与当前语言不一致时,自动切换语言
if ($sort->acode != get_lg() && Config::get('lgautosw') !== '0') {
cookie('lg', $sort->acode);
}
if ($sort->listtpl) {
$this->checkPageLevel($sort->gcode, $sort->gtype, $sort->gnote);
$content = parent::parser($this->htmldir . $sort->listtpl); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$pagetitle = $sort->title ? "{sort:title}" : "{sort:name}"; // 页面标题
$content = str_replace('{pboot:pagetitle}', $this->config('list_title') ?: ($pagetitle . '-{pboot:sitetitle}-{pboot:sitesubtitle}'), $content);
$content = str_replace('{pboot:pagekeywords}', '{sort:keywords}', $content);
$content = str_replace('{pboot:pagedescription}', '{sort:description}', $content);
$content = $this->parser->parserPositionLabel($content, $sort->scode); // CMS当前位置标签解析
$content = $this->parser->parserSortLabel($content, $sort); // CMS分类信息标签解析
$content = $this->parser->parserListLabel($content, $sort->scode); // CMS分类列表标签解析
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
} else {
error('请到后台设置分类栏目列表页模板!');
}
$this->cache($content, true);
}
// 详情页
private function getContentPage($data)
{
// 调用内容语言与当前语言不一致时,自动切换语言
if ($data->acode != get_lg() && Config::get('lgautosw') !== '0') {
cookie('lg', $data->acode);
}
// 读取模板
if (! ! $sort = $this->model->getSort($data->scode)) {
if ($sort->contenttpl) {
$this->checkPageLevel($sort->gcode, $sort->gtype, $sort->gnote); // 检查栏目权限
$this->checkPageLevel($data->gcode, $data->gtype, $data->gnote); // 检查内容权限
$content = parent::parser($this->htmldir . $sort->contenttpl); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$content = str_replace('{pboot:pagetitle}', $this->config('content_title') ?: '{content:title}-{sort:name}-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = str_replace('{pboot:pagekeywords}', '{content:keywords}', $content);
$content = str_replace('{pboot:pagedescription}', '{content:description}', $content);
$content = $this->parser->parserPositionLabel($content, $sort->scode); // CMS当前位置标签解析
$content = $this->parser->parserSortLabel($content, $sort); // CMS分类信息标签解析
$content = $this->parser->parserCurrentContentLabel($content, $sort, $data); // CMS内容标签解析
$content = $this->parser->parserCommentLabel($content); // 文章评论
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
} else {
error('请到后台设置分类栏目内容页模板!');
}
} else {
_404('您访问内容的分类已经不存在,请核对后再试!');
}
$this->cache($content, true);
}
// 单页
private function getAboutPage($sort)
{
// 调用栏目语言与当前语言不一致时,自动切换语言
if ($sort->acode != get_lg() && Config::get('lgautosw') !== '0') {
cookie('lg', $sort->acode);
}
// 读取数据
if (! $data = $this->model->getAbout($sort->scode)) {
_404('您访问的内容不存在,请核对后重试!');
}
if ($sort->contenttpl) {
$this->checkPageLevel($sort->gcode, $sort->gtype, $sort->gnote);
$content = parent::parser($this->htmldir . $sort->contenttpl); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$pagetitle = $sort->title ? "{sort:title}" : "{content:title}"; // 页面标题
$content = str_replace('{pboot:pagetitle}', $this->config('about_title') ?: ($pagetitle . '-{pboot:sitetitle}-{pboot:sitesubtitle}'), $content);
$content = str_replace('{pboot:pagekeywords}', '{content:keywords}', $content);
$content = str_replace('{pboot:pagedescription}', '{content:description}', $content);
$content = $this->parser->parserPositionLabel($content, $sort->scode); // CMS当前位置标签解析
$content = $this->parser->parserSortLabel($content, $sort); // CMS分类信息标签解析
$content = $this->parser->parserCurrentContentLabel($content, $sort, $data); // CMS内容标签解析
$content = $this->parser->parserCommentLabel($content); // 文章评论
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
} else {
error('请到后台设置分类栏目内容页模板!');
}
$this->cache($content, true);
}
// 检查页面权限
private function checkPageLevel($gcode, $gtype, $gnote)
{
if ($gcode) {
$deny = false;
$gtype = $gtype ?: 4;
switch ($gtype) {
case 1:
if ($gcode <= session('pboot_gcode')) {
$deny = true;
}
break;
case 2:
if ($gcode < session('pboot_gcode')) {
$deny = true;
}
break;
case 3:
if ($gcode != session('pboot_gcode')) {
$deny = true;
}
break;
case 4:
if ($gcode > session('pboot_gcode')) {
$deny = true;
}
break;
case 5:
if ($gcode >= session('pboot_gcode')) {
$deny = true;
}
break;
}
if ($deny) {
$gnote = $gnote ?: '您的权限不足,无法浏览本页面!';
if (session('pboot_uid')) { // 已经登录
error($gnote);
} else {
if ($this->config('login_no_wait')) {
location(Url::home('member/login', null, "backurl=" . urlencode(get_current_url())));
} else {
error($gnote, Url::home('member/login', null, "backurl=" . urlencode(get_current_url())));
}
}
}
}
}
//首页跳转并过滤注入字符
/*
* @param $type url模式
* @param $isSecSiteDir 是否为二级目录 boolean
* */
private function urlJump($type, $isSecSiteDir){
//首页开启了分页直接跳转
if(strpos($_SERVER['REQUEST_URI'],'/?page=') === 0){
$this->getIndexPage();
}
$http = is_https() ? 'https://' : 'http://';
$matches1 = '';
switch ($type){
//普通模式
case 1:
$preg1 = '';
if($isSecSiteDir === true){
if($_SERVER['REQUEST_URI'] == SITE_DIR . '/index.php'){
$preg1 = '/^\/.*?\/index.php/';
} elseif($_SERVER['REQUEST_URI'] == '/index.php'){
$preg1 = '/^\/index.php/';
}
} else {
$preg1 = '/^\/index.php/';
}
preg_match($preg1,$_SERVER['REQUEST_URI'],$matches1);
break;
//伪静态
case 2:
$preg2 = '';
if($isSecSiteDir === true){
if($_SERVER['REQUEST_URI'] == SITE_DIR . '/'){
$preg2 = '/^\/.*/';
} elseif($_SERVER['REQUEST_URI'] == '/'){
$preg2 = '/^\/$/';
}
} else {
$preg2 = '/^\//';
}
preg_match($preg2,$_SERVER['REQUEST_URI'],$matches1);
break;
//兼容模式
case 3:
$preg3 = '';
if($isSecSiteDir === true){
if(strpos($_SERVER['REQUEST_URI'], SITE_DIR) === 0){
$preg3 = '/(^\/.*?\/index.php)|(^\/.*)/';
} elseif(strpos($_SERVER['REQUEST_URI'], '/') === 0){
$preg3 = '/(^\/index.php)|(^\/)/';
}
} else {
$preg3 = '/(^\/index.php)|(^\/)/';
}
preg_match($preg3,$_SERVER['REQUEST_URI'],$matches1);
break;
}
// if(strpos($matches1[0],'/?page=') !== 0 || $matches1[0]){
// $this->getIndexPage();
// }
// if(strpos($_SERVER['REQUEST_URI'],'?page') !== 0){
// $this->getIndexPage();
// }
if($matches1[0]){
if($_SERVER['REQUEST_URI'] == $matches1[0]){
$this->getIndexPage();
} elseif(strpos($matches1[0],'/?page=') !== false) {
$this->getIndexPage();
}else{
//读取后台首页404访问配置
if($this->config('url_index_404') == 1){
_404('您访问的页面不存在,请核对后重试!');
}
header("Location: " . $http . $_SERVER['HTTP_HOST'] . $matches1[0], true, 301);
}
} else {
_404('您访问的页面不存在,请核对后重试!');
}
}
}

View File

@@ -0,0 +1,565 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2020年06月26日
* 会员前台控制器
*/
namespace app\home\controller;
use core\basic\Controller;
use app\home\model\MemberModel;
use core\basic\Url;
class MemberController extends Controller
{
protected $parser;
protected $model;
protected $htmldir;
public function __construct()
{
$this->model = new MemberModel();
$this->parser = new ParserController();
$this->htmldir = $this->config('tpl_html_dir') ? $this->config('tpl_html_dir') . '/' : '';
}
// 会员登录页面
public function login()
{
// 已经登录时跳转到用户中心
if (session('pboot_uid')) {
location(Url::home('member/ucenter'));
}
// 执行登录验证
if ($_POST) {
if ($this->config('login_status') === '0') {
error('系统已经关闭登录功能,请到后台开启再试!');
}
// 验证码验证
$checkcode = strtolower(post('checkcode', 'var'));
if ($this->config('login_check_code') !== '0') {
if (! $checkcode) {
alert_back('验证码不能为空!');
}
if ($checkcode != session('checkcode')) {
alert_back('验证码错误!');
}
}
$username = post('username');
$password = post('password');
if (! $username) {
alert_back('用户账号不能为空!');
}
// 检查用户名
if (! $this->model->checkUsername("username='$username' or useremail='$username' or usermobile='$username'")) {
alert_back('用户账号不存在!');
}
// 检查密码
if (! $password) {
alert_back('用户密码不能为空!');
} else {
$password = md5(md5($password));
}
// 登录验证
if (! ! $login = $this->model->login("(username='$username' or useremail='$username' or usermobile='$username') AND password='$password'")) {
if (! $login->status) {
alert_back('您的账号待审核,请联系管理员!');
}
session('pboot_uid', $login->id);
session('pboot_ucode', $login->ucode);
session('pboot_username', $login->username);
session('pboot_useremail', $login->seremail);
session('pboot_usermobile', $login->usermobile);
session('pboot_gid', $login->gid);
session('pboot_gcode', $login->gcode);
session('pboot_gname', $login->gname);
if (! ! $backurl = get('backurl')) {
alert_location('登录成功!', $backurl, 1);
} else {
alert_location('登录成功!', Url::home('member/ucenter'), 1);
}
} else {
alert_back('账号密码错误,请核对后重试!', 0);
}
} else {
$content = parent::parser($this->htmldir . 'member/login.html'); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$content = str_replace('{pboot:pagetitle}', $this->config('login_title') ?: '会员登录-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = $this->parser->parserPositionLabel($content, 0, '会员登录', Url::home('member/login')); // CMS当前位置标签解析
$content = $this->parser->parserSpecialPageSortLabel($content, - 2, '会员登录', Url::home('member/login')); // 解析分类标签
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
echo $content;
exit();
}
}
// 会员注册页面
public function register()
{
// 已经登录时跳转到用户中心
if (session('pboot_uid')) {
location(Url::home('member/ucenter'));
}
// 执行注册
if ($_POST) {
if ($this->config('register_status') === '0') {
error('系统已经关闭注册功能,请到后台开启再试!');
}
if (time() - session('lastreg') < 10) {
alert_back('您注册太频繁了,请稍后再试!');
}
// 验证码验证
$checkcode = strtolower(post('checkcode', 'var'));
if ($this->config('register_check_code') !== '0') {
if (! $checkcode) {
alert_back('验证码不能为空!');
}
if ($checkcode != session('checkcode')) {
alert_back('验证码错误!');
}
}
$ucode = get_auto_code($this->model->getLastUcode(), 1);
$username = post('username'); // 接受用户名、邮箱、手机三种方式
$nickname = post('nickname');
$password = post('password');
$rpassword = post('rpassword');
$useremail = '';
$usermobile = '';
// 注册类型判断
if ($this->config('register_type') == 2) { // 邮箱注册
$useremail = $username;
if (! $useremail) {
alert_back('账号不能为空,请输入注册的邮箱账号!');
}
if (! preg_match('/^[\w]+@[\w\.]+\.[a-zA-Z]+$/', $useremail)) {
alert_back('账号格式不正确,请输入正确的邮箱账号!');
}
if ($this->model->checkUsername("useremail='$useremail' OR username='$useremail'")) {
alert_back('您输入的邮箱已被注册!');
}
} elseif ($this->config('register_type') == 3) { // 手机注册
$usermobile = $username;
if (! $usermobile) {
alert_back('账号不能为空,请输入注册的手机号码!');
}
if (! preg_match('/^1[0-9]{10}$/', $usermobile)) {
alert_back('账号格式不正确,请输入正确的手机号码!');
}
if ($this->model->checkUsername("usermobile='$usermobile' OR username='$usermobile'")) {
alert_back('您输入的手机号码已被注册!');
}
} else { // 账号注册
if (! $username) {
alert_back('用户名不能为空!');
}
if (! preg_match('/^[\w\@\.]+$/', $username)) {
alert_back('用户账号含有不允许的特殊字符!');
}
// 检查用户名
if ($this->model->checkUsername("username='$username' OR useremail='$username' OR usermobile='$username'")) {
alert_back('您输入的账号已被注册!');
}
}
if ($password != $rpassword) {
alert_back('确认密码不正确!');
}
if (! $password) {
alert_back('密码不能为空!');
} else {
$password = md5(md5($password));
}
// 默认值设置
$status = $this->config('register_verify') ? 0 : 1; // 默认不需要审核
$score = $this->config('register_score') ?: 0;
$group = $this->model->getFirstGroup();
$gid = $this->model->getGroupID($this->config('register_gcode')) ?: $group->id;
// 构建数据
$data = array(
'ucode' => $ucode,
'username' => $username,
'useremail' => $useremail,
'usermobile' => $usermobile,
'nickname' => $nickname,
'password' => $password,
'headpic' => '',
'status' => $status,
'gid' => $gid,
'wxid' => '',
'qqid' => '',
'wbid' => '',
'activation' => 1,
'score' => $score,
'register_time' => get_datetime(),
'login_count' => 0,
'last_login_ip' => 0,
'last_login_time' => 0
);
// 读取字段
if (! ! $field = $this->model->getField()) {
foreach ($field as $value) {
$field_data = post($value->name);
if (is_array($field_data)) { // 如果是多选等情况时转换
$field_data = implode(',', $field_data);
}
$field_data = preg_replace_r('pboot:if', '', $field_data);
if ($value->required && ! $field_data) {
alert_back($value->description . '不能为空!');
} else {
$data[$value->name] = $field_data;
}
}
}
// 执行注册
if ($this->model->register($data)) {
session('lastreg', time()); // 记录最后提交时间
if ($status) {
alert_location('注册成功!', Url::home('member/login'), 1);
} else {
alert_location('注册成功,请等待管理员审核!', Url::home('member/login'), 1);
}
} else {
error('会员注册失败!', - 1);
}
} else {
$content = parent::parser($this->htmldir . 'member/register.html'); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$content = str_replace('{pboot:pagetitle}', $this->config('register_title') ?: '会员注册-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = $this->parser->parserPositionLabel($content, 0, '会员注册', Url::home('member/register')); // CMS当前位置标签解析
$content = $this->parser->parserSpecialPageSortLabel($content, - 3, '会员注册', Url::home('member/register')); // 解析分类标签
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
echo $content;
exit();
}
}
//找回密码
public function retrieve(){
if($_POST){
// 验证码验证
$checkcode = strtolower(post('checkcode', 'var'));
$email = post('email');
$username = post('username');
$password = post('password');
if (! $checkcode) {
alert_back('验证码不能为空!');
}
if ($checkcode != session('checkcode')) {
alert_back('验证码错误!');
}
$where = ['username' => $username];
$userInfo = object_to_array($this->model->checkUsername($where));
if(!$userInfo){
alert_back('该用户不存在!');
}
if(!empty($userInfo['useremail']) && $userInfo['useremail'] != $email){
alert_back('与注册邮箱不匹配,请联系管理员!');
}
$data = [
'useremail' => $email,
'password' => md5(md5($password))
];
$this->model->updatePassword($where,$data);
alert_location('修改成功!', Url::home('member/login'), 1);
} else {
$content = parent::parser($this->htmldir . 'member/retrieve.html'); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$content = str_replace('{pboot:pagetitle}', $this->config('register_title') ?: '找回密码-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = $this->parser->parserPositionLabel($content, 0, '找回密码', Url::home('member/retrieve')); // CMS当前位置标签解析
$content = $this->parser->parserSpecialPageSortLabel($content, - 3, '找回密码', Url::home('member/retrieve')); // 解析分类标签
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
echo $content;
exit();
}
}
// 用户中心
public function ucenter()
{
// 未登录时跳转到用户登录
if (! session('pboot_uid')) {
location(Url::home('member/login'));
}
$content = parent::parser($this->htmldir . 'member/ucenter.html'); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$content = str_replace('{pboot:pagetitle}', $this->config('ucenter_title') ?: '个人中心-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = $this->parser->parserPositionLabel($content, 0, '个人中心', Url::home('member/ucenter')); // CMS当前位置标签解析
$content = $this->parser->parserSpecialPageSortLabel($content, - 4, '个人中心', Url::home('member/ucenter')); // 解析分类标签
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
echo $content;
exit();
}
// 用户修改
public function umodify()
{
// 未登录时跳转到用户登录
if (! session('pboot_uid')) {
location(Url::home('member/login'));
}
// 执行资料修改
if ($_POST && session('pboot_uid')) {
$nickname = post('nickname');
$useremail = post('useremail');
$usermobile = post('usermobile');
$opassword = post('opassword');
$password = post('password');
$rpassword = post('rpassword');
$headpic = str_replace(SITE_DIR, '', post('headpic'));
if (! $opassword) {
alert_back('请输入当前密码!');
} else {
if (! $this->model->checkUsername(" password='" . md5(md5($opassword)) . "' AND id='" . session('pboot_uid') . "'")) {
alert_back('您输入的当前密码不正确!');
}
}
if ($useremail) { // 邮箱校验
if (! preg_match('/^[\w]+@[\w\.]+\.[a-zA-Z]+$/', $useremail)) {
alert_back('邮箱格式不正确,请输入正确的邮箱账号!');
}
if ($this->model->checkUsername("(useremail='$useremail' OR username='$useremail') AND id<>'" . session('pboot_uid') . "'")) {
alert_back('您输入的邮箱已被注册!');
}
}
if ($usermobile) { // 手机检验
if (! preg_match('/^1[0-9]{10}$/', $usermobile)) {
alert_back('手机格式不正确,请输入正确的手机号码!');
}
if ($this->model->checkUsername("(usermobile='$usermobile' OR username='$usermobile') AND id<>'" . session('pboot_uid') . "'")) {
alert_back('您输入的手机号码已被注册!');
}
}
// 构建数据
$data = array(
'nickname' => $nickname,
'useremail' => $useremail,
'usermobile' => $usermobile,
'headpic' => $headpic
);
// 密码修改
if ($password) {
if ($password != $rpassword) {
alert_back('确认密码不正确!');
} else {
$data['password'] = md5(md5($password));
}
}
// 读取字段
if (! ! $field = $this->model->getField()) {
foreach ($field as $value) {
$field_data = post($value->name);
if (is_array($field_data)) { // 如果是多选等情况时转换
$field_data = implode(',', $field_data);
}
$field_data = preg_replace_r('pboot:if', '', $field_data);
if ($value->required && ! $field_data) {
alert_back($value->description . '不能为空!');
} else {
$data[$value->name] = $field_data;
}
}
}
// 不允许修改的字段
unset($data['id']);
unset($data['ucode']);
unset($data['username']);
unset($data['status']);
unset($data['gid']);
unset($data['wxid']);
unset($data['qqid']);
unset($data['wbid']);
unset($data['score']);
unset($data['register_time']);
unset($data['login_count']);
unset($data['last_login_ip']);
unset($data['last_login_time']);
// 执行修改
if ($this->model->modUser($data)) {
alert_location('修改成功!', Url::home('member/umodify'), 1);
} else {
error('资料修改失败!', - 1);
}
} else {
$content = parent::parser($this->htmldir . 'member/umodify.html'); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$content = str_replace('{pboot:pagetitle}', $this->config('umodify_title') ?: '资料修改-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = $this->parser->parserPositionLabel($content, 0, '资料修改', Url::home('member/umodify')); // CMS当前位置标签解析
$content = $this->parser->parserSpecialPageSortLabel($content, - 5, '资料修改', Url::home('member/umodify')); // 解析分类标签
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
echo $content;
exit();
}
}
// 退出登录
public function logout()
{
session('pboot_uid', '');
session('pboot_ucode', '');
session('pboot_username', '');
session('pboot_useremail', '');
session('pboot_usermobile', '');
session('pboot_gid', '');
session('pboot_gcode', '');
session('pboot_gname', '');
location(Url::home('member/login'));
}
// 文件上传方法(Ajax)
public function upload()
{
// 必须登录
if (! session('pboot_uid')) {
json(0, '请先登录!');
}
$ext = $this->config('home_upload_ext') ?: "jpg,jpeg,png,gif,xls,xlsx,doc,docx,ppt,pptx,rar,zip,pdf,txt";
$upload = upload('upload', $ext);
if (is_array($upload)) {
json(1, $upload);
} else {
json(0, $upload);
}
}
// 发送邮件
public function sendEmail()
{
$retrieve = post('retrieve');
//$retrieve存在时为找回密码邮箱验证不进行验证码模式判断
if(!$retrieve){
if ($this->config('register_check_code') != 2) {
json(0, '发送失败,后台配置非邮箱验证码模式!');
}
}
if (time() - session('lastsend') < 10) {
json(0, '您提交太频繁了,请稍后再试!');
}
if (! session('sendemail')) {
json(0, '非法提交发送邮件!');
}
// 发送邮箱参数
if (! ! $to = post('to')) {
if (! preg_match('/^[\w]+@[\w]+\.[a-zA-Z]+$/', $to)) {
json(0, '邮箱格式不正确,请输入正确的邮箱账号!');
}
} else {
json(0, '发送失败缺少发送对象参数to');
}
// 检查邮箱注册
if(!$retrieve) {
if ($this->model->checkUsername("useremail='$to' OR username='$to'")) {
alert_back('您输入的邮箱已被注册!');
}
}
$rs = false;
if ($to) {
session('lastsend', time()); // 记录最后提交时间
$mail_subject = "" . CMSNAME . "】您有新的验证码信息,请注意查收!";
$code = create_code(4);
session('checkcode', strtolower($code));
$mail_body = "您的验证码为:" . $code;
$mail_body .= '<br>来自网站 ' . get_http_url() . ' ' . date('Y-m-d H:i:s') . '';
$rs = sendmail($this->config(), $to, $mail_subject, $mail_body);
}
if ($rs === true) {
json(1, '发送成功!');
} else {
json(0, '发送失败,' . $rs);
}
}
// 检查用户是否注册
public function isRegister()
{
// 接受用户名、邮箱、手机三种方式
$info = '';
if (! $username = post('username')) {
$err = '账号不能为空!';
}
// 注册类型判断
if ($this->config('register_type') == 2) { // 邮箱注册
if (! preg_match('/^[\w]+@[\w\.]+\.[a-zA-Z]+$/', $username)) {
$err = '账号格式不正确,请输入正确的邮箱账号!';
}
if ($this->model->checkUsername("useremail='$username' OR username='$username'")) {
$err = '您输入的邮箱已被注册!';
} else {
$suc = '您输入的邮箱可以使用!';
}
} elseif ($this->config('register_type') == 3) { // 手机注册
if (! preg_match('/^1[0-9]{10}$/', $username)) {
$err = '账号格式不正确,请输入正确的手机号码!';
}
if ($this->model->checkUsername("usermobile='$username' OR username='$username'")) {
$err = '您输入的手机号码已被注册!';
} else {
$suc = '您输入的手机号码可以使用!';
}
} else { // 账号注册
if (! preg_match('/^[\w\@\.]+$/', $username)) {
$err = '用户账号含有不允许的特殊字符!';
}
// 检查用户名
if ($this->model->checkUsername("username='$username' OR useremail='$username' OR usermobile='$username'")) {
$err = '您输入的账号已被注册!';
} else {
$suc = '您输入的账号可以使用!';
}
}
if ($err) {
json(1, $err);
} else {
json(0, $suc);
}
}
public function _empty()
{
_404('您访问的地址不存在,请核对再试!');
}
}

View File

@@ -0,0 +1,112 @@
<?php
/**
* @copyright (C)2020-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2020年3月8日
* 留言控制器
*/
namespace app\home\controller;
use core\basic\Controller;
use app\home\model\ParserModel;
use core\basic\Url;
class MessageController extends Controller
{
protected $model;
public function __construct()
{
$this->model = new ParserModel();
}
// 留言新增
public function index()
{
if ($_POST) {
if ($this->config('message_status') === '0') {
error('系统已经关闭留言功能,请到后台开启再试!');
}
if (time() - session('lastsub') < 10) {
alert_back('您提交太频繁了,请稍后再试!');
}
// 需登录
if ($this->config('message_rqlogin') && ! session('pboot_uid')) {
if (! ! $backurl = $_SERVER['HTTP_REFERER']) {
alert_location("请先注册登录后再留言!", Url::home('member/login', null, "backurl=" . urlencode($backurl)));
} else {
alert_location("请先注册登录后再留言!", Url::home('member/login'));
}
}
// 验证码验证
$checkcode = strtolower(post('checkcode', 'var'));
if ($this->config('message_check_code') !== '0') {
if (! $checkcode) {
alert_back('验证码不能为空!');
}
if ($checkcode != session('checkcode')) {
alert_back('验证码错误!');
}
}
// 读取字段
if (! $form = $this->model->getFormField(1)) {
alert_back('留言表单不存在任何字段,请核对后重试!');
}
// 接收数据
$mail_body = '';
foreach ($form as $value) {
$field_data = post($value->name);
if (is_array($field_data)) { // 如果是多选等情况时转换
$field_data = implode(',', $field_data);
}
$field_data = preg_replace_r('/pboot:if/i', '', $field_data);
if ($value->required && ! $field_data) {
alert_back($value->description . '不能为空!');
} else {
$data[$value->name] = $field_data;
$mail_body .= $value->description . '' . $field_data . '<br>';
}
}
$status = $this->config('message_verify') === '0' ? 1 : 0;
// 设置额外数据
if ($data) {
$data['acode'] = get_lg();
$data['user_ip'] = ip2long(get_user_ip());
$data['user_os'] = get_user_os();
$data['user_bs'] = get_user_bs();
$data['recontent'] = '';
$data['status'] = $status;
$data['create_user'] = 'guest';
$data['update_user'] = 'guest';
$data['uid'] = session('pboot_uid');
}
if ($this->model->addMessage($data)) {
session('lastsub', time()); // 记录最后提交时间
$this->log('留言提交成功!');
if ($this->config('message_send_mail') && $this->config('message_send_to')) {
$mail_subject = "" . CMSNAME . "】您有新的" . $value->form_name . "信息,请注意查收!";
$mail_body .= '<br>来自网站 ' . get_http_url() . ' ' . date('Y-m-d H:i:s') . '';
sendmail($this->config(), $this->config('message_send_to'), $mail_subject, $mail_body);
}
alert_location('提交成功!', '-1', 1);
} else {
$this->log('留言提交失败!');
alert_back('提交失败!');
}
} else {
alert_back('提交失败请使用POST方式提交');
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
<?php
/**
* @copyright (C)2020-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2020年3月8日
* 搜索控制器
*/
namespace app\home\controller;
use core\basic\Controller;
use core\basic\Url;
class SearchController extends Controller
{
protected $parser;
protected $htmldir;
public function __construct()
{
$this->parser = new ParserController();
$this->htmldir = $this->config('tpl_html_dir') ? $this->config('tpl_html_dir') . '/' : '';
}
// 内容搜索
public function index()
{
$searchtpl = request('searchtpl');
if (! preg_match('/^[\w]+\.html$/', $searchtpl)) {
$searchtpl = 'search.html';
}
$content = parent::parser($this->htmldir . $searchtpl); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$pagetitle = get('keyword', 'var') ? get('keyword', 'var') . '-' : '';
$content = str_replace('{pboot:pagetitle}', $this->config('search_title') ?: $pagetitle . '搜索结果-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = $this->parser->parserPositionLabel($content, 0, '搜索', Url::home('search')); // CMS当前位置标签解析
$content = $this->parser->parserSpecialPageSortLabel($content, - 1, '搜索结果', Url::home('search')); // 解析分类标签
$content = $this->parser->parserSearchLabel($content); // 搜索结果标签
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
echo $content; // 搜索页面不缓存
exit();
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年7月15日
* 生成sitemap文件
*/
namespace app\home\controller;
use core\basic\Controller;
use app\home\model\SitemapModel;
use core\basic\Url;
class SitemapController extends Controller
{
protected $model;
public function __construct()
{
$this->model = new SitemapModel();
}
public function index()
{
header("Content-type:text/xml;charset=utf-8");
$str = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
//$str .= '<urlset>' . "\n";
$str .= '<urlset xmlns= "http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n" ;
$str .= $this->makeNode('', date('Y-m-d'), '1.00', 'always'); // 根目录
$sorts = $this->model->getSorts();
$Parser = new ParserController();
foreach ($sorts as $value) {
if ($value->outlink) {
continue;
} elseif ($value->type == 1) {
$link = $Parser->parserLink(1, $value->urlname, 'about', $value->scode, $value->filename);
$str .= $this->makeNode($link, date('Y-m-d'), '0.80', 'daily');
} else {
$link = $Parser->parserLink(2, $value->urlname, 'list', $value->scode, $value->filename);
$str .= $this->makeNode($link, date('Y-m-d'), '0.80', 'daily');
$contents = $this->model->getSortContent($value->scode);
foreach ($contents as $value2) {
if ($value2->outlink) { // 外链
continue;
} else {
$link = $Parser->parserLink(2, $value2->urlname, 'content', $value2->scode, $value2->sortfilename, $value2->id, $value2->filename);
}
$str .= $this->makeNode($link, date('Y-m-d', strtotime($value2->date)), '0.60', 'daily');
}
}
}
echo $str . "\n</urlset>";
}
// 生成结点信息
private function makeNode($link, $date, $priority = 0.60, $changefreq = 'always')
{
$node = '
<url>
<loc>' . get_http_url() . $link . '</loc>
<priority>' . $priority . '</priority>
<lastmod>' . $date . '</lastmod>
<changefreq>' . $changefreq . '</changefreq>
</url>';
return $node;
}
// 文本格式
public function linkTxt()
{
header("Content-type:text/plain;charset=utf-8");
$sorts = $this->model->getSorts();
$Parser = new ParserController();
$str = get_http_url() . "\n";
foreach ($sorts as $value) {
if ($value->outlink) {
continue;
} elseif ($value->type == 1) {
$link = $Parser->parserLink(1, $value->urlname, 'about', $value->scode, $value->filename);
$str .= get_http_url() . $link . "\n";
} else {
$link = $Parser->parserLink(2, $value->urlname, 'list', $value->scode, $value->filename);
$str .= get_http_url() . $link . "\n";
$contents = $this->model->getSortContent($value->scode);
foreach ($contents as $value2) {
if ($value2->outlink) { // 外链
continue;
} else {
$link = $Parser->parserLink(2, $value2->urlname, 'content', $value2->scode, $value2->sortfilename, $value2->id, $value2->filename);
}
$str .= get_http_url() . $link . "\n";
}
}
}
echo $str;
}
}

View File

@@ -0,0 +1,88 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @license This is not a freeware, use is subject to license terms
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2021年10月27日
*
*/
namespace app\home\controller;
use core\basic\Controller;
class SpiderController extends Controller
{
private $url;
public function __construct($url = null)
{
$this->url = $url ? escape_string($url) : get('url');
}
public function index()
{
$rs = $this->getSpider();
if ($rs !== false) {
$this->log($rs . '爬行' . $this->url);
}
}
private function getSpider()
{
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($useragent, 'googlebot') !== false) {
return 'Google';
} elseif (strpos($useragent, 'baiduspider') !== false) {
return 'Baidu';
} elseif (strpos($useragent, 'webscan') !== false) {
return '360WebScan';
} elseif (strpos($useragent, '360spider') !== false) {
return '360So';
} elseif (strpos($useragent, 'adsbot') !== false) {
return 'Adwords';
} elseif (strpos($useragent, 'bingbot') !== false) {
return 'Bing';
} elseif (strpos($useragent, 'slurp') !== false) {
return 'Yahoo';
} elseif (strpos($useragent, 'sosospider') !== false) {
return 'Soso';
} elseif (strpos($useragent, 'sogou') !== false) {
return 'Sogou';
} elseif (strpos($useragent, 'yodaobot') !== false) {
return 'Yodao';
} elseif (strpos($useragent, 'speedy') !== false) {
return 'Speedy';
} elseif (strpos($useragent, 'yandexbot') !== false) {
return 'Yandex';
} elseif (strpos($useragent, 'easouspider') !== false) {
return 'Easou';
} elseif (strpos($useragent, 'symantecspider') !== false) {
return 'Symantec';
} elseif (strpos($useragent, 'qiniu') !== false) {
return 'Qiniu';
} elseif (strpos($useragent, 'jiankongbao') !== false) {
return 'JianKongBao';
} elseif (strpos($useragent, 'dnspod') !== false) {
return 'DNSPod';
} elseif (strpos($useragent, 'linkpadbot') !== false) {
return 'Linkpad';
} elseif (strpos($useragent, 'mj12bot') !== false) {
return 'MJ12';
} elseif (strpos($useragent, 'dingtalkbot') !== false) {
return 'DingTalk';
} elseif (strpos($useragent, 'bytespider') !== false) {
return 'Byte';
} elseif (strpos($useragent, 'zoominfobot') !== false) {
return 'Zoominfo';
} elseif (strpos($useragent, 'yisouspider') !== false) {
return 'Yisou';
} elseif (strpos($useragent, 'spider') !== false) {
return 'other-spider';
} elseif (strpos($useragent, 'bot') !== false) {
return 'other-bot';
}
return false;
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* @copyright (C)2020-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2020年3月8日
* 标签控制器
*/
namespace app\home\controller;
use core\basic\Controller;
use core\basic\Url;
class TagController extends Controller
{
protected $parser;
protected $htmldir;
public function __construct()
{
$this->parser = new ParserController();
$this->htmldir = $this->config('tpl_html_dir') ? $this->config('tpl_html_dir') . '/' : '';
}
// 内容搜索
public function index()
{
// 在非兼容模式接受地址第二参数值
if (defined('RVAR')) {
$_GET['tag'] = RVAR;
}
if (! get('tag')) {
_404('您访问的页面不存在,请核对后重试!');
}
$tagstpl = request('tagstpl');
if (! preg_match('/^[\w]+\.html$/', $tagstpl)) {
$tagstpl = 'tags.html';
}
$content = parent::parser($this->htmldir . $tagstpl); // 框架标签解析
$content = $this->parser->parserBefore($content); // CMS公共标签前置解析
$content = $this->parser->parserPositionLabel($content, 0, '相关内容', Url::home('tag/' . get('tag'))); // CMS当前位置标签解析
$content = $this->parser->parserSpecialPageSortLabel($content, - 2, '相关内容', Url::home('tag/' . get('tag'))); // 解析分类标签
$content = $this->parser->parserAfter($content); // CMS公共标签后置解析
$this->cache($content, true);
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年3月8日
*
*/
namespace app\home\model;
use core\basic\Model;
class DoModel extends Model
{
// 新增访问
public function addVisits($id)
{
$data = array(
'visits' => '+=1'
);
parent::table('ay_content')->where("id=$id")->update($data);
}
// 新增喜欢
public function addLikes($id)
{
$data = array(
'likes' => '+=1'
);
parent::table('ay_content')->where("id=$id")->update($data);
}
// 新增喜欢
public function addOppose($id)
{
$data = array(
'oppose' => '+=1'
);
parent::table('ay_content')->where("id=$id")->update($data);
}
}

View File

@@ -0,0 +1,129 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2020年06月26日
* 会员前台模型
*/
namespace app\home\model;
use core\basic\Model;
use core\basic\Config;
class MemberModel extends Model
{
// 会员登录
public function login($where)
{
$field = array(
'a.id',
'a.ucode',
'a.username',
'a.useremail',
'a.usermobile',
'a.gid',
'a.status',
'b.gcode',
'b.gname'
);
$join = array(
'ay_member_group b',
'a.gid=b.id',
'LEFT'
);
if (! ! $user = parent::table('ay_member a')->field($field)
->join($join)
->where($where)
->find()) {
$data = array(
'login_count' => '+=1',
'last_login_ip' => ip2long(get_user_ip()),
'last_login_time' => get_datetime()
);
// 登录积分
$score = Config::get('login_score') ?: 0;
if (is_numeric($score) && $score > 0) {
$data['score'] = '+=' . $score;
}
// 更新登录信息
parent::table('ay_member')->where('id=' . $user->id)->update($data);
}
return $user;
}
// 会员注册
public function register($data)
{
return parent::table('ay_member')->insert($data);
}
// 检查会员名称
public function checkUsername($where)
{
return parent::table('ay_member')->where($where)->find();
}
// 读取会员字段
public function getField()
{
return parent::table('ay_member_field')->field('name,description,required')
->where('status=1')
->order('sorting,id')
->select();
}
// 获取最后一个code
public function getLastUcode()
{
return parent::table('ay_member')->order('id DESC')->value('ucode');
}
// 获取当前会员信息
public function getUser()
{
$field = array(
'a.*',
'b.gcode',
'b.gname'
);
$join = array(
'ay_member_group b',
'a.gid=b.id',
'LEFT'
);
return parent::table('ay_member a')->field($field)
->join($join)
->where("a.id='" . session('pboot_uid') . "'")
->find();
}
// 修改会员资料
public function modUser($data)
{
return parent::table('ay_member')->where("id='" . session('pboot_uid') . "'")->update($data);
}
// 获取第一个等级
public function getFirstGroup()
{
return parent::table('ay_member_group')->order('gcode asc')->find();
}
// 获取等级ID
public function getGroupID($gcode)
{
return parent::table('ay_member_group')->where("gcode='$gcode'")->value('id');
}
//未登录状态下找回密码
public function updatePassword($where,$data){
return parent::table('ay_member')->where($where)->update($data);
}
public function getImage()
{
return parent::table('ay_member')->column('headpic');
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,80 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年2月14日
* Sitemap模型
*/
namespace app\home\model;
use core\basic\Model;
class SitemapModel extends Model
{
// 分类栏目列表
public function getSorts()
{
$fields = array(
'a.id',
'a.pcode',
'a.scode',
'a.name',
'a.filename',
'a.outlink',
'b.type',
'b.urlname'
);
$join = array(
'ay_model b',
'a.mcode=b.mcode',
'LEFT'
);
$result = parent::table('ay_content_sort a')->field($fields)
->where('a.status=1')
->where("a.acode='" . get_lg() . "'")
->join($join)
->order('a.pcode,a.sorting,a.id')
->select();
return $result;
}
// 指定列表内容
public function getSortContent($scode)
{
$fields = array(
'a.id',
'a.filename',
'a.date',
'c.type',
'c.urlname',
'b.scode',
'b.filename as sortfilename'
);
$join = array(
array(
'ay_content_sort b',
'a.scode=b.scode',
'LEFT'
),
array(
'ay_model c',
'b.mcode=c.mcode',
'LEFT'
)
);
$where = array(
'a.status=1',
'c.type=2',
"a.date<'" . date('Y-m-d H:i:s') . "'"
);
return parent::table('ay_content a')->field($fields)
->where("a.scode='$scode'")
->where($where)
->join($join)
->select();
}
}