fix svgs
del doubanAPI
del QQ通知
change lightbox2
This commit is contained in:
浪子 2025-03-15 09:31:21 +08:00
parent cd8738f10e
commit bfc8076867
7 changed files with 9 additions and 136 deletions

26
db.php
View File

@ -1,26 +0,0 @@
<?php
$movie_id = $_GET['id'];
$api_url = "https://api.loliko.cn/movies/{$movie_id}";
$context = stream_context_create([
'http' => [
'ignore_errors' => true,
'timeout' => 10 // 设置10秒超时
]
]);
$response = file_get_contents($api_url, false, $context);
if ($response === FALSE) {
header("HTTP/1.1 500 Internal Server Error");
echo json_encode(['error' => 'Failed to fetch data from API']);
} else {
$responseData = json_decode($response, true);
if (json_last_error() === JSON_ERROR_NONE) {
header('Content-Type: application/json');
echo $response;
} else {
header("HTTP/1.1 500 Internal Server Error");
echo json_encode(['error' => 'Invalid JSON response from API']);
}
}

View File

@ -1,13 +0,0 @@
/**
* ViewImage.min.js 2.0.2
* MIT License - http://www.opensource.org/licenses/mit-license.php
* https://tokinx.github.io/ViewImage/
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(b){return b.raw=b};$jscomp.createTemplateTagFirstArgWithRaw=function(b,a){b.raw=a;return b};$jscomp.arrayIteratorImpl=function(b){var a=0;return function(){return a<b.length?{done:!1,value:b[a++]}:{done:!0}}};$jscomp.arrayIterator=function(b){return{next:$jscomp.arrayIteratorImpl(b)}};$jscomp.makeIterator=function(b){var a="undefined"!=typeof Symbol&&Symbol.iterator&&b[Symbol.iterator];return a?a.call(b):$jscomp.arrayIterator(b)};
$jscomp.arrayFromIterator=function(b){for(var a,d=[];!(a=b.next()).done;)d.push(a.value);return d};$jscomp.arrayFromIterable=function(b){return b instanceof Array?b:$jscomp.arrayFromIterator($jscomp.makeIterator(b))};
(function(){window.ViewImage=new function(){var b=this;this.target="[view-image] img";this.listener=function(a){if(!(a.ctrlKey||a.metaKey||a.shiftKey||a.altKey)){var d=String(b.target.split(",").map(function(g){return g.trim()+":not([no-view])"})),c=a.target.closest(d);if(c){var e=c.closest("[view-image]")||document.body;d=[].concat($jscomp.arrayFromIterable(e.querySelectorAll(d))).map(function(g){return g.href||g.src});b.display(d,c.href||c.src);a.stopPropagation();a.preventDefault()}}};this.init=
function(a){a&&(b.target=a);["removeEventListener","addEventListener"].forEach(function(d){document[d]("click",b.listener,!1)})};this.display=function(a,d){var c=a.indexOf(d),e=(new DOMParser).parseFromString('\n <div class="view-image">\n <style>.view-image{position:fixed;inset:0;z-index:500;padding:1rem;display:flex;flex-direction:column;animation:view-image-in 300ms;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px)}.view-image__out{animation:view-image-out 300ms}@keyframes view-image-in{0%{opacity:0}}@keyframes view-image-out{100%{opacity:0}}.view-image-btn{width:32px;height:32px;display:flex;justify-content:center;align-items:center;cursor:pointer;border-radius:3px;background-color:rgba(255,255,255,0.2)}.view-image-btn:hover{background-color:rgba(255,255,255,0.5)}.view-image-close__full{position:absolute;inset:0;background-color:rgba(48,55,66,0.3);z-index:unset;cursor:zoom-out;margin:0}.view-image-container{height:0;flex:1;display:flex;align-items:center;justify-content:center;}.view-image-lead{display:contents}.view-image-lead img{position:relative;z-index:1;max-width:100%;max-height:100%;object-fit:contain;border-radius:3px}.view-image-lead__in img{animation:view-image-lead-in 300ms}.view-image-lead__out img{animation:view-image-lead-out 300ms forwards}@keyframes view-image-lead-in{0%{opacity:0;transform:translateY(-20px)}}@keyframes view-image-lead-out{100%{opacity:0;transform:translateY(20px)}}[class*=__out] ~ .view-image-loading{display:block}.view-image-loading{position:absolute;inset:50%;width:8rem;height:2rem;color:#aab2bd;overflow:hidden;text-align:center;margin:-1rem -4rem;z-index:1;display:none}.view-image-loading::after{content:"";position:absolute;inset:50% 0;width:100%;height:3px;background:rgba(255,255,255,0.5);transform:translateX(-100%) translateY(-50%);animation:view-image-loading 800ms -100ms ease-in-out infinite}@keyframes view-image-loading{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}.view-image-tools{position:relative;display:flex;justify-content:space-between;align-content:center;color:#fff;max-width:600px;position: absolute; bottom: 5%; left: 1rem; right: 1rem; backdrop-filter: blur(10px);margin:0 auto;padding:10px;border-radius:5px;background:rgba(0,0,0,0.1);margin-bottom:constant(safe-area-inset-bottom);margin-bottom:env(safe-area-inset-bottom);z-index:1}.view-image-tools__count{width:60px;display:flex;align-items:center;justify-content:center}.view-image-tools__flip{display:flex;gap:10px}.view-image-tools [class*=-close]{margin:0 10px}</style>\n <div class="view-image-container">\n <div class="view-image-lead"></div>\n <div class="view-image-loading"></div>\n <div class="view-image-close view-image-close__full"></div>\n </div>\n <div class="view-image-tools">\n <div class="view-image-tools__count">\n <span><b class="view-image-index">'+
(c+1)+"</b>/"+a.length+'</span>\n </div>\n <div class="view-image-tools__flip">\n <div class="view-image-btn view-image-tools__flip-prev">\n <svg width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M31 36L19 24L31 12" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>\n </div>\n <div class="view-image-btn view-image-tools__flip-next">\n <svg width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M19 12L31 24L19 36" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>\n </div>\n </div>\n <div class="view-image-btn view-image-close">\n <svg width="16" height="16" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M8 8L40 40" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 40L40 8" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>\n </div>\n </div>\n </div>\n ',
"text/html").body.firstChild,g=function(f){var h={Escape:"close",ArrowLeft:"tools__flip-prev",ArrowRight:"tools__flip-next"};h[f.key]&&e.querySelector(".view-image-"+h[f.key]).click()},l=function(f){var h=new Image,k=e.querySelector(".view-image-lead");k.className="view-image-lead view-image-lead__out";setTimeout(function(){k.innerHTML="";h.onload=function(){setTimeout(function(){k.innerHTML='<img src="'+h.src+'" alt="ViewImage" no-view/>';k.className="view-image-lead view-image-lead__in"},100)};
h.src=f},300)};document.body.appendChild(e);l(d);window.addEventListener("keydown",g);e.onclick=function(f){f.target.closest(".view-image-close")?(window.removeEventListener("keydown",g),e.onclick=null,e.classList.add("view-image__out"),setTimeout(function(){return e.remove()},290)):f.target.closest(".view-image-tools__flip")&&(c=f.target.closest(".view-image-tools__flip-prev")?0===c?a.length-1:c-1:c===a.length-1?0:c+1,l(a[c]),e.querySelector(".view-image-index").innerHTML=c+1)}}}})();

View File

@ -51,10 +51,6 @@ function themeConfig($form) {
array('0'=> _t('否'), '1'=> _t('是')),
'0', _t('是否显示页面加载时间'), _t('选择“是”将在页脚显示加载时间。'));
$form->addInput($showtime);
$qqboturl = new Typecho_Widget_Helper_Form_Element_Text('qqboturl', NULL, 'https://bot.asbid.cn', _t('QQ机器人API,保持默认则需添加 2280858259 为好友'), _t('基于cqhttp,有评论时QQ通知'));
$form->addInput($qqboturl);
$qqnum = new Typecho_Widget_Helper_Form_Element_Text('qqnum', NULL, '122790336', _t('QQ号码'), _t('用于接收QQ通知的号码'));
$form->addInput($qqnum);
}
function get_post_view($archive) {
$cid = $archive->cid;
@ -137,63 +133,6 @@ function getPermalinkFromCoid($coid) {
if (empty($row)) return '';
return '<a href="#comment-'.$coid.'" style="text-decoration: none;">@'.$row['author'].'</a>';
}
// 评论提交通知函数
function notifyQQBot($comment) {
$options = Helper::options();
// 检查评论是否已经审核通过
if ($comment->status != "approved") {
error_log('Comment is not approved.');
return;
}
// 获取配置中的QQ机器人API地址
$cq_url = $options->qqboturl;
// 检查API地址是否为空
if (empty($cq_url)) {
error_log('QQ Bot URL is empty. Using default URL.');
$cq_url = 'https://bot.asbid.cn';
}
// 获取QQ号码
$qqnum = $options->qqnum;
// 检查QQ号码是否为空
if (empty($qqnum)) {
error_log('QQ number is empty.');
return;
}
// 如果是管理员自己发的评论则不发送通知
if ($comment->authorId === $comment->ownerId) {
error_log('This comment is by the post owner.');
return;
}
// 构建消息内容
$msg = '「' . $comment->author . '」在文章《' . $comment->title . '》中发表了评论!';
$msg .= "\n评论内容:\n{$comment->text}\n永久链接地址:{$comment->permalink}";
// 准备发送消息的数据
$_message_data_ = [
'user_id' => (int) trim($qqnum),
'message' => str_replace(["\r\n", "\r", "\n"], "\r\n", htmlspecialchars_decode(strip_tags($msg)))
];
// 输出调试信息
error_log('Sending message to QQ Bot: ' . print_r($_message_data_, true));
// 初始化Curl请求
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "{$cq_url}/send_msg?" . http_build_query($_message_data_, '', '&'),
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 0
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
error_log('Curl error: ' . curl_error($ch));
} else {
error_log('Response: ' . $response);
}
curl_close($ch);
}
Typecho_Plugin::factory('Widget_Feedback')->finishComment = 'notifyQQBot';
/**
* 图片灯箱
@ -434,25 +373,3 @@ function commentApprove($widget, $email = NULL)
}
return $result;
}
/** 获取评论者地址 */
//function get_ip_location($ip) {
// $apiUrl = "https://www.nazo.run/ip/{$ip}";
// $response = file_get_contents($apiUrl);
// $data = json_decode($response, true);
//
// if ($data && $data['code'] == 0) {
// return array(
// 'country' => $data['data']['country'],
// 'region' => $data['data']['region'],
// 'city' => $data['data']['city']
// );
// }
//}
//function display_location($location) {
// echo htmlspecialchars($location['country'] ?? 'Unknown') . ' ' .
// htmlspecialchars($location['region'] ?? ' ') . ' ' .
// htmlspecialchars($location['city'] ?? ' ');
//}

