diff --git a/.htaccess b/.htaccess
index 9af0319..ed2dc09 100644
--- a/.htaccess
+++ b/.htaccess
@@ -8,5 +8,10 @@ RewriteRule '^login$' ./index.php?c=login [L]
RewriteRule '^admin$' ./index.php?c=admin [L]
RewriteRule '^ico/(.+)' ./index.php?c=icon&url=$1 [L]
RewriteRule '^([A-Za-z0-9]+)$' ./index.php?u=$1 [L]
-RewriteRule '^(.+)/click/([A-Za-z0-9]+)$' ./index.php?c=$2&id=$3&u=$1 [L]
-RewriteRule '^(.+)/click/(.+)' ./$3 [L]
\ No newline at end of file
+RewriteRule '^([A-Za-z0-9]+).html$' ./index.php?u=$1 [L]
+RewriteRule '^([a-zA-Z0-9]+)/(click|article)/([A-Za-z0-9]+)$' ./index.php?c=$2&id=$3&u=$1 [L]
+RewriteRule '^([a-zA-Z0-9]+)/(click|article)/([A-Za-z0-9]+)\.html$' ./index.php?c=$2&id=$3&u=$1 [L]
+RewriteRule '^([a-zA-Z0-9]+)/(click|article)/(templates|static|data|system)/(.+)' /$3/$4 [L]
+RewriteRule '^([a-zA-Z0-9]+)/(click|article)/favicon\.ico' /favicon.ico [L]
+# 站点地图(可选)
+RewriteRule '^sitemap.xml$' ./index.php?c=sitemap [L]
diff --git a/index.php b/index.php
index 90d7f17..2a962d8 100644
--- a/index.php
+++ b/index.php
@@ -79,7 +79,7 @@ if(empty($c) || $c == 'index'){
require "./system/login.php";//登陆
}elseif(in_array($c,['admin','click','api','ico','icon','verify'])){
require "./system/{$c}.php";
-}elseif(in_array($c,['apply','guestbook','article'])){
+}elseif(in_array($c,['apply','guestbook','article','sitemap'])){
if($global_config['Maintenance'] != 0){Amsg(-1,'网站正在进行维护,请稍后再试!');}
require "./system/expand/{$c}.php";
}else{
diff --git a/rewrite.php b/rewrite.php
new file mode 100644
index 0000000..86967a7
--- /dev/null
+++ b/rewrite.php
@@ -0,0 +1,30 @@
+ "sitemap_config"]));
+ if(isset($sitemap_config['zhudong']) && $sitemap_config['zhudong'] == '1'){
+ $sitemap_path = DIR . "/data/user/{$u}/sitemap.php";
+ require DIR .'/system/expand/sitemap_create.php';
+ if(is_Update_Sitemap($sitemap_config,$sitemap_path)){
+ create_sitemap($sitemap_config,$sitemap_path,$u);
+ }
+ }
+
msgA(['code'=>1,'msg'=>'添加成功','id'=>$lid]);
//上传图标
}elseif($_GET['type'] === 'upload_images'){
@@ -1823,6 +1833,9 @@ function read_data(){
msgA( ['code'=>1,'data'=>[$category_count,$link_count,$index_count,$click_count] ]);
//连通测试
}elseif($_GET['type'] == 'connectivity_test'){
+ if($GLOBALS['global_config']['offline'] == '1'){
+ msg(1,'您已开启离线模式,无法使用该功能!');
+ }
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_POST['url']);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
@@ -2026,7 +2039,63 @@ function write_article(){
require DIR . '/system/api_article.php';
exit;
}
-
+//百度推送
+function other_baidu_push(){
+ global $u,$global_config;
+ if ( $global_config['offline'] == '1'){
+ msg(-1,"离线模式无法使用此功能");
+ }
+ if(!is_subscribe('bool')){
+ msg(-1,"未检测到有效授权,无法使用该功能!");
+ }
+ if(empty($_POST['push_api'])){
+ msg(-1,'请输入接口地址');
+ }
+ if(empty($_POST['id'])){
+ msg(-1,'请提交链接ID');
+ }
+ $host = $_SERVER['HTTP_HOST']; // 获取主机名
+ $port = isset($_SERVER['SERVER_PORT']) ? ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) : ''; // 获取端口号
+ $scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; // 获取协议
+ $host = $scheme.$host.$port;
+ $ids = json_decode($_POST['id']) ?? 0;
+ if(count($ids)<1){
+ msg(-1,'解析数据失败,请检查格式是否正确');
+ }
+ $urls=[];
+ if($_POST['type'] == 'link'){
+ foreach($ids as $id){
+ $urls[] = "{$host}/{$u}/click/{$id}.html";
+ }
+ }elseif($_POST['type'] == 'article'){
+ foreach($ids as $id){
+ $urls[] = "{$host}/{$u}/article/{$id}.html";
+ }
+ }else{
+ msg(-1,'无效类型');
+ }
+
+ if(!empty($urls)){
+ $api = $_POST['push_api'];
+ write_user_config('baidu_push_api',$api,'config','百度推送API');
+ $ch = curl_init();
+ $options = array(
+ CURLOPT_URL => $api,
+ CURLOPT_POST => true,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_POSTFIELDS => implode("\n", $urls),
+ CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
+ );
+ curl_setopt_array($ch, $options);
+ $result = curl_exec($ch);
+ $result = json_decode($result,true) ?? '';
+ if(empty($result)){
+ msg(-1,'推送失败');
+ }else{
+ msgA(['code'=>curl_getinfo($ch, CURLINFO_HTTP_CODE),'data'=>$result]);
+ }
+ }
+}
//获取链接信息
function other_get_link_info(){
global $global_config;
diff --git a/system/api_root.php b/system/api_root.php
index 635157e..b6a5283 100644
--- a/system/api_root.php
+++ b/system/api_root.php
@@ -798,6 +798,12 @@ function other_root(){
}
msg(1,'操作成功');
+ }elseif($_GET['type'] == 'write_sitemap_config'){
+ if(!is_subscribe('bool')){
+ msg(-1,'未检测到有效授权');
+ }
+ write_global_config('sitemap_config',$_POST,'站点地图配置');
+ msg(1,'保存成功');
}
}
diff --git a/system/expand/sitemap.php b/system/expand/sitemap.php
new file mode 100644
index 0000000..ed97644
--- /dev/null
+++ b/system/expand/sitemap.php
@@ -0,0 +1,46 @@
+ "sitemap_config"]));
+
+//储存路径
+$sitemap_path = DIR . "/data/user/{$u}/sitemap.php";
+
+//载入生成脚本
+require 'sitemap_create.php';
+
+//是否为手动生成
+if(!empty($_GET['mode'])){
+ if($sitemap_config['switch'] != '1'){
+ msg(-1,'请将功能开关设为开启并保存');
+ }else{
+ create_sitemap($sitemap_config,$sitemap_path,$u);
+ msg(1,'生成完毕');
+ }
+}else{
+ //未开启被动请求时,如果有缓存文件则返回
+ if($sitemap_config['beidong'] != '1'){
+ if(file_exists($sitemap_path)){
+ exit(file_get_contents($sitemap_path) ?? '');
+ }
+ exit;
+ }
+}
+
+//未开启功能时不输出任何数据
+if($sitemap_config['switch'] != '1'){
+ exit;
+}
+
+//判断是否需要更新
+if(is_Update_Sitemap($sitemap_config,$sitemap_path)){
+ exit (create_sitemap($sitemap_config,$sitemap_path,$u));
+}else{
+ exit(file_get_contents($sitemap_path) ?? '');
+}
+
+?>
diff --git a/system/expand/sitemap_create.php b/system/expand/sitemap_create.php
new file mode 100644
index 0000000..ee109e4
--- /dev/null
+++ b/system/expand/sitemap_create.php
@@ -0,0 +1,134 @@
+ 30 * 24 * 60 * 60, // 30天
+ 'weekly' => 7 * 24 * 60 * 60, // 7天
+ 'daily' => 24 * 60 * 60, // 1天
+ 'hourly' => 60 * 60, // 1小时
+ 'minute' => 60, //1分钟
+ 'second' => 1 //1秒
+ ];
+
+ $interval_seconds = $timeIntervals[$sitemap_config['changefreq']] ?? 86400; //间隔秒
+ if (time() - $up_time >= $interval_seconds){
+ return true;
+ }else{
+ return false;
+ }
+ //缓存文件不存在时重新创建地图
+ }else{
+ return true;
+ }
+}
+
+//创建地图数据函数
+function create_sitemap($sitemap_config,$sitemap_path,$u){
+ //创建一个空的 XML 文档
+ $xml = new DOMDocument('1.0', 'UTF-8');
+ $xml->formatOutput = true;
+ //创建根元素
+ $urlset = $xml->createElement('urlset');
+ $urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
+ $xml->appendChild($urlset);
+ //今天
+ $today = date("Y-m-d\TH:i:s", time());
+ //域名
+ $host = $_SERVER['HTTP_HOST']; // 获取主机名
+ $port = isset($_SERVER['SERVER_PORT']) ? ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']) : ''; // 获取端口号
+ $scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; // 获取协议
+ $host = $scheme.$host.$port;
+ //用户主页 0.关闭 1.动态地址 2.静态地址 3.二级域名
+ if($sitemap_config['user_homepage'] > 0){
+ //读取用户列表
+ $user_list = select_db('global_user','User','');
+ if($sitemap_config['user_homepage'] == '3'){
+ $strings = explode('.',$_SERVER['HTTP_HOST']);
+ if(count($strings) == 3){
+ $root_domain = "{$strings[1]}.{$strings[2]}";
+ }elseif(count($strings) == 2){
+ $root_domain = $_SERVER['HTTP_HOST'];
+ }else{
+ $sitemap_config['user_homepage'] == '1';
+ }
+ }
+ //遍历用户列表
+ foreach($user_list as $user){
+ if($sitemap_config['user_homepage'] == '2'){
+ $locurl = "{$host}/{$user}.html";
+ }elseif($sitemap_config['user_homepage'] == '3'){
+ $locurl = "{$scheme}{$user}.{$root_domain}";
+ }else{
+ $locurl = "{$host}/index.php?u={$user}";
+ }
+ //生成数据
+ $url = createUrlElement($xml, $locurl, $today, $sitemap_config['user_homepage_changefreq'], $sitemap_config['user_homepage_weight']);
+ $urlset->appendChild($url);
+ }
+
+ }
+
+ //过度页面 0.关闭 1.动态 2.静态
+ if($sitemap_config['click_page'] > 0){
+ $category_parent = []; //父分类
+ $categorys = []; //全部分类
+ //查找条件 - 分类
+ $where['uid'] = UID;
+ $where['fid'] = 0;
+ $where['pid'] = 0;
+ $where['status'] = 1;
+ $where['ORDER'] = ['weight'=>'ASC'];
+ $where['property'] = 0;
+ //查找一级分类
+ $category_parent = select_db('user_categorys','cid',$where);
+ //遍历二级分类
+ foreach ($category_parent as $cid) {
+ $where['fid'] = $cid;
+ $category_subitem = select_db('user_categorys','cid',$where);
+ array_push($categorys,$cid);
+ $categorys = array_merge ($categorys,$category_subitem);
+ }
+
+ //遍历链接
+ foreach ($categorys as $cid) {
+ $where['fid'] = $cid;
+ $links = select_db('user_links',['lid','up_time'],$where);
+ foreach ($links as $link) {
+ if($sitemap_config['click_page'] == '2'){
+ $locurl = "{$host}/{$u}/click/{$link['lid']}.html";
+ }else{
+ $locurl = "{$host}/index.php?c=click&id={$link['lid']}&u={$u}";
+ }
+ $url = createUrlElement($xml, $locurl, date("Y-m-d\TH:i:s", $link['up_time']), $sitemap_config['click_page_changefreq'], $sitemap_config['click_page_weight']);
+ $urlset->appendChild($url);
+ }
+ }
+ }
+
+ //保存 XML 内容到文件
+ $xml->save($sitemap_path);
+
+ //返回内容
+ return $xml->saveXML();
+}
+
+// 生成URL元素
+function createUrlElement($xml, $loc, $lastmod, $changefreq, $priority) {
+ $url = $xml->createElement('url');
+
+ $locElem = $xml->createElement('loc', htmlspecialchars($loc));
+ $url->appendChild($locElem);
+
+ $lastmodElem = $xml->createElement('lastmod', $lastmod);
+ $url->appendChild($lastmodElem);
+
+ $changefreqElem = $xml->createElement('changefreq', $changefreq);
+ $url->appendChild($changefreqElem);
+
+ $priorityElem = $xml->createElement('priority', $priority);
+ $url->appendChild($priorityElem);
+
+ return $url;
+}
\ No newline at end of file
diff --git a/system/install.php b/system/install.php
index 3f07b5b..52d9b1c 100644
--- a/system/install.php
+++ b/system/install.php
@@ -288,8 +288,8 @@ function Write_Config(){
$o_config['RegOption'] = '0'; //注册配置
$o_config['Libs'] = './static'; //静态库路径
$o_config['Default_User'] = $_POST['User']; //默认用户
- $o_config['XSS_WAF'] = '1'; //防XSS脚本
- $o_config['SQL_WAF'] = '1'; //防SQL注入
+ $o_config['XSS_WAF'] = '0'; //防XSS脚本
+ $o_config['SQL_WAF'] = '0'; //防SQL注入
$o_config['offline'] = '0'; //离线模式
$o_config['Debug'] = '0'; //调试模式
$o_config['Maintenance'] = '0'; //维护模式
diff --git a/system/templates.php b/system/templates.php
index 8f52029..6bc8572 100644
--- a/system/templates.php
+++ b/system/templates.php
@@ -55,7 +55,7 @@ if($c == 'index'){
$dir_path = DIR.'/templates/guestbook';
}elseif($c == 'apply'){ //收录
$theme = $s_templates['apply'];
- $dir_path = DIR.'/templates/guestbook/';
+ $dir_path = DIR.'/templates/apply/';
}elseif($c == $global_config['Login'] || $c == $USER_DB['Login']){ //登录
$theme = $s_templates['login'];
$dir_path = DIR.'/templates/login';
diff --git a/system/version.txt b/system/version.txt
index 0e69520..4ab274a 100644
--- a/system/version.txt
+++ b/system/version.txt
@@ -1 +1 @@
-v2.0.37-20230830
\ No newline at end of file
+v2.0.38-20230906
\ No newline at end of file
diff --git a/templates/admin/js/link_list.js b/templates/admin/js/link_list.js
index fefc3d8..02dfb30 100644
--- a/templates/admin/js/link_list.js
+++ b/templates/admin/js/link_list.js
@@ -270,45 +270,6 @@ layui.use(['form','table','dropdown','miniTab'], function () {
return true;
}
})
- }else if(event === 'icon_pull'){
- layer.alert('存在链接图标时如何处理 ?', {icon: 3, title:'请选择',btn: ['保持原样', '重新拉取', '取消'],
- btnAlign: 'c',
- btn1: function(){icon_pull_test('0')}, //跳过
- btn2: function(){icon_pull_test('1')} //覆盖
- });
- function icon_pull_test(cover){
- let i = 0;
- let success = 0;
- let skip = 0;
- let fail = 0;
- let total = checkStatus.data.length;
- layer.load(1, {shade:[0.5,'#fff']});//加载层
- let msg_id = layer.msg('正在拉取中', {icon: 16,time: 1000*300});
- icon_pull(i);
- function icon_pull(id){
- if(i >= total){
- layer.closeAll();
- layer.alert('总计:' + total +',成功:' + success + ',失败:'+ fail + (skip > 0 ? (',跳过:' + skip):'' ),{icon:1,title:'信息',anim: 2,shadeClose: false,closeBtn: 0});
- return true;
- }
- $("#layui-layer"+ msg_id+" .layui-layer-padding").html('[ ' + i + ' / ' + total + ' ] 正在拉取图标');
- $.post(get_api('write_link','icon_pull'),{id:checkStatus.data[i].lid,cover:cover},function(data,status){
- if(data.msg == 'success'){
- success ++;
- }else if(data.msg == 'fail'){
- fail ++;
- }else if(data.msg == 'skip'){
- skip ++;
- }else{
- layer.closeAll();
- layer.alert(data.msg,{icon:2,title:'信息',anim: 2,shadeClose: false,closeBtn: 0});
- return true;
- }
- i ++;
- icon_pull(i);
- });
- }
- }
}else if(event === 'link_extend'){
extend_data = '';
index = layer.open({type: 1,scrollbar: false,shadeClose: true,title: '编辑扩展字段',area : ['100%', '100%'],content: $('.link_extend')});
@@ -322,6 +283,8 @@ layui.use(['form','table','dropdown','miniTab'], function () {
});
}else if(event === 'msg_pull'){
index = layer.open({type: 1,scrollbar: false,shadeClose: true,title: '批量识别链接信息',area : ['100%', '100%'],content: $('.msg_pull')});
+ }else if(event === 'push'){
+ index = layer.open({type: 1,scrollbar: false,shadeClose: true,title: '推送工具',area : ['100%', '100%'],content: $('.push')});
}
});
@@ -359,6 +322,23 @@ layui.use(['form','table','dropdown','miniTab'], function () {
return false;
});
+ //开始推送
+ $('#start_push').click(function () {
+ let checkStatus = table.checkStatus('table');
+ tableIds = checkStatus.data.map(function (value) {return value.lid;});
+ tableIds = JSON.stringify(tableIds);
+ $.post(get_api('other_baidu_push'),{'type':'link','push_api':$('#push_api').val(),'id':tableIds},function(data,status){
+ if(data.code == -1){
+ layer.msg(data.msg,{icon: 5});
+ }else if(data.code == 200){
+ layer.alert('成功推送的条数: ' + data.data.success + '
当天剩余的可推送条数: ' + data.data.remain + (data.data.not_same_site && data.data.not_same_site.length > 0 ? "
未处理的条数(非本站URL): " + data.data.not_same_site.length:'') + (data.data.not_valid && data.data.not_valid.length > 0 ? "
不合法的URL条数: " + data.data.not_valid.length:''));
+ }else{
+ layer.alert('错误代码: ' + data.data.error + '
错误描述: ' + data.data.message);
+ }
+ });
+ return false;
+ });
+
table.render({
elem: '#link_extend_list'
,height: 'full-150'
diff --git a/templates/admin/js/theme.js b/templates/admin/js/theme.js
index 0cab8ca..6e9c9b4 100644
--- a/templates/admin/js/theme.js
+++ b/templates/admin/js/theme.js
@@ -143,7 +143,7 @@ layui.use(function(){
${upordw}
${t.state == 'local' || t.state == 'up' ? '':''}
- ${t.state == 'local' && active == 'home' ? '':''}
+ ${(t.state == 'local' || t.state == 'up') && active == 'home' ? '':''}
${t.config == '1' && theme_set == true ? '':''}
${(t.state == 'local' || t.state == 'up' ) && is_admin == true ? '':''}
diff --git a/templates/admin/page/expand/article-edit.php b/templates/admin/page/expand/article-edit.php
index 8d04a45..0b4d7ed 100644
--- a/templates/admin/page/expand/article-edit.php
+++ b/templates/admin/page/expand/article-edit.php
@@ -216,6 +216,7 @@ const toolbar = createToolbar({
})
+
layui.use(['form','upload'], function () {
var form = layui.form,
upload = layui.upload;
@@ -308,6 +309,18 @@ layui.use(['form','upload'], function () {
});
return false;
});
+ $(".content").dblclick(function(){
+ layer.prompt({
+ formType: 2,
+ value: editor.getHtml(),
+ maxlength:9999999,
+ title: 'HTML代码编辑',
+ area: ['800px', '350px']
+ }, function(value, index, elem){
+ editor.setHtml(value);
+ layer.close(index); // 关闭层
+ });
+ });
});
function truncateString(str,n) {
diff --git a/templates/admin/page/expand/article-list.php b/templates/admin/page/expand/article-list.php
index 9e7f6cd..ae05d27 100644
--- a/templates/admin/page/expand/article-list.php
+++ b/templates/admin/page/expand/article-list.php
@@ -131,6 +131,30 @@ require dirname(__DIR__).'/header.php' ?>
+