156 lines
6.6 KiB
PHP
156 lines
6.6 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
|
|
header('Location: admin_login.php');
|
|
exit;
|
|
}
|
|
|
|
$settings_file = 'settings.json';
|
|
$settings = json_decode(file_get_contents($settings_file), true);
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
echo '<pre>POST data: ';
|
|
print_r($_POST);
|
|
echo '</pre>';
|
|
|
|
$settings['trial_duration_public'] = intval($_POST['trial_duration_public']);
|
|
$settings['trial_duration_premium'] = intval($_POST['trial_duration_premium']);
|
|
$settings['public_price_monthly'] = floatval($_POST['public_price_monthly']);
|
|
$settings['premium_price_monthly'] = floatval($_POST['premium_price_monthly']);
|
|
$settings['public_price_yearly'] = floatval($_POST['public_price_yearly']);
|
|
$settings['premium_price_yearly'] = floatval($_POST['premium_price_yearly']);
|
|
|
|
echo '<pre>Settings to save: ';
|
|
print_r($settings);
|
|
echo '</pre>';
|
|
|
|
if (is_writable($settings_file)) {
|
|
echo '<p>settings.json is writable.</p>';
|
|
} else {
|
|
echo '<p>settings.json is NOT writable.</p>';
|
|
}
|
|
|
|
$result = file_put_contents($settings_file, json_encode($settings, JSON_PRETTY_PRINT));
|
|
|
|
if ($result === false) {
|
|
echo '<p>Error saving settings!</p>';
|
|
$error = error_get_last();
|
|
if ($error) {
|
|
echo '<pre>Error details: ';
|
|
print_r($error);
|
|
echo '</pre>';
|
|
}
|
|
} else {
|
|
echo '<p>Settings saved successfully.</p>';
|
|
header('Location: admin_settings.php?success=1');
|
|
exit;
|
|
}
|
|
exit; // Stop execution to see debug output
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>App Settings - Admin Panel</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<style>
|
|
.sidebar {
|
|
width: 280px;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
height: 100vh;
|
|
background-color: #1E1E1E;
|
|
padding-top: 20px;
|
|
}
|
|
.main-content {
|
|
margin-left: 280px;
|
|
padding: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="sidebar d-flex flex-column p-3">
|
|
<h3 class="text-white text-center mb-4">Admin Panel</h3>
|
|
<ul class="nav nav-pills flex-column mb-auto">
|
|
<li class="nav-item">
|
|
<a href="admin.php" class="nav-link text-white"><i class="bi bi-speedometer2 me-2"></i>Dashboard</a>
|
|
</li>
|
|
<li>
|
|
<a href="admin_users.php" class="nav-link text-white"><i class="bi bi-people-fill me-2"></i>Users</a>
|
|
</li>
|
|
<li>
|
|
<a href="admin_content.php" class="nav-link text-white"><i class="bi bi-tv-fill me-2"></i>Premium Content</a>
|
|
</li>
|
|
<li>
|
|
<a href="admin_settings.php" class="nav-link active text-white"><i class="bi bi-gear-fill me-2"></i>App Settings</a>
|
|
</li>
|
|
</ul>
|
|
<hr>
|
|
<div class="dropdown">
|
|
<a href="admin.php?action=logout" class="d-flex align-items-center text-white text-decoration-none">
|
|
<i class="bi bi-box-arrow-right me-2"></i>
|
|
<strong>Sign out</strong>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<main class="main-content">
|
|
<h1 class="mb-4">App Settings</h1>
|
|
|
|
<?php if (isset($_GET['success'])): ?>
|
|
<div class="alert alert-success">Settings saved successfully.</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="card form-card">
|
|
<div class="card-body">
|
|
<form method="POST" action="admin_settings.php">
|
|
<h4 class="mb-3">Trial Durations (in days)</h4>
|
|
<div class="row mb-3">
|
|
<div class="col-md-6">
|
|
<label for="trial_duration_public" class="form-label">Public Trial</label>
|
|
<input type="number" class="form-control" id="trial_duration_public" name="trial_duration_public" value="<?php echo $settings['trial_duration_public']; ?>">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label for="trial_duration_premium" class="form-label">Premium Trial</label>
|
|
<input type="number" class="form-control" id="trial_duration_premium" name="trial_duration_premium" value="<?php echo $settings['trial_duration_premium']; ?>">
|
|
</div>
|
|
</div>
|
|
|
|
<h4 class="mb-3">Subscription Pricing ($)</h4>
|
|
<div class="row mb-3">
|
|
<div class="col-md-6">
|
|
<label for="public_price_monthly" class="form-label">Public - Monthly</label>
|
|
<input type="text" class="form-control" id="public_price_monthly" name="public_price_monthly" value="<?php echo $settings['public_price_monthly']; ?>">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label for="public_price_yearly" class="form-label">Public - Yearly</label>
|
|
<input type="text" class="form-control" id="public_price_yearly" name="public_price_yearly" value="<?php echo $settings['public_price_yearly']; ?>">
|
|
</div>
|
|
</div>
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<label for="premium_price_monthly" class="form-label">Premium - Monthly</label>
|
|
<input type="text" class="form-control" id="premium_price_monthly" name="premium_price_monthly" value="<?php echo $settings['premium_price_monthly']; ?>">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label for="premium_price_yearly" class="form-label">Premium - Yearly</label>
|
|
<input type="text" class="form-control" id="premium_price_yearly" name="premium_price_yearly" value="<?php echo $settings['premium_price_yearly']; ?>">
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary">Save Settings</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
</body>
|
|
</html>
|