mirror of
https://github.com/jkjoy/typecho-theme-farallon.git
synced 2026-08-13 01:39:16 +00:00
Compare commits
7 Commits
0.6.2
..
458fad51bb
| Author | SHA1 | Date | |
|---|---|---|---|
| 458fad51bb | |||
| f1b8c138ac | |||
| 0289493b1d | |||
| b98790a646 | |||
| dbe59a80de | |||
| 5edbf772c7 | |||
| 0f64cc9bba |
+18
-19
@@ -1,7 +1,8 @@
|
||||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
<div class="post--ingle__comments">
|
||||
<?php $this->comments()->to($comments); ?>
|
||||
<?php if($this->allow('comment') && stripos($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'zh') > -1): ?>
|
||||
<?php $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
|
||||
if($this->allow('comment') && stripos($language, 'zh') > -1): ?>
|
||||
<?php if ($this->is('attachment')) : ?>
|
||||
<?php else: ?>
|
||||
<h3 class="comments--title" id="comments">
|
||||
@@ -49,8 +50,7 @@
|
||||
<?php if ($comments->have()): ?>
|
||||
<?php $comments->listComments(); ?>
|
||||
|
||||
<?php
|
||||
$comments->pageNav(
|
||||
<?php $comments->pageNav(
|
||||
' ',
|
||||
' ',
|
||||
1,
|
||||
@@ -92,31 +92,31 @@ function threadedComments($comments, $options) {
|
||||
}
|
||||
echo $commentClass;
|
||||
?>">
|
||||
<?php $commentApprove = commentApprove($comments, $comments->mail); ?>
|
||||
<div class="comment-body" id="<?php $comments->theId(); ?>">
|
||||
<div class="comment-meta">
|
||||
<div class="comment--avatar">
|
||||
<?php if ($comments->url): ?>
|
||||
<a href="<?php echo $comments->url ?>" target="_blank" rel="external nofollow"><?php echo $comments->gravatar('40', ''); ?> </a>
|
||||
<a href="<?php echo $comments->url ?>" target="_blank" rel="external nofollow" title=" <?php echo $commentApprove['userDesc']; ?> ">
|
||||
<?php echo $comments->gravatar('40', ''); ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<?php echo $comments->gravatar('40', ''); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="comment--meta">
|
||||
<div class="comment--author"><?php echo $comments->author; ?>
|
||||
<div class="comment--author">
|
||||
<span style="color: <?php echo $commentApprove['bgColor']; ?>;">
|
||||
<p class="tooltip" data-tooltip=" <?php echo $commentApprove['userLevel']; ?> ">
|
||||
<?php echo $comments->author; ?>
|
||||
</p>
|
||||
</span>
|
||||
<span class="dot"></span>
|
||||
<?php $commentApprove = commentApprove($comments, $comments->mail); ?>
|
||||
<span style="color: <?php echo $commentApprove['bgColor']; ?>;">
|
||||
<?php echo $commentApprove['userLevel']; ?>
|
||||
</span>
|
||||
<span class="dot"></span>
|
||||
<div class="comment--time"><?php $comments->date('Y-m-d H:i'); ?></div>
|
||||
<span class="dot"></span>
|
||||
<!-- <span class="dot"></span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M12 20.8995L16.9497 15.9497C19.6834 13.2161 19.6834 8.78392 16.9497 6.05025C14.2161 3.31658 9.78392 3.31658 7.05025 6.05025C4.31658 8.78392 4.31658 13.2161 7.05025 15.9497L12 20.8995ZM12 23.7279L5.63604 17.364C2.12132 13.8492 2.12132 8.15076 5.63604 4.63604C9.15076 1.12132 14.8492 1.12132 18.364 4.63604C21.8787 8.15076 21.8787 13.8492 18.364 17.364L12 23.7279ZM12 13C13.1046 13 14 12.1046 14 11C14 9.89543 13.1046 9 12 9C10.8954 9 10 9.89543 10 11C10 12.1046 10.8954 13 12 13ZM12 15C9.79086 15 8 13.2091 8 11C8 8.79086 9.79086 7 12 7C14.2091 7 16 8.79086 16 11C16 13.2091 14.2091 15 12 15Z"></path></svg>
|
||||
<?php
|
||||
$ip = $comments->ip; // Ensure this is the correct property for IP
|
||||
$location = get_ip_location($ip);
|
||||
echo htmlspecialchars($location['country']);
|
||||
?>
|
||||
-->
|
||||
<?php //$ip = $comments->ip; $location = get_ip_location($ip); display_location($location); ?>
|
||||
<span class="comment-reply-link u-cursorPointer">
|
||||
<?php $comments->reply('<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true" class="" ><g><path d="M12 3.786c-4.556 0-8.25 3.694-8.25 8.25s3.694 8.25 8.25 8.25c1.595 0 3.081-.451 4.341-1.233l1.054 1.7c-1.568.972-3.418 1.534-5.395 1.534-5.661 0-10.25-4.589-10.25-10.25S6.339 1.786 12 1.786s10.25 4.589 10.25 10.25c0 .901-.21 1.77-.452 2.477-.592 1.731-2.343 2.477-3.917 2.334-1.242-.113-2.307-.74-3.013-1.647-.961 1.253-2.45 2.011-4.092 1.78-2.581-.363-4.127-2.971-3.76-5.578.366-2.606 2.571-4.688 5.152-4.325 1.019.143 1.877.637 2.519 1.342l1.803.258-.507 3.549c-.187 1.31.761 2.509 2.079 2.629.915.083 1.627-.356 1.843-.99.2-.585.345-1.224.345-1.83 0-4.556-3.694-8.25-8.25-8.25zm-.111 5.274c-1.247-.175-2.645.854-2.893 2.623-.249 1.769.811 3.143 2.058 3.319 1.247.175 2.645-.854 2.893-2.623.249-1.769-.811-3.144-2.058-3.319z"></path></g></svg>'); ?>
|
||||
</span>
|
||||
@@ -124,8 +124,7 @@ function threadedComments($comments, $options) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="comment-content">
|
||||
<?php if ($comments->parent) {echo getPermalinkFromCoid($comments->parent);}?>
|
||||
<?php $comments->content(); ?>
|
||||
<?php if ($comments->parent) {echo getPermalinkFromCoid($comments->parent);} $comments->content();?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($comments->children) { ?>
|
||||
@@ -134,4 +133,4 @@ function threadedComments($comments, $options) {
|
||||
</ol>
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
.neodb-container{--db-item-width:150px;--db-item-height:180px;--db-music-width:150px;--db-music-height:150px;--db-primary-color:var(--farallon-hover-color);--db-background-white:var(--farallon-background-white);--db-background-gray:var(--farallon-background-gray);--db-border-color:var(--farallon-border-color);--db-text-light:var(--farallon-text-light);}.neodb-nav{padding:30px 0 20px;display:flex;align-items:center;flex-wrap:wrap;}.neodb-navItem{font-size:20px;cursor:pointer;border-bottom:1px solid rgba(0,0,0,0);transition:0.5s border-color;display:flex;align-items:center;text-transform:capitalize;}.neodb-navItem.current,.neodb-navItem:hover{border-color:inherit;}.neodb-navItem{margin-right:20px;}.neodb-score svg{fill:#f5c518;margin-right:5px;}.neodb-list{display:flex;align-items:flex-start;flex-wrap:wrap;}.neodb-image{width:var(--db-item-width);height:var(--db-item-height);object-fit:cover;border-radius:4px;}.neodb-image:hover{box-shadow:0 0 10px var(--db-border-color);}.neodb-title{margin-top:2px;font-size:14px;line-height:1.4;}.neodb-title a:hover{color:var(--db-primary-color);text-decoration:underline;}.neodb-genreItem{background:var(--db-background-gray);font-size:12px;padding:5px 12px;border-radius:4px;margin-right:6px;margin-bottom:10px;line-height:1.4;cursor:pointer;}.neodb-genreItem.is-active,.neodb-genreItem:hover{background-color:var(--db-primary-color);color:var(--db-background-white);}.neodb-genres{padding-bottom:15px;display:flex;flex-wrap:wrap;}.neodb-genres.u-hide + .neodb-list{padding-top:10px;}.neodb-score{display:flex;align-items:center;font-size:14px;color:var(--db-text-light);}.neodb-item{width:var(--db-item-width);margin-right:20px;margin-bottom:20px;position:relative;}.neodb-item__music img{width:var(--db-music-width);height:var(--db-music-height);object-fit:cover;}.neodb-date{position:relative;font-size:20px;color:var(--farallon-text-light);font-weight:900;line-height:1;}.neodb-date::before{content:"";position:absolute;top:0.5em;bottom:-2px;left:-10px;width:3.4em;z-index:-1;background:var(--farallon-hover-color);opacity:0.3;transform:skew(-35deg);transition:opacity 0.2s ease;border-radius:3px 8px 10px 6px;}.neodb-date{margin-top:30px;margin-bottom:10px;}.neodb-dateList{padding-left:15px;padding-top:5px;padding-right:15px;}.neodb-card__list{display:flex;align-items:center;padding:15px 0;border-bottom:1px dotted var(--farallon-border-color);font-size:14px;color:rgba(0,0,0,0.55);}.neodb-card__list:last-child{border-bottom:0;}.neodb-card__list .title{font-size:18px;margin-bottom:5px;}.neodb-card__list .rating{margin:0 0 0px;font-size:14px;line-height:1;display:flex;align-items:center;}.neodb-card__list .rating .allstardark{position:relative;color:#f99b01;height:16px;width:80px;background-repeat:repeat;background-image:url("../images/star.svg");background-size:auto 100%;margin-right:5px;}.neodb-card__list .rating .allstarlight{position:absolute;left:0;color:#f99b01;height:16px;overflow:hidden;background-repeat:repeat;background-image:url("../images/star-fill.svg");background-size:auto 100%;}.neodb-card__list img{width:80px;border-radius:4px;height:80px;object-fit:cover;flex:0 0 auto;margin-right:15px;}.neodb-titleDate{display:flex;flex-direction:column;line-height:1.1;margin-bottom:10px;flex:0 0 auto;margin-right:15px;align-items:center;}.neodb-titleDate__day{font-weight:900;font-size:44px;}.neodb-titleDate__month{font-size:14px;color:var(--farallon-text-light);font-weight:900;}.neodb-list__card{display:block;}.neodb-dateList__card{display:flex;flex-wrap:wrap;align-items:flex-start;}.neodb-listBydate{display:flex;align-items:flex-start;margin-top:15px;}@media (max-width:600px){.neodb-listBydate{flex-direction:column;}}
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -17,7 +17,7 @@
|
||||
is_single = false;
|
||||
post_id = 0;
|
||||
is_archive = false;
|
||||
VERSION = "0.6.2";
|
||||
VERSION = "0.6.3";
|
||||
constructor() {
|
||||
super();
|
||||
this.initCopyright();
|
||||
|
||||
Vendored
+142
@@ -0,0 +1,142 @@
|
||||
class NeoDB {
|
||||
constructor(config) {
|
||||
this.container = config.container;
|
||||
this.types = config.types ?? ["book", "movie", "tv", "music", "game", "podcast"];
|
||||
this.baseAPI = config.baseAPI;
|
||||
this.type = "movie";
|
||||
this.status = "complete";
|
||||
this.finished = false;
|
||||
this.paged = 1;
|
||||
this.subjects = [];
|
||||
this._create();
|
||||
}
|
||||
|
||||
on(event, element, callback) {
|
||||
const nodeList = document.querySelectorAll(element);
|
||||
nodeList.forEach((item) => {
|
||||
item.addEventListener(event, callback);
|
||||
});
|
||||
}
|
||||
|
||||
_handleTypeClick() {
|
||||
this.on("click", ".neodb-navItem", (t) => {
|
||||
const self = t.currentTarget;
|
||||
if (self.classList.contains("current")) return;
|
||||
this.type = self.dataset.type;
|
||||
document.querySelector(".neodb-list").innerHTML = "";
|
||||
document.querySelector(".lds-ripple").classList.remove("u-hide");
|
||||
document.querySelector(".neodb-navItem.current").classList.remove("current");
|
||||
self.classList.add("current");
|
||||
this.paged = 1;
|
||||
this.finished = false;
|
||||
this.subjects = [];
|
||||
this._fetchData();
|
||||
});
|
||||
}
|
||||
|
||||
_renderTypes() {
|
||||
document.querySelector(".neodb-nav").innerHTML = this.types
|
||||
.map((item) => {
|
||||
return `<span class="neodb-navItem${
|
||||
this.type == item ? " current" : ""
|
||||
}" data-type="${item}">${item}</span>`;
|
||||
})
|
||||
.join("");
|
||||
this._handleTypeClick();
|
||||
}
|
||||
|
||||
_fetchData() {
|
||||
const params = new URLSearchParams({
|
||||
type: "complete",
|
||||
category: this.type,
|
||||
page: this.paged.toString(),
|
||||
});
|
||||
|
||||
return fetch(this.baseAPI + "?" + params.toString())
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
if (data.length) {
|
||||
// 过滤重复项
|
||||
data = data.filter(item => !this.subjects.some(existing => existing.item.id === item.item.id));
|
||||
|
||||
if (data.length) {
|
||||
this.subjects = [...this.subjects, ...data];
|
||||
this._renderListTemplate();
|
||||
}
|
||||
|
||||
document.querySelector(".lds-ripple").classList.add("u-hide");
|
||||
} else {
|
||||
this.finished = true; // 没有更多数据
|
||||
document.querySelector(".lds-ripple").classList.add("u-hide");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_renderListTemplate() {
|
||||
document.querySelector(".neodb-list").innerHTML = this.subjects
|
||||
.map((item) => {
|
||||
const coverImage = item.item.cover_image_url;
|
||||
const title = item.item.title;
|
||||
const rating = item.item.rating;
|
||||
const link = item.item.id;
|
||||
|
||||
return `<div class="neodb-item">
|
||||
<img src="${coverImage}" referrerpolicy="no-referrer" class="neodb-image">
|
||||
<div class="neodb-score">
|
||||
${rating ? `<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 20.1l5.82 3.682c1.066.675 2.37-.322 2.09-1.584l-1.543-6.926 5.146-4.667c.94-.85.435-2.465-.799-2.567l-6.773-.602L13.29.89a1.38 1.38 0 0 0-2.581 0l-2.65 6.53-6.774.602C.052 8.126-.453 9.74.486 10.59l5.147 4.666-1.542 6.926c-.28 1.262 1.023 2.26 2.09 1.585L12 20.099z"></path></svg>${rating}` : ""}
|
||||
</div>
|
||||
<div class="neodb-title">
|
||||
<a href="${link}" target="_blank">${title}</a>
|
||||
</div>
|
||||
|
||||
</div>`;
|
||||
})
|
||||
.join("");
|
||||
}
|
||||
|
||||
_handleScroll() {
|
||||
let isLoading = false; // 标志位,表示是否正在加载数据
|
||||
let lastScrollTop = 0; // 上一次的滚动位置
|
||||
|
||||
window.addEventListener("scroll", () => {
|
||||
const scrollY = window.scrollY || window.pageYOffset;
|
||||
const moreElement = document.querySelector(".block-more");
|
||||
|
||||
// 检查滚动到底部的条件
|
||||
if (
|
||||
moreElement.offsetTop + moreElement.clientHeight <= scrollY + window.innerHeight &&
|
||||
document.querySelector(".lds-ripple").classList.contains("u-hide") &&
|
||||
!this.finished &&
|
||||
!isLoading // 确保没有正在加载数据
|
||||
) {
|
||||
isLoading = true; // 设置标志位为 true,表示正在加载数据
|
||||
document.querySelector(".lds-ripple").classList.remove("u-hide");
|
||||
this.paged++;
|
||||
this._fetchData().finally(() => {
|
||||
isLoading = false; // 数据加载完成后,重置标志位
|
||||
});
|
||||
}
|
||||
|
||||
// 更新上一次的滚动位置
|
||||
lastScrollTop = scrollY;
|
||||
});
|
||||
}
|
||||
|
||||
_create() {
|
||||
if (document.querySelector(".neodb-container")) {
|
||||
const container = document.querySelector(this.container);
|
||||
if (!container) return;
|
||||
container.innerHTML = `
|
||||
<nav class="neodb-nav"></nav>
|
||||
<div class="neodb-list"></div>
|
||||
<div class="block-more block-more__centered">
|
||||
<div class="lds-ripple"></div>
|
||||
</div>
|
||||
`;
|
||||
this._renderTypes();
|
||||
this._fetchData();
|
||||
this._handleScroll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+23
-37
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||
require_once 'qqwry.php';
|
||||
function themeConfig($form) {
|
||||
$logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点 LOGO 地址'));
|
||||
$form->addInput($logoUrl);
|
||||
@@ -336,41 +335,25 @@ function commentApprove($widget, $email = NULL)
|
||||
"commentNum" => 0//评论数量
|
||||
);
|
||||
if (empty($email)) return $result;
|
||||
|
||||
$result['state'] = 1;
|
||||
$master = array(
|
||||
'基友邮箱1@qq.com',
|
||||
'基友邮箱1@qq.com'
|
||||
);
|
||||
$result['state'] = 1;
|
||||
if ($widget->authorId == $widget->ownerId) {
|
||||
$result['isAuthor'] = 1;
|
||||
$result['userLevel'] = '博主';
|
||||
$result['userDesc'] = '很帅的博主';
|
||||
$result['userLevel'] = '作者';
|
||||
$result['userDesc'] = '博主';
|
||||
$result['bgColor'] = '#FFD700';
|
||||
$result['commentNum'] = 999;
|
||||
} else if (in_array($email, $master)) {
|
||||
$result['userLevel'] = '基友';
|
||||
$result['userDesc'] = '很帅的基友';
|
||||
$result['bgColor'] = '#65C186';
|
||||
$result['commentNum'] = 888;
|
||||
} else {
|
||||
//数据库获取
|
||||
$db = Typecho_Db::get();
|
||||
//获取评论条数
|
||||
$commentNumSql = $db->fetchAll($db->select(array('COUNT(cid)'=>'commentNum'))
|
||||
->from('table.comments')
|
||||
->where('mail = ?', $email));
|
||||
$commentNum = $commentNumSql[0]['commentNum'];
|
||||
|
||||
//获取友情链接
|
||||
$linkSql = $db->fetchAll($db->select()->from('table.links')
|
||||
->where('user = ?',$email));
|
||||
|
||||
//等级判定
|
||||
if($commentNum==1){
|
||||
$result['userLevel'] = '初识';
|
||||
$result['bgColor'] = '#999999';
|
||||
$userDesc = '你已经向目的地迈出了第一步!';
|
||||
$userDesc = '初来乍到的新朋友';
|
||||
} else {
|
||||
if ($commentNum<3 && $commentNum>1) {
|
||||
$result['userLevel'] = '初识';
|
||||
@@ -391,7 +374,7 @@ function commentApprove($widget, $email = NULL)
|
||||
$result['userLevel'] = '老铁';
|
||||
$result['bgColor'] = '#A0DAD0';
|
||||
}
|
||||
$userDesc = '你已经向目的地前进了'.$commentNum.'步!';
|
||||
$userDesc = '已有'.$commentNum.'条评论';
|
||||
}
|
||||
if($linkSql){
|
||||
$result['userLevel'] = '博友';
|
||||
@@ -405,19 +388,22 @@ function commentApprove($widget, $email = NULL)
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/** 获取评论者地址 */
|
||||
function get_ip_location($ip) {
|
||||
$qqwry = new QQWry(__DIR__ . '/dist/qqwry.dat');
|
||||
$detail = $qqwry->getDetail($ip);
|
||||
if ($detail) {
|
||||
// Assuming dataA is country and dataB is province
|
||||
return array(
|
||||
'country' => $detail['dataA']
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
'country' => 'Unknown'
|
||||
);
|
||||
}
|
||||
}
|
||||
//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'] ?? ' ');
|
||||
//}
|
||||
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="zh-CN">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 一款单栏主题. 移植自HUGO主题 Farallon 原作者 bigfa
|
||||
* @package Farallon
|
||||
* @author 老孙
|
||||
* @version 0.6.2
|
||||
* @version 0.6.3
|
||||
* @link https://www.imsun.org
|
||||
*/
|
||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/**
|
||||
* 文章归档
|
||||
*
|
||||
@@ -20,7 +20,8 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
$output = '<div class="archives">'; // Start archives container
|
||||
while ($archives->next()) {
|
||||
$year_tmp = date('Y', $archives->created);
|
||||
$mon_tmp = date('m', $archives->created);
|
||||
$mon_tmp = date('m', $archives->created);
|
||||
|
||||
// 检查是否需要新的年份标题
|
||||
if ($year != $year_tmp) {
|
||||
if ($year > 0) {
|
||||
@@ -28,7 +29,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
}
|
||||
$year = $year_tmp;
|
||||
$mon = 0; // 重置月份
|
||||
$output .= '<div class="archive-year"><h2 class="archive--title__year">' . $year . '</h2>'; // 开始新的年份div
|
||||
$output .= '<div class="archive-year"><h2 class="archive--title__year">' . $year . '年</h2>'; // 开始新的年份div
|
||||
}
|
||||
// 检查是否需要新的月份标题
|
||||
if ($mon != $mon_tmp) {
|
||||
@@ -36,7 +37,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
$output .= '</ul>'; // 结束上一个月份的列表
|
||||
}
|
||||
$mon = $mon_tmp;
|
||||
$output .= '<h3 class="archive--title__month"></h3>';// '. $mon . '
|
||||
$output .= '<h3 class="archive--title__month">' . $mon . '月</h3>';
|
||||
$output .= '<ul class="archive--list">'; // 开始新的月份列表
|
||||
}
|
||||
// 输出文章项
|
||||
@@ -56,5 +57,4 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
?>
|
||||
</div>
|
||||
</section>
|
||||
<?php $this->need('footer.php'); ?>
|
||||
|
||||
<?php $this->need('footer.php'); ?>
|
||||
+16
-4
@@ -24,10 +24,18 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
window.onload = function() {
|
||||
let offset = 0; // 初始偏移量
|
||||
const limit = 20; // 每次加载的数量
|
||||
|
||||
function formatHTML(toots) {
|
||||
let htmlString = '';
|
||||
toots.forEach(toot => {
|
||||
const { content, account, url, created_at, media_attachments} = toot;
|
||||
// 判断是否存在 reblog
|
||||
const isReblog = toot.reblog && toot.reblog.content;
|
||||
const content = isReblog ? toot.reblog.content : toot.content;
|
||||
const url = isReblog ? toot.reblog.url : toot.url;
|
||||
const account = isReblog ? toot.reblog.account : toot.account;
|
||||
const created_at = isReblog ? toot.reblog.created_at : toot.created_at;
|
||||
const media_attachments = isReblog ? toot.reblog.media_attachments : toot.media_attachments;
|
||||
|
||||
let mediaHTML = ''; // 初始化资源相关HTML为空字符串
|
||||
// 处理媒体附件
|
||||
if (media_attachments.length > 0) {
|
||||
@@ -56,6 +64,7 @@ window.onload = function() {
|
||||
});
|
||||
return htmlString;
|
||||
}
|
||||
|
||||
function fetchToots() {
|
||||
return fetch('<?php echo $tooot; ?>')
|
||||
.then(response => response.json())
|
||||
@@ -64,6 +73,7 @@ window.onload = function() {
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
||||
function fetchAndDisplayToots() {
|
||||
fetchToots().then(data => {
|
||||
const memosContainer = document.getElementById('tooot');
|
||||
@@ -76,18 +86,20 @@ window.onload = function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 在页面加载完成后获取并展示 toots
|
||||
fetchAndDisplayToots();
|
||||
|
||||
// 绑定“加载更多”按钮的点击事件
|
||||
document.getElementById('loadmore').addEventListener('click', fetchAndDisplayToots);
|
||||
};
|
||||
|
||||
window.ViewImage && ViewImage.init('.content img');
|
||||
</script>
|
||||
<style>
|
||||
div pre code {
|
||||
/* 迫使文字断行 */
|
||||
white-space: pre-wrap; /* CSS3 */
|
||||
word-wrap: break-word; /* 老版本的浏览器 */
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-all;
|
||||
word-break: break-word;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Neodb 页面
|
||||
*
|
||||
* @package custom
|
||||
*/
|
||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
<?php $this->need('header.php'); ?>
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/neodb.css'); ?>">
|
||||
<script src="<?php $this->options->themeUrl('/dist/js/neodb.js'); ?>"></script>
|
||||
<section class="site--main">
|
||||
<header class="archive--header">
|
||||
<h1 class="post--single__title"><?php $this->title() ?></h1>
|
||||
<h2 class="post--single__subtitle"><?php $this->content(); ?></h2>
|
||||
</header>
|
||||
<div class="site--main">
|
||||
<div class="neodb-container"></div>
|
||||
<?php $neodb = $this->fields->neodb ? $this->fields->neodb : 'https://neodb.imsun.org'; ?>
|
||||
<script>
|
||||
const neodb = new NeoDB({
|
||||
container: ".neodb-container",
|
||||
baseAPI: "<?php echo $neodb; ?>/api",
|
||||
types: ["book", "movie", "tv", "music", "game"],
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</section>
|
||||
<?php $this->need('footer.php'); ?>
|
||||
@@ -1,164 +0,0 @@
|
||||
<?php
|
||||
// 数据来源:纯真IP数据库 qqwry.dat
|
||||
// 初始化类:new QQWry($fileName)
|
||||
// 请求方式:getDetail($ip)
|
||||
// 返回格式:
|
||||
// {
|
||||
// "beginIP": IP段起始点
|
||||
// "endIP": IP段结束点
|
||||
// "dataA": 数据段1
|
||||
// "dataB": 数据段2
|
||||
// }
|
||||
//
|
||||
// 请求版本:getVersion()
|
||||
// 返回格式:YYYYMMDD
|
||||
|
||||
class QQWry {
|
||||
private $fp; // 文件指针
|
||||
private $firstRecord; // 第一条记录的偏移地址
|
||||
private $lastRecord; // 最后一条记录的偏移地址
|
||||
private $recordNum; // 总记录条数
|
||||
|
||||
public function __construct($fileName) { // 构造函数
|
||||
$this->fp = fopen($fileName, 'rb');
|
||||
$this->firstRecord = $this->read4byte();
|
||||
$this->lastRecord = $this->read4byte();
|
||||
$this->recordNum = ($this->lastRecord - $this->firstRecord) / 7; // 每条索引长度为7字节
|
||||
}
|
||||
|
||||
public function __destruct() { // 析构函数
|
||||
if ($this->fp) {
|
||||
fclose($this->fp);
|
||||
}
|
||||
}
|
||||
|
||||
private function read4byte() { // 读取4字节并转为long
|
||||
return unpack('Vlong', fread($this->fp, 4))['long'];
|
||||
}
|
||||
|
||||
private function read3byte() { // 读取3字节并转为long
|
||||
return unpack('Vlong', fread($this->fp, 3) . chr(0))['long'];
|
||||
}
|
||||
|
||||
private function readString() { // 读取字符串
|
||||
$str = '';
|
||||
$char = fread($this->fp, 1);
|
||||
while (ord($char) != 0) { // 读到二进制0结束
|
||||
$str .= $char;
|
||||
$char = fread($this->fp, 1);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function zipIP($ip) { // IP地址转为数字
|
||||
$ip_arr = explode('.', $ip);
|
||||
$tmp = (16777216 * intval($ip_arr[0])) + (65536 * intval($ip_arr[1])) + (256 * intval($ip_arr[2])) + intval($ip_arr[3]);
|
||||
return pack('N', intval($tmp)); // 32位无符号大端序长整型
|
||||
}
|
||||
|
||||
private function unzipIP($ip) { // 数字转为IP地址
|
||||
return long2ip($ip);
|
||||
}
|
||||
|
||||
public function getVersion() { // 获取当前数据库的版本
|
||||
fseek($this->fp, $this->lastRecord + 4);
|
||||
$tmp = $this->getRecord($this->read3byte())['B'];
|
||||
return substr($tmp, 0, 4) . substr($tmp, 7, 2) . substr($tmp, 12, 2);
|
||||
}
|
||||
|
||||
public function getDetail($ip) { // 获取IP地址区段及所在位置
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { // 判断是否为IPv4地址
|
||||
return null;
|
||||
}
|
||||
|
||||
fseek($this->fp, $this->searchRecord($ip)); // 跳转到对应IP记录的位置
|
||||
$detail['beginIP'] = $this->unzipIP($this->read4byte()); // 目标IP所在网段的起始IP
|
||||
$offset = $this->read3byte(); // 索引后3字节为对应记录的偏移量
|
||||
fseek($this->fp, $offset);
|
||||
$detail['endIP'] = $this->unzipIP($this->read4byte()); // 目标IP所在网段的结束IP
|
||||
|
||||
$tmp = $this->getRecord($offset); // 获取记录的dataA与dataB
|
||||
$detail['dataA'] = $tmp['A'];
|
||||
$detail['dataB'] = $tmp['B'];
|
||||
|
||||
if ($detail['beginIP'] == '255.255.255.0') { // 去除附加信息
|
||||
$detail['dataA'] = 'IANA';
|
||||
$detail['dataB'] = '保留地址';
|
||||
}
|
||||
if ($detail['dataA'] == ' CZ88.NET' || $detail['dataA'] == '纯真网络') {
|
||||
$detail['dataA'] = '';
|
||||
}
|
||||
if ($detail['dataB'] == ' CZ88.NET') {
|
||||
$detail['dataB'] = '';
|
||||
}
|
||||
return $detail;
|
||||
}
|
||||
|
||||
private function searchRecord($ip) { // 根据IP地址获取索引的绝对偏移量
|
||||
$ip = $this->zipIP($ip); // 转为数字以比较大小
|
||||
$down = 0;
|
||||
$up = $this->recordNum;
|
||||
while ($down <= $up) { // 二分法查找
|
||||
$mid = floor(($down + $up) / 2); // 计算二分点
|
||||
fseek($this->fp, $this->firstRecord + $mid * 7);
|
||||
$beginip = strrev(fread($this->fp, 4)); // 获取二分区域的下边界
|
||||
if ($ip < $beginip) { // 目标IP在二分区域以下
|
||||
$up = $mid - 1; // 缩小搜索的上边界
|
||||
} else {
|
||||
fseek($this->fp, $this->read3byte());
|
||||
$endip = strrev(fread($this->fp, 4)); // 获取二分区域的上边界
|
||||
if ($ip > $endip) { // 目标IP在二分区域以上
|
||||
$down = $mid + 1; // 缩小搜索的下边界
|
||||
} else { // 目标IP在二分区域内
|
||||
return $this->firstRecord + $mid * 7; // 返回索引的偏移量
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->lastRecord; // 无法找到对应索引,返回最后一条记录的偏移量
|
||||
}
|
||||
|
||||
private function getRecord($offset) { // 读取IP记录的数据
|
||||
fseek($this->fp, $offset + 4);
|
||||
$flag = ord(fread($this->fp, 1));
|
||||
if ($flag == 1) { // dataA与dataB均重定向
|
||||
$offset = $this->read3byte(); // 重定向偏移
|
||||
fseek($this->fp, $offset);
|
||||
if (ord(fread($this->fp, 1)) == 2) { // dataA再次重定向
|
||||
fseek($this->fp, $this->read3byte());
|
||||
$data['A'] = $this->readString();
|
||||
fseek($this->fp, $offset + 4);
|
||||
$data['B'] = $this->getDataB();
|
||||
} else { // dataA无重定向
|
||||
fseek($this->fp, -1, SEEK_CUR); // 文件指针回退1字节
|
||||
$data['A'] = $this->readString();
|
||||
$data['B'] = $this->getDataB();
|
||||
}
|
||||
} else if ($flag == 2) { // dataA重定向
|
||||
fseek($this->fp, $this->read3byte());
|
||||
$data['A'] = $this->readString();
|
||||
fseek($this->fp, $offset + 8); // IP占4字节, 重定向标志占1字节, dataA指针占3字节
|
||||
$data['B'] = $this->getDataB();
|
||||
} else { // dataA无重定向
|
||||
fseek($this->fp, -1, SEEK_CUR); // 文件指针回退1字节
|
||||
$data['A'] = $this->readString();
|
||||
$data['B'] = $this->getDataB();
|
||||
}
|
||||
$data['A'] = iconv("GBK", "UTF-8", $data['A']); // GBK -> UTF-8
|
||||
$data['B'] = iconv("GBK", "UTF-8", $data['B']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getDataB() { // 从fp指定偏移获取dataB
|
||||
$flag = ord(fread($this->fp, 1));
|
||||
if ($flag == 0) { // dataB无信息
|
||||
return '';
|
||||
} else if ($flag == 1 || $flag == 2) { // dataB重定向
|
||||
fseek($this->fp, $this->read3byte());
|
||||
return $this->readString();
|
||||
} else { // dataB无重定向
|
||||
fseek($this->fp, -1, SEEK_CUR); // 文件指针回退1字节
|
||||
return $this->readString();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user