From bc8b2638e91438bdb554b61846b74f93423e6f56 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Tue, 10 Dec 2024 10:40:01 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.simple.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/config.simple.php b/config.simple.php index 19684a0..0ff6d14 100755 --- a/config.simple.php +++ b/config.simple.php @@ -9,12 +9,10 @@ $db = new medoo([ //用户名 define('USER','{username}'); -//密码 -define('PASSWORD','{password}'); +// 加密后的密码 +define('ENCRYPTED_PASSWORD','{encrypted_password}'); //邮箱,用于后台Gravatar头像显示 define('EMAIL','{email}'); -//token参数,API需要使用,0.9.19版本这个废弃了,请通过后台设置 -define('TOKEN','xiaoz.me'); //主题风格,0.9.18废弃了,请通过后台设置 define('TEMPLATE','default'); @@ -31,4 +29,4 @@ $site_setting['description'] = 'OneNav是一款使用PHP + SQLite3开发的 //这两项不要修改 $site_setting['user'] = USER; -$site_setting['password'] = PASSWORD; \ No newline at end of file +$site_setting['password'] = ENCRYPTED_PASSWORD; \ No newline at end of file From d0f14597cc89da81fba7c095c1fbda907bcccc69 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Tue, 10 Dec 2024 10:40:29 +0800 Subject: [PATCH 02/14] 20241210 --- class/Api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/Api.php b/class/Api.php index e2ae280..577e023 100755 --- a/class/Api.php +++ b/class/Api.php @@ -1200,7 +1200,7 @@ class Api { * 验证是否登录 */ protected function is_login(){ - $key = md5(USER.PASSWORD.'onenav'.$_SERVER['HTTP_USER_AGENT']); + $key = md5(USER.ENCRYPTED_PASSWORD.'onenav'.$_SERVER['HTTP_USER_AGENT']); //获取session $session = $_COOKIE['key']; //如果已经成功登录 From f8a10616ae57e2a1729df4444a652aa62573a0c5 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Tue, 10 Dec 2024 10:40:51 +0800 Subject: [PATCH 03/14] 20241210 --- controller/admin.php | 1 + controller/index.php | 4 +++- controller/init.php | 25 +++++++++++++++++++++---- controller/login.php | 9 ++++++--- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/controller/admin.php b/controller/admin.php index 0afc081..facdff3 100755 --- a/controller/admin.php +++ b/controller/admin.php @@ -323,6 +323,7 @@ $page = $page.'.php'; function check_auth($user,$password){ if ( !is_login() ) { + // exit("dsdfd"); $msg = "

认证失败,请重新登录

"; require('templates/admin/403.php'); exit; diff --git a/controller/index.php b/controller/index.php index f78470e..e6f97ba 100755 --- a/controller/index.php +++ b/controller/index.php @@ -10,10 +10,12 @@ $site = unserialize($site); $link_num = empty( $site['link_num'] ) ? 30 : intval($site['link_num']); - //如果已经登录,获取所有分类和链接 // 载入辅助函数 require('functions/helper.php'); +// 明文密码检查 +unSafe(); + if( is_login() ){ //查询所有分类目录 $categorys = []; diff --git a/controller/init.php b/controller/init.php index 893c48b..a0ff397 100755 --- a/controller/init.php +++ b/controller/init.php @@ -10,18 +10,33 @@ function check_env() { //获取组件信息 $ext = get_loaded_extensions(); - //检查PHP版本,需要大于5.6小于8.0 + //检查PHP版本,需要大于7.0小于8.0 $php_version = floatval(PHP_VERSION); $uri = $_SERVER["REQUEST_URI"]; - if( ( $php_version < 5.6 ) || ( $php_version > 8 ) ) { - exit("当前PHP版本{$php_version}不满足要求,需要5.6 <= PHP <= 7.4"); + if( ( $php_version < 7 ) || ( $php_version > 8 ) ) { + exit("当前PHP版本{$php_version}不满足要求,需要7.0 <= PHP <= 7.4"); } //检查是否支持pdo_sqlite if ( !array_search('pdo_sqlite',$ext) ) { exit("不支持PDO_SQLITE组件,请先开启!"); } + + if ( !array_search('openssl', $ext) ) { + exit("不支持OPENSSL组件,请先开启!"); + } + + //检查是否支持zlib + if ( !array_search('zlib', $ext) ) { + exit("不支持ZLIB组件,请先开启!"); + } + + //检查是否支持curl + if ( !array_search('curl', $ext) ) { + exit("不支持CURL组件,请先开启!"); + } + //如果配置文件存在 if( file_exists("data/config.php") ) { exit("配置文件已存在,无需再次初始化!"); @@ -88,7 +103,9 @@ function init($data){ //替换内容 $content = str_replace('{email}',$data['email'],$content); $content = str_replace('{username}',$data['username'],$content); - $content = str_replace('{password}',$data['password'],$content); + // $content = str_replace('{password}',$data['password'],$content); + // 存入加密后的密码,用户名 + 密码,再进行MD5加密 + $content = str_replace('{encrypted_password}',md5($data['username'].$data['password']),$content); //写入配置文件 if( !file_put_contents($config_file,$content) ) { diff --git a/controller/login.php b/controller/login.php index 2d2d6ce..e017d45 100755 --- a/controller/login.php +++ b/controller/login.php @@ -7,7 +7,8 @@ require('functions/helper.php'); $username = $site_setting['user']; -$password = $site_setting['password']; +// 加密后的密码 +$password = ENCRYPTED_PASSWORD; $ip = getIP(); //如果认证通过,直接跳转到后台管理 $key = md5($username.$password.'onenav'.$_SERVER['HTTP_USER_AGENT']); @@ -25,8 +26,10 @@ if( is_login() ){ //登录检查 if( $_GET['check'] == 'login' ) { - $user = $_POST['user']; - $pass = $_POST['password']; + $user = trim($_POST['user']); + $pass = trim($_POST['password']); + // 用户密码进行加密处理,加密算法为用户名 + 密码,再进行MD5加密 + $pass = md5($user.$pass); header('Content-Type:application/json; charset=utf-8'); if( ($user === $username) && ($pass === $password) ) { $key = md5($username.$password.'onenav'.$_SERVER['HTTP_USER_AGENT']); From c6382a67a94187296c7a050dbd62a7e1f62274dc Mon Sep 17 00:00:00 2001 From: xiaoz Date: Tue, 10 Dec 2024 10:41:35 +0800 Subject: [PATCH 04/14] fix bug --- templates/admin/edit_link_new.php | 2 +- templates/admin/footer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/admin/edit_link_new.php b/templates/admin/edit_link_new.php index e1d26b8..08b54db 100755 --- a/templates/admin/edit_link_new.php +++ b/templates/admin/edit_link_new.php @@ -22,7 +22,7 @@
- +
diff --git a/templates/admin/footer.php b/templates/admin/footer.php index 5b49288..3ae9185 100755 --- a/templates/admin/footer.php +++ b/templates/admin/footer.php @@ -1,6 +1,6 @@ From e368b22e12e168bee487fa60c9a4382cbbf08a62 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Tue, 17 Dec 2024 12:34:06 +0800 Subject: [PATCH 05/14] add column --- db/sql/20241209.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/sql/20241209.sql diff --git a/db/sql/20241209.sql b/db/sql/20241209.sql new file mode 100644 index 0000000..3096eab --- /dev/null +++ b/db/sql/20241209.sql @@ -0,0 +1,2 @@ +ALTER TABLE on_links ADD check_status INTEGER DEFAULT (0) NOT NULL; +ALTER TABLE on_links ADD last_checked_time TEXT; \ No newline at end of file From 0abd4a4f811077e3ee279e788c58fef189aa4854 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Tue, 17 Dec 2024 12:34:33 +0800 Subject: [PATCH 06/14] update db --- db/onenav.simple.db3 | Bin 61440 -> 61440 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/db/onenav.simple.db3 b/db/onenav.simple.db3 index 9013039a0645dd00295b8d5aca7dbb12db35fe58..194f0a2fec7b961ec9bbf8bf2bad78701dda7850 100644 GIT binary patch delta 702 zcmZp8z})bFd4jaydLPjB6d3rJWEuFvS#tRIGs$i&S;@%N z;=|4^E-TB}k-a&K=_sRxh^xD6kb;Y=n`5X?h=PWJrh=b; zh=O0JkB^Q*PGWIMJXn2dN_CJ)y4>&ge%Gklk!ZV$raPzjTM~r$?7(`*NhSPq`0t}3b=EjN) zj2xUC3=A9$!v1-weu-rYlMC}rrP!00fbxds=8B4F@{^b3c?omGF#@Gk{ml{DCvVR8 zW#pWEAomIj(2|#vXXJ%3@h_YFA+NW-k%2=HsM@-b7o?m6*|w+aW<1|JF{7lUpx8=Z zzr4I$FF!9eFR@IoB)>o(>Y!&c)<4Eznwgn$aq-<^;N;uKz%R?U zk3WrnIsa|`ets{$C;XcQ6_)Z%-d881#&5yE1#yWqvo#|QH*svLXAzX(;(Nxx|A_w> z|0@1I{v!S`ek*=CekQ(WK*LV)$w=|BF{rYLG8h>cnHU-wSn3rQ=ASisr4UChoGmCE4XStxw$h*ma(Lj=0o`I9&7X$w?zA5~Pyazab z@i1{Kb8X_1-Yh8afMfHoj2(Vq|{DsJU^XD&yn>xmQ>sn0Of`&&Ug7 zVqlp3A+LAxr5sJ(2u5xOMpb`vMFtKI&dEi&zLH#gKN&dr_A&6w^6leK<6q8qi~lx% zKff3MW1_% z_^tTm_?dvZUhr*Zn$N@tRFKBNf0utI{~7+>Kt&z= Date: Tue, 17 Dec 2024 12:36:13 +0800 Subject: [PATCH 07/14] upate --- class/Api.php | 232 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) diff --git a/class/Api.php b/class/Api.php index 577e023..9dd8f25 100755 --- a/class/Api.php +++ b/class/Api.php @@ -2613,7 +2613,239 @@ class Api { $this->return_json(-2000,'','failure'); } } + + /** + * name: 批量检测链接 + * description:check_status,0:未检测,1:正常,2:异常,3:未知(比如启用了cf) + */ + public function batch_check_links(){ + set_time_limit(1200); // 设置执行最大时间为20分钟 + // 验证授权 + $this->auth($token); + // 验证订阅 + $this->check_is_subscribe(); + + // 记录开始时间 + $start_time = microtime(true); + + // 获取所有链接 + $links = $this->db->select('on_links', '*'); + + // 设置并发限制(最大30个并发) + $max_concurrent_requests = 30; + $multi_curl = curl_multi_init(); // 初始化curl_multi + $curl_handles = []; // 存储curl句柄 + $link_count = count($links); // 获取链接数量 + $completed_links = 0; // 已完成检测的链接数 + + // 设置curl超时时间为20分钟(1200秒) + $timeout = 10; + + // 错误链接 + $error_num = 0; + + // 并发处理每个链接 + foreach ($links as $link) { + // 创建一个curl句柄 + $ch = curl_init(); + + // 设置curl选项 + curl_setopt($ch, CURLOPT_URL, $link['url']); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 返回内容而不是输出 + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // 设置请求超时时间 + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // 设置连接超时时间 + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); // 跟随重定向 + // 设置UA + curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36"); + curl_setopt($ch, CURLOPT_HTTPGET, true); // 确保使用GET请求 + curl_setopt($ch, CURLOPT_HEADER, true); // 获取响应头 + + // 将curl句柄加入到multi句柄中 + curl_multi_add_handle($multi_curl, $ch); + + // 存储每个链接的ID,方便回调时更新状态 + $curl_handles[$link['id']] = $ch; + } + + // 执行curl请求并监听 + do { + $status = curl_multi_exec($multi_curl, $active); // 执行请求 + if ($status > 0) { + // 如果发生错误,输出错误信息 + // echo "Curl error: " . curl_multi_strerror($status); + } + + // 等待活动的请求完成 + if ($active) { + curl_multi_select($multi_curl, 1); // 阻塞直到有活动的请求 + } + } while ($active); + + // 处理每个请求的返回结果 + foreach ($curl_handles as $id => $ch) { + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 获取HTTP状态码 + $error = curl_error($ch); // 获取cURL错误信息 + + $header = curl_multi_getcontent($ch); // 获取完整的响应内容,包括头部 + // 获取Server头 + preg_match('/^Server:\s*(.*)$/mi', $header, $matches); + $server_header = isset($matches[1]) ? $matches[1] : ''; // 获取Server头的值 + // 获取当前时间戳 + $last_checked_time = date('Y-m-d H:i:s'); + + // 判断链接是否有效,HTTP状态码大于400视为异常,超时或其他错误也视为异常 + if ($error || $http_code >= 400) { + // 判断Server头中是否包含cloudflare和waf,不区分大小写 + if (stripos($server_header, 'cloudflare') !== false || stripos($server_header, 'waf') !== false) { + $check_status = 3; // 未知 + } else { + $check_status = 2; // 异常 + // 错误数量+1 + $error_num++; + } + } else { + $check_status = 1; // 正常 + } + + // 更新数据库字段 + $this->db->update('on_links', [ + 'check_status' => $check_status, + 'last_checked_time' => $last_checked_time + ], ['id' => $id]); + + // 删除curl句柄,释放资源 + curl_multi_remove_handle($multi_curl, $ch); + curl_close($ch); // 关闭curl句柄 + + // 完成一个链接的检测 + $completed_links++; + } + + // 关闭multi句柄 + curl_multi_close($multi_curl); + + // 记录结束时间 + $end_time = microtime(true); + + // 计算总共花费的时间 + $elapsed_time = $end_time - $start_time; + // 精确到s就行 + $elapsed_time = round($elapsed_time, 2); + + // 返回成功 + $this->return_json(200, [ + 'completed_links' => $completed_links, + 'elapsed_time' => $elapsed_time, + 'error_num' => $error_num + ], 'success'); + } + + // 获取过渡页API + public function transition_page(){ + //获取当前站点信息 + $transition_page = $this->db->get('on_options','value',[ 'key' => "s_transition_page" ]); + $transition_page = unserialize($transition_page); + // 返回数据 + $this->return_json(200,$transition_page,'success'); + } + + /** + * AI检索 + */ + public function ai_search() { + set_time_limit(1200); // 设置执行最大时间为20分钟 + + // 验证授权 + $this->auth($token); + + // 验证订阅 + $this->check_is_subscribe(); + + // 获取用户输入 + $content = $_GET['content']; + + // 查询出所有链接,只需要url, title, description, url_standby字段 + $links = $this->db->select('on_links', ['url', 'title', 'description', 'url_standby']); + + // 将链接数据转换为AI需要的JSON格式 + $bookmarks = []; + foreach ($links as $link) { + $bookmarks[] = [ + 'title' => $link['title'], + 'url' => $link['url'], + 'url_standby' => $link['url_standby'], + 'description' => $link['description'] + ]; + } + // 将数据转换为JSON格式 + $bookmarks = json_encode($bookmarks); + + // 创建AI请求的消息内容 + $messages = [ + [ + "role" => "system", + "content" => "我会给你一段JSON格式的书签数据,其中包含每个链接的标题、URL、标签和描述等信息。你需要根据用户提供的指令或关键词,结合你所学的知识判断,并智能匹配与之相关的链接。请根据关键词的相关性来排序匹配结果,并返回匹配的链接列表以及对应的名称。 + +在返回匹配的链接时,确保: +1. 返回的链接与用户提供的关键词高度相关,优先匹配精确相关的内容。 +2. 根据相关性将结果按从高到低排序,以确保最相关的链接出现在列表的前面。 +3. 对于匹配结果,再根据你所学的知识推荐额外的5个相关链接,确保这些推荐的链接也与用户的需求相关。 + +例如,用户输入“AI技术”,如果书签数据中有相关的AI资源,你需要返回相关的链接列表,并根据关键词“AI”排序结果。同时,你还应该推荐额外的5个相关链接,帮助用户发现更多有价值的资源。 +" + ], + [ + "role" => "user", + "content" => $bookmarks // 你可以根据实际需求修改用户输入 + ], + [ + "role" => "user", + "content" => $content // 你可以根据实际需求修改用户输入 + ] + ]; + + // var_dump($messages); + + // 发送请求到AI接口 + $response = $this->send_to_ai($bookmarks, $messages); + + echo $response; + } + + private function send_to_ai($bookmarks, $messages) { + // 准备请求数据 + $data = [ + 'model' => 'qwen-plus', + 'messages' => $messages, + 'stream' => false + ]; + + // 设置请求头和授权信息 + $headers = [ + 'Content-Type: application/json', + 'Authorization: Bearer sk-xxx' // 用你的实际API密钥替换 + ]; + + // 使用cURL发送请求 + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); + + // 获取响应并关闭cURL + $response = curl_exec($ch); + curl_close($ch); + + // var_dump($response); + // exit; + + // 解析响应 + return $response; + } } + From aed1fdcc909889ce3a0e88b116f5c6f97a91771d Mon Sep 17 00:00:00 2001 From: xiaoz Date: Tue, 17 Dec 2024 12:36:43 +0800 Subject: [PATCH 08/14] update --- controller/api.php | 38 ++++++++++++++++++++++++++++++++++++-- controller/init.php | 4 ++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/controller/api.php b/controller/api.php index 3d2b7ca..327ebb3 100755 --- a/controller/api.php +++ b/controller/api.php @@ -17,12 +17,46 @@ $api = new Api($db); $method = $_GET['method']; //可变函数变量 $var_func = htmlspecialchars(trim($method),ENT_QUOTES); +// 屏蔽的方法,让其不调用class/Api.php 中的方法 +$deny_func = [ + '__construct', + 'auth', + 'batch_create_category', + 'check_is_subscribe', + 'check_link', + 'curl_get', + 'deldir', + 'down_updater', + 'err_msg', + 'general_upload', + 'getData', + 'getIP', + 'is_login', + 'is_subscribe', + 'return_json', + 'set_option', + 'set_option_bool', + 'update_link_status', + 'send_to_ai' +]; +// 判断是否在屏蔽列表中 +if( in_array($var_func,$deny_func) ) { + exit('method not found!'); +} //判断函数是否存在,存在则条用可变函数,否则抛出错误 if ( function_exists($var_func) ) { - //调用可变函数 + //调用可变函数,优先调用本文件内声明的函数 $var_func($api); }else{ - exit('method not found!'); + // 其次调用class中的函数 + if( method_exists($api,$var_func) ) { + // 存在则调用 + $api->$var_func(); + } + else{ + // 如果本文件和class/Api.php 中都不存在则抛出错误 + exit('method not found!'); + } } diff --git a/controller/init.php b/controller/init.php index a0ff397..5418116 100755 --- a/controller/init.php +++ b/controller/init.php @@ -91,6 +91,10 @@ function init($data){ if( !preg_match($p_patt,$data['password']) ) { err_msg(-2000,'密码格式不正确!'); } + // 验证邮箱是否合法 + if( !filter_var($data['email'],FILTER_VALIDATE_EMAIL) ) { + err_msg(-2000,'邮箱格式不正确!'); + } $config_file = "data/config.php"; //检查配置文件是否存在,存在则不允许设置 if( file_exists($config_file) ) { From 1dea8e2e07b49e23c6dca6d5c6893b7d580dd572 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Tue, 17 Dec 2024 12:37:22 +0800 Subject: [PATCH 09/14] update template --- templates/admin/add_category.php | 3 +- templates/admin/add_link.php | 2 +- templates/admin/index.php | 2 +- templates/admin/init.php | 86 ++++++++++------ templates/admin/link_list.php | 108 ++++++++++++++++++-- templates/admin/setting/subscribe.php | 8 +- templates/admin/setting/transition_page.php | 4 +- templates/admin/static/embed.js | 66 ++++++------ templates/admin/static/style.css | 3 + 9 files changed, 208 insertions(+), 74 deletions(-) diff --git a/templates/admin/add_category.php b/templates/admin/add_category.php index b6ebf5b..08ece36 100755 --- a/templates/admin/add_category.php +++ b/templates/admin/add_category.php @@ -7,8 +7,7 @@
-

