This commit is contained in:
tao 2022-08-02 18:46:05 +08:00
parent 36bdf774ba
commit 7eb272c437
31 changed files with 815 additions and 490 deletions

View File

@ -3,8 +3,8 @@
> TaoLer是一个简单迅捷的轻论坛系统适用于个人或组织区域型信息交流发布平台。 > TaoLer是一个简单迅捷的轻论坛系统适用于个人或组织区域型信息交流发布平台。
* 官网https://www.aieok.com * 官网https://www.aieok.com
* 版本TaoLer 1.9.2 * 版本TaoLer 1.9.3
* 日期2022.4.19 * 日期2022.4.22
webman版新架构已适配90% webman版新架构已适配90%
@ -99,21 +99,16 @@
#### 前后台独立域名的绑定 #### 前后台独立域名的绑定
1. 手动修改`config/app.php`文件内的`'domain_bind'`对应的应用。 1. 支持设置绑定域名
```html
// 域名绑定(自动多应用模式有效)
'domain_bind' => [
'bbs' => 'index', //bbs.xxx.com 访问的是Index应用
'adm' => 'admin', //adm.xxx.com 访问的是Admin应用
'api' => 'api' //api.xxx.com 访问的是Admin应用
'www.test.com' => 'test' //www.test.com 访问的是Test应用
],
```
2. 后面会针对动态的设置绑定域名功能开发...此处待完成
> 如果绑定`index`应用对应的域名,后台`admin`应用也必须独立绑定域名,否则原`xxx.com/admin`访问路径就无法再访问。 > 如果绑定`index`应用对应的域名,后台`admin`应用也必须独立绑定域名,否则原`xxx.com/admin`访问路径就无法再访问。
2. 支持应用设置映射
> 域名绑定的优先级高于应用映射若绑定过域名直接访问域名如果没有绑定过域名访问路径为xxx.com/youbind.
如后台的映射地址 www.xxx.com/youadmin
#### 使用说明 #### 使用说明

Binary file not shown.

View File

