投稿功能

This commit is contained in:
Developer
2026-03-30 07:32:12 +08:00
parent 59d82c9029
commit aeddc200a7
6 changed files with 986 additions and 30 deletions

View File

@@ -167,7 +167,14 @@ if (isset($_GET['api'])) {
exit;
}
$required = ['name', 'catename', 'url', 'keywords', 'introduce', 'captcha'];
$img = isset($_POST['img']) ? trim($_POST['img']) : '';
$isFlutter = strpos($img, 'Flutter') !== false;
$required = ['name', 'catename', 'url', 'keywords', 'introduce'];
if (!$isFlutter) {
$required[] = 'captcha';
}
foreach ($required as $field) {
if (!isset($_POST[$field]) || empty(trim($_POST[$field]))) {
echo json_encode(['ok' => false, 'error' => "缺少必填字段:{$field}"]);
@@ -175,13 +182,15 @@ if (isset($_GET['api'])) {
}
}
$captcha = trim($_POST['captcha']);
$captcha_key = 'captcha_' . session_id();
if (!isset($_SESSION[$captcha_key]) || $_SESSION[$captcha_key] != $captcha) {
echo json_encode(['ok' => false, 'error' => '验证码错误,请重新输入']);
exit;
if (!$isFlutter) {
$captcha = trim($_POST['captcha']);
$captcha_key = 'captcha_' . session_id();
if (!isset($_SESSION[$captcha_key]) || $_SESSION[$captcha_key] != $captcha) {
echo json_encode(['ok' => false, 'error' => '验证码错误,请重新输入']);
exit;
}
unset($_SESSION[$captcha_key]);
}
unset($_SESSION[$captcha_key]);
try {
$name = trim($_POST['name']);