1. 关于字体图标的说明请参考帮助文档:https://dwz.ovh/7nr1f

-

2. 权重越大,排序越靠前

+

注意:权重越大,分类排序越靠前

diff --git a/templates/admin/add_link.php b/templates/admin/add_link.php index f8eb7e8..d4fa317 100755 --- a/templates/admin/add_link.php +++ b/templates/admin/add_link.php @@ -9,7 +9,7 @@

1. 权重越大,排序越靠前

2. 识别功能可以自动获取链接标题和描述信息,但不确保一定成功

-

3. 仅 5iux/heimdall/tushan2/webstack 支持自定义图标,其余主题均自动获取链接图标。

+

3. 仅 default2/5iux/heimdall/tushan2/webstack 支持自定义图标,其余主题均自动获取链接图标。

diff --git a/templates/admin/index.php b/templates/admin/index.php index 68f6657..adec37d 100755 --- a/templates/admin/index.php +++ b/templates/admin/index.php @@ -107,7 +107,7 @@
-

Chrome浏览器扩展

+

浏览器扩展

https://dwz.ovh/4kxn2

diff --git a/templates/admin/init.php b/templates/admin/init.php index 753aaa0..df0a0ba 100755 --- a/templates/admin/init.php +++ b/templates/admin/init.php @@ -13,8 +13,21 @@ @@ -23,36 +36,49 @@
- +
-
-
- -
- -
-
-
- -
- -
-
+ +
+
+

