码桶
发现社区成员的开源项目
index.php10.4 KB
<?php
/**
* Jimmy的小屋 - 世界上最好的个人博客 (交互完美版)
*/
header('Content-Type: text/html; charset=utf-8'); // 强制UTF-8防乱码
// ================= 1. 核心实质知识点库 =================
$knowledgeBase = [
'民航客机' => [
'波音737MAX复飞背后的MCAS系统改进:2019年两起空难后,波音对MCAS系统进行了彻底重构。新系统不再依赖单一攻角传感器,而是同时读取两个传感器数据,只有当两者一致时才触发修正。同时MCAS的权限被大幅限制,每次只能微调机头角度,且只能触发一次,从根本上杜绝了系统反复强行压低机头的致命缺陷。',
'客机机翼的翼梢小翼设计原理:现代客机机翼末端的翼梢小翼并非装饰,而是为了减少翼尖涡流带来的诱导阻力。当机翼产生升力时,下翼面的高压气流会绕过翼尖流向上翼面,形成涡流消耗能量。翼梢小翼像一道屏障阻挡了这种绕流,可节省3%-5%的燃油,对航空公司来说是巨大的成本优势。',
],
'互联网知识' => [
'BGP协议:互联网的指路明灯:BGP(边界网关协议)是互联网的核心路由协议。它负责在不同的自治系统(AS)之间交换路由信息。简单来说,BGP就像是互联网世界的“邮政系统”,它不关心包裹的具体内容,只负责计算出一条从A点到B点最快、最稳定的路径,确保你的数据能跨越半个地球准确送达。',
'HTTPS与TLS加密:当你访问一个带锁头图标的网站时,你的浏览器和服务器正在进行TLS握手。这个过程使用了非对称加密(如RSA)来安全地交换密钥,然后切换到对称加密(如AES)来传输实际数据。这确保了你的密码和聊天记录在传输过程中不会被窃听。',
]
];
// ================= 2. 每日实质文章生成引擎 =================
define('GSO_DIR', __DIR__ . '/gso');
define('AUTO_FILE', GSO_DIR . '/auto_articles.gso');
if (!is_dir(GSO_DIR)) mkdir(GSO_DIR, 0777, true);
function loadGso($file) { return file_exists($file) ? json_decode(file_get_contents($file), true) : []; }
function saveGso($file, $data) { file_put_contents($file, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); }
function getDailyArticles($knowledgeBase) {
$articles = loadGso(AUTO_FILE);
$today = date('Y-m-d');
$todayGenerated = [];
foreach ($articles as $a) { if ($a['date'] === $today) $todayGenerated[$a['category']] = ($todayGenerated[$a['category']] ?? 0) + 1; }
foreach ($knowledgeBase as $cat => $points) {
$needed = 5 - ($todayGenerated[$cat] ?? 0);
if ($needed <= 0) continue;
$shuffled = $points; shuffle($shuffled);
$selected = array_slice($shuffled, 0, $needed);
foreach ($selected as $point) {
$titleParts = explode(":", $point, 2);
$title = "[{$cat}] " . ($titleParts[0] ?? $cat);
$content = "【{$today} 深度硬核解析】\n\n一、 核心概念\n" . $point . "\n\n二、 底层原理解析\n在{$cat}领域,这一现象的背后有着严谨的科学逻辑。它不仅仅是理论上的推演,更是经过无数次实验和工程实践验证的真理。\n\n三、 实际应用场景\n在实际的工业与生活中,这一知识点发挥着不可替代的作用。工程师们正是基于这一原理,不断优化设计,解决了诸多传统方案无法攻克的瓶颈问题。\n\n四、 总结与启发\n在“{$cat}”领域,理解这些底层原理,能帮助我们更好地认识世界。";
$articles[] = [
'id' => md5($today . $cat . $point . rand(1000, 9999)),
'title' => $title, 'content' => $content,
'category' => $cat, 'date' => $today
];
}
}
usort($articles, function($a, $b) { return strcmp($b['date'], $a['date']); });
saveGso(AUTO_FILE, $articles);
return $articles;
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jimmy的小屋 | 世界上最好的个人博客</title>
<style>
:root { --bg: #0f172a; --card: rgba(255,255,255,0.05); --primary: #38bdf8; --accent: #a855f7; --text: #f8fafc; --sub: #94a3b8; }
* { margin: 0; padding: 0; box-sizing: border-box; transition: all 0.3s ease; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; align-items: center; overflow-x: hidden; line-height: 1.8; position: relative; }
body::before, body::after { content: ''; position: absolute; border-radius: 50%; filter: blur(100px); z-index: 0; animation: float 10s infinite alternate ease-in-out; }
body::before { width: 500px; height: 500px; background: rgba(56, 189, 248, 0.2); top: -10%; left: -10%; }
body::after { width: 600px; height: 600px; background: rgba(168, 85, 247, 0.2); bottom: -10%; right: -10%; animation-delay: 2s; }
@keyframes float { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(50px, 30px) scale(1.1); } }
.container { position: relative; z-index: 1; max-width: 800px; width: 95%; margin: 40px auto; background: var(--card); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); border-radius: 24px; padding: 40px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); flex: 1; }
h1 { font-size: 2.5rem; background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 10px; }
h2 { color: var(--primary); margin: 30px 0 15px; font-size: 1.5rem; }
.sub { color: var(--sub); margin-bottom: 30px; font-size: 1.1rem; }
.nav { display: flex; gap: 10px; margin-bottom: 30px; flex-wrap: wrap; }
.nav a { padding: 8px 16px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); border-radius: 50px; color: var(--text); text-decoration: none; font-size: 14px; }
.nav a:hover, .nav a.active { background: var(--primary); color: var(--bg); border-color: var(--primary); }
.article-card { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); padding: 20px; border-radius: 12px; margin-bottom: 15px; }
.tag { display: inline-block; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 12px; margin-bottom: 8px; }
.article-card h3 { font-size: 1.2rem; margin-bottom: 10px; color: var(--primary); }
.article-card p { color: var(--sub); font-size: 15px; white-space: pre-line; }
/* 关于我页面的特殊样式 */
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-top: 20px; }
.skill-tag { background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.3); padding: 10px; border-radius: 8px; text-align: center; color: var(--primary); font-weight: bold; }
.footer { position: relative; z-index: 1; padding: 20px; text-align: center; color: var(--sub); font-size: 14px; margin-bottom: 20px; }
.footer a { color: var(--primary); text-decoration: none; }
</style>
</head>
<body>
<div class="container">
<?php
$action = $_GET['action'] ?? 'home';
$articles = getDailyArticles($knowledgeBase);
if ($action === 'home'):
?>
<h1>Jimmy的小屋</h1>
<p class="sub">世界上最好的个人博客。在这里,探索硬核知识,记录生活点滴。</p>
<div class="nav">
<a href="?action=home" class="active">首页</a>
<a href="?action=list">硬核博客</a>
<a href="?action=about">关于我</a>
</div>
<h2>今日系统自动生成实质文章</h2>
<?php if (!empty($articles)): ?>
<div class="article-card">
<span class="tag"><?= $articles[0]['category'] ?> · <?= $articles[0]['date'] ?></span>
<h3><?= $articles[0]['title'] ?></h3>
<p><?= nl2br($articles[0]['content']) ?></p>
</div>
<?php endif; ?>
<?php elseif ($action === 'list'): ?>
<h1>硬核博客</h1>
<p class="sub">每天自动更新,全部实质长文展示,拒绝省略号。</p>
<div class="nav">
<a href="?action=home">首页</a>
<a href="?action=list" class="active">硬核博客</a>
<a href="?action=about">关于我</a>
</div>
<?php foreach ($articles as $a): ?>
<div class="article-card">
<span class="tag"><?= $a['category'] ?> · <?= $a['date'] ?></span>
<h3><?= $a['title'] ?></h3>
<p><?= nl2br($a['content']) ?></p>
</div>
<?php endforeach; ?>
<?php elseif ($action === 'about'): ?>
<h1>关于我</h1>
<p class="sub">你好,我是 Jimmy,这个网站的站长兼全栈开发者。</p>
<div class="nav">
<a href="?action=home">首页</a>
<a href="?action=list">硬核博客</a>
<a href="?action=about" class="active">关于我</a>
</div>
<div class="article-card">
<h3>👨💻 我的故事</h3>
<p>我热爱技术,喜欢折腾代码,也热衷于探索这个世界的底层逻辑。建立这个博客,是为了给自己留一个数字自留地,分享我的硬核知识库、生活随笔,以及我对这个世界的一些思考。</p>
</div>
<h2>🛠️ 技能标签</h2>
<div class="about-grid">
<div class="skill-tag">PHP / 后端</div>
<div class="skill-tag">前端 UI/UX</div>
<div class="skill-tag">硬核科普</div>
<div class="skill-tag">终身学习</div>
</div>
<div class="article-card" style="margin-top: 30px;">
<h3>📬 联系我</h3>
<p>如果你对我的博客感兴趣,或者想交流技术,欢迎通过以下方式联系我:</p>
<p>邮箱[email protected]
</div>
<?php endif; ?>
</div>
<footer class="footer">
© 2026 Jimmy的小屋 | <a href="https://beian.miit.gov.cn/" target="_blank">晋ICP备2026009182号-1</a>
</footer>
</body>
</html>