V1.0正式版
This commit is contained in:
parent
d2fc7a83a8
commit
529ad70e11
150
README.md
150
README.md
@ -1,10 +1,148 @@
|
|||||||
## SecHub 网安工具集
|
# SecHub - 网络安全工具集
|
||||||
|
|
||||||
### 技术栈
|

|
||||||
|
|
||||||
PHP: 网页实现
|
## 项目简介
|
||||||
Json: 存储工具集
|
|
||||||
|
|
||||||
### 部署
|
SecHub 是一个面向网络安全领域的工具集合系统,提供多种网络安全工具的集中管理。该项目采用 JSON 存储工具信息,通过 PHP 网页界面实现工具的展示与访问,为安全研究人员和从业者提供一站式的工具导航平台。
|
||||||
|
|
||||||
直接复制本项目放置于服务器上即可
|
## 功能特性
|
||||||
|
|
||||||
|
- 🛠️ **工具分类管理**:按类别组织网络安全工具,便于查找和使用
|
||||||
|
- 🔍 **智能搜索**:支持全局搜索和栏目内搜索,快速定位所需工具
|
||||||
|
- 🌓 **主题切换**:支持白天/黑夜模式切换,保护视力
|
||||||
|
- 📱 **响应式设计**:适配各种屏幕尺寸,移动端友好
|
||||||
|
- 💾 **数据持久化**:使用 SQLite 数据库存储工具信息,提高查询效率
|
||||||
|
- 🔄 **自动同步**:JSON 数据变更时自动同步到数据库
|
||||||
|
- 📥 **数据导出**:支持下载原始 JSON 数据文件
|
||||||
|
|
||||||
|
## 技术栈
|
||||||
|
|
||||||
|
- **后端**: PHP
|
||||||
|
- **数据库**: SQLite
|
||||||
|
- **前端**: HTML, CSS, JavaScript
|
||||||
|
- **数据存储**: JSON 文件
|
||||||
|
- **架构**: JSON 驱动架构
|
||||||
|
|
||||||
|
## 项目结构
|
||||||
|
|
||||||
|
```
|
||||||
|
SecHub/
|
||||||
|
├── assets/
|
||||||
|
│ ├── css/
|
||||||
|
│ │ └── style.css # 样式文件
|
||||||
|
│ ├── db/
|
||||||
|
│ │ └── sechub.db # SQLite 数据库
|
||||||
|
│ ├── imgs/
|
||||||
|
│ │ ├── beian.png # 备案图标
|
||||||
|
│ │ └── favicon.ico # 网站图标
|
||||||
|
│ └── json/
|
||||||
|
│ └── template.json # json模板
|
||||||
|
│
|
||||||
|
├── db.php # 数据库管理类
|
||||||
|
├── index.php # 主页面
|
||||||
|
└── search.php # 搜索 API
|
||||||
|
```
|
||||||
|
|
||||||
|
## 部署方式
|
||||||
|
|
||||||
|
### 环境要求
|
||||||
|
|
||||||
|
- PHP 7.0+
|
||||||
|
- PDO SQLite 扩展
|
||||||
|
- Web 服务器(Apache/Nginx)
|
||||||
|
|
||||||
|
### 快速部署
|
||||||
|
|
||||||
|
1. 克隆或下载本项目
|
||||||
|
2. 将项目文件放置于 Web 服务器根目录
|
||||||
|
3. 确保 `assets/db/` 目录具有写入权限
|
||||||
|
4. 访问 `index.php` 即可使用
|
||||||
|
|
||||||
|
### 权限设置
|
||||||
|
|
||||||
|
确保以下目录具有写入权限:
|
||||||
|
```bash
|
||||||
|
chmod 755 assets/db/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 使用说明
|
||||||
|
|
||||||
|
### 添加新工具
|
||||||
|
|
||||||
|
在对应的 JSON 文件中添加工具信息,格式如下:
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"section": "安全工具"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "工具名称",
|
||||||
|
"url": "https://example.com",
|
||||||
|
"description": "工具描述"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 搜索功能
|
||||||
|
|
||||||
|
- **全局搜索**:在顶部搜索框输入关键词,实时显示所有栏目中的匹配结果
|
||||||
|
- **栏目搜索**:在每个栏目内的搜索框输入关键词,仅在该栏目中搜索
|
||||||
|
|
||||||
|
### 主题切换
|
||||||
|
|
||||||
|
点击右上角的月亮/太阳图标切换白天/黑夜模式,系统会记住您的选择。
|
||||||
|
|
||||||
|
## 数据格式
|
||||||
|
|
||||||
|
每个 JSON 文件包含一个数组,第一个元素定义栏目名称,后续元素为具体的工具信息:
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"section": "栏目名称"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "工具名称",
|
||||||
|
"url": "工具链接",
|
||||||
|
"description": "工具描述"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
## 核心功能说明
|
||||||
|
|
||||||
|
### 数据库同步机制
|
||||||
|
|
||||||
|
系统采用智能同步机制,仅在 JSON 文件修改时间超过 5 分钟时才更新数据库,避免频繁读写影响性能。
|
||||||
|
|
||||||
|
### 搜索算法
|
||||||
|
|
||||||
|
支持对工具名称、描述和 URL 进行模糊搜索,提供实时的搜索结果反馈。
|
||||||
|
|
||||||
|
### 响应式设计
|
||||||
|
|
||||||
|
采用现代 CSS Grid 布局,自动适配不同屏幕尺寸,提供良好的移动端体验。
|
||||||
|
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情
|
||||||
|
|
||||||
|
## 联系方式
|
||||||
|
|
||||||
|
- 项目主页: [https://git.masonliu.com/MasonLiu/SecHub](https://git.masonliu.com/MasonLiu/SecHub)
|
||||||
|
- 作者: MasonLiu
|
||||||
|
- 邮箱: [您的邮箱地址]
|
||||||
|
|
||||||
|
## 备案信息
|
||||||
|
|
||||||
|
**示例网站:**[sehub.masonliu.com](https://sechub.masonliu.com)
|
||||||
|
|
||||||
|
- ICP 备案号: 蜀ICP备2026025173号
|
||||||
|
- 公安备案号: 川公网安备51162302000285号
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
© 2026 SecHub - Gaming Master Cybersecurity | MasonLiu
|
||||||
@ -5,64 +5,162 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
|
||||||
background: #f5f5f5;
|
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
transition: background-color 0.3s ease, color 0.3s ease;
|
padding-bottom: 40px;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
color: #2d3748;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode {
|
body.dark-mode {
|
||||||
background: #1a1a1a;
|
background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
|
||||||
color: #e0e0e0;
|
color: #e2e8f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
max-width: 1400px;
|
max-width: 1400px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
padding-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #333;
|
margin-bottom: 40px;
|
||||||
margin-bottom: 30px;
|
padding: 30px 20px;
|
||||||
padding: 20px 0;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
transition: color 0.3s ease;
|
background: rgba(255, 255, 255, 0.9);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode header {
|
body.dark-mode header {
|
||||||
color: #e0e0e0;
|
background: rgba(26, 32, 44, 0.9);
|
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
header h1 {
|
header h1 {
|
||||||
font-size: 2rem;
|
font-size: 2.2rem;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 10px;
|
||||||
color: #2c3e50;
|
color: #2b6cb0;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -0.5px;
|
||||||
transition: color 0.3s ease;
|
transition: color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode header h1 {
|
body.dark-mode header h1 {
|
||||||
color: #ecf0f1;
|
color: #63b3ed;
|
||||||
}
|
}
|
||||||
|
|
||||||
header p {
|
header p {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
color: #666;
|
color: #718096;
|
||||||
transition: color 0.3s ease;
|
transition: color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode header p {
|
body.dark-mode header p {
|
||||||
color: #b0b0b0;
|
color: #a0aec0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 搜索框样式 */
|
||||||
|
.search-container {
|
||||||
|
position: relative;
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 20px auto 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px 20px;
|
||||||
|
font-size: 1rem;
|
||||||
|
border: 2px solid #e2e8f0;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: white;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input:focus {
|
||||||
|
border-color: #4299e1;
|
||||||
|
box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .search-input {
|
||||||
|
background: #2d3748;
|
||||||
|
border-color: #4a5568;
|
||||||
|
color: #e2e8f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .search-input:focus {
|
||||||
|
border-color: #63b3ed;
|
||||||
|
box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-results {
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
margin-top: 8px;
|
||||||
|
background: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
|
||||||
|
max-height: 70vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
z-index: 9999;
|
||||||
|
display: none;
|
||||||
|
padding: 15px;
|
||||||
|
border: 2px solid #e2e8f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .search-results {
|
||||||
|
background: #2d3748;
|
||||||
|
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
|
||||||
|
border-color: #4a5568;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* body.search-active {
|
||||||
|
padding-bottom: 400px;
|
||||||
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
.search-result-section {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-result-section:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-result-title {
|
||||||
|
font-size: 1rem;
|
||||||
|
color: #4a5568;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
border-bottom: 2px solid #e2e8f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .search-result-title {
|
||||||
|
color: #a0aec0;
|
||||||
|
border-bottom-color: #4a5568;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-results {
|
||||||
|
text-align: center;
|
||||||
|
color: #a0aec0;
|
||||||
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-toggle {
|
.theme-toggle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 20px;
|
right: 20px;
|
||||||
top: 50%;
|
top: 20px;
|
||||||
transform: translateY(-50%);
|
background: white;
|
||||||
background: #fff;
|
border: 2px solid #e2e8f0;
|
||||||
border: 2px solid #e0e0e0;
|
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
width: 45px;
|
width: 45px;
|
||||||
height: 45px;
|
height: 45px;
|
||||||
@ -72,22 +170,22 @@ body.dark-mode header p {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: 1.3rem;
|
font-size: 1.3rem;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-toggle:hover {
|
.theme-toggle:hover {
|
||||||
transform: translateY(-50%) scale(1.1);
|
transform: scale(1.1);
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||||
border-color: #3498db;
|
border-color: #4299e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .theme-toggle {
|
body.dark-mode .theme-toggle {
|
||||||
background: #2c2c2c;
|
background: #2d3748;
|
||||||
border-color: #444;
|
border-color: #4a5568;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .theme-toggle:hover {
|
body.dark-mode .theme-toggle:hover {
|
||||||
border-color: #f39c12;
|
border-color: #63b3ed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-tooltip {
|
.theme-tooltip {
|
||||||
@ -132,48 +230,133 @@ body.dark-mode .theme-toggle:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.section {
|
.section {
|
||||||
margin-bottom: 30px;
|
margin-bottom: 35px;
|
||||||
}
|
background: rgba(255, 255, 255, 0.95);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
.section-title {
|
border-radius: 16px;
|
||||||
color: #2c3e50;
|
padding: 25px;
|
||||||
font-size: 1.4rem;
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
|
||||||
margin-bottom: 15px;
|
|
||||||
padding: 10px 15px;
|
|
||||||
border-left: 4px solid #3498db;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 4px;
|
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body.dark-mode .section {
|
||||||
|
background: rgba(26, 32, 44, 0.95);
|
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
color: #2b6cb0;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0;
|
||||||
|
transition: color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
body.dark-mode .section-title {
|
body.dark-mode .section-title {
|
||||||
color: #ecf0f1;
|
color: #63b3ed;
|
||||||
background: #2c2c2c;
|
}
|
||||||
border-left-color: #f39c12;
|
|
||||||
|
.section-search {
|
||||||
|
padding: 8px 15px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
border: 2px solid #e2e8f0;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: white;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
outline: none;
|
||||||
|
min-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-btn {
|
||||||
|
padding: 6px 14px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
border: 2px solid #4299e1;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: white;
|
||||||
|
color: #4299e1;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
outline: none;
|
||||||
|
font-weight: 500;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-btn:hover {
|
||||||
|
background: #4299e1;
|
||||||
|
color: white;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 2px 6px rgba(66, 153, 225, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .download-btn {
|
||||||
|
background: #2d3748;
|
||||||
|
border-color: #63b3ed;
|
||||||
|
color: #63b3ed;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .download-btn:hover {
|
||||||
|
background: #63b3ed;
|
||||||
|
color: #2d3748;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-search:focus {
|
||||||
|
border-color: #4299e1;
|
||||||
|
box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .section-search {
|
||||||
|
background: #2d3748;
|
||||||
|
border-color: #4a5568;
|
||||||
|
color: #e2e8f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .section-search:focus {
|
||||||
|
border-color: #63b3ed;
|
||||||
|
box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cards-grid {
|
.cards-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||||
gap: 15px;
|
gap: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
background: white;
|
background: white;
|
||||||
border-radius: 8px;
|
border-radius: 12px;
|
||||||
padding: 18px;
|
padding: 20px;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border: 1px solid #e0e0e0;
|
border: 1px solid #e2e8f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .card {
|
body.dark-mode .card {
|
||||||
background: #2c2c2c;
|
background: #2d3748;
|
||||||
border-color: #444;
|
border-color: #4a5568;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card::before {
|
.card::before {
|
||||||
@ -182,26 +365,26 @@ body.dark-mode .card {
|
|||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 3px;
|
height: 4px;
|
||||||
background: linear-gradient(90deg, #3498db, #2980b9);
|
background: linear-gradient(90deg, #4299e1, #667eea);
|
||||||
transform: scaleX(0);
|
transform: scaleX(0);
|
||||||
transform-origin: left;
|
transform-origin: left;
|
||||||
transition: transform 0.3s ease;
|
transition: transform 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .card::before {
|
body.dark-mode .card::before {
|
||||||
background: linear-gradient(90deg, #f39c12, #e67e22);
|
background: linear-gradient(90deg, #63b3ed, #90cdf4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card:hover {
|
.card:hover {
|
||||||
transform: translateY(-3px);
|
transform: translateY(-4px);
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
|
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
|
||||||
border-color: #3498db;
|
border-color: #4299e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .card:hover {
|
body.dark-mode .card:hover {
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
|
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
|
||||||
border-color: #f39c12;
|
border-color: #63b3ed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card:hover::before {
|
.card:hover::before {
|
||||||
@ -213,85 +396,88 @@ body.dark-mode .card:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.card-title {
|
.card-title {
|
||||||
font-size: 1.1rem;
|
font-size: 1.15rem;
|
||||||
color: #2c3e50;
|
color: #2d3748;
|
||||||
margin-bottom: 6px;
|
margin-bottom: 8px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
transition: color 0.3s ease;
|
transition: color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .card-title {
|
body.dark-mode .card-title {
|
||||||
color: #ecf0f1;
|
color: #e2e8f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-link {
|
.card-link {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
color: #3498db;
|
color: #4299e1;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
transition: color 0.2s ease;
|
transition: color 0.2s ease;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .card-link {
|
body.dark-mode .card-link {
|
||||||
color: #f39c12;
|
color: #63b3ed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-link:hover {
|
.card-link:hover {
|
||||||
color: #2980b9;
|
color: #2b6cb0;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .card-link:hover {
|
body.dark-mode .card-link:hover {
|
||||||
color: #e67e22;
|
color: #90cdf4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-description {
|
.card-description {
|
||||||
color: #666;
|
color: #718096;
|
||||||
line-height: 1.5;
|
line-height: 1.6;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
transition: color 0.3s ease;
|
transition: color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .card-description {
|
body.dark-mode .card-description {
|
||||||
color: #b0b0b0;
|
color: #a0aec0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #999;
|
color: #a0aec0;
|
||||||
padding: 30px;
|
padding: 40px;
|
||||||
background: #fff;
|
background: rgba(255, 255, 255, 0.5);
|
||||||
border-radius: 8px;
|
border-radius: 12px;
|
||||||
border: 1px dashed #ddd;
|
border: 2px dashed #cbd5e0;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .empty-state {
|
body.dark-mode .empty-state {
|
||||||
background: #2c2c2c;
|
background: rgba(45, 55, 72, 0.5);
|
||||||
border-color: #444;
|
border-color: #4a5568;
|
||||||
color: #888;
|
color: #718096;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-state p {
|
.empty-state p {
|
||||||
font-size: 0.95rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #999;
|
color: #718096;
|
||||||
margin-top: 40px;
|
margin-top: 50px;
|
||||||
padding: 25px 20px;
|
padding: 30px 20px;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
background: #fff;
|
background: rgba(255, 255, 255, 0.9);
|
||||||
border-top: 1px solid #e0e0e0;
|
backdrop-filter: blur(10px);
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode footer {
|
body.dark-mode footer {
|
||||||
background: #2c2c2c;
|
background: rgba(26, 32, 44, 0.9);
|
||||||
border-top-color: #444;
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||||
color: #888;
|
color: #a0aec0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer-content {
|
.footer-content {
|
||||||
@ -301,12 +487,12 @@ body.dark-mode footer {
|
|||||||
|
|
||||||
.copyright {
|
.copyright {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
color: #666;
|
color: #4a5568;
|
||||||
transition: color 0.3s ease;
|
transition: color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .copyright {
|
body.dark-mode .copyright {
|
||||||
color: #b0b0b0;
|
color: #a0aec0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.beian-info {
|
.beian-info {
|
||||||
@ -319,7 +505,7 @@ body.dark-mode .copyright {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.beian-link {
|
.beian-link {
|
||||||
color: #999;
|
color: #718096;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
transition: color 0.2s ease;
|
transition: color 0.2s ease;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@ -328,25 +514,25 @@ body.dark-mode .copyright {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .beian-link {
|
body.dark-mode .beian-link {
|
||||||
color: #888;
|
color: #a0aec0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.beian-link:hover {
|
.beian-link:hover {
|
||||||
color: #3498db;
|
color: #4299e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .beian-link:hover {
|
body.dark-mode .beian-link:hover {
|
||||||
color: #f39c12;
|
color: #63b3ed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.beian-divider {
|
.beian-divider {
|
||||||
color: #ddd;
|
color: #cbd5e0;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
transition: color 0.3s ease;
|
transition: color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode .beian-divider {
|
body.dark-mode .beian-divider {
|
||||||
color: #555;
|
color: #4a5568;
|
||||||
}
|
}
|
||||||
|
|
||||||
.beian-icon {
|
.beian-icon {
|
||||||
@ -355,11 +541,11 @@ body.dark-mode .beian-divider {
|
|||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
header h1 {
|
header h1 {
|
||||||
font-size: 1.6rem;
|
font-size: 1.8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-title {
|
.section-title {
|
||||||
font-size: 1.2rem;
|
font-size: 1.3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cards-grid {
|
.cards-grid {
|
||||||
@ -367,7 +553,7 @@ body.dark-mode .beian-divider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
padding: 15px;
|
padding: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-toggle {
|
.theme-toggle {
|
||||||
@ -375,6 +561,7 @@ body.dark-mode .beian-divider {
|
|||||||
height: 40px;
|
height: 40px;
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
|
top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-tooltip {
|
.theme-tooltip {
|
||||||
@ -383,6 +570,15 @@ body.dark-mode .beian-divider {
|
|||||||
bottom: -32px;
|
bottom: -32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.section-header {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-search {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
padding: 20px 15px;
|
padding: 20px 15px;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
@ -404,7 +600,7 @@ body.dark-mode .beian-divider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
header h1 {
|
header h1 {
|
||||||
font-size: 1.4rem;
|
font-size: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
header p {
|
header p {
|
||||||
@ -412,12 +608,11 @@ body.dark-mode .beian-divider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.section-title {
|
.section-title {
|
||||||
font-size: 1.1rem;
|
font-size: 1.2rem;
|
||||||
padding: 8px 12px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-title {
|
.card-title {
|
||||||
font-size: 1rem;
|
font-size: 1.05rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
|
|||||||
BIN
assets/db/sechub.db
Normal file
BIN
assets/db/sechub.db
Normal file
Binary file not shown.
BIN
assets/imgs/favicon.ico
Normal file
BIN
assets/imgs/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
@ -1,20 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"section": "插件/非独立小工具"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Nuclei Templates",
|
|
||||||
"url": "https://github.com/projectdiscovery/nuclei-templates",
|
|
||||||
"description": "社区驱动的漏洞扫描模板集合,支持多种协议和技术栈"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "CVE-Exploit",
|
|
||||||
"url": "https://github.com/trickest/cve",
|
|
||||||
"description": "最新CVE漏洞的POC和EXP收集仓库"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Web POC",
|
|
||||||
"url": "https://github.com/dorkerdevil/Web-Pentest",
|
|
||||||
"description": "Web应用渗透测试POC脚本合集"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"section": "POC/EXP"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Nuclei Templates",
|
|
||||||
"url": "https://github.com/projectdiscovery/nuclei-templates",
|
|
||||||
"description": "社区驱动的漏洞扫描模板集合,支持多种协议和技术栈"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "CVE-Exploit",
|
|
||||||
"url": "https://github.com/trickest/cve",
|
|
||||||
"description": "最新CVE漏洞的POC和EXP收集仓库"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Web POC",
|
|
||||||
"url": "https://github.com/dorkerdevil/Web-Pentest",
|
|
||||||
"description": "Web应用渗透测试POC脚本合集"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
10
assets/json/template.json
Normal file
10
assets/json/template.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"section": "栏目名称"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "工具名称",
|
||||||
|
"url": "工具链接",
|
||||||
|
"description": "工具描述"
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -1,25 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"section": "安全工具"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Burp Suite",
|
|
||||||
"url": "https://portswigger.net/burp",
|
|
||||||
"description": "专业的Web安全测试工具集,包含代理、扫描器等多种功能模块"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SQLMap",
|
|
||||||
"url": "https://github.com/sqlmapproject/sqlmap",
|
|
||||||
"description": "自动化SQL注入检测和利用工具,支持多种数据库类型"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Dirsearch",
|
|
||||||
"url": "https://github.com/maurosoria/dirsearch",
|
|
||||||
"description": "高性能Web目录和文件枚举工具,支持多线程和多种输出格式"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Nmap",
|
|
||||||
"url": "https://nmap.org/",
|
|
||||||
"description": "网络发现和安全审计工具,支持端口扫描、服务检测等功能"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
353
db.php
Normal file
353
db.php
Normal file
@ -0,0 +1,353 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SecHub 数据库管理类
|
||||||
|
* 负责JSON数据到SQLite的转换和管理
|
||||||
|
*/
|
||||||
|
|
||||||
|
class SecHubDatabase {
|
||||||
|
private $dbPath;
|
||||||
|
private $jsonDir;
|
||||||
|
private $db;
|
||||||
|
|
||||||
|
public function __construct($dbPath, $jsonDir) {
|
||||||
|
$this->dbPath = $dbPath;
|
||||||
|
$this->jsonDir = $jsonDir;
|
||||||
|
$this->initDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据库连接
|
||||||
|
*/
|
||||||
|
private function initDatabase() {
|
||||||
|
try {
|
||||||
|
$this->db = new PDO('sqlite:' . $this->dbPath);
|
||||||
|
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// 创建同步日志表
|
||||||
|
$this->createSyncLogTable();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("数据库连接失败: " . $e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建同步日志表
|
||||||
|
*/
|
||||||
|
private function createSyncLogTable() {
|
||||||
|
$sql = "CREATE TABLE IF NOT EXISTS json_sync_log (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
json_filename TEXT UNIQUE NOT NULL,
|
||||||
|
table_name TEXT NOT NULL,
|
||||||
|
last_sync_time DATETIME NOT NULL,
|
||||||
|
json_file_mtime INTEGER NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)";
|
||||||
|
|
||||||
|
$this->db->exec($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查并同步JSON数据到数据库
|
||||||
|
*/
|
||||||
|
public function syncJsonToDatabase() {
|
||||||
|
$jsonFiles = glob($this->jsonDir . '*.json');
|
||||||
|
|
||||||
|
foreach ($jsonFiles as $file) {
|
||||||
|
$this->syncSingleFile($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步单个JSON文件到数据库
|
||||||
|
*/
|
||||||
|
private function syncSingleFile($filePath) {
|
||||||
|
$filename = basename($filePath);
|
||||||
|
$tableName = pathinfo($filename, PATHINFO_FILENAME);
|
||||||
|
|
||||||
|
// 检查是否需要更新
|
||||||
|
if (!$this->shouldUpdate($filePath, $tableName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取JSON数据
|
||||||
|
$data = $this->loadJsonData($filePath);
|
||||||
|
if (empty($data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建或更新表
|
||||||
|
$this->createTable($tableName, $data[0]);
|
||||||
|
|
||||||
|
// 清空旧数据
|
||||||
|
$this->clearTable($tableName);
|
||||||
|
|
||||||
|
// 插入新数据(跳过第一个section项)
|
||||||
|
$items = array_slice($data, 1);
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$this->insertItem($tableName, $item, $data[0]['section'] ?? $tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新同步日志
|
||||||
|
$this->updateSyncLog($filename, $tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新同步日志
|
||||||
|
*/
|
||||||
|
private function updateSyncLog($filename, $tableName) {
|
||||||
|
$jsonFile = $this->jsonDir . $filename;
|
||||||
|
$jsonModified = filemtime($jsonFile);
|
||||||
|
$syncTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// 检查是否已存在记录
|
||||||
|
$sql = "SELECT id FROM json_sync_log WHERE json_filename = :filename";
|
||||||
|
$stmt = $this->db->prepare($sql);
|
||||||
|
$stmt->execute([':filename' => $filename]);
|
||||||
|
$exists = $stmt->fetch();
|
||||||
|
|
||||||
|
if ($exists) {
|
||||||
|
// 更新现有记录
|
||||||
|
$sql = "UPDATE json_sync_log
|
||||||
|
SET table_name = :table_name,
|
||||||
|
last_sync_time = :sync_time,
|
||||||
|
json_file_mtime = :mtime
|
||||||
|
WHERE json_filename = :filename";
|
||||||
|
} else {
|
||||||
|
// 插入新记录
|
||||||
|
$sql = "INSERT INTO json_sync_log (json_filename, table_name, last_sync_time, json_file_mtime)
|
||||||
|
VALUES (:filename, :table_name, :sync_time, :mtime)";
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($sql);
|
||||||
|
$stmt->execute([
|
||||||
|
':filename' => $filename,
|
||||||
|
':table_name' => $tableName,
|
||||||
|
':sync_time' => $syncTime,
|
||||||
|
':mtime' => $jsonModified
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否需要更新
|
||||||
|
*/
|
||||||
|
private function shouldUpdate($jsonFile, $tableName) {
|
||||||
|
$filename = basename($jsonFile);
|
||||||
|
$jsonModified = filemtime($jsonFile);
|
||||||
|
|
||||||
|
// 查询该JSON文件的同步记录
|
||||||
|
$sql = "SELECT * FROM json_sync_log WHERE json_filename = :filename";
|
||||||
|
$stmt = $this->db->prepare($sql);
|
||||||
|
$stmt->execute([':filename' => $filename]);
|
||||||
|
$log = $stmt->fetch();
|
||||||
|
|
||||||
|
// 如果没有同步记录,需要更新
|
||||||
|
if (!$log) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算时间差(秒)
|
||||||
|
$timeDiff = $jsonModified - $log['json_file_mtime'];
|
||||||
|
|
||||||
|
// 如果JSON文件修改时间比记录的晚至少5分钟(300秒),则需要更新
|
||||||
|
if ($timeDiff >= 300) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 否则不需要更新
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载JSON数据
|
||||||
|
*/
|
||||||
|
private function loadJsonData($filePath) {
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = file_get_contents($filePath);
|
||||||
|
if ($content === false) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode($content, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
error_log("JSON解析错误: " . json_last_error_msg());
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_array($data) ? $data : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建数据表
|
||||||
|
*/
|
||||||
|
private function createTable($tableName, $firstItem) {
|
||||||
|
// 清理表名,只保留字母、数字和下划线
|
||||||
|
$tableName = preg_replace('/[^a-zA-Z0-9_]/', '_', $tableName);
|
||||||
|
|
||||||
|
$sql = "CREATE TABLE IF NOT EXISTS {$tableName} (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
section TEXT NOT NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
url TEXT,
|
||||||
|
description TEXT,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)";
|
||||||
|
|
||||||
|
$this->db->exec($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空表数据
|
||||||
|
*/
|
||||||
|
private function clearTable($tableName) {
|
||||||
|
$tableName = preg_replace('/[^a-zA-Z0-9_]/', '_', $tableName);
|
||||||
|
$this->db->exec("DELETE FROM {$tableName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入数据项
|
||||||
|
*/
|
||||||
|
private function insertItem($tableName, $item, $section) {
|
||||||
|
$tableName = preg_replace('/[^a-zA-Z0-9_]/', '_', $tableName);
|
||||||
|
|
||||||
|
$sql = "INSERT INTO {$tableName} (section, name, url, description)
|
||||||
|
VALUES (:section, :name, :url, :description)";
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($sql);
|
||||||
|
$stmt->execute([
|
||||||
|
':section' => $section,
|
||||||
|
':name' => $item['name'] ?? '',
|
||||||
|
':url' => $item['url'] ?? '',
|
||||||
|
':description' => $item['description'] ?? ''
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局搜索
|
||||||
|
*/
|
||||||
|
public function globalSearch($keyword) {
|
||||||
|
if (empty($keyword)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tables = $this->getAllTables();
|
||||||
|
$results = [];
|
||||||
|
|
||||||
|
foreach ($tables as $table) {
|
||||||
|
$tableName = $table['name'];
|
||||||
|
$sql = "SELECT *, '{$tableName}' as source_table FROM {$tableName}
|
||||||
|
WHERE name LIKE :keyword
|
||||||
|
OR description LIKE :keyword
|
||||||
|
OR url LIKE :keyword
|
||||||
|
ORDER BY name";
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($sql);
|
||||||
|
$stmt->execute([':keyword' => '%' . $keyword . '%']);
|
||||||
|
$items = $stmt->fetchAll();
|
||||||
|
|
||||||
|
if (!empty($items)) {
|
||||||
|
$results[$tableName] = [
|
||||||
|
'section' => $items[0]['section'] ?? $tableName,
|
||||||
|
'items' => $items
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按栏目搜索
|
||||||
|
*/
|
||||||
|
public function searchBySection($section, $keyword) {
|
||||||
|
if (empty($keyword)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tables = $this->getAllTables();
|
||||||
|
$results = [];
|
||||||
|
|
||||||
|
foreach ($tables as $table) {
|
||||||
|
$tableName = $table['name'];
|
||||||
|
$sql = "SELECT * FROM {$tableName}
|
||||||
|
WHERE section = :section
|
||||||
|
AND (name LIKE :keyword
|
||||||
|
OR description LIKE :keyword
|
||||||
|
OR url LIKE :keyword)
|
||||||
|
ORDER BY name";
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($sql);
|
||||||
|
$stmt->execute([
|
||||||
|
':section' => $section,
|
||||||
|
':keyword' => '%' . $keyword . '%'
|
||||||
|
]);
|
||||||
|
$items = $stmt->fetchAll();
|
||||||
|
|
||||||
|
if (!empty($items)) {
|
||||||
|
$results[] = $items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_merge(...$results);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有栏目配置
|
||||||
|
*/
|
||||||
|
public function getSectionsConfig() {
|
||||||
|
$tables = $this->getAllTables();
|
||||||
|
$sections = [];
|
||||||
|
|
||||||
|
foreach ($tables as $table) {
|
||||||
|
$tableName = $table['name'];
|
||||||
|
$sql = "SELECT DISTINCT section FROM {$tableName} LIMIT 1";
|
||||||
|
$stmt = $this->db->query($sql);
|
||||||
|
$row = $stmt->fetch();
|
||||||
|
|
||||||
|
if ($row) {
|
||||||
|
$sections[$tableName] = [
|
||||||
|
'title' => $row['section'],
|
||||||
|
'table' => $tableName
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定栏目的所有项目
|
||||||
|
*/
|
||||||
|
public function getItemsBySection($tableName) {
|
||||||
|
$tableName = preg_replace('/[^a-zA-Z0-9_]/', '_', $tableName);
|
||||||
|
$sql = "SELECT * FROM {$tableName} ORDER BY name";
|
||||||
|
$stmt = $this->db->query($sql);
|
||||||
|
return $stmt->fetchAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有表名
|
||||||
|
*/
|
||||||
|
private function getAllTables() {
|
||||||
|
$sql = "SELECT name FROM sqlite_master
|
||||||
|
WHERE type='table'
|
||||||
|
AND name NOT LIKE 'sqlite_%'
|
||||||
|
AND name != 'json_sync_log'
|
||||||
|
ORDER BY name";
|
||||||
|
$stmt = $this->db->query($sql);
|
||||||
|
return $stmt->fetchAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭数据库连接
|
||||||
|
*/
|
||||||
|
public function close() {
|
||||||
|
$this->db = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
258
index.php
258
index.php
@ -3,63 +3,18 @@
|
|||||||
* SecHub - 网络安全工具导航页
|
* SecHub - 网络安全工具导航页
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 定义JSON文件路径
|
// 定义路径
|
||||||
$jsonDir = __DIR__ . '/assets/json/';
|
$jsonDir = __DIR__ . '/assets/json/';
|
||||||
|
$dbDir = __DIR__ . '/assets/db/';
|
||||||
|
$dbPath = $dbDir . 'sechub.db';
|
||||||
|
|
||||||
/**
|
// 确保数据库目录存在
|
||||||
* 读取JSON文件并返回数据
|
if (!is_dir($dbDir)) {
|
||||||
* @param string $filePath JSON文件路径
|
mkdir($dbDir, 0755, true);
|
||||||
* @return array 解析后的数据数组
|
|
||||||
*/
|
|
||||||
function loadJsonData($filePath) {
|
|
||||||
if (!file_exists($filePath)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = file_get_contents($filePath);
|
|
||||||
if ($content === false) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = json_decode($content, true);
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
|
||||||
error_log("JSON解析错误: " . json_last_error_msg());
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return is_array($data) ? $data : [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// 引入数据库类
|
||||||
* 获取所有JSON文件并自动识别栏目配置
|
require_once __DIR__ . '/db.php';
|
||||||
* @param string $jsonDir JSON目录路径
|
|
||||||
* @return array 栏目配置数组
|
|
||||||
*/
|
|
||||||
function getSectionsConfig($jsonDir) {
|
|
||||||
$sections = [];
|
|
||||||
$jsonFiles = glob($jsonDir . '*.json');
|
|
||||||
|
|
||||||
foreach ($jsonFiles as $file) {
|
|
||||||
$filename = basename($file);
|
|
||||||
$data = loadJsonData($file);
|
|
||||||
|
|
||||||
if (!empty($data) && isset($data[0]['section'])) {
|
|
||||||
$sections[$filename] = [
|
|
||||||
'title' => $data[0]['section'],
|
|
||||||
'file' => $filename,
|
|
||||||
'items' => array_slice($data, 1)
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
$sections[$filename] = [
|
|
||||||
'title' => pathinfo($filename, PATHINFO_FILENAME),
|
|
||||||
'file' => $filename,
|
|
||||||
'items' => $data
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染卡片HTML
|
* 渲染卡片HTML
|
||||||
@ -81,8 +36,17 @@ function renderCard($item) {
|
|||||||
</div>";
|
</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动获取栏目配置
|
// 初始化数据库并同步数据
|
||||||
$sections = getSectionsConfig($jsonDir);
|
try {
|
||||||
|
$database = new SecHubDatabase($dbPath, $jsonDir);
|
||||||
|
$database->syncJsonToDatabase();
|
||||||
|
|
||||||
|
// 获取栏目配置
|
||||||
|
$sections = $database->getSectionsConfig();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log("数据库初始化失败: " . $e->getMessage());
|
||||||
|
$sections = [];
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -90,6 +54,7 @@ $sections = getSectionsConfig($jsonDir);
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="shortcut icon" href="./assets/imgs/favicon.ico" type="image/x-icon">
|
||||||
<title>SecHub - 网络安全工具集</title>
|
<title>SecHub - 网络安全工具集</title>
|
||||||
<link rel="stylesheet" href="assets/css/style.css">
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
@ -98,6 +63,17 @@ $sections = getSectionsConfig($jsonDir);
|
|||||||
<header>
|
<header>
|
||||||
<h1>SecHub 网安工具集</h1>
|
<h1>SecHub 网安工具集</h1>
|
||||||
<p>一站式网络安全工具与资源导航平台</p>
|
<p>一站式网络安全工具与资源导航平台</p>
|
||||||
|
|
||||||
|
<!-- 全局搜索框 -->
|
||||||
|
<div class="search-container">
|
||||||
|
<input type="text"
|
||||||
|
id="global-search"
|
||||||
|
class="search-input"
|
||||||
|
placeholder="🔍 搜索工具名称、描述或链接..."
|
||||||
|
autocomplete="off">
|
||||||
|
<div id="search-results" class="search-results"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button id="theme-toggle" class="theme-toggle" title="点击切换白天/黑夜模式">
|
<button id="theme-toggle" class="theme-toggle" title="点击切换白天/黑夜模式">
|
||||||
<span class="theme-icon">🌙</span>
|
<span class="theme-icon">🌙</span>
|
||||||
<span class="theme-tooltip">切换主题</span>
|
<span class="theme-tooltip">切换主题</span>
|
||||||
@ -106,20 +82,38 @@ $sections = getSectionsConfig($jsonDir);
|
|||||||
|
|
||||||
<?php foreach ($sections as $key => $config): ?>
|
<?php foreach ($sections as $key => $config): ?>
|
||||||
<?php
|
<?php
|
||||||
$items = $config['items'] ?? [];
|
$items = $database->getItemsBySection($key);
|
||||||
|
// 获取对应的JSON文件名
|
||||||
|
$jsonFile = $key . '.json';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<section class="section">
|
<section class="section" data-section="<?= htmlspecialchars($key) ?>">
|
||||||
|
<div class="section-header">
|
||||||
|
<div class="section-title-wrapper">
|
||||||
<h2 class="section-title">
|
<h2 class="section-title">
|
||||||
<?= htmlspecialchars($config['title']) ?>
|
<?= htmlspecialchars($config['title']) ?>
|
||||||
</h2>
|
</h2>
|
||||||
|
<!-- 下载按钮 -->
|
||||||
|
<button class="download-btn"
|
||||||
|
onclick="downloadJson('<?= htmlspecialchars($jsonFile) ?>')"
|
||||||
|
title="下载JSON文件">
|
||||||
|
📥 下载数据源
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<!-- 单项搜索框 -->
|
||||||
|
<input type="text"
|
||||||
|
class="section-search"
|
||||||
|
data-section="<?= htmlspecialchars($key) ?>"
|
||||||
|
placeholder="🔍 在此栏目中搜索..."
|
||||||
|
autocomplete="off">
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php if (empty($items)): ?>
|
<?php if (empty($items)): ?>
|
||||||
<div class="empty-state">
|
<div class="empty-state">
|
||||||
<p>暂无数据,请在 <?= htmlspecialchars($config['file']) ?> 中添加项目</p>
|
<p>暂无数据</p>
|
||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<div class="cards-grid">
|
<div class="cards-grid" data-section-items="<?= htmlspecialchars($key) ?>">
|
||||||
<?php foreach ($items as $item): ?>
|
<?php foreach ($items as $item): ?>
|
||||||
<?= renderCard($item) ?>
|
<?= renderCard($item) ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@ -145,6 +139,152 @@ $sections = getSectionsConfig($jsonDir);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// HTML转义函数
|
||||||
|
function escapeHtml(text) {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.textContent = text;
|
||||||
|
return div.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 渲染卡片函数(用于搜索结果)
|
||||||
|
function renderCardJS(item) {
|
||||||
|
const name = item.name || '未命名';
|
||||||
|
const url = item.url || '#';
|
||||||
|
const description = item.description || '暂无简介';
|
||||||
|
|
||||||
|
return `
|
||||||
|
<div class="card" onclick="window.open('${url}', '_blank')">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title">${escapeHtml(name)}</h3>
|
||||||
|
<a href="${url}" target="_blank" class="card-link" onclick="event.stopPropagation()">${escapeHtml(url)}</a>
|
||||||
|
</div>
|
||||||
|
<p class="card-description">${escapeHtml(description)}</p>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 全局搜索功能
|
||||||
|
const globalSearchInput = document.getElementById('global-search');
|
||||||
|
const searchResults = document.getElementById('search-results');
|
||||||
|
let searchTimeout;
|
||||||
|
|
||||||
|
globalSearchInput.addEventListener('input', function() {
|
||||||
|
clearTimeout(searchTimeout);
|
||||||
|
const keyword = this.value.trim();
|
||||||
|
|
||||||
|
if (keyword.length === 0) {
|
||||||
|
searchResults.style.display = 'none';
|
||||||
|
showAllSections();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
searchTimeout = setTimeout(() => {
|
||||||
|
performGlobalSearch(keyword);
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
function performGlobalSearch(keyword) {
|
||||||
|
fetch(`search.php?action=global&keyword=${encodeURIComponent(keyword)}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
displaySearchResults(data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('搜索失败:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function displaySearchResults(results) {
|
||||||
|
searchResults.innerHTML = '';
|
||||||
|
|
||||||
|
if (Object.keys(results).length === 0) {
|
||||||
|
searchResults.innerHTML = '<div class="no-results">未找到相关结果</div>';
|
||||||
|
searchResults.style.display = 'block';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(results).forEach(tableName => {
|
||||||
|
const section = results[tableName];
|
||||||
|
const sectionDiv = document.createElement('div');
|
||||||
|
sectionDiv.className = 'search-result-section';
|
||||||
|
|
||||||
|
const title = document.createElement('h3');
|
||||||
|
title.className = 'search-result-title';
|
||||||
|
title.textContent = section.section;
|
||||||
|
sectionDiv.appendChild(title);
|
||||||
|
|
||||||
|
const cardsGrid = document.createElement('div');
|
||||||
|
cardsGrid.className = 'cards-grid';
|
||||||
|
|
||||||
|
section.items.forEach(item => {
|
||||||
|
const cardDiv = document.createElement('div');
|
||||||
|
cardDiv.innerHTML = renderCardJS(item);
|
||||||
|
cardsGrid.appendChild(cardDiv.firstElementChild);
|
||||||
|
});
|
||||||
|
|
||||||
|
sectionDiv.appendChild(cardsGrid);
|
||||||
|
searchResults.appendChild(sectionDiv);
|
||||||
|
});
|
||||||
|
|
||||||
|
searchResults.style.display = 'block';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showAllSections() {
|
||||||
|
// 不需要做任何事,因为栏目一直显示
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideAllSections() {
|
||||||
|
// 不需要隐藏栏目
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载JSON文件
|
||||||
|
function downloadJson(filename) {
|
||||||
|
const url = `assets/json/${filename}`;
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.download = filename;
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 单项搜索功能
|
||||||
|
document.querySelectorAll('.section-search').forEach(input => {
|
||||||
|
input.addEventListener('input', function() {
|
||||||
|
const section = this.dataset.section;
|
||||||
|
const keyword = this.value.trim();
|
||||||
|
const cardsGrid = document.querySelector(`[data-section-items="${section}"]`);
|
||||||
|
|
||||||
|
if (!cardsGrid) return;
|
||||||
|
|
||||||
|
const cards = cardsGrid.querySelectorAll('.card');
|
||||||
|
|
||||||
|
cards.forEach(card => {
|
||||||
|
const title = card.querySelector('.card-title').textContent.toLowerCase();
|
||||||
|
const description = card.querySelector('.card-description').textContent.toLowerCase();
|
||||||
|
const link = card.querySelector('.card-link').textContent.toLowerCase();
|
||||||
|
|
||||||
|
if (keyword === '' ||
|
||||||
|
title.includes(keyword.toLowerCase()) ||
|
||||||
|
description.includes(keyword.toLowerCase()) ||
|
||||||
|
link.includes(keyword.toLowerCase())) {
|
||||||
|
card.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
card.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 点击其他地方关闭搜索结果
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
if (!e.target.closest('.search-container')) {
|
||||||
|
searchResults.style.display = 'none';
|
||||||
|
if (globalSearchInput.value.trim() === '') {
|
||||||
|
showAllSections();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 黑夜模式切换功能
|
// 黑夜模式切换功能
|
||||||
(function() {
|
(function() {
|
||||||
const themeToggle = document.getElementById('theme-toggle');
|
const themeToggle = document.getElementById('theme-toggle');
|
||||||
|
|||||||
44
search.php
Normal file
44
search.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SecHub 搜索API
|
||||||
|
*/
|
||||||
|
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
||||||
|
// 定义路径
|
||||||
|
$jsonDir = __DIR__ . '/assets/json/';
|
||||||
|
$dbDir = __DIR__ . '/assets/db/';
|
||||||
|
$dbPath = $dbDir . 'sechub.db';
|
||||||
|
|
||||||
|
// 引入数据库类
|
||||||
|
require_once __DIR__ . '/db.php';
|
||||||
|
|
||||||
|
$action = $_GET['action'] ?? '';
|
||||||
|
$keyword = $_GET['keyword'] ?? '';
|
||||||
|
|
||||||
|
if (empty($action) || empty($keyword)) {
|
||||||
|
echo json_encode([]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$database = new SecHubDatabase($dbPath, $jsonDir);
|
||||||
|
|
||||||
|
if ($action === 'global') {
|
||||||
|
// 全局搜索
|
||||||
|
$results = $database->globalSearch($keyword);
|
||||||
|
echo json_encode($results, JSON_UNESCAPED_UNICODE);
|
||||||
|
} elseif ($action === 'section') {
|
||||||
|
// 栏目搜索
|
||||||
|
$section = $_GET['section'] ?? '';
|
||||||
|
$results = $database->searchBySection($section, $keyword);
|
||||||
|
echo json_encode($results, JSON_UNESCAPED_UNICODE);
|
||||||
|
} else {
|
||||||
|
echo json_encode([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$database->close();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log("搜索失败: " . $e->getMessage());
|
||||||
|
echo json_encode(['error' => '搜索失败']);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user