初始化OneNav

+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
-
- -
- -
-
- -
- -
- - +
+ +
+ +
+
+ +
+ +
+ + +
+
diff --git a/templates/admin/link_list.php b/templates/admin/link_list.php index 0a2c800..5f25431 100755 --- a/templates/admin/link_list.php +++ b/templates/admin/link_list.php @@ -9,9 +9,9 @@
    -
  1. 仅 5iux/heimdall/tushan2/webstack 支持自定义图标,其余主题均自动获取链接图标。
  2. +
  3. 仅 default2/5iux/heimdall/tushan2/webstack 支持自定义图标,其余主题均自动获取链接图标。
  4. 分类的私有属性优先级高于链接的私有属性
  5. -
  6. 权重数字越大,排序越靠前
  7. +
  8. 权重数字越大,链接排序越靠前
@@ -39,16 +39,24 @@
-
+
-
+
+ +
+
+ +
+
+ +
@@ -128,6 +136,59 @@ layui.use(['table','form'], function(){ }); }); + // 提交批量检测 + form.on('submit(batch_check)', function(data){ + let content = ` +
    +
  • 1. 此功能仅订阅用户可用!
  • +
  • 2. 检测较为耗时,检测期间请勿关闭和刷新此页面!
  • +
  • 3. 检测结果仅供参考,无法确保100%准确,具体以实际访问为准!
  • +
