-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpool_manager.php
More file actions
62 lines (59 loc) · 2.26 KB
/
Copy pathpool_manager.php
File metadata and controls
62 lines (59 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/core/Database.php';
require_once __DIR__ . '/init_check.php';
require_once __DIR__ . '/core/Session.php';
require_once __DIR__ . '/core/TokenSystem.php';
require_once __DIR__ . '/core/StockEngine.php';
require_once __DIR__ . '/core/GachaEngine.php';
require_once __DIR__ . '/core/TradingEngine.php';
require_once __DIR__ . '/core/PoolEngine.php';
require_once __DIR__ . '/core/QuestEngine.php';
require_once __DIR__ . '/core/MarketEngine.php';
require_once __DIR__ . '/adapters/manager.php';
Session::start();
require_once __DIR__ . '/core/AutoJob.php';
AutoJob::run();
Session::requireAuth();
$user = Session::user();
if (!$user || !$user['is_admin']) { header('Location: ' . url('/')); exit; }
$message = '';
$error = '';
// Handle POST actions
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = $_POST['action'] ?? '';
if ($action === 'create') {
$name = trim($_POST['pool_name'] ?? '');
if ($name) { PoolEngine::createPool($name); $message = "卡池「{$name}」已创建。"; }
}
if ($action === 'delete') {
$pid = (int)($_POST['pool_id'] ?? 0);
if ($pid) { PoolEngine::deletePool($pid); $message = '卡池已删除。'; }
}
if ($action === 'split') {
$pid = (int)($_POST['pool_id'] ?? 0);
$newName = trim($_POST['new_pool_name'] ?? '');
$splitAt = (int)($_POST['split_at'] ?? 0);
if ($pid && $newName) {
try { PoolEngine::splitPool($pid, $newName, $splitAt); $message = "已分割为新卡池「{$newName}」。"; }
catch (Exception $e) { $error = $e->getMessage(); }
}
}
if ($action === 'set_limited') {
$pid = (int)($_POST['pool_id'] ?? 0);
$expiresAt = $_POST['expires_at'] ?? '';
if ($pid && $expiresAt) {
PoolEngine::setLimited($pid, $expiresAt);
$message = '✅ 已设为绝版卡池,到期后卡牌自动变为绝版。';
}
}
if ($action === 'unset_limited') {
$pid = (int)($_POST['pool_id'] ?? 0);
if ($pid) {
PoolEngine::unsetLimited($pid);
$message = '✅ 已移除绝版状态。';
}
}
}
$pools = PoolEngine::getAllPools();
require_once __DIR__ . '/templates/pool_manager.php';