105 lines
4.8 KiB
PHP
105 lines
4.8 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
// Fetch settings
|
|
$settings = [];
|
|
try {
|
|
$stmt = db()->query("SELECT setting_key, setting_value FROM bot_settings");
|
|
while ($row = $stmt->fetch()) {
|
|
$settings[$row['setting_key']] = $row['setting_value'];
|
|
}
|
|
} catch (PDOException $e) {
|
|
// Table might not exist yet or other DB error
|
|
}
|
|
|
|
$discordToken = $settings['discord_token'] ?? '';
|
|
$voiceChannelId = $settings['voice_channel_id'] ?? '1457687430189682781';
|
|
$sahurTime = $settings['sahur_time'] ?? '03:30';
|
|
|
|
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Discord Bot for Sahur Alarm and Music';
|
|
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Sahur Bot Command Center</title>
|
|
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<header class="header">
|
|
<div>
|
|
<h1>Sahur Bot</h1>
|
|
<p style="margin:0; color:var(--text-muted); font-size: 0.875rem;">Command Center</p>
|
|
</div>
|
|
<div id="bot-status">
|
|
<span class="badge badge-disconnected">Offline</span>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="card">
|
|
<h2 class="card-title">Bot Configuration</h2>
|
|
<form id="config-form">
|
|
<div class="form-group">
|
|
<label class="form-label" for="discord_token">Discord Bot Token</label>
|
|
<input type="password" id="discord_token" name="discord_token" class="form-control" placeholder="MTAx..." value="<?= htmlspecialchars($discordToken) ?>">
|
|
<small style="color:var(--text-muted); font-size: 0.75rem;">Never share your token with anyone.</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="voice_channel_id">Voice Channel ID</label>
|
|
<input type="text" id="voice_channel_id" name="voice_channel_id" class="form-control" placeholder="1457..." value="<?= htmlspecialchars($voiceChannelId) ?>">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label" for="sahur_time">Alarm Time (WIB)</label>
|
|
<input type="time" id="sahur_time" name="sahur_time" class="form-control" value="<?= htmlspecialchars($sahurTime) ?>">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Save Settings</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h2 class="card-title">Sound Preview</h2>
|
|
<p style="color:var(--text-muted); font-size: 0.875rem; margin-bottom: 12px;">This sound will be played in the voice channel at <?= htmlspecialchars($sahurTime) ?> WIB.</p>
|
|
<audio controls class="audio-player">
|
|
<source src="assets/audio/sahur.mp3" type="audio/mpeg">
|
|
Your browser does not support the audio element.
|
|
</audio>
|
|
<div style="margin-top: 16px; display: flex; flex-direction: column; gap: 12px;">
|
|
<button id="test-audio-btn" class="btn" style="border: 1px solid var(--border);">Test Play Locally</button>
|
|
|
|
<div style="padding: 16px; background: #f8fafc; border: 1px dashed var(--border); border-radius: var(--radius);">
|
|
<label class="form-label" style="margin-bottom: 8px; display: block;">Upload Sahur MP3</label>
|
|
<input type="file" id="sahur-upload" accept="audio/mpeg" style="font-size: 0.75rem; width: 100%;">
|
|
<button id="upload-btn" class="btn btn-primary" style="margin-top: 10px; width: 100%; display: none;">Upload Now</button>
|
|
<div id="upload-status" style="margin-top: 8px; font-size: 0.75rem;"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h2 class="card-title">Bot Code Status</h2>
|
|
<p style="color:var(--text-muted); font-size: 0.875rem;">The <code>discord.js v14</code> bot skeleton has been generated in the <code>/bot</code> directory.</p>
|
|
<div style="background: #f1f5f9; padding: 12px; border-radius: var(--radius); font-family: monospace; font-size: 0.75rem; color: #334155; margin-top: 8px;">
|
|
# To start the bot:<br>
|
|
cd bot<br>
|
|
npm install<br>
|
|
DISCORD_TOKEN="your_token" node index.js
|
|
</div>
|
|
</div>
|
|
|
|
<footer style="margin-top: 48px; text-align: center; color: var(--text-muted); font-size: 0.75rem;">
|
|
© <?= date('Y') ?> Sahur Bot • Powered by Flatlogic LAMP
|
|
</footer>
|
|
</div>
|
|
|
|
<script src="assets/js/main.js?v=<?= time() ?>"></script>
|
|
</body>
|
|
</html>
|