+ `; + // 弹出确认提示 + layer.confirm(content, { + btn: ['开始检测','取消'], + title: '即将对链接进行批量检测!', + area: ['400px', 'auto'] + + }, function(){ + // 关闭确认提示 + layer.closeAll('dialog'); + // 显示全局加载 + var index = layer.load(1); + $.ajax({ + url: '/index.php?c=api&method=batch_check_links', + type: 'GET', + success: function(response) { + // 请求成功后执行的代码 + if( response.code == 200 ) { + // 关闭全局加载 + layer.close(index); + layer.msg("批量检测成功!",{icon:1}); + // 2s后重新载入页面 + setTimeout(function(){ + location.reload(); + },2000); + } + else{ + layer.msg(response.msg,{icon:5}); + // 关闭全局加载 + layer.close(index); + } + }, + error: function(xhr, status, error) { + layer.close(index); + // 请求出错时执行的代码 + console.log(error); + layer.msg("批量检测失败!",{icon:5}); + } + }); + }, function(){ + // 取消后执行的代码 + }); + return false; + }); + // 提交搜索 form.on('submit(search_keyword)', function(data){ console.log(data.field); @@ -180,8 +241,22 @@ layui.use(['table','form'], function(){ return up_time; } - }} - ,{field: 'weight', title: '权重', width: 75,sort:true,edit: 'text'} + }} + ,{field: 'check_status', title: '状态', width: 80,sort:true,templet:function(d){ + let title = `检测时间:${d.last_checked_time}`; + if(d.check_status == 1) { + return `正常`; + } + else if(d.check_status == 2) { + return `异常`; + } + else if(d.check_status == 3) { + return `未知`; + } + else { + return `未检测`; + } + }} ,{field: 'property', title: '私有', width: 80, sort: true,templet: function(d){ if(d.property == 1) { return ''; @@ -190,6 +265,7 @@ layui.use(['table','form'], function(){ return ''; } }} + ,{field: 'weight', title: '权重', width: 75,sort:true,edit: 'text'} ,{field: 'click', title: '点击数',width:90,sort:true} ,{fixed: 'right', title:'操作', toolbar: '#link_operate'} ]] @@ -252,7 +328,21 @@ function reset_query(){ } }} - ,{field: 'weight', title: '权重', width: 75,sort:true,edit: 'text'} + ,{field: 'check_status', title: '状态', width: 80,sort:true,templet:function(d){ + let title = `检测时间:${d.last_checked_time}`; + if(d.check_status == 1) { + return `正常`; + } + else if(d.check_status == 2) { + return `异常`; + } + else if(d.check_status == 3) { + return `未知`; + } + else { + return `未检测`; + } + }} ,{field: 'property', title: '私有', width: 80, sort: true,templet: function(d){ if(d.property == 1) { return ''; @@ -261,6 +351,7 @@ function reset_query(){ return ''; } }} + ,{field: 'weight', title: '权重', width: 75,sort:true,edit: 'text'} ,{field: 'click', title: '点击数',width:90,sort:true} ,{fixed: 'right', title:'操作', toolbar: '#link_operate'} ]] @@ -268,7 +359,8 @@ function reset_query(){ // 渲染链接列表END }) } - + + \ No newline at end of file diff --git a/templates/admin/setting/subscribe.php b/templates/admin/setting/subscribe.php index 507a6d8..439f993 100755 --- a/templates/admin/setting/subscribe.php +++ b/templates/admin/setting/subscribe.php @@ -61,7 +61,7 @@
- 购买订阅 + 购买订阅
@@ -120,6 +120,12 @@