@ -123,7 +123,8 @@ class Index extends AdminController
$res['msg'] = ''; $res['msg'] = '';
$res['count'] = $count; $res['count'] = $count;
foreach($forumList as $k=>$v){ foreach($forumList as $k=>$v){
$url = (string) str_replace("admin","index",$this->domain.url('article/detail',['id'=>$v['aid']])); //$url = (string) str_replace("admin","index",$this->domain.url('article/detail',['id'=>$v['aid']]));
$url = $this->getRouteUrl($v['aid']);
$res['data'][]= ['id'=>$url,'title'=>htmlspecialchars($v['title']),'name'=>$v['name'],'catename'=>$v['catename'],'pv'=>$v['pv']]; $res['data'][]= ['id'=>$url,'title'=>htmlspecialchars($v['title']),'name'=>$v['name'],'catename'=>$v['catename'],'pv'=>$v['pv']];
} }
} else { } else {
@ -152,7 +153,7 @@ class Index extends AdminController
if ($count) { if ($count) {
$res = ['code'=>0,'msg'=>'','count'=>$count]; $res = ['code'=>0,'msg'=>'','count'=>$count];
foreach($replys as $k => $v){ foreach($replys as $k => $v){
$res['data'][] = ['content'=>htmlspecialchars($v['content']),'title'=>htmlspecialchars($v['title']),'cid'=>str_replace("admin","index",$this->domain.(string) url('article/detail',['id'=>$v['cid']])),'name'=>$v['name']]; $res['data'][] = ['content'=>htmlspecialchars($v['content']),'title'=>htmlspecialchars($v['title']),'cid'=>$this->getRouteUrl($v['cid']),'name'=>$v['name']];
} }
} else { } else {
$res = ['code'=>-1,'msg'=>'本周还没评论']; $res = ['code'=>-1,'msg'=>'本周还没评论'];
@ -183,7 +184,6 @@ class Index extends AdminController
//$mail = Db::name('system')->where('id',1)->value('auth_mail'); // bug邮件发送 //$mail = Db::name('system')->where('id',1)->value('auth_mail'); // bug邮件发送
if(Request::isAjax()){ if(Request::isAjax()){
$data = Request::only(['type','title','content','post']); $data = Request::only(['type','title','content','post']);
//halt($data);
$apiRes = Api::urlPost($url,$data); $apiRes = Api::urlPost($url,$data);
$data['poster'] = Session::get('admin_id'); $data['poster'] = Session::get('admin_id');
unset($data['post']); unset($data['post']);

View File

@ -2,7 +2,7 @@
/* /*
* @Author: TaoLer <alipey_tao@qq.com> * @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2022-04-13 09:54:31 * @Date: 2022-04-13 09:54:31
* @LastEditTime: 2022-04-19 16:42:47 * @LastEditTime: 2022-04-21 11:39:38
* @LastEditors: TaoLer * @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置 * @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\app\admin\controller\Seo.php * @FilePath: \TaoLer\app\admin\controller\Seo.php
@ -16,19 +16,30 @@ use think\facade\View;
use think\facade\Request; use think\facade\Request;
use think\facade\Db; use think\facade\Db;
use taoser\SetArr; use taoser\SetArr;
use app\admin\model\PushJscode;
class Seo extends AdminController class Seo extends AdminController
{ {
public function index() public function index()
{ {
// 站点地图
$xml = '';
$xmlArr = $this->getXmlFile(public_path());
foreach($xmlArr as $v) {
$map = $this->getIndexUrl().'/'.$v;
$xml .= $map."\n";
}
// robots
if(is_file($rob = public_path().'robots.txt')){ if(is_file($rob = public_path().'robots.txt')){
$robots = file_get_contents($rob); $robots = file_get_contents($rob);
} else { } else {
$robots = ''; $robots = '';
} }
// push_js
View::assign('robots',$robots); $pushjs = new PushJscode();
$jscode = $pushjs->getAllCodes();
View::assign(['xml'=>$xml,'jscode'=>$jscode,'robots'=>$robots]);
return View::fetch(); return View::fetch();
} }
@ -161,7 +172,6 @@ class Seo extends AdminController
$str .= <<<STR $str .= <<<STR
<url> <url>
<loc>$url</loc> <loc>$url</loc>
<mobile:mobile type="pc,mobile"/>
<lastmod>$time</lastmod> <lastmod>$time</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
<priority>0.5</priority> <priority>0.5</priority>
@ -258,46 +268,41 @@ class Seo extends AdminController
} }
/** /**
* 获取文章链接地址 * 保存搜索平台js代码
* *
* @param integer $aid * @return void
* @return string
*/ */
protected function getRouteUrl(int $aid) : string public function savePushJs()
{ {
$indexUrl = $this->getIndexUrl(); $data = Request::only(['name','jscode']);
$artUrl = (string) url('detail_id', ['id' => $aid]); if(empty($data['name'])) {
return json(['code'=>-1,'msg'=>'请术输入名称']);
// 判断是否开启绑定
//$domain_bind = array_key_exists('domain_bind',config('app'));
// 判断index应用是否绑定域名
$bind_index = array_search('index',config('app.domain_bind'));
// 判断admin应用是否绑定域名
$bind_admin = array_search('admin',config('app.domain_bind'));
// 判断index应用是否域名映射
$map_index = array_search('index',config('app.app_map'));
// 判断admin应用是否域名映射
$map_admin = array_search('admin',config('app.app_map'));
$index = $map_index ? $map_index : 'index'; // index应用名
$admin = $map_admin ? $map_admin : 'admin'; // admin应用名
if($bind_index) {
// index绑定域名
$url = $indexUrl . str_replace($admin.'/','',$artUrl);
} else { // index未绑定域名
// admin绑定域名
if($bind_admin) {
$url = $indexUrl .'/' . $index . $artUrl;
} else {
$url = $indexUrl . str_replace($admin,$index,$artUrl);
}
} }
if(empty($data['jscode'])){
return json(['code'=>-1,'msg'=>'请术输入代码']);
}
$push = new PushJscode();
$res = $push->saveCode($data);
if(!$res) {
return json(['code'=>-1,'msg'=>'保存失败']);
}
return json(['code'=>0,'msg'=>'保存成功']);
}
return $url; /**
* 删除平台js代码
*
* @return void
*/
public function delPushJs()
{
$id = (int) input('id');
$push = new PushJscode();
$res = $push->delCode($id);
if(!$res) {
return json(['code'=>-1,'msg'=>'删除失败']);
}
return json(['code'=>0,'msg'=>'删除成功']);
} }
} }

View File

@ -2,7 +2,7 @@
/* /*
* @Author: TaoLer <alipey_tao@qq.com> * @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2021-12-06 16:04:50 * @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-04-19 14:06:54 * @LastEditTime: 2022-04-22 06:30:01
* @LastEditors: TaoLer * @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置 * @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\app\admin\controller\Set.php * @FilePath: \TaoLer\app\admin\controller\Set.php
@ -22,6 +22,7 @@ use taoler\com\Files;
use think\facade\Session; use think\facade\Session;
use think\facade\Cookie; use think\facade\Cookie;
use taoser\SetArr; use taoser\SetArr;
use app\common\lib\SetArr as SetArrConf;
class Set extends AdminController class Set extends AdminController
{ {
@ -30,13 +31,22 @@ class Set extends AdminController
parent::initialize(); parent::initialize();
$this->sysInfo = $this->getSystem(); $this->sysInfo = $this->getSystem();
} }
//网站设置显示 //网站设置显示
public function index() public function index()
{ {
$mailserver = MailServer::find(1); $mailserver = MailServer::find(1);
$template = Files::getDirName('../view'); $template = Files::getDirName('../view');
$email = Db::name('admin')->where('id',1)->value('email'); $email = Db::name('admin')->where('id',1)->value('email');
View::assign(['sysInfo'=>$this->sysInfo,'mailserver'=>$mailserver,'template'=>$template,'email'=>$email]);
// 应用映射
$index_map = array_search('index',config('app.app_map'));
$admin_map = array_search('admin',config('app.app_map'));
$index_map = $index_map ? $index_map : '';
$admin_map = $admin_map ? $admin_map : '';
View::assign(['sysInfo'=>$this->sysInfo,'mailserver'=>$mailserver,'template'=>$template,'email'=>$email,'index_map'=>$index_map,'admin_map'=>$admin_map]);
// 域名绑定
if(!empty(config('app.domain_bind'))){ if(!empty(config('app.domain_bind'))){
$data = array_flip(config('app.domain_bind')); $data = array_flip(config('app.domain_bind'));
$domain_bind = [ $domain_bind = [
@ -50,6 +60,20 @@ class Set extends AdminController
]; ];
} }
View::assign($domain_bind); View::assign($domain_bind);
// url美化
$urlArr = config('taoler.url_rewrite');
$urlRe = [];
foreach($urlArr as $k => $v) {
if(!empty($v)) {
$urlRe[$k] = substr($v, 0, strrpos($v, '/'));
} else {
$urlRe[$k] = '';
}
}
View::assign('url_re',$urlRe);
return View::fetch('set/system/website'); return View::fetch('set/system/website');
} }
@ -68,44 +92,6 @@ class Set extends AdminController
} }
} }
// 域名绑定
public function setDomain()
{
if(Request::isPost()){
//$data = Request::only(['index','admin']);
$data = Request::param();
//dump($data);
if($data['domain_check'] == 'on') {
unset($data['domain_check']);
$data = array_flip($data);
if(empty(config('app.domain_bind'))){
// 写入token
$res = SetArr::name('app')->add([
'domain_bind'=> $data,
]);
}else{
// 编辑
$res = SetArr::name('app')->edit([
'domain_bind'=> $data,
]);
}
//清空缓存
Cookie::delete('adminAuth');
Session::clear();
} else {
$res = SetArr::name('app')->delete([
'domain_bind'=> config('app.domain_bind'),
]);
}
if($res == true){
return json(['code'=>0,'msg'=>'成功']);
} else{
return json(['code'=>-1,'msg'=>'失败']);
}
}
}
//综合设置 //综合设置
public function server() public function server()
{ {
@ -130,8 +116,13 @@ class Set extends AdminController
} }
} }
public function sendMailCode() /**
{ * 发验证码
*
* @return void
*/
public function sendMailCode()
{
if(Request::isPost()){ if(Request::isPost()){
$email = Request::param('email'); $email = Request::param('email');
$code = mt_rand('1111','9999'); $code = mt_rand('1111','9999');
@ -146,8 +137,13 @@ class Set extends AdminController
return json($res); return json($res);
} }
public function activeMailServer() /**
{ * 邮件激活
*
* @return void
*/
public function activeMailServer()
{
if(Request::isPost()){ if(Request::isPost()){
$eCode = Request::param('code'); $eCode = Request::param('code');
$sCode = Cache::get('test_code'); $sCode = Cache::get('test_code');
@ -199,13 +195,150 @@ class Set extends AdminController
} }
} }
// 域名绑定
public function setDomain()
{
$str = file_get_contents(str_replace('\\', '/', app()->getConfigPath() . 'app.php'));
if(Request::isPost()){
$data = Request::only(['index','admin','domain_check']);
//$data = Request::param();
//dump($data);
if($data['domain_check'] == 'on') {
// 过滤空项目
$domain_bind = [];
if(!empty($data['index'])){
$domain_bind[$data['index']] ='index';
if(config('app.default_app') == $domain_bind[$data['index']]) {
if(empty($data['admin'])) {
return json(['code'=>-1, 'msg'=>'默认应用和Index一致时必须绑定Admin域名,否则无法进入后台']);
}
}
}
if(!empty($data['admin'])){
$domain_bind[$data['admin']] ='admin';
}
// 匹配整个domain_map数组
$pats_domain_bind = '/\'(domain_bind)\'[^\]]*\],/';
// 空数组
$rep_domain_null = "'domain_bind'\t=> [\n\t],";
$str = preg_replace($pats_domain_bind, $rep_domain_null, $str);
// 匹配'domain_bind' => [
$pats = '/\'(domain_bind)\'\s*=>\s*\[\r?\n/';
preg_match($pats,$str,$arr);
// 拼接数组内字符串
$domainArr = '';
foreach($domain_bind as $k => $v){
$domainArr .= "\t\t'". $k. "' => '" . $v . "',\n";
}
// 追加组成新数组写入文件
$reps = $arr[0].$domainArr;
$str = preg_replace($pats, $reps, $str);
$res = file_put_contents(app()->getConfigPath() . 'app.php', $str);
// 如果编辑了后台 ,需要清理退出缓存
if(!empty($domain_bind[$data['admin']])) {
//清空缓存
Cookie::delete('adminAuth');
Session::clear();
}
} else {
$res = SetArr::name('app')->delete([
'domain_bind'=> config('app.domain_bind'),
]);
}
if($res == true){
return json(['code'=>0,'msg'=>'成功']);
} else{
return json(['code'=>-1,'msg'=>'失败']);
}
}
}
/**
* 绑定应用映射
*
* @return void
*/
public function bindMap()
{
$data = Request::only(['index_map','admin_map']);
$str = file_get_contents(str_replace('\\', '/', app()->getConfigPath() . 'app.php'));
// 过滤空项目
$app_map = [];
if(!empty($data['index_map'])){
$app_map[$data['index_map']]='index';
}
if(!empty($data['admin_map'])){
$app_map[$data['admin_map']] ='admin';
}
//halt($app_map);
// $set = new SetArrConf('app');
// $res = $set->delete(['app_map' => config('app.app_map')])->add([
// 'app_map' => $app_map,
// ])->put();
// halt($res);
// 匹配整个app_map数组
$pats_app_map = '/\'(app_map)\'[^\]]*\],/';
preg_match($pats_app_map,$str,$arr_map);
// 空数组
$rep_map_null = "'app_map'\t=> [\n\t],";
$str = preg_replace($pats_app_map, $rep_map_null, $str);
// 匹配'app_map' => [
$pats = '/\'(app_map)\'\s*=>\s*\[\r?\n/';
preg_match($pats,$str,$arr);
// 拼接数组内字符串
$appArr = '';
foreach($app_map as $k => $v){
$appArr .= "\t\t'". $k. "' => '" . $v . "',\n";
}
// 追加组成新数组写入文件
$reps = $arr[0].$appArr;
$str = preg_replace($pats, $reps, $str);
$res = file_put_contents(app()->getConfigPath() . 'app.php', $str);
if(!$res) {
return json(['code'=>-1,'msg'=>'绑定失败']);
}
return json(['code'=>0,'msg'=>'绑定成功']);
}
/**
* URL美化设置访问链接
*
* @return void
*/
public function setUrl() public function setUrl()
{ {
//
$data = Request::only(['article_as','cate_as']); $data = Request::only(['article_as','cate_as']);
$arr = [ $arr = [];
'url_rewrite'=>$data, foreach($data as $k => $v) {
]; if(!empty($v)) {
$arr['url_rewrite'][$k] = $v . '/';
} else {
$arr['url_rewrite'][$k] = '';
}
}
if(empty($arr['url_rewrite']['cate_as'])) return json(['code'=>-1,'msg'=>'分类不能为空']);
if(!array_key_exists('url_rewrite',config('taoler'))){ if(!array_key_exists('url_rewrite',config('taoler'))){
$result = SetArr::name('taoler')->add($arr); $result = SetArr::name('taoler')->add($arr);
} else { } else {

View File

@ -0,0 +1,63 @@
<?php
/*
* @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2022-04-20 10:45:41
* @LastEditTime: 2022-04-20 12:34:40
* @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\app\admin\model\PushJscode.php
* Copyright (c) 2020~2022 http://www.aieok.com All rights reserved.
*/
namespace app\admin\model;
use think\Model;
class PushJscode extends Model
{
/**
* 保存代码
*
* @param [type] $data
* @return void
*/
public function saveCode($data)
{
$res = $this->save($data);
if($res == true) {
return true;
} else {
return false;
}
}
/**
* 获取所有数据
*
* @return void
*/
public function getAllCodes()
{
//
return $this->select();
}
/**
* 删除数据
*
* @param [type] $id
* @return void
*/
public function delCode($id)
{
//
$res = $this::destroy($id);
if($res == true) {
return true;
} else {
return false;
}
}
}

View File

@ -2,7 +2,7 @@
/* /*
* @Author: TaoLer <alipey_tao@qq.com> * @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2021-12-06 16:04:50 * @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-04-19 14:31:41 * @LastEditTime: 2022-04-21 17:02:15
* @LastEditors: TaoLer * @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置 * @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\app\admin\route\route.php * @FilePath: \TaoLer\app\admin\route\route.php
@ -11,8 +11,8 @@
use think\facade\Route; use think\facade\Route;
//详情页URL别称 // 动态详情页URL别称
$detail_as = config('taoler.url_rewrite.article_as'); $detail_as = config('taoler.url_rewrite.article_as');
Route::get('captcha/[:config]','\\think\\captcha\\CaptchaController@index'); Route::get('captcha/[:config]','\\think\\captcha\\CaptchaController@index');
Route::get($detail_as.'/:id', '\app\index\controller\Article::detail')->name('detail_id'); Route::get(config('taoler.url_rewrite.article_as').'<id>', '\app\index\controller\Article@detail')->name('detail_id');

View File

@ -85,13 +85,13 @@
<div carousel-item> <div carousel-item>
<ul class="layui-row layui-col-space10"> <ul class="layui-row layui-col-space10">
<li class="layui-col-xs6"> <li class="layui-col-xs6">
<a lay-href="{:url('admin/Forum/replys')}" class="layadmin-backlog-body"> <a lay-href="{:url('Forum/replys')}" class="layadmin-backlog-body">
<h3>待审评论</h3> <h3>待审评论</h3>
<p><cite>{$comms}</cite></p> <p><cite>{$comms}</cite></p>
</a> </a>
</li> </li>
<li class="layui-col-xs6"> <li class="layui-col-xs6">
<a lay-href="{:url('admin/Forum/list')}" class="layadmin-backlog-body"> <a lay-href="{:url('Forum/list')}" class="layadmin-backlog-body">
<h3>待审帖子</h3> <h3>待审帖子</h3>
<p><cite>{$forums}</cite></p> <p><cite>{$forums}</cite></p>
</a> </a>
@ -226,7 +226,7 @@
<td> <td>
<script type="text/html" template> <script type="text/html" template>
TaoLer_{:config('taoler.version')} TaoLer_{:config('taoler.version')}
<a href="http://bbs.aieok.com/doc/timeline.html" target="_blank" style="padding-left: 15px;">更新日志</a> <a href="https://www.aieok.com/bbs/doc/timeline.html" target="_blank" style="padding-left: 15px;">更新日志</a>
</script> </script>
</td> </td>
</tr> </tr>

View File

@ -1,3 +1,12 @@
<!--
* @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-04-21 11:05:47
* @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\app\admin\view\public\base.html
* Copyright (c) 2020~2022 http://www.aieok.com All rights reserved.
-->
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -10,7 +19,7 @@
<link rel="stylesheet" href="/static/admin/style/admin.css" media="all"> <link rel="stylesheet" href="/static/admin/style/admin.css" media="all">
{block name="css"}{/block} {block name="css"}{/block}
</head> </head>
<body {if($Request.url=='/admin/index/index')}class="layui-layout-body"{/if}> <body {if($Request.url==url('index/index'))}class="layui-layout-body"{/if}>
{block name="body"}内容{/block} {block name="body"}内容{/block}
<script src="/static/layui/jquery.min.js" charset="utf-8"></script> <script src="/static/layui/jquery.min.js" charset="utf-8"></script>
<script src="/static/layui/layui.js"></script> <script src="/static/layui/layui.js"></script>

View File

@ -1,5 +1,14 @@
<!--
* @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-04-21 11:06:13
* @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\app\admin\view\public\footer.html
* Copyright (c) 2020~2022 http://www.aieok.com All rights reserved.
-->
<div class="layui-footer"> <div class="layui-footer">
<!-- 底部固定区域 --> <!-- 底部固定区域 -->
© <a href="http://www.aieok.com">aieok.com</a> - 联系QQ317927823 © <a href="https://www.aieok.com">aieok.com</a> - 联系QQ317927823
</div> </div>

View File

@ -12,6 +12,7 @@
<li class="layui-this" lay-id="push">百度推送</li> <li class="layui-this" lay-id="push">百度推送</li>
<li lay-id="map">站点地图</li> <li lay-id="map">站点地图</li>
<li lay-id="robots">robots</li> <li lay-id="robots">robots</li>
<li lay-id="push_js">自动提交</li>
</ul> </ul>
<div class="layui-tab-content"> <div class="layui-tab-content">
<div class="layui-tab-item"> <div class="layui-tab-item">
@ -97,6 +98,12 @@
<button class="layui-btn" lay-submit lay-filter="map_xml">生成</button> <button class="layui-btn" lay-submit lay-filter="map_xml">生成</button>
</div> </div>
</div> </div>
<hr>
<div class="layui-form-item">
<div class="layui-input-block">
<textarea type="text" class="layui-textarea" style="height: 300px;">{$xml}</textarea>
</div>
</div>
</div> </div>
</div> </div>
@ -105,7 +112,7 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">内容</label> <label class="layui-form-label">内容</label>
<div class="layui-input-block"> <div class="layui-input-block">
<textarea type="text" name="robots" placeholder="请正确填写robots内容" class="layui-textarea" style="height: 500px;">{$robots}</textarea> <textarea type="text" name="robots" placeholder="请正确填写robots内容" class="layui-textarea" style="height: 400px;">{$robots}</textarea>
<div class="layui-form-mid layui-word-aux">会自动写入sitemap的链接</div> <div class="layui-form-mid layui-word-aux">会自动写入sitemap的链接</div>
</div> </div>
</div> </div>
@ -115,6 +122,47 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="layui-tab-item">
<div class="layui-form" wid100 lay-filter="push_js">
<div class="layui-form-item">
<label class="layui-form-label">名称</label>
<div class="layui-input-inline">
<input type="text" name="name" required placeholder="请正确填写js平台名称" class="layui-input">
</div>
<div class="layui-form-mid layui-word-aux">js自动收录平台</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">JS代码</label>
<div class="layui-input-block">
<textarea type="text" name="jscode" required placeholder="请正确填写robots内容" class="layui-textarea" style="height: 200px;"></textarea>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn layui-btn-danger" lay-submit lay-filter="push_jscode_submit">新增</button>
</div>
</div>
</div>
{volist name="jscode" id="vo"}
<hr>
<div class="layui-form" wid100>
<div class="layui-form-item">
<label class="layui-form-label">{$vo.name}</label>
<div class="layui-input-block">
<textarea type="text" name="jscode" placeholder="请正确填写robots内容" class="layui-textarea" style="height: 200px;">{$vo.jscode}</textarea>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<input type="text" name="id" class="layui-hide" value="{$vo.id}">
<button class="layui-btn layui-btn-sm" lay-submit lay-filter="push_jscode_del">删除</button>
</div>
</div>
</div>
{/volist}
</div> </div>
</div> </div>
@ -145,10 +193,11 @@
var field = data.field; var field = data.field;
$.post("{:url('seo/push')}",field,function(res){ $.post("{:url('seo/push')}",field,function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
}); location.reload();
});
} else { } else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"推送失败",content:res.msg,icon:5,anim:6});
} }
}); });
return false; return false;
@ -159,10 +208,11 @@
var field = data.field; var field = data.field;
$.post("{:url('seo/config')}",field,function(res){ $.post("{:url('seo/config')}",field,function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
location.reload();
}); });
} else { } else {
layer.open({title:"置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"置失败",content:res.msg,icon:5,anim:6});
} }
}); });
return false; return false;
@ -173,21 +223,23 @@
var field = data.field; var field = data.field;
$.post("{:url('seo/map')}",field,function(res){ $.post("{:url('seo/map')}",field,function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
location.reload();
}); });
} else { } else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"生成失败",content:res.msg,icon:5,anim:6});
} }
}); });
return false; return false;
}); });
// map // robots
form.on('submit(robots_submit)', function(data){ form.on('submit(robots_submit)', function(data){
var field = data.field; var field = data.field;
$.post("{:url('seo/robots')}",field,function(res){ $.post("{:url('seo/robots')}",field,function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
location.reload();
}); });
} else { } else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"设置失败",content:res.msg,icon:5,anim:6});
@ -196,12 +248,40 @@
return false; return false;
}); });
// 添加自动提交JS代码
form.on('submit(push_jscode_submit)', function(data){
var field = data.field;
$.post("{:url('seo/savePushJs')}",field,function(res){
if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000},function(){
location.reload();
});
} else {
layer.open({title:"添加失败",content:res.msg,icon:5,anim:6});
}
});
return false;
});
//显示当前tab // 删除自动提交JS代码
form.on('submit(push_jscode_del)', function(data){
var field = data.field;
$.post("{:url('seo/delPushJs')}",field,function(res){
if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000},function(){
location.reload();
});
} else {
layer.open({title:"删除失败",content:res.msg,icon:5,anim:6});
}
});
return false;
});
// 显示当前tab
if(location.hash){ if(location.hash){
element.tabChange('seo-tabs-brief', location.hash.replace(/^#/, '')); element.tabChange('seo-tabs-brief', location.hash.replace(/^#/, ''));
} }
element.on('tab(seo-tabs-brief)', function(){ element.on('tab(seo-tabs-brief)', function(){
var othis = $(this), layid = othis.attr('lay-id'); var othis = $(this), layid = othis.attr('lay-id');
if(layid){ if(layid){

View File

@ -13,6 +13,7 @@
<li lay-id="email">邮箱服务</li> <li lay-id="email">邮箱服务</li>
<li lay-id="config">服务配置</li> <li lay-id="config">服务配置</li>
<li lay-id="domain">域名绑定</li> <li lay-id="domain">域名绑定</li>
<li lay-id="bind_map">应用映射</li>
<li lay-id="url_rewrite">URL美化</li> <li lay-id="url_rewrite">URL美化</li>
</ul> </ul>
<div class="layui-tab-content"> <div class="layui-tab-content">
@ -276,14 +277,14 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">Index前端</label> <label class="layui-form-label">Index前端</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" name="index" {if(!empty(config('app.domain_bind'))) } value="{$index}" {/if} class="layui-input"> <input type="text" name="index" value="{$index}" class="layui-input">
</div> </div>
<div class="layui-form-mid layui-word-aux">www.aieok.com</div> <div class="layui-form-mid layui-word-aux">www.aieok.com</div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">Admin后端</label> <label class="layui-form-label">Admin后端</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" name="admin" {if(!empty(config('app.domain_bind'))) } value="{$admin}" {/if} class="layui-input"> <input type="text" name="admin" value="{$admin}" class="layui-input">
</div> </div>
<div class="layui-form-mid layui-word-aux">admin.aieok.com</div> <div class="layui-form-mid layui-word-aux">admin.aieok.com</div>
</div> </div>
@ -298,20 +299,43 @@
</div> </div>
</div> </div>
</div> </div>
<div class="layui-tab-item">
<div class="layui-form" wid100 lay-filter="bind_map">
<div class="layui-form-item">
<label class="layui-form-label">Index应用</label>
<div class="layui-input-inline">
<input type="text" name="index_map" required value="{$index_map}" class="layui-input">
</div>
<div class="layui-form-mid layui-word-aux">改变后原路径访问无效</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">Admin应用</label>
<div class="layui-input-inline">
<input type="text" name="admin_map" required value="{$admin_map}" class="layui-input">
</div>
<div class="layui-form-mid layui-word-aux">设置后需要使用新路径</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="set_bind_map">确认保存</button>
</div>
</div>
</div>
</div>
<div class="layui-tab-item"> <div class="layui-tab-item">
<div class="layui-form" wid100 lay-filter="url_rewrite"> <div class="layui-form" wid100 lay-filter="url_rewrite">
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">帖子别名</label> <label class="layui-form-label">帖子别名</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" name="article_as" required value="{:config('taoler.url_rewrite.article_as')}" class="layui-input"> <input type="text" name="article_as" required value="{$url_re['article_as']}" class="layui-input">
</div> </div>
<div id="artdesc" class="layui-form-mid layui-word-aux">www.aieok.com/article/1.html</div> <div id="artdesc" class="layui-form-mid layui-word-aux">www.aieok.com/article/1.html</div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">分类别名</label> <label class="layui-form-label">分类别名</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" name="cate_as" required value="{:config('taoler.url_rewrite.cate_as')}" class="layui-input"> <input type="text" name="cate_as" required value="{$url_re['cate_as']}" class="layui-input">
</div> </div>
<div id="catedesc" class="layui-form-mid layui-word-aux">www.aieok.com/cate/ask.html</div> <div id="catedesc" class="layui-form-mid layui-word-aux">www.aieok.com/cate/ask.html</div>
</div> </div>
@ -333,20 +357,20 @@
</div> </div>
{/block} {/block}
{block name="js"} {block name="js"}
<script> <script>
var setWebSite ="{:url('Set/website')}"; var setWebSite ="{:url('Set/website')}";
var setEmail ="{:url('Set/email')}"; var setEmail ="{:url('Set/email')}";
layui.config({ layui.config({
base: '/static/admin/' //静态资源所在路径 base: '/static/admin/' //静态资源所在路径
}).extend({ }).extend({
index: 'lib/index' //主入口模块 index: 'lib/index' //主入口模块
}).use(['index', 'set', 'upload'], function(){ }).use(['index', 'set', 'upload'], function(){
var $ = layui.$ var $ = layui.$
,form = layui.form ,form = layui.form
,upload = layui.upload; ,upload = layui.upload;
var element =layui.element ; var element =layui.element ;
//LOGO选完文件后不自动上传 //LOGO选完文件后不自动上传
upload.render({ upload.render({
elem: '#logo-img' elem: '#logo-img'
,url: "{:url('set/upload')}" ,url: "{:url('set/upload')}"
@ -358,8 +382,7 @@
,bindAction: '#logo-upload-button' ,bindAction: '#logo-upload-button'
,done: function(res){ ,done: function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
},function(){
location.reload(); location.reload();
}); });
} else { } else {
@ -367,116 +390,132 @@
} }
} }
}); });
//网站配置 //网站配置
form.on('submit(set_system_config)', function(data){ form.on('submit(set_system_config)', function(data){
var field = data.field; var field = data.field;
$.post("{:url('set/config')}",field,function(res){ $.post("{:url('set/config')}",field,function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
location.reload();
}); });
} else { } else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"设置失败",content:res.msg,icon:5,anim:6});
} }
}); });
return false; return false;
}); });
//邮箱发送测试码 //邮箱发送测试码
form.on('submit(test_system_email)', function(data){ form.on('submit(test_system_email)', function(data){
var field = data.field; var field = data.field;
$.post("{:url('set/sendMailCode')}",field,function(res){ $.post("{:url('set/sendMailCode')}",field,function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
location.reload();
}); });
} else { } else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"设置失败",content:res.msg,icon:5,anim:6});
} }
}); });
return false; return false;
}); });
//邮箱激活 //邮箱激活
form.on('submit(active_system_email)', function(data){ form.on('submit(active_system_email)', function(data){
var field = data.field; var field = data.field;
$.post("{:url('set/activeMailServer')}",field,function(res){ $.post("{:url('set/activeMailServer')}",field,function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
location.reload();
}); });
} else { } else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"设置失败",content:res.msg,icon:5,anim:6});
} }
}); });
return false; return false;
}); });
//网站配置 //网站配置
form.on('submit(set_system_domain)', function(data){ form.on('submit(set_system_domain)', function(data){
var field = data.field; var field = data.field;
$.post("{:url('set/setDomain')}",field,function(res){ $.post("{:url('set/setDomain')}",field,function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
}, function(){ location.reload();
parent.location.href = '/'; });
});
} else { } else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"设置失败",content:res.msg,icon:5,anim:6});
} }
}); });
return false; return false;
}); });
// URL美化 // URL美化
form.on('submit(set_url_rewrite)', function(data){ form.on('submit(set_url_rewrite)', function(data){
var field = data.field; var field = data.field;
$.post("{:url('set/setUrl')}",field,function(res){ $.post("{:url('set/setUrl')}",field,function(res){
if(res.code == 0){ if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000 layer.msg(res.msg,{icon:6,tiye:2000},function(){
}, function(){ location.reload();
//parent.location.href = '/'; });
});
} else { } else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"设置失败",content:res.msg,icon:5,anim:6});
} }
}); });
return false; return false;
}); });
// 获取描述的内容 // 获取描述的内容
$("input[name='article_as']").bind('input propertychange', function(){ $("input[name='article_as']").bind('input propertychange', function(){
var content = $(this).val() var content = $(this).val()
$('#artdesc').html('如www.aieok.com/'+ content +'/1.html'); $('#artdesc').html('如www.aieok.com/'+ content +'/1.html');
}) })
$("input[name='cate_as']").bind('input propertychange', function(){ $("input[name='cate_as']").bind('input propertychange', function(){
var content = $(this).val() var content = $(this).val()
$('#catedesc').html('如www.aieok.com/'+ content +'/ask.html'); $('#catedesc').html('如www.aieok.com/'+ content +'/ask.html');
}) })
// 域名绑定
form.on('switch(domain_check)', function(data){
var data = data.elem;
status = data.checked ? 'on' : 'off';
if(status == 'on'){
$('#set_domain').removeClass('layui-hide');
} else {
$('#set_domain').addClass('layui-hide');
$.post("{:url('set/setDomain')}",{"domain_check":status},function(res){
if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000},function(){
location.reload();
});
} else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6});
}
});
}
return false;
});
form.on('switch(domain_check)', function(data){ // 应用映射
var data = data.elem; form.on('submit(set_bind_map)', function(data){
status = data.checked ? 'on' : 'off'; var field = data.field;
if(status == 'on'){ $.post("{:url('set/bindMap')}",field,function(res){
$('#set_domain').removeClass('layui-hide'); if(res.code == 0){
} else { layer.msg(res.msg,{icon:6,tiye:2000},function(){
$('#set_domain').addClass('layui-hide'); window.location.reload();
$.post("{:url('set/setDomain')}",{"domain_check":status},function(res){ });
if(res.code == 0){
layer.msg(res.msg,{icon:6,tiye:2000
}, function(){
parent.location.href = '/';
});
} else { } else {
layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); layer.open({title:"设置失败",content:res.msg,icon:5,anim:6});
} }
}); });
} return false;
return false; });
});
//显示当前tab //显示当前tab
if(location.hash){ if(location.hash){
element.tabChange('website-tabs-brief', location.hash.replace(/^#/, '')); element.tabChange('website-tabs-brief', location.hash.replace(/^#/, ''));
} }
element.on('tab(website-tabs-brief)', function(){ element.on('tab(website-tabs-brief)', function(){
var othis = $(this), layid = othis.attr('lay-id'); var othis = $(this), layid = othis.attr('lay-id');
if(layid){ if(layid){

View File

@ -137,5 +137,48 @@ class AdminController extends \app\BaseController
return $runTime; return $runTime;
} }
/**
* 获取文章链接地址
*
* @param integer $aid
* @return string
*/
protected function getRouteUrl(int $aid) : string
{
$indexUrl = $this->getIndexUrl();
$artUrl = (string) url('detail_id', ['id' => $aid]);
// 判断是否开启绑定
//$domain_bind = array_key_exists('domain_bind',config('app'));
// 判断index应用是否绑定域名
$bind_index = array_search('index',config('app.domain_bind'));
// 判断admin应用是否绑定域名
$bind_admin = array_search('admin',config('app.domain_bind'));
// 判断index应用是否域名映射
$map_index = array_search('index',config('app.app_map'));
// 判断admin应用是否域名映射
$map_admin = array_search('admin',config('app.app_map'));
$index = $map_index ? $map_index : 'index'; // index应用名
$admin = $map_admin ? $map_admin : 'admin'; // admin应用名
if($bind_index) {
// index绑定域名
$url = $indexUrl . str_replace($admin.'/','',$artUrl);
} else { // index未绑定域名
// admin绑定域名
if($bind_admin) {
$url = $indexUrl .'/' . $index . $artUrl;
} else {
$url = $indexUrl . str_replace($admin,$index,$artUrl);
}
}
return $url;
}
} }

View File

@ -1,101 +1,64 @@
<?php <?php
/* /**
* @Author: TaoLer <alipey_tao@qq.com> * PHP配置文件的新增、编辑、删除
* @Date: 2022-04-10 14:13:41 * 正则字符串内容进行替换
* @LastEditTime: 2022-04-16 11:30:02 * 支持三级数组
* @LastEditors: TaoLer * 数组内数值索引元素在前,关联子数组在后
* @Description: 搜索引擎SEO优化设置 * @author Taoser changlin_zhao@qq.com
* @FilePath: \TaoLer\app\common\lib\SetArr.php * 2022
* Copyright (c) 2020~2022 http://www.aieok.com All rights reserved.
*/ */
namespace app\common\lib; namespace app\common\lib;
class SetArr class SetArr
{ {
protected static string $str = ''; /**
protected static string $configName = ''; * 数组字符串
protected static string $configFile = ''; *
* @var string
*/
protected string $str = '';
function __construct(string $configName) function __construct(string $configName)
{ {
self::$configName = $configName; /*
self::$configFile = app()->getConfigPath() . $configName . '.php'; // 自动识别是插件配置还是项目配置
self::$str = file_get_contents(self::$configFile); //加载配置文件 if(stripos()(__DIR__, 'vendor')){
// confing/plugin插件配置路径
$namespace = strtolower(__NAMESPACE__);
$path = config_path() . '/plugin/'.$namespace.'/'.$configName.'.php';
} else {
//config/*.php配置路径
$path= config_path() . '/' . $configName. ".php";
}
*/
// 配置文件名称
$this->configName = $configName;
// 文件路径
$this->configFile = str_replace('\\', '/', app()->getConfigPath() . $configName . '.php');
//加载配置文件
$this->str = file_get_contents($this->configFile);
} }
/**
* 修改配置
* @param string $file
* @param array $data
* @return \think\response\Json
*/
function setConfig(string $file,array $data=[])
{
if (is_array($data)){
$fileurl = app()->getConfigPath() . $file.".php";
$string = file_get_contents($fileurl); //加载配置文件
foreach ($data as $key => $value) {
if(is_array($value)){//二维数组
foreach ($value as $k => $v) {
if(is_int($v)){//数字类型
$pats = '/\'' . $k . '\'(.*?),/';
$reps = "'". $k. "'". " => " . $v .",";
//halt($reps);
}else{//字符类型
$pats = '/\'' . $k . '\'(.*?)\',/';
$reps = "'". $k. "'". " => " . "'".$v ."',";
}
$string = preg_replace($pats, $reps, $string); // 正则查找然后替换
}
}else{//一维数组
if(is_int($value)){//数字类型
$pats = '/\'' . $key . '\'(.*?),/';
$reps = "'". $key. "'". " => " . "".$value .",";
}else{//字符类型
$pats = '/\'' . $key . '\'(.*?)\',/';
$reps = "'". $key. "'". " => " . "'".$value ."',";
}
$string = preg_replace($pats, $reps, $string); // 正则查找然后替换
}
}
try {
file_put_contents($fileurl, $string); // 写入配置文件
}
catch (\Exception $e) {
// 这是进行异常捕获
//$e->getMessage();
return json(['code'=>-1,'msg'=> $file . '无写入权限']);
}
return json(['code'=>0,'msg'=>'配置修改成功']);
}else{
return json(['code'=>-1,'msg'=>'配置项错误!']);
}
}
/** /**
* 新增配置项,支持三级数组配置 * 新增配置项,支持三级数组配置
* *
* @param array $arr * @param array $arr
* @return boolean * @return $this
*/ */
public static function add(array $arr) :bool public function add(array $arr)
{ {
//dump(self::$str); //dump($this->str);
//正则];数组结尾 //正则];数组结尾
$end = '/\];/'; $end = '/\];/';
//一级配置内容追加到return [一级配置,之后 //一级配置内容追加到return [一级配置,之后
$start = self::getArrSonCount(config(self::$configName)) ? '/return\s*\[[^\[|\]]*,\r?\n/' : '/return\s*\[\r?\n?/'; $start = $this->getArrSonCount(config($this->configName)) ? '/return\s*\[[^\[|\]]*,\r?\n/' : '/return\s*\[\r?\n?/';
if(is_array($arr)) { if(is_array($arr)) {
foreach ($arr as $k => $v) foreach ($arr as $k => $v)
{ {
if(!is_array($v)) { if(!is_array($v)) {
preg_match($start,self::$str,$arrstart); preg_match($start,$this->str,$arrstart);
if(is_int($k)) { if(is_int($k)) {
// 数值数组 // 数值数组
if(is_string($v)){ if(is_string($v)){
@ -114,7 +77,7 @@ class SetArr
} else { } else {
// 键值关联数组 // 键值关联数组
//判断是否存在KEY //判断是否存在KEY
if (array_key_exists($k,config(self::$configName))) { if (array_key_exists($k,config($this->configName))) {
echo $k.'不能添加已存在的配置项'; echo $k.'不能添加已存在的配置项';
return false; return false;
} }
@ -130,12 +93,12 @@ class SetArr
$reps = $arrstart[0]."\t'" . $k . "' => " . $v .",\n"; $reps = $arrstart[0]."\t'" . $k . "' => " . $v .",\n";
} }
} }
self::$str = preg_replace($start, $reps, self::$str); $this->str = preg_replace($start, $reps, $this->str);
} else { } else {
// $v是数组存在多级配置 // $v是数组存在多级配置
// $k不存在新增二级配置数组, 数组插入];之前 // $k不存在新增二级配置数组, 数组插入];之前
if (!array_key_exists($k,config(self::$configName))) { if (!array_key_exists($k,config($this->configName))) {
// 拼接数组内元素 // 拼接数组内元素
$sonArr = ''; $sonArr = '';
foreach($v as $kk => $vv) { foreach($v as $kk => $vv) {
@ -246,14 +209,14 @@ class SetArr
} }
} }
$reps = "\t'". $k. "' => [\n".$sonArr."\t],\n];"; $reps = "\t'". $k. "' => [\n".$sonArr."\t],\n];";
self::$str = preg_replace($end, $reps, self::$str); $this->str = preg_replace($end, $reps, $this->str);
} else { } else {
// $k已存在二级配置是数组需要添加二级或三数组元素 // $k已存在二级配置是数组需要添加二级或三数组元素
// 把$v的子元素追加在匹配$k => [之后 // 把$v的子元素追加在匹配$k => [之后
// //匹配$k => [ // //匹配$k => [
// $kpats = '/\''.$k.'\'\s*=>\s*\[\r?\n/'; // $kpats = '/\''.$k.'\'\s*=>\s*\[\r?\n/';
// preg_match($kpats,self::$str,$arrk); // preg_match($kpats,$this->str,$arrk);
// 新增二级配置 // 新增二级配置
// 往数组中追加子元素 // 往数组中追加子元素
@ -266,11 +229,20 @@ class SetArr
//$kpats = '/\''.$k.'\'\s*=>\s*\[[^\[]*,[^\]]/'; //$kpats = '/\''.$k.'\'\s*=>\s*\[[^\[]*,[^\]]/';
//$kpats = '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/'; //$kpats = '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/';
// 添加一维数组,数组中有元素匹配到最后一个数组,没有数组,匹配到数组开头[ // 添加一维数组,数组中有元素匹配到最后一个数组,没有数组,匹配到数组开头[
$kpats = self::getArrSonCount(config(self::$configName.'.'.$k)) ? '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$k.'\'\s*=>\s*\[\r?\n/'; // 读$k 数组
preg_match($kpats,self::$str,$arrk); $k_arr = '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*\]/';
//halt($arrk); preg_match($k_arr,$this->str,$k_arr);
//$k_arr[0]
$k_arr = preg_replace('/[\s|\'|>]/', '', $k_arr[0]);
dump($k_arr);
$k_ar = eval('$'.$k_arr);
$n = $this->getArrSonCount($k_ar);
dump($n);
$kpats = $this->getArrSonCount(config($this->configName.'.'.$k)) ? '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$k.'\'\s*=>\s*\[\r?\n/';
preg_match($kpats,$this->str,$arrk);
dump($k,$kpats,$this->str,$arrk);
if(!is_int($kk)) { if(!is_int($kk)) {
if(array_key_exists($kk,config(self::$configName.'.'.$k))) { if(array_key_exists($kk,config($this->configName.'.'.$k))) {
echo $kk.'不能添加已存在的配置项kk'; echo $kk.'不能添加已存在的配置项kk';
return false; return false;
} }
@ -301,24 +273,24 @@ class SetArr
$reps = $arrk[0]."\t\t". $vv . ",\n"; $reps = $arrk[0]."\t\t". $vv . ",\n";
} }
} }
self::$str = preg_replace($kpats, $reps, self::$str); $this->str = preg_replace($kpats, $reps, $this->str);
} else { } else {
// 2. $vv是数组 // 2. $vv是数组
// 匹配到数组内部的后面 // 匹配到数组内部的后面
$sonArrnum = self::getArrSonNum(config(self::$configName.'.'.$k)); $sonArrnum = $this->getArrSonNum(config($this->configName.'.'.$k));
if($sonArrnum > 0) { if($sonArrnum > 0) {
// 数组存在子数组,匹配到最后一个数组],\n后面 // 数组存在子数组,匹配到最后一个数组],\n后面
$kpats = '/\''.$k.'\'([^\]]*\]){'.$sonArrnum.'},\r?\n/'; $kpats = '/\''.$k.'\'([^\]]*\]){'.$sonArrnum.'},\r?\n/';
} else { } else {
// 没有子数组 // 没有子数组
//$kpats = '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/'; //$kpats = '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/';
$kpats = self::getArrSonCount(config(self::$configName.'.'.$k)) ? '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$k.'\'\s*=>\s*\[\r?\n/'; $kpats = $this->getArrSonCount(config($this->configName.'.'.$k)) ? '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$k.'\'\s*=>\s*\[\r?\n/';
} }
preg_match($kpats,self::$str,$arrk); preg_match($kpats,$this->str,$arrk);
//dump($sonArrnum,$arrk);
// a.$vv数组不存在新建数组及它的子数组$kkk // a.$vv数组不存在新建数组及它的子数组$kkk
if(!array_key_exists($kk,config(self::$configName . '.' . $k))) { if(!array_key_exists($kk,config($this->configName . '.' . $k))) {
$sonArrson = ''; $sonArrson = '';
foreach($vv as $kkk => $vvv) { foreach($vv as $kkk => $vvv) {
@ -359,7 +331,7 @@ class SetArr
$sonArrsonArr = ''; $sonArrsonArr = '';
foreach($vvv as $kkkk => $vvvv) { foreach($vvv as $kkkk => $vvvv) {
if(!is_int($kkkk)) { if(!is_int($kkkk)) {
if(array_key_exists($kkkk,config(self::$configName.'.'.$k.'.'.$kk.'.'.$kkk))) { if(array_key_exists($kkkk,config($this->configName.'.'.$k.'.'.$kk.'.'.$kkk))) {
echo $kkkk."已存在?"; echo $kkkk."已存在?";
return false; return false;
} }
@ -397,12 +369,12 @@ class SetArr
} }
} }
$reps = $arrk[0]."\t\t'". $kk. "' => [\n".$sonArrson."\t\t],\n"; $reps = $arrk[0]."\t\t'". $kk. "' => [\n".$sonArrson."\t\t],\n";
self::$str = preg_replace($kpats, $reps, self::$str); $this->str = preg_replace($kpats, $reps, $this->str);
} else { } else {
// b.$vv数组已存在 // b.$vv数组已存在
// 匹配包含$k $kk=>[ // 匹配包含$k $kk=>[
// $kkpats = '/\'' . $k . '\'[\s\S]*?(?:'.$kk.')\'[^\[]*\[\r?\n/'; // $kkpats = '/\'' . $k . '\'[\s\S]*?(?:'.$kk.')\'[^\[]*\[\r?\n/';
// preg_match($kkpats,self::$str,$arrkk); // preg_match($kkpats,$this->str,$arrkk);
foreach($vv as $kkk => $vvv) { foreach($vv as $kkk => $vvv) {
//halt(123,$arrkk[0]); //halt(123,$arrkk[0]);
@ -411,12 +383,12 @@ class SetArr
// 匹配包含$k $kk=>[ ***, // 匹配包含$k $kk=>[ ***,
//$kkpats = '/\'' . $k . '\'[\s\S]*?(?:'.$kk.')\'[^\[]*\[\r?\n/'; //$kkpats = '/\'' . $k . '\'[\s\S]*?(?:'.$kk.')\'[^\[]*\[\r?\n/';
//$kkpats = '/\'' . $k . '\'[\s\S]*?(?:'.$kk.')\'\s*=>\s*\[[^\[|\]]*,/'; //$kkpats = '/\'' . $k . '\'[\s\S]*?(?:'.$kk.')\'\s*=>\s*\[[^\[|\]]*,/';
$kkpats = self::getArrSonCount(config(self::$configName.'.'.$k.'.'.$kk)) ? '/\''.$kk.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$kk.'\'\s*=>\s*\[\r?\n/'; $kkpats = $this->getArrSonCount(config($this->configName.'.'.$k.'.'.$kk)) ? '/\''.$kk.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$kk.'\'\s*=>\s*\[\r?\n/';
preg_match($kkpats,self::$str,$arrkk); preg_match($kkpats,$this->str,$arrkk);
//halt($arrkk);
if(!is_int($kkk)) { if(!is_int($kkk)) {
//判断第三级key是否存在 //判断第三级key是否存在
if(array_key_exists($kkk,config(self::$configName.'.'.$k.'.'.$kk))) { if(array_key_exists($kkk,config($this->configName.'.'.$k.'.'.$kk))) {
echo $kkk.'不能添加已存在的配置项kkk'; echo $kkk.'不能添加已存在的配置项kkk';
return false; return false;
} }
@ -446,12 +418,12 @@ class SetArr
$repsk = $arrkk[0]."\t\t\t" . $vvv . ",\n"; $repsk = $arrkk[0]."\t\t\t" . $vvv . ",\n";
} }
} }
self::$str = preg_replace($kkpats,$repsk, self::$str); $this->str = preg_replace($kkpats,$repsk, $this->str);
} else { } else {
// $vvv是数组,a.数组存在b.数组不存在 // $vvv是数组,a.数组存在b.数组不存在
//a. $kkk数组存在 //a. $kkk数组存在
if(array_key_exists($kkk,config(self::$configName.'.'.$k.'.'.$kk))) { if(array_key_exists($kkk,config($this->configName.'.'.$k.'.'.$kk))) {
//匹配包含$k $kk $kkk 到]的内容 //匹配包含$k $kk $kkk 到]的内容
//$sonPats = '/\'' . $k . '\'[\s\S]*?(?:'.$kk.')\'[\s\S]*?(?:'.$kkk.')\' [^\]]*/'; //$sonPats = '/\'' . $k . '\'[\s\S]*?(?:'.$kk.')\'[\s\S]*?(?:'.$kkk.')\' [^\]]*/';
//[\s\S]*?(?:'.$kkk.')\'(.*),/ //[\s\S]*?(?:'.$kkk.')\'(.*),/
@ -459,14 +431,14 @@ class SetArr
// $k3pats = '/\'' . $kk k. '\'[\s\S]*?(?:'.$kkk.')\'\s*=>\s*\[\r?\n/'; // $k3pats = '/\'' . $kk k. '\'[\s\S]*?(?:'.$kkk.')\'\s*=>\s*\[\r?\n/';
// 正则到数组内的元素,不包含子数组 // 正则到数组内的元素,不包含子数组
//$k3pats = '/\'' . $kkk . '\'\s*=>\s*\[[^\[|\]]*,\r?\n/'; //$k3pats = '/\'' . $kkk . '\'\s*=>\s*\[[^\[|\]]*,\r?\n/';
$k3pats = self::getArrSonCount(config(self::$configName.'.'.$k.'.'.$kk.'.'.$kkk)) ? '/\''.$kkk.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$kkk.'\'\s*=>\s*\[\r?\n/'; $k3pats = $this->getArrSonCount(config($this->configName.'.'.$k.'.'.$kk.'.'.$kkk)) ? '/\''.$kkk.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$kkk.'\'\s*=>\s*\[\r?\n/';
preg_match($k3pats,self::$str,$arrk3); preg_match($k3pats,$this->str,$arrk3);
//halt($arrk3);
foreach($vvv as $kkkk => $vvvv) { foreach($vvv as $kkkk => $vvvv) {
preg_match($k3pats,self::$str,$arrk3); preg_match($k3pats,$this->str,$arrk3);
if(!is_int($kkkk)) { if(!is_int($kkkk)) {
// 多维数组 // 多维数组
if(array_key_exists($kkkk,config(self::$configName.'.'.$k.'.'.$kk.'.'.$kkk))) { if(array_key_exists($kkkk,config($this->configName.'.'.$k.'.'.$kk.'.'.$kkk))) {
echo $kkkk."已存在k4"; echo $kkkk."已存在k4";
return false; return false;
} }
@ -497,23 +469,23 @@ class SetArr
$sonReps = $arrk3[0]."\t\t\t\t" . $vvvv . ",\n"; $sonReps = $arrk3[0]."\t\t\t\t" . $vvvv . ",\n";
} }
} }
self::$str = preg_replace($k3pats,$sonReps, self::$str); $this->str = preg_replace($k3pats,$sonReps, $this->str);
} }
} else { } else {
// b. $kkk不存在 // b. $kkk不存在
// 匹配到数组内部的后面k // 匹配到数组内部的后面k
$sonArrnum = self::getArrSonNum(config(self::$configName.'.'.$k.'.'.$kk)); $sonArrnum = $this->getArrSonNum(config($this->configName.'.'.$k.'.'.$kk));
if($sonArrnum > 0) { if($sonArrnum > 0) {
// 数组存在子数组,匹配到最后一个数组],\n后面 // 数组存在子数组,匹配到最后一个数组],\n后面
$kkpats = '/\''.$kk.'\'([^\]]*\]){'.$sonArrnum.'},\r?\n/'; $kkpats = '/\''.$kk.'\'([^\]]*\]){'.$sonArrnum.'},\r?\n/';
} else { } else {
// 没有子数组k // 没有子数组k
//$kkpats = '/\''.$kk.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/'; //$kkpats = '/\''.$kk.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/';
$kkpats = self::getArrSonCount(config(self::$configName.'.'.$k.'.'.$kk)) ? '/\''.$kk.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$kk.'\'\s*=>\s*\[\r?\n/'; $kkpats = $this->getArrSonCount(config($this->configName.'.'.$k.'.'.$kk)) ? '/\''.$kk.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$kk.'\'\s*=>\s*\[\r?\n/';
} }
preg_match($kkpats,self::$str,$arrkk); preg_match($kkpats,$this->str,$arrkk);
//halt($arrkk);
$sonArrsonArr = ''; $sonArrsonArr = '';
foreach($vvv as $kkkk => $vvvv) { foreach($vvv as $kkkk => $vvvv) {
if(is_array($vvvv)) { if(is_array($vvvv)) {
@ -549,7 +521,7 @@ class SetArr
} }
} }
$reps = $arrkk[0]."\t\t\t'".$kkk."' => [\n" . $sonArrsonArr . "\t\t\t],\n"; $reps = $arrkk[0]."\t\t\t'".$kkk."' => [\n" . $sonArrsonArr . "\t\t\t],\n";
self::$str = preg_replace($kkpats,$reps, self::$str); $this->str = preg_replace($kkpats,$reps, $this->str);
} }
} }
} }
@ -560,7 +532,9 @@ class SetArr
} }
} }
//写入配置 //写入配置
return file_put_contents(self::$configFile, self::$str) ? true : false; //return file_put_contents($this->configFile, $this->str) ? true : false;
return $this;
} }
} }
@ -570,9 +544,9 @@ class SetArr
* 仅支持键值对的数组修改 * 仅支持键值对的数组修改
* *
* @param array $arr * @param array $arr
* @return boolean * @return $this
*/ */
public static function edit($arr) :bool public function edit($arr)
{ {
// 只能修改有键值对的数组 // 只能修改有键值对的数组
@ -580,14 +554,14 @@ class SetArr
foreach($arr as $k => $v) { foreach($arr as $k => $v) {
// key不存在 // key不存在
if(!array_key_exists($k,config(self::$configName))) { if(!array_key_exists($k,config($this->configName))) {
echo $k.'不存在 '; echo $k.'不存在 ';
return false; return false;
} }
// 一级数组修改 // 一级数组修改
if(!is_array($v)) { if(!is_array($v)) {
$pats ='/return\s*\[[^\[|\]]*,\r?\n/'; $pats ='/return\s*\[[^\[|\]]*,\r?\n/';
preg_match($pats,self::$str,$arr); preg_match($pats,$this->str,$arr);
//halt($arr); //halt($arr);
if(is_string($v)){ if(is_string($v)){
// 字符串 // 字符串
@ -606,13 +580,13 @@ class SetArr
$patk = '/\'' . $k . '\'(.*),/'; $patk = '/\'' . $k . '\'(.*),/';
$reps = preg_replace($patk, $repk, $arr[0]); $reps = preg_replace($patk, $repk, $arr[0]);
// 正则查找然后替换 // 正则查找然后替换
self::$str = preg_replace($pats, $reps, self::$str); $this->str = preg_replace($pats, $reps, $this->str);
} else { } else {
// 正则二级配置 // 正则二级配置
$pats = '/\'' . $k . '\'\s*=>\s*\[[^\[|\]]*,/'; $pats = '/\'' . $k . '\'\s*=>\s*\[[^\[|\]]*,/';
// 二级和三级 // 二级和三级
foreach($v as $kk => $vv) { foreach($v as $kk => $vv) {
if(!array_key_exists($kk, config(self::$configName.'.'.$k))) { if(!array_key_exists($kk, config($this->configName.'.'.$k))) {
echo $kk.'不存在'; echo $kk.'不存在';
return false; return false;
} }
@ -633,18 +607,18 @@ class SetArr
// 数字 // 数字
$repkk = "'". $kk . "' => " . $vv .","; $repkk = "'". $kk . "' => " . $vv .",";
} }
preg_match($pats,self::$str,$arrk); preg_match($pats,$this->str,$arrk);
// 正则需要替换的部分 // 正则需要替换的部分
$patkk = '/\'' . $kk . '\'(.*?),/'; $patkk = '/\'' . $kk . '\'(.*?),/';
$reps = preg_replace($patkk, $repkk, $arrk[0]); $reps = preg_replace($patkk, $repkk, $arrk[0]);
self::$str = preg_replace($pats, $reps, self::$str); $this->str = preg_replace($pats, $reps, $this->str);
} else { } else {
// 三级配置 // 三级配置
// 正则二级下的三级配置 // 正则二级下的三级配置
//$pats = '/\'' . $kkk . '\'[\s\S]*?(?:'.$kkk.')\'(.*),/'; //$pats = '/\'' . $kkk . '\'[\s\S]*?(?:'.$kkk.')\'(.*),/';
$pats = '/\'' . $kk . '\'\s*=>\s*\[[^\[|\]]*,/'; $pats = '/\'' . $kk . '\'\s*=>\s*\[[^\[|\]]*,/';
foreach($vv as $kkk => $vvv) { foreach($vv as $kkk => $vvv) {
if(!array_key_exists($kkk, config(self::$configName.'.'.$k.'.'.$kk))) { if(!array_key_exists($kkk, config($this->configName.'.'.$k.'.'.$kk))) {
echo $kkk.'不存在'; echo $kkk.'不存在';
return false; return false;
} }
@ -662,18 +636,18 @@ class SetArr
} else { } else {
$arrReps = "'" . $kkk . "' => " . $vvv . ","; $arrReps = "'" . $kkk . "' => " . $vvv . ",";
} }
preg_match($pats,self::$str,$arrkk); preg_match($pats,$this->str,$arrkk);
// 正则需要替换的部分 // 正则需要替换的部分
$arrPats = '/\'' . $kkk . '\'(.*),/'; $arrPats = '/\'' . $kkk . '\'(.*),/';
$reps = preg_replace($arrPats, $arrReps, $arrkk[0]); $reps = preg_replace($arrPats, $arrReps, $arrkk[0]);
self::$str = preg_replace($pats, $reps, self::$str); $this->str = preg_replace($pats, $reps, $this->str);
} else { } else {
// 四级配置 // 四级配置
// 正则$kkk // 正则$kkk
//$pats = '/\'' . $kk . '\'[\s\S]*?(?:'.$kkk.')\'[\s\S]*?(?:'.$kkkk.')\'(.*),/'; //$pats = '/\'' . $kk . '\'[\s\S]*?(?:'.$kkk.')\'[\s\S]*?(?:'.$kkkk.')\'(.*),/';
$pats = '/\'' . $kkk . '\'\s*=>\s*\[[^\[|\]]*,/'; $pats = '/\'' . $kkk . '\'\s*=>\s*\[[^\[|\]]*,/';
foreach($vvv as $kkkk => $vvvv) { foreach($vvv as $kkkk => $vvvv) {
if(!array_key_exists($kkkk, config(self::$configName.'.'.$k.'.'.$kk.'.'.$kkk))){ if(!array_key_exists($kkkk, config($this->configName.'.'.$k.'.'.$kk.'.'.$kkk))){
echo $kkk.'不存在'; echo $kkk.'不存在';
return false; return false;
} }
@ -690,10 +664,10 @@ class SetArr
} else { } else {
$repskkkk = "'" . $kkkk . "' => " . $vvvv . ","; $repskkkk = "'" . $kkkk . "' => " . $vvvv . ",";
} }
preg_match($pats,self::$str,$arrkkk); preg_match($pats,$this->str,$arrkkk);
$patskkkk = '/\'' . $kkkk . '\'(.*),/'; $patskkkk = '/\'' . $kkkk . '\'(.*),/';
$reps = preg_replace($patskkkk, $repskkkk, $arrkkk[0]); $reps = preg_replace($patskkkk, $repskkkk, $arrkkk[0]);
self::$str = preg_replace($pats, $reps, self::$str); $this->str = preg_replace($pats, $reps, $this->str);
} }
} }
@ -704,7 +678,8 @@ class SetArr
} }
//写入配置 //写入配置
return file_put_contents(self::$configFile, self::$str) ? true : false; //return file_put_contents($this->configFile, $this->str) ? true : false;
return $this;
} }
/** /**
@ -713,9 +688,9 @@ class SetArr
* 子元素被删除会清理空数组 * 子元素被删除会清理空数组
* *
* @param array $arr * @param array $arr
* @return boolean * @return $this
*/ */
public static function delete($arr) :bool public function delete($arr)
{ {
// 只能修改有键值对的数组 // 只能修改有键值对的数组
if(!is_array($arr)) return false; if(!is_array($arr)) return false;
@ -725,17 +700,17 @@ class SetArr
if(!is_array($v)) { if(!is_array($v)) {
// 正则开头到,不包含子数组 // 正则开头到,不包含子数组
$pats ='/return\s*\[[^\[|\]]*,\r?\n/'; $pats ='/return\s*\[[^\[|\]]*,\r?\n/';
preg_match($pats,self::$str,$arr); preg_match($pats,$this->str,$arr);
if(!isset($arr[0])) { if(!isset($arr[0])) {
echo '有误,删除项可能并不存在'; echo '有误,删除项可能并不存在';
return false; return false;
} }
if(is_int($k)) { if(is_int($k)) {
// 一维数组正则 // 一维数组正则
$patk = self::getPats($v); $patk = $this->getPats($v);
} else { } else {
// key不存在 // key不存在
if(!array_key_exists($k,config(self::$configName))) { if(!array_key_exists($k,config($this->configName))) {
echo $k.'不存在 '; echo $k.'不存在 ';
return false; return false;
} }
@ -744,7 +719,7 @@ class SetArr
// 正则查找然后替换 // 正则查找然后替换
$reps = preg_replace($patk, '', $arr[0]); $reps = preg_replace($patk, '', $arr[0]);
self::$str = preg_replace($pats, $reps, self::$str); $this->str = preg_replace($pats, $reps, $this->str);
} else { } else {
// 二级和三级 // 二级和三级
@ -753,16 +728,16 @@ class SetArr
if(!is_array($vv)) { if(!is_array($vv)) {
// 正则二级配置 // 正则二级配置
$pats = '/\'' . $k . '\'\s*=>\s*\[[^\[|\]]*,\r?\n/'; $pats = '/\'' . $k . '\'\s*=>\s*\[[^\[|\]]*,\r?\n/';
preg_match($pats,self::$str,$arrk); preg_match($pats,$this->str,$arrk);
if(!isset($arrk[0])) { if(!isset($arrk[0])) {
echo $k.'有误,可能并不存在'; echo $k.'有误,可能并不存在';
return false; return false;
} }
if(is_int($kk)) { if(is_int($kk)) {
$patkk = self::getPats($vv); $patkk = $this->getPats($vv);
} else { } else {
// key不存在 // key不存在
if(!array_key_exists($kk,config(self::$configName.'.'.$k))) { if(!array_key_exists($kk,config($this->configName.'.'.$k))) {
echo $kk.'不存在 '; echo $kk.'不存在 ';
return false; return false;
} }
@ -770,7 +745,7 @@ class SetArr
$patkk = '/[^\n]*\'' . $kk . '\'(.*?),\r?\n/'; $patkk = '/[^\n]*\'' . $kk . '\'(.*?),\r?\n/';
} }
$reps = preg_replace($patkk, '', $arrk[0]); $reps = preg_replace($patkk, '', $arrk[0]);
self::$str = preg_replace($pats, $reps, self::$str); $this->str = preg_replace($pats, $reps, $this->str);
} else { } else {
// 三级配置 // 三级配置
@ -778,15 +753,15 @@ class SetArr
if(!is_array($vvv)) { if(!is_array($vvv)) {
// 正则二级下的三级配置 // 正则二级下的三级配置
$pats = '/\'' . $kk . '\'\s*=>\s*\[[^\[|\]]*,\r?\n/'; $pats = '/\'' . $kk . '\'\s*=>\s*\[[^\[|\]]*,\r?\n/';
preg_match($pats,self::$str,$arrkk); preg_match($pats,$this->str,$arrkk);
if(!isset($arrkkk[0])) { if(!isset($arrkkk[0])) {
echo $kk.'有误,可能并不存在'; echo $kk.'有误,可能并不存在';
return false; return false;
} }
if(is_int($kkk)) { if(is_int($kkk)) {
$patkkk = self::getPats($vvv); $patkkk = $this->getPats($vvv);
} else { } else {
if(!array_key_exists($kkk, config(self::$configName.'.'.$k.'.'.$kk))) { if(!array_key_exists($kkk, config($this->configName.'.'.$k.'.'.$kk))) {
echo $kkk.'不存在'; echo $kkk.'不存在';
return false; return false;
} }
@ -795,7 +770,7 @@ class SetArr
// 正则需要替换的部分 // 正则需要替换的部分
$reps = preg_replace($patkkk, '', $arrkk[0]); $reps = preg_replace($patkkk, '', $arrkk[0]);
self::$str = preg_replace($pats, $reps, self::$str); $this->str = preg_replace($pats, $reps, $this->str);
} else { } else {
// 四级配置 // 四级配置
@ -803,15 +778,15 @@ class SetArr
if(!is_array($vvvv)) { if(!is_array($vvvv)) {
// 正则$kkk // 正则$kkk
$pats = '/\'' . $kkk . '\'\s*=>\s*\[[^\[|\]]*,\r?\n/'; $pats = '/\'' . $kkk . '\'\s*=>\s*\[[^\[|\]]*,\r?\n/';
preg_match($pats,self::$str,$arrkkk); preg_match($pats,$this->str,$arrkkk);
if(!isset($arrkkk[0])) { if(!isset($arrkkk[0])) {
echo $kkk.'有误,可能并不存在'; echo $kkk.'有误,可能并不存在';
return false; return false;
} }
if(is_int($kkkk)) { if(is_int($kkkk)) {
$patskkkk = self::getPats($vvvv); $patskkkk = $this->getPats($vvvv);
} else { } else {
if(!array_key_exists($kkkk, config(self::$configName.'.'.$k.'.'.$kk.'.'.$kkk))){ if(!array_key_exists($kkkk, config($this->configName.'.'.$k.'.'.$kk.'.'.$kkk))){
echo $kkkk.'不存在'; echo $kkkk.'不存在';
return false; return false;
} }
@ -819,7 +794,7 @@ class SetArr
} }
$reps = preg_replace($patskkkk, '', $arrkkk[0]); $reps = preg_replace($patskkkk, '', $arrkkk[0]);
self::$str = preg_replace($pats, $reps, self::$str); $this->str = preg_replace($pats, $reps, $this->str);
} else { } else {
echo '不支持更多的层级数组'; echo '不支持更多的层级数组';
} }
@ -836,13 +811,19 @@ class SetArr
* 'key' => [ * 'key' => [
* ], * ],
*/ */
$nullArray = '/[^\n]*\'\w+\'\s*=>\s*\[\s*\]{1}\S*\,?\r?\n/m'; //$nullArray = '/[^\n]*\'\w+\'\s*=>\s*\[\s*\]{1}\S*\,?\r?\n/m';
//preg_match($nullArray,self::$str,$arr); //preg_match($nullArray,$this->str,$arr);
self::$str = preg_replace($nullArray, '', self::$str); //$this->str = preg_replace($nullArray, '', $this->str);
} }
//写入配置 //写入配置
return file_put_contents(self::$configFile, self::$str) ? true : false; //return file_put_contents($this->configFile, $this->str) ? true : false;
return $this;
}
public function put()
{
return file_put_contents($this->configFile, $this->str) ? true : false;
} }
/** /**
@ -851,7 +832,7 @@ class SetArr
* @param [type] $arr * @param [type] $arr
* @return integer * @return integer
*/ */
public static function getArrSonNum($arr) :int public function getArrSonNum($arr) :int
{ {
$i = 0; $i = 0;
foreach ($arr as $val) { foreach ($arr as $val) {
@ -860,7 +841,7 @@ class SetArr
foreach($val as $vv){ foreach($val as $vv){
if(is_array($vv)){ if(is_array($vv)){
$i++; $i++;
self::getArrSonNum($vv); $this->getArrSonNum($vv);
} }
} }
} }
@ -874,7 +855,7 @@ class SetArr
* @param [type] $v * @param [type] $v
* @return string * @return string
*/ */
public static function getPats($v) :string public function getPats($v) :string
{ {
if(is_bool($v)){ if(is_bool($v)){
//布尔 //布尔
@ -928,7 +909,7 @@ class SetArr
* @param array $array * @param array $array
* @return boolean * @return boolean
*/ */
public static function getArrSonCount(array $array) :bool public function getArrSonCount(array $array) :bool
{ {
// 数组元素数量 // 数组元素数量
$count = count($array); $count = count($array);

View File

@ -14,8 +14,7 @@ use think\exception\ValidateException;
use taoler\com\Message; use taoler\com\Message;
use app\common\lib\Msgres; use app\common\lib\Msgres;
use app\common\lib\Uploads; use app\common\lib\Uploads;
use app\common\lib\SetArr; use taoser\SetArr;
use taoler\com\Api;
class Article extends BaseController class Article extends BaseController
{ {
@ -94,8 +93,9 @@ class Article extends BaseController
$ad_artImg = $ad->getSliderList(4); $ad_artImg = $ad->getSliderList(4);
//分类钻展赞助 //分类钻展赞助
$ad_comm = $ad->getSliderList(7); $ad_comm = $ad->getSliderList(7);
$push_js = Db::name('push_jscode')->where(['delete_time'=>0])->cache(true)->select();
View::assign(['article'=>$artDetail,'pv'=>$pv,'artHot'=>$artHot,'ad_art'=>$ad_artImg,'ad_comm'=>$ad_comm,$download,'page'=>$page,'comments'=>$comments,'jspage'=>'jie']); View::assign(['article'=>$artDetail,'pv'=>$pv,'artHot'=>$artHot,'ad_art'=>$ad_artImg,'ad_comm'=>$ad_comm,$download,'page'=>$page,'comments'=>$comments,'jspage'=>'jie','push_js'=>$push_js]);
return View::fetch('article/'.$tpl.'/detail'); return View::fetch('article/'.$tpl.'/detail');
} }
@ -391,7 +391,7 @@ class Article extends BaseController
$post_data = substr($o,0,-1); $post_data = substr($o,0,-1);
$res = $this->request_post($url, $post_data); $res = $this->request_post($url, $post_data);
// 写入token // 写入token
(new SetArr('taoler'))::edit([ SetArr::name('taoler')->edit([
'baidu'=> [ 'baidu'=> [
'access_token' => json_decode($res)->access_token, 'access_token' => json_decode($res)->access_token,
] ]

View File

@ -3,6 +3,7 @@ namespace app\index\controller;
use app\common\controller\BaseController; use app\common\controller\BaseController;
use think\facade\Session; use think\facade\Session;
use think\facade\Cache;
use app\common\model\Comment as CommentModel; use app\common\model\Comment as CommentModel;
use app\common\model\Article; use app\common\model\Article;
use app\common\model\UserZan; use app\common\model\UserZan;
@ -22,6 +23,8 @@ class Comment extends BaseController
if($jie){ if($jie){
$res['status'] = 0; $res['status'] = 0;
} }
// 清除文章tag缓存
Cache::tag('tagArtDetail')->clear();
} }
return json($res); return json($res);
} }

View File

@ -37,10 +37,6 @@ class Login extends BaseController
} }
//获取登录前访问页面refer //获取登录前访问页面refer
$refer = Request::server('HTTP_REFERER'); $refer = Request::server('HTTP_REFERER');
//$domain = Request::domain();
//截取域名后面的字符
//$url = substr($refer,strlen($domain));
Cookie::set('url',$refer);
if(Request::isAjax()) { if(Request::isAjax()) {
//登陆前数据校验 //登陆前数据校验
@ -86,7 +82,7 @@ class Login extends BaseController
$user = new User(); $user = new User();
$res = $user->login($data); $res = $user->login($data);
if ($res == 1) { //登陆成功 if ($res == 1) { //登陆成功
return Msgres::success('login_success',Cookie::get('url')); return Msgres::success('login_success',$refer);
} else { } else {
return Msgres::error($res); return Msgres::error($res);
} }

View File

@ -2,7 +2,7 @@
/* /*
* @Author: TaoLer <alipey_tao@qq.com> * @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2021-12-06 16:04:50 * @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-04-19 13:19:28 * @LastEditTime: 2022-04-22 06:33:20
* @LastEditors: TaoLer * @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置 * @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\app\index\route\route.php * @FilePath: \TaoLer\app\index\route\route.php
@ -18,14 +18,13 @@ $cate_as = config('taoler.url_rewrite.cate_as');
Route::get('captcha/[:config]','\\think\\captcha\\CaptchaController@index'); Route::get('captcha/[:config]','\\think\\captcha\\CaptchaController@index');
Route::rule('/', 'index'); // 首页访问路由 Route::rule('/', 'index'); // 首页访问路由
Route::group(function () use($detail_as,$cate_as){ Route::group(function () use($detail_as,$cate_as){
Route::get($detail_as .'/:id', 'article/detail'); Route::get("$detail_as<id>", 'article/detail');
Route::get($cate_as.'/<ename>$','article/cate'); Route::get("$cate_as<ename>",'article/cate')->name('cate');
Route::get($cate_as.'/<ename>/<type>$', 'article/cate')->name('cate_type'); Route::get("$cate_as<ename>/<type>$", 'article/cate')->name('cate_type');
Route::rule($cate_as.'/<ename>/<type>/<page>', 'article/cate')->name('cate_page'); Route::rule("$cate_as<ename>/<type>/<page>", 'article/cate')->name('cate_page');
Route::rule('add','Article/add'); Route::rule('add','Article/add');
Route::rule('tags','Article/tags')->allowCrossDomain(); Route::rule('tags','Article/tags')->allowCrossDomain();
Route::rule('edit/[:id]','Article/edit'); Route::rule('edit/[:id]','Article/edit');
//Route::rule('del/:id','article/delete');
})->pattern([ })->pattern([
'ename' => '\w+', 'ename' => '\w+',
'type' => '\w+', 'type' => '\w+',
@ -40,7 +39,7 @@ Route::rule('login','login/index');
Route::rule('forget','login/forget'); Route::rule('forget','login/forget');
Route::rule('postcode','login/postcode'); Route::rule('postcode','login/postcode');
Route::rule('respass','login/respass'); Route::rule('respass','login/respass');
Route::rule('reg','Login/reg') Route::rule('reg$','Login/reg')
->middleware(\app\middleware\CheckRegister::class); ->middleware(\app\middleware\CheckRegister::class);
Route::rule('search/[:keywords]', 'index/search'); // 搜索 Route::rule('search/[:keywords]', 'index/search'); // 搜索

View File

@ -1,4 +1,13 @@
<?php <?php
/*
* @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-04-22 06:24:03
* @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\app\middleware\Auth.php
* Copyright (c) 2020~2022 http://www.aieok.com All rights reserved.
*/
declare(strict_types=1); declare(strict_types=1);
namespace app\middleware; namespace app\middleware;
@ -45,12 +54,12 @@ class Auth
//没有登录及当前非登录页重定向登录页 //没有登录及当前非登录页重定向登录页
if(!Session::has('admin_id') && $path !== 'admin/login/index' && !(stristr($request->pathinfo(),"captcha.html") || stristr($request->pathinfo(),"addons")) ) if(!Session::has('admin_id') && $path !== 'admin/login/index' && !(stristr($request->pathinfo(),"captcha.html") || stristr($request->pathinfo(),"addons")) )
{ {
return redirect((string) url('admin/login/index')); return redirect((string) url('login/index'));
} }
//登陆后无法访问登录页 //登陆后无法访问登录页
if(Session::has('admin_id') && $path == 'admin/login/index'){ if(Session::has('admin_id') && $path == 'admin/login/index'){
return redirect((string) url('admin/index/index')); return redirect((string) url('index/index'));
} }
// 排除公共权限 // 排除公共权限

View File

@ -2,7 +2,7 @@
/* /*
* @Author: TaoLer <alipey_tao@qq.com> * @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2021-12-06 16:04:50 * @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-04-19 16:49:29 * @LastEditTime: 2022-04-21 20:56:48
* @LastEditors: TaoLer * @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置 * @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\config\app.php * @FilePath: \TaoLer\config\app.php
@ -27,17 +27,10 @@ return [
'default_timezone' => 'Asia/Shanghai', 'default_timezone' => 'Asia/Shanghai',
// 应用映射(自动多应用模式有效) // 应用映射(自动多应用模式有效)
'app_map' => [ 'app_map' => [
//'bbs' => 'index', ],
//'*' => 'home',
//'admin1' => 'admin',
],
// 域名绑定(自动多应用模式有效) // 域名绑定(自动多应用模式有效)
'domain_bind' => [ 'domain_bind' => [
//'bbs' => 'index',
//'adm' => 'admin',
//'www'=>'home',
//'api' => 'api'
], ],
// 禁止URL访问的应用列表自动多应用模式有效 // 禁止URL访问的应用列表自动多应用模式有效

View File

@ -2,7 +2,7 @@
/* /*
* @Author: TaoLer <alipey_tao@qq.com> * @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2021-12-06 16:04:50 * @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-04-19 16:48:27 * @LastEditTime: 2022-04-22 06:57:15
* @LastEditors: TaoLer * @LastEditors: TaoLer
* @Description: 网站公共配置 * @Description: 网站公共配置
* @FilePath: \TaoLer\config\taoler.php * @FilePath: \TaoLer\config\taoler.php
@ -16,13 +16,12 @@ return [
// 应用名,此项不可更改 // 应用名,此项不可更改
'appname' => 'TaoLer', 'appname' => 'TaoLer',
// 版本配置 // 版本配置
'version' => '1.9.2', 'version' => '1.9.3',
// 加盐 // 加盐
'salt' => 'taoler', 'salt' => 'taoler',
// 数据库备份目录 // 数据库备份目录
'databasebackdir' => app()->getRootPath() .'data/', 'databasebackdir' => app()->getRootPath() .'data/',
'article_as' => 'aa',
'cate_as' => 'column',
// 配置 // 配置
'config' =>[ 'config' =>[
'email_notice' => 0, 'email_notice' => 0,
@ -38,8 +37,8 @@ return [
// 百度标签分词 // 百度标签分词
'baidu' => [ 'baidu' => [
'grant_type' => '', 'grant_type' => '',
'client_id' => 'aa', 'client_id' => '',
'client_secret' => 'aa', 'client_secret' => '',
'access_token' => '', 'access_token' => '',
'push_api' => 'http://', 'push_api' => 'http://',
], ],
@ -58,9 +57,9 @@ return [
// URL美化 // URL美化
'url_rewrite' => [ 'url_rewrite' => [
// 详情url // 详情url
'article_as' => 'article', 'article_as' => 'article/',
// 分类url // 分类url
'cate_as' => 'column', 'cate_as' => 'column/',
], ],

View File

@ -5,7 +5,7 @@
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
'reference' => '1250b449335a867caa1976e6117d3b3448b5d7bf', 'reference' => '3f2bac47e4326e46b7e195dcaf909dfef2fb4c17',
'name' => 'taoser/taoler', 'name' => 'taoser/taoler',
'dev' => true, 'dev' => true,
), ),
@ -160,7 +160,7 @@
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
'reference' => '1250b449335a867caa1976e6117d3b3448b5d7bf', 'reference' => '3f2bac47e4326e46b7e195dcaf909dfef2fb4c17',
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'taoser/think-addons' => array( 'taoser/think-addons' => array(

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2022-04-18 13:52:33 // This file is automatically generated at:2022-04-22 08:07:42
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'taoser\\addons\\Service', 0 => 'taoser\\addons\\Service',

View File

@ -2,10 +2,10 @@
/* /*
* @Author: TaoLer <alipey_tao@qq.com> * @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2022-04-14 16:05:35 * @Date: 2022-04-14 16:05:35
* @LastEditTime: 2022-04-17 07:04:31 * @LastEditTime: 2022-04-20 14:49:27
* @LastEditors: TaoLer * @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置 * @Description: 搜索引擎SEO优化设置
* @FilePath: \undefinede:\github\think-setarr\src\SetArr.php * @FilePath: \TaoLer\vendor\taoser\think-setarr\src\SetArr.php
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved. * Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
*/ */
namespace taoser; namespace taoser;
@ -219,6 +219,7 @@ class SetArr
//$kpats = '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/'; //$kpats = '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/';
// 添加一维数组,数组中有元素匹配到最后一个数组,没有数组,匹配到数组开头[ // 添加一维数组,数组中有元素匹配到最后一个数组,没有数组,匹配到数组开头[
$kpats = self::getArrSonCount(config(self::$configName.'.'.$k)) ? '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$k.'\'\s*=>\s*\[\r?\n/'; $kpats = self::getArrSonCount(config(self::$configName.'.'.$k)) ? '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$k.'\'\s*=>\s*\[\r?\n/';
preg_match($kpats,self::$str,$arrk); preg_match($kpats,self::$str,$arrk);
if(!is_int($kk)) { if(!is_int($kk)) {
@ -790,7 +791,7 @@ class SetArr
*/ */
$nullArray = '/[^\n]*\'\w+\'\s*=>\s*\[\s*\]{1}\S*\,?\r?\n/m'; $nullArray = '/[^\n]*\'\w+\'\s*=>\s*\[\s*\]{1}\S*\,?\r?\n/m';
//preg_match($nullArray,self::$str,$arr); //preg_match($nullArray,self::$str,$arr);
self::$str = preg_replace($nullArray, '', self::$str); //self::$str = preg_replace($nullArray, '', self::$str);
} }
//写入配置 //写入配置

View File

@ -416,19 +416,10 @@ $("#rdown").hover(function(){
content: "<img src='/qrcode/?text={$Request.domain}{:url('article/detail',['id' => $article.id])}&size=230'>" content: "<img src='/qrcode/?text={$Request.domain}{:url('article/detail',['id' => $article.id])}&size=230'>"
}); });
} }
//推送百度收录服务
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script> </script>
{volist name="push_js" id="vo"}
{$vo.jscode|raw}
{/volist}
{/block} {/block}

View File

@ -10,37 +10,19 @@
<div class="layui-col-md12 content detail"> <div class="layui-col-md12 content detail">
<div class="fly-panel detail-box"> <div class="fly-panel detail-box">
{//标题} {//标题}
<h1 style="color:{$article.title_color};" align="center">{$article.title}</h1> <h1 style="color:{$article.title_color}; margin:10px 5px 15px 5px;" align="center">{$article.title}</h1>
<div class="detail_qrcode layui-hide-xs" onclick="PhoneDown();" id="mobile"></div>
{//图标}
<div class="fly-detail-info">
<span id="LAY_jieAdmin" data-id="{$article['id']}"></span>
<span class="fly-list-nums">
<a href="#comment"><i class="iconfont" title="{:lang('reply')}">&#xe60c;</i>{$article.comments_count}</a><i class="iconfont" title="浏览">&#xe60b;</i>{$pv}
</span>
</div>
{//作者} {//作者}
<div class="detail-about"> <div class="detail-about" align="center">
<a class="fly-avatar" href="{:url('user/home',['id'=>$article.user.id])}"> <div class="detail-hits" style="left:-30px;">
<img src="{$article.user.user_img}" alt="{$article.user.name}"> <span>{$article.user.name} /</span>
<i class="iconfont icon-renzheng" title="认证信息"></i> <span class="post-time" style="padding-top: 5px;" data="{$article.create_time}">{$article.create_time}</span>
</a> <span>/ <i class="iconfont" title="浏览">&#xe60b;</i> {$pv}</span>
<div class="fly-detail-user">
<a href="{:url('user/home',['id'=>$article.user.id])}" class="fly-link">
{if config('taoler.config.area_show') == 1}<i class="layui-badge layui-bg-green " title="">{:getAsing($article.user.area_id) ?: '无'}</i>{/if}
<cite>{$article.user.nickname ?: $article.user.name}</cite>
</a>
<span class="layui-btn layui-btn-xs guanzhu" >关注</span>
</div>
<div class="detail-hits">
<!--span style="padding-right: 10px; color: #FF7200">悬赏60飞吻</span-->
<span class="post-time" data="{$article.create_time}" style="padding-top: 5px;"></span>
</div> </div>
</div> </div>
<hr> <hr style="margin-bottom: 25px">
{// 内容} {// 内容}
<div class="detail-body photos" id="content">{$article.content}</div> <div class="detail-body photos" style="font-size: 18px;line-height: 200%;" id="content">{$article.content}</div>
{//管理} {//管理}
{if (($article.upzip !== '') || session('?user_name'))} {if (($article.upzip !== '') || session('?user_name'))}
@ -51,13 +33,17 @@
<div class="fly-admin-box" data-id="{$article.id}"> <div class="fly-admin-box" data-id="{$article.id}">
{if ($user.auth ?? '')} {if ($user.auth ?? '')}
<span class="layui-btn layui-btn-xs jie-admin" type="del"><i class="layui-icon layui-icon-delete"></i></span> <span class="layui-btn layui-btn-xs jie-admin" type="del"><i class="layui-icon layui-icon-delete"></i></span>
{if($article.is_top == 0)}<span class="layui-btn layui-btn-xs jie-admin" type="set" field="top" rank="1"><i class="layui-icon layui-icon-top"></i></span> {if($article.is_top == 0)}
{else /}<span class="layui-btn layui-btn-xs jie-admin" type="set" field="top" rank="0" style="background-color:#ccc;">{:lang('cancel topping')}</span>{/if} <span class="layui-btn layui-btn-xs jie-admin" type="set" field="top" rank="1"><i class="layui-icon layui-icon-top"></i></span>
{if($article.is_hot == 0)} {else /}
<span class="layui-btn layui-btn-xs jie-admin" type="set" field="top" rank="0" style="background-color:#ccc;">{:lang('cancel topping')}</span>
{/if}
{if($article.is_hot == 0)}
<span class="layui-btn layui-btn-xs jie-admin" type="set" field="hot" rank="1"><i class="layui-icon layui-icon-fire"></i></span> <span class="layui-btn layui-btn-xs jie-admin" type="set" field="hot" rank="1"><i class="layui-icon layui-icon-fire"></i></span>
{else /} {else /}
<span class="layui-btn layui-btn-xs jie-admin" type="set" field="hot" rank="0" style="background-color:#ccc;">{:lang('cancel hoting')}</span> <span class="layui-btn layui-btn-xs jie-admin" type="set" field="hot" rank="0" style="background-color:#ccc;">{:lang('cancel hoting')}</span>
{/if} {/if}
{if($article.is_reply == 1)} {if($article.is_reply == 1)}
<span class="layui-btn layui-btn-xs jie-admin" type="set" field="reply" rank="0"><i class="layui-icon layui-icon-face-cry"></i></span> <span class="layui-btn layui-btn-xs jie-admin" type="set" field="reply" rank="0"><i class="layui-icon layui-icon-face-cry"></i></span>
{else /} {else /}
@ -68,7 +54,7 @@
{if(session('user_name')==$article.user.name || ($user.auth ?? ''))} {if(session('user_name')==$article.user.name || ($user.auth ?? ''))}
<span class="layui-btn layui-btn-xs jie-admin" type="edit"><a href="{:url('article/edit',['id'=>$article.id])}">{:lang('edit')}</a></span> <span class="layui-btn layui-btn-xs jie-admin" type="edit"><a href="{:url('article/edit',['id'=>$article.id])}">{:lang('edit')}</a></span>
{/if} {/if}
</div> </div>
</div> </div>
{/if} {/if}
</div> </div>
@ -192,8 +178,8 @@ layui.use(['fly', 'face','colorpicker','plyr', 'laypage'], function(){
//首次不执行 //首次不执行
if(!first){ if(!first){
var page = obj.curr; var page = obj.curr;
var url = "{:url('article/detail',['id'=>$article.id])}"; var url = "{:url('article/detail',['id'=>$article.id])}";
var id = "{$article.id}"; var id = "{$article.id}";
$.post("{:url('article/detail')}",{"id":id,"page":page},function(){ $.post("{:url('article/detail')}",{"id":id,"page":page},function(){
window.location.href = url + '?page=' + page + '#flyReply'; window.location.href = url + '?page=' + page + '#flyReply';
}); });
@ -306,18 +292,10 @@ layui.use(['fly', 'face','colorpicker','plyr', 'laypage'], function(){
}); });
} }
//推送百度收录服务 //推送百度收录服务
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script> </script>
{volist name="push_js" id="vo"}
{$vo.jscode|raw}
{/volist}
{/block} {/block}

View File

@ -391,20 +391,10 @@ layui.use(['fly', 'face','colorpicker','plyr', 'laypage'], function(){
content: "<img src='/qrcode/?text={$Request.domain}{:url('article/detail',['id' => $article.id])}&size=230'>" content: "<img src='/qrcode/?text={$Request.domain}{:url('article/detail',['id' => $article.id])}&size=230'>"
}); });
} }
//推送百度收录服务
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script> </script>
{volist name="push_js" id="vo"}
{$vo.jscode|raw}
{/volist}
{/block} {/block}

View File

@ -7,7 +7,7 @@
<div class="fly-panel fly-panel-user" pad20> <div class="fly-panel fly-panel-user" pad20>
<div class="layui-tab layui-tab-brief" lay-filter="user"> <div class="layui-tab layui-tab-brief" lay-filter="user">
<ul class="layui-tab-title"> <ul class="layui-tab-title">
<li><a href="{:url('index/login/index')}">{:lang('login')}</a></li> <li><a href="{:url('login/index')}">{:lang('login')}</a></li>
<li class="layui-this">{if cache('repass')==2}{:lang('reset password')}{else /}{:lang('retrieve password')}{/if}</li> <li class="layui-this">{if cache('repass')==2}{:lang('reset password')}{else /}{:lang('retrieve password')}{/if}</li>
</ul> </ul>
<div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;"> <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">

View File

@ -6,7 +6,7 @@
</li> </li>
{volist name="cateList" id="cate"} {volist name="cateList" id="cate"}
<li {if condition="$cate.ename eq $Request.param.ename"} class="layui-this" {/if}> <li {if condition="$cate.ename eq $Request.param.ename"} class="layui-this" {/if}>
<a href="{:url('article/cate',['ename' => $cate.ename])}">{:cookie('think_lang') == 'en-us' ? $cate.ename : $cate.catename}{if condition="$cate.is_hot eq 1"}<span class="layui-badge-dot"></span>{/if}</a> <a href="{:url('cate',['ename' => $cate.ename])}">{:cookie('think_lang') == 'en-us' ? $cate.ename : $cate.catename}{if condition="$cate.is_hot eq 1"}<span class="layui-badge-dot"></span>{/if}</a>
</li> </li>
{/volist} {/volist}
<li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li> <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>

View File

@ -35,7 +35,7 @@
{volist name="cateList" id="cate"} {volist name="cateList" id="cate"}
<li {if condition="$cate.ename eq $Request.param.ename"} class="layui-this" {/if}> <li {if condition="$cate.ename eq $Request.param.ename"} class="layui-this" {/if}>
<div class="layui-menu-body-title"> <div class="layui-menu-body-title">
<a href="{:url('article/cate',['ename' => $cate.ename])}"><i class="layui-icon {$cate.icon}"></i> {:cookie('think_lang') == 'en-us' ? $cate.ename : $cate.catename} <a href="{:url('cate',['ename' => $cate.ename])}"><i class="layui-icon {$cate.icon}"></i> {:cookie('think_lang') == 'en-us' ? $cate.ename : $cate.catename}
<span class="layui-font-12 layui-font-gray">>> {$cate.ename}</span> <span class="layui-font-12 layui-font-gray">>> {$cate.ename}</span>
{if condition="$cate.is_hot eq 1"}<span class="layui-badge-dot"></span>{/if} {if condition="$cate.is_hot eq 1"}<span class="layui-badge-dot"></span>{/if}
</a> </a>

View File

@ -1,3 +1,12 @@
<!--
* @Author: TaoLer <alipey_tao@qq.com>
* @Date: 2021-12-06 16:04:51
* @LastEditTime: 2022-04-21 21:52:57
* @LastEditors: TaoLer
* @Description: 搜索引擎SEO优化设置
* @FilePath: \TaoLer\view\taoler\index\user\message.html
* Copyright (c) 2020~2022 http://www.aieok.com All rights reserved.
-->
{extend name="public/user" /} {block name="content"} {extend name="public/user" /} {block name="content"}
<div class="layui-tab layui-tab-brief" lay-filter="user" id="LAY_msg" style="margin-top: 15px"> <div class="layui-tab layui-tab-brief" lay-filter="user" id="LAY_msg" style="margin-top: 15px">
<button class="layui-btn layui-btn-danger" id="LAY_delallmsg"> <button class="layui-btn layui-btn-danger" id="LAY_delallmsg">
@ -7,9 +16,9 @@
</div> </div>
{/block} {block name="script"} {/block} {block name="script"}
<script> <script>
var messageFind = "{:url('index/Message/find')}", var messageFind = "{:url('Message/find')}",
messageRemove = "{:url('index/Message/remove')}", messageRemove = "{:url('Message/remove')}",
userNameJump = "{:url('index/Index/jump')}"; userNameJump = "{:url('Index/jump')}";
//点开标题改变帖子已读状态 //点开标题改变帖子已读状态
$("#LAY_minemsg").on("click", ".art-title", function () { $("#LAY_minemsg").on("click", ".art-title", function () {