View File

@ -13,7 +13,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
</header>
<section class="category--list">
<?php $this->widget('Widget_Metas_Category_List')->to($categories); ?>
<?php while($categories->next()): ?>
<?php while($categories->next()): ?>
<?php
// 获取分类 ID
$categoryId = $categories->mid;
@ -30,7 +30,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endwhile; ?>
</section>
</div>
<?php $this->need('footer.php'); ?>

View File

@ -14,7 +14,8 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<article class="post--single">
<?php $tooot = $this->fields->tooot ? $this->fields->tooot : 'https://bbapi.ima.cm'; ?>
<script src="<?php $this->options->themeUrl('/dist/js/marked.min.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('/dist/js/view-image.min.js'); ?>"></script>
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/lightbox.min.css'); ?>">
<script src="<?php $this->options->themeUrl('/dist/js/lightbox-plus-jquery.min.js'); ?>"></script>
<div id="tooot"></div>
<div class="nav-links" id="loadmore">
<span class="loadmore">加载更多</span>
@ -41,7 +42,7 @@ window.onload = function() {
if (media_attachments.length > 0) {
media_attachments.forEach(attachment => {
if (attachment.type === 'image') {
mediaHTML += `<a href="${attachment.url}" target="_blank"><img src="${attachment.preview_url}" class="thumbnail-image img" ></a>`;
mediaHTML += `<a href="${attachment.url}" target="_blank" data-lightbox="image-set"><img src="${attachment.preview_url}" class="thumbnail-image img" ></a>`;
}
});
}
@ -64,7 +65,6 @@ window.onload = function() {
});
return htmlString;
}
function fetchToots() {
return fetch('<?php echo $tooot; ?>')
.then(response => response.json())
@ -73,7 +73,6 @@ window.onload = function() {
return [];
});
}
function fetchAndDisplayToots() {
fetchToots().then(data => {
const memosContainer = document.getElementById('tooot');
@ -86,15 +85,11 @@ window.onload = function() {
}
});
}
// 在页面加载完成后获取并展示 toots
fetchAndDisplayToots();
// 绑定“加载更多”按钮的点击事件
document.getElementById('loadmore').addEventListener('click', fetchAndDisplayToots);
};
window.ViewImage && ViewImage.init('.content img');
</script>
<style>
div pre code {

View File

@ -19,7 +19,8 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
?>
<article class="post--single">
<script src="<?php $this->options->themeUrl('/dist/js/marked.min.js'); ?>"></script>
<script src="<?php $this->options->themeUrl('/dist/js/view-image.min.js'); ?>"></script>
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/lightbox.min.css'); ?>">
<script src="<?php $this->options->themeUrl('/dist/js/lightbox-plus-jquery.min.js'); ?>"></script>
<div id="talk"></div>
<div class="nav-links" id="loadmore">
<span class="loadmore">加载更多</span>
@ -82,7 +83,7 @@ function Format(item) {
content = text.replace(/\[(.*?)\]\((.*?)\)/g, `<a href="$2" target="_blank">$1</a>`);
if (imgs) {
content += `<div class="resimg">`
imgs.forEach(e => content += `<a href="${e}" class="img" data-thumb="${e}"><img class="no-lazyload thumbnail-image" src="${e}"></a>`
imgs.forEach(e => content += `<a href="${e}" class="img" data-thumb="${e}" data-lightbox="images"><img class="no-lazyload thumbnail-image" src="${e}"></a>`
)
content += '</div>'
}
@ -114,7 +115,6 @@ document.getElementById('loadmore').addEventListener('click', function() {
loadMemos(currentPage);
});
window.ViewImage && ViewImage.init('.content img');
</script>
<style>
div pre code {

View File

@ -288,7 +288,7 @@ document.addEventListener('DOMContentLoaded', function() {
const url = link.href;
const movieId = url.match(/subject\/(\d+)/)[1];
link.innerHTML += ' <span class="loading">(加载中...)</span>';
fetchWithRetry(`<?php $this->options->themeUrl('db.php'); ?>?id=${movieId}`)
fetchWithRetry(`https://api.loliko.cn/movies/${movieId}`)
.then(data => {
const movieInfo = createMovieInfoHTML(data, url);
const wrapper = document.createElement('div');