diff --git a/README.md b/README.md index 51f380a..7722487 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,8 @@ - PHP >= 7.4 - PDO扩展 -- PDO MySQL扩展(必须使用MySQL或MariaDB) +- PDO MySQL扩展(使用MySQL 5.7+或MariaDB时) +- PDO SQLite扩展(使用SQLite时) - GD扩展(验证码功能) - cURL扩展(网站信息抓取) @@ -52,8 +53,9 @@ - PHP版本选择7.4或以上 3. **配置数据库** - - 在宝塔面板中创建MySQL数据库 + - 在宝塔面板中创建MySQL数据库(推荐MariaDB或MySQL 5.7+) - 记录数据库名、用户名、密码 + - 安装时勾选"兼容MySQL 5.7"选项(如使用MySQL 5.7) 4. **设置文件权限** ```bash @@ -65,6 +67,7 @@ 5. **运行安装向导** - 访问 `http://your-domain/install.php` - 按照向导完成安装配置 + - 选择数据库类型(默认MariaDB/MySQL,可选SQLite) 6. **安全设置** - 安装完成后删除或重命名 `install.php` @@ -126,6 +129,7 @@ 4. **运行安装** - 访问安装向导完成配置 + - 选择数据库类型(默认MariaDB/MySQL,可选SQLite) ## 🎯 使用说明 @@ -173,6 +177,9 @@ private $host = 'localhost'; private $db_name = 'submission_system'; private $username = 'root'; private $password = ''; + +// 使用SQLite(设置为true) +private $use_sqlite = false; ``` ### 功能配置 diff --git a/admin/index.php b/admin/index.php index 9051119..4c45e0d 100644 --- a/admin/index.php +++ b/admin/index.php @@ -102,37 +102,66 @@ $offset = ($page - 1) * $limit; $limit = (int)$limit; $offset = (int)$offset; +// 检查数据库版本 +$is_mysql_57 = $database->isMySQL57(); + if ($type === 'website') { $count_stmt = $db->prepare("SELECT COUNT(*) FROM website_submissions WHERE status = ?"); $count_stmt->execute([$filter]); $total = $count_stmt->fetchColumn(); - $stmt = $db->prepare(" - SELECT id, url, title, description, platforms, contact, status, admin_note, created_at - FROM website_submissions - WHERE status = ? - ORDER BY created_at DESC - LIMIT ?, ? - "); - $stmt->bindValue(1, $filter, PDO::PARAM_STR); - $stmt->bindValue(2, $offset, PDO::PARAM_INT); - $stmt->bindValue(3, $limit, PDO::PARAM_INT); + if ($is_mysql_57) { + $stmt = $db->prepare(" + SELECT id, url, title, description, platforms, contact, status, admin_note, created_at + FROM website_submissions + WHERE status = ? + ORDER BY created_at DESC + LIMIT ?, ? + "); + $stmt->bindValue(1, $filter, PDO::PARAM_STR); + $stmt->bindValue(2, $offset, PDO::PARAM_INT); + $stmt->bindValue(3, $limit, PDO::PARAM_INT); + } else { + $stmt = $db->prepare(" + SELECT id, url, title, description, platforms, contact, status, admin_note, created_at + FROM website_submissions + WHERE status = ? + ORDER BY created_at DESC + LIMIT ? OFFSET ? + "); + $stmt->bindValue(1, $filter, PDO::PARAM_STR); + $stmt->bindValue(2, $limit, PDO::PARAM_INT); + $stmt->bindValue(3, $offset, PDO::PARAM_INT); + } $stmt->execute(); } else { $count_stmt = $db->prepare("SELECT COUNT(*) FROM app_submissions WHERE status = ?"); $count_stmt->execute([$filter]); $total = $count_stmt->fetchColumn(); - $stmt = $db->prepare(" - SELECT id, name, platform, version, icon_url, download_url, website_url, description, platforms, contact, status, admin_note, created_at - FROM app_submissions - WHERE status = ? - ORDER BY created_at DESC - LIMIT ?, ? - "); - $stmt->bindValue(1, $filter, PDO::PARAM_STR); - $stmt->bindValue(2, $offset, PDO::PARAM_INT); - $stmt->bindValue(3, $limit, PDO::PARAM_INT); + if ($is_mysql_57) { + $stmt = $db->prepare(" + SELECT id, name, platform, version, icon_url, download_url, website_url, description, platforms, contact, status, admin_note, created_at + FROM app_submissions + WHERE status = ? + ORDER BY created_at DESC + LIMIT ?, ? + "); + $stmt->bindValue(1, $filter, PDO::PARAM_STR); + $stmt->bindValue(2, $offset, PDO::PARAM_INT); + $stmt->bindValue(3, $limit, PDO::PARAM_INT); + } else { + $stmt = $db->prepare(" + SELECT id, name, platform, version, icon_url, download_url, website_url, description, platforms, contact, status, admin_note, created_at + FROM app_submissions + WHERE status = ? + ORDER BY created_at DESC + LIMIT ? OFFSET ? + "); + $stmt->bindValue(1, $filter, PDO::PARAM_STR); + $stmt->bindValue(2, $limit, PDO::PARAM_INT); + $stmt->bindValue(3, $offset, PDO::PARAM_INT); + } $stmt->execute(); } @@ -146,7 +175,7 @@ $total_pages = ceil($total / $limit);