add.php
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>深夜清單|管理後台</title>
|
||||
<title>影片清單|管理後台</title>
|
||||
<link rel="stylesheet" href="../../assets/css/style.css">
|
||||
<link rel="stylesheet" href="css/vedio-list.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||
@@ -14,7 +14,7 @@
|
||||
<body class="vedio-admin-page">
|
||||
<header class="inner-page-header">
|
||||
<div class="header-inner site-header-inner">
|
||||
<h1 class="main-title">深夜清單後台</h1>
|
||||
<h1 class="main-title">影片清單後台</h1>
|
||||
<div class="subtitle-wrap">
|
||||
<span class="sub-title">ADMIN · CRUD</span>
|
||||
</div>
|
||||
|
||||
@@ -1,40 +1,51 @@
|
||||
<?php
|
||||
$error = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$maxRank = $Drama->q("SELECT MAX(`rank`) AS m FROM `dramas`");
|
||||
$nextRank = ((int)($maxRank[0]['m'] ?? 0)) + 1;
|
||||
$type = $_POST['type'] ?? '';
|
||||
|
||||
$data = [
|
||||
'title' => trim($_POST['title'] ?? ''),
|
||||
'type' => $_POST['type'] ?? 'drama',
|
||||
'platform' => $_POST['platform'] ?? '其他',
|
||||
'watch_url' => trim($_POST['watch_url'] ?? ''),
|
||||
'current_season' => max(1, (int)($_POST['current_season'] ?? 1)),
|
||||
'current_episode' => max(0, (int)($_POST['current_episode'] ?? 0)),
|
||||
'current_position' => trim($_POST['current_position'] ?? ''),
|
||||
'progress_note' => trim($_POST['progress_note'] ?? ''),
|
||||
'status' => $_POST['status'] ?? 'want',
|
||||
'rating' => $_POST['rating'] !== '' ? $_POST['rating'] : null,
|
||||
'intro' => trim($_POST['intro'] ?? ''),
|
||||
'note' => trim($_POST['note'] ?? ''),
|
||||
'sh' => 1,
|
||||
'rank' => $nextRank,
|
||||
];
|
||||
if (!in_array($type, ['variety', 'drama'], true)) {
|
||||
$error = '請選擇正確的類型(綜藝或戲劇)。';
|
||||
} else {
|
||||
$maxRank = $Drama->q("SELECT MAX(`rank`) AS m FROM `dramas`");
|
||||
$nextRank = ((int)($maxRank[0]['m'] ?? 0)) + 1;
|
||||
|
||||
// DB::save 用字串拼接;null 改空字串避免 SQL 破掉
|
||||
if ($data['rating'] === null) {
|
||||
$data['rating'] = '';
|
||||
$data = [
|
||||
'title' => trim($_POST['title'] ?? ''),
|
||||
'type' => $type,
|
||||
'platform' => $_POST['platform'] ?? '其他',
|
||||
'watch_url' => trim($_POST['watch_url'] ?? ''),
|
||||
'current_season' => max(1, (int)($_POST['current_season'] ?? 1)),
|
||||
'current_episode' => max(0, (int)($_POST['current_episode'] ?? 0)),
|
||||
'current_position' => trim($_POST['current_position'] ?? ''),
|
||||
'progress_note' => trim($_POST['progress_note'] ?? ''),
|
||||
'status' => $_POST['status'] ?? 'want',
|
||||
'rating' => $_POST['rating'] !== '' ? $_POST['rating'] : null,
|
||||
'intro' => trim($_POST['intro'] ?? ''),
|
||||
'note' => trim($_POST['note'] ?? ''),
|
||||
'sh' => 1,
|
||||
'rank' => $nextRank,
|
||||
];
|
||||
|
||||
// DB::save 用字串拼接;null 改空字串避免 SQL 破掉
|
||||
if ($data['rating'] === null) {
|
||||
$data['rating'] = '';
|
||||
}
|
||||
|
||||
$Drama->save($data);
|
||||
to("?do=drama");
|
||||
exit;
|
||||
}
|
||||
|
||||
$Drama->save($data);
|
||||
to("?do=drama");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<section>
|
||||
<h2 class="section-title">新增作品</h2>
|
||||
|
||||
<form class="admin-form" method="post" action="?do=add">
|
||||
<?php if ($error): ?>
|
||||
<p class="empty-hint"><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form class="admin-form" method="post" action="?do=add" enctype="multipart/form-data">
|
||||
<label for="title">劇名/節目名</label>
|
||||
<input type="text" id="title" name="title" required>
|
||||
|
||||
@@ -54,7 +65,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<option value="YouTube">YouTube</option>
|
||||
<option value="其他">其他</option>
|
||||
</select>
|
||||
|
||||
<label for="poster">海報圖片</label>
|
||||
<input type="file" id="poster" name="poster">
|
||||
<label for="watch_url">直接觀看網址</label>
|
||||
<input type="url" id="watch_url" name="watch_url" placeholder="https://...">
|
||||
|
||||
|
||||
@@ -99,6 +99,19 @@
|
||||
text-align: center;
|
||||
padding: 0.75rem;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.vedio-list-page .drama-card__poster--image {
|
||||
padding: 0;
|
||||
background: var(--color-surface-soft);
|
||||
}
|
||||
|
||||
.vedio-list-page .drama-card__poster--image img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.vedio-list-page .drama-card__meta {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-- 深夜清單 / 追劇資料庫
|
||||
-- 影片清單 / 追劇資料庫
|
||||
-- 本機 XAMPP:phpMyAdmin 匯入此檔即可
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS `vedio_list` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>水晶男孩|深夜清單</title>
|
||||
<title>水晶男孩|影片清單</title>
|
||||
<link rel="stylesheet" href="../../assets/css/style.css">
|
||||
<link rel="stylesheet" href="../../assets/css/index.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||
@@ -17,7 +17,7 @@
|
||||
<body class="vedio-list-page">
|
||||
<header class="inner-page-header">
|
||||
<div class="header-inner site-header-inner">
|
||||
<h1 class="main-title">深夜清單</h1>
|
||||
<h1 class="main-title">影片清單</h1>
|
||||
<div class="subtitle-wrap">
|
||||
<span class="sub-title">DRAMA & VARIETY WATCH LIST</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user