This commit is contained in:
2026-08-24 16:32:53 +08:00
parent 604fb26cb2
commit c8b886e550
5 changed files with 28 additions and 2 deletions
+8
View File
@@ -9,9 +9,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$maxRank = $Drama->q("SELECT MAX(`rank`) AS m FROM `dramas`");
$nextRank = ((int)($maxRank[0]['m'] ?? 0)) + 1;
$posterName = '';
if (!empty($_FILES['poster']['name']) && $_FILES['poster']['error'] === UPLOAD_ERR_OK) {
$ext = strtolower(pathinfo($_FILES['poster']['name'], PATHINFO_EXTENSION));
$posterName = uniqid('poster_') . '.' . $ext;
move_uploaded_file($_FILES['poster']['tmp_name'], __DIR__ . '/../uploads/' . $posterName);
}
$data = [
'title' => trim($_POST['title'] ?? ''),
'type' => $type,
'poster' => $posterName,
'platform' => $_POST['platform'] ?? '其他',
'watch_url' => trim($_POST['watch_url'] ?? ''),
'current_season' => max(1, (int)($_POST['current_season'] ?? 1)),
+13 -1
View File
@@ -11,6 +11,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$row['title'] = trim($_POST['title'] ?? $row['title']);
$row['type'] = $_POST['type'] ?? $row['type'];
$row['platform'] = $_POST['platform'] ?? $row['platform'];
if (!empty($_FILES['poster']['name']) && $_FILES['poster']['error'] === UPLOAD_ERR_OK) {
$ext = strtolower(pathinfo($_FILES['poster']['name'], PATHINFO_EXTENSION));
$row['poster'] = uniqid('poster_') . '.' . $ext;
move_uploaded_file($_FILES['poster']['tmp_name'], __DIR__ . '/../uploads/' . $row['poster']);
}
$row['watch_url'] = trim($_POST['watch_url'] ?? '');
$row['current_season'] = max(1, (int)($_POST['current_season'] ?? 1));
$row['current_episode'] = max(0, (int)($_POST['current_episode'] ?? 0));
@@ -29,7 +35,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<section>
<h2 class="section-title">編輯作品</h2>
<form class="admin-form" method="post" action="?do=edit&amp;id=<?= (int)$row['id'] ?>">
<form class="admin-form" method="post" action="?do=edit&amp;id=<?= (int)$row['id'] ?>" enctype="multipart/form-data">
<label for="title">劇名/節目名</label>
<input type="text" id="title" name="title" required
value="<?= htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8') ?>">
@@ -52,6 +58,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<?php endforeach; ?>
</select>
<label for="poster">海報圖片</label>
<?php if (!empty($row['poster'])): ?>
<img src="../uploads/<?= htmlspecialchars($row['poster'], ENT_QUOTES, 'UTF-8') ?>" alt="" style="max-width:120px;display:block;margin-bottom:0.5rem;">
<?php endif; ?>
<input type="file" id="poster" name="poster" accept="image/*">
<label for="watch_url">直接觀看網址</label>
<input type="url" id="watch_url" name="watch_url"
value="<?= htmlspecialchars($row['watch_url'] ?? '', ENT_QUOTES, 'UTF-8') ?>"
+7 -1
View File
@@ -52,7 +52,13 @@ $rows = $Drama->all($where, " ORDER BY `rank` ASC, `id` ASC");
$posterLabel = htmlspecialchars(strtoupper($row['platform']) . ' · ' . $typeText, ENT_QUOTES, 'UTF-8');
?>
<article class="drama-card" data-type="<?= htmlspecialchars($row['type'], ENT_QUOTES, 'UTF-8') ?>">
<div class="drama-card__poster" aria-hidden="true"><?= $posterLabel ?></div>
<div class="drama-card__poster<?= !empty($row['poster']) ? ' drama-card__poster--image' : '' ?>" aria-hidden="true">
<?php if (!empty($row['poster'])): ?>
<img src="uploads/<?= htmlspecialchars($row['poster'], ENT_QUOTES, 'UTF-8') ?>" alt="">
<?php else: ?>
<?= $posterLabel ?>
<?php endif; ?>
</div>
<div class="drama-card__meta">
<span class="drama-tag"><?= htmlspecialchars($typeText, ENT_QUOTES, 'UTF-8') ?></span>
<span class="drama-tag drama-tag--platform"><?= htmlspecialchars($row['platform'], ENT_QUOTES, 'UTF-8') ?></span>
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB