Compare commits

...

1 Commits

Author SHA1 Message Date
Flatlogic Bot
32175f18e1 panel by kisal 2025-11-25 04:46:09 +00:00
5 changed files with 381 additions and 103 deletions

229
admin.php Normal file
View File

@ -0,0 +1,229 @@
<?php
session_start();
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/db/db_setup.php';
// Handle Add User POST Request
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_user'])) {
$username = trim($_POST['username']);
$email = trim($_POST['email']);
$password = $_POST['password'];
$role = $_POST['role'];
if (empty($username) || empty($email) || empty($password) || empty($role)) {
$_SESSION['toast'] = ['type' => 'danger', 'message' => 'All fields are required.'];
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$_SESSION['toast'] = ['type' => 'danger', 'message' => 'Invalid email format.'];
} else {
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT id FROM users WHERE username = ? OR email = ?");
$stmt->execute([$username, $email]);
if ($stmt->fetch()) {
$_SESSION['toast'] = ['type' => 'danger', 'message' => 'Username or email already exists.'];
} else {
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT INTO users (username, email, password, role) VALUES (?, ?, ?, ?)");
$stmt->execute([$username, $email, $hashed_password, $role]);
$_SESSION['toast'] = ['type' => 'success', 'message' => 'User added successfully!'];
}
} catch (PDOException $e) {
$_SESSION['toast'] = ['type' => 'danger', 'message' => 'Database error: ' . $e->getMessage()];
}
}
header("Location: admin.php");
exit;
}
// Fetch all users
try {
$pdo = db();
$users_stmt = $pdo->query("SELECT id, username, email, role, status, created_at FROM users ORDER BY created_at DESC");
$users = $users_stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$users = [];
$_SESSION['toast'] = ['type' => 'danger', 'message' => 'Could not fetch users.'];
}
$toast = $_SESSION['toast'] ?? null;
unset($_SESSION['toast']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Panel - IPTV Manager</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
<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">
</head>
<body>
<div class="d-flex">
<!-- Sidebar -->
<nav class="sidebar bg-dark d-flex flex-column p-3">
<a href="/" class="d-flex align-items-center mb-4 text-white text-decoration-none">
<i class="bi bi-broadcast-pin me-2 fs-4"></i>
<span class="fs-4">IPTV Panel</span>
</a>
<ul class="nav nav-pills flex-column mb-auto">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">
<i class="bi bi-people-fill me-2"></i> Users
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
<i class="bi bi-person-badge me-2"></i> Resellers
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
<i class="bi bi-box me-2"></i> Packages
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
<i class="bi bi-list-task me-2"></i> Playlists
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
<i class="bi bi-gear-fill me-2"></i> Settings
</a>
</li>
</ul>
<hr>
<div class="dropdown">
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
<img src="https://i.pravatar.cc/40?u=admin" alt="" width="32" height="32" class="rounded-circle me-2">
<strong>Superadmin</strong>
</a>
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
<li><a class="dropdown-item" href="#">Profile</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Sign out</a></li>
</ul>
</div>
</nav>
<!-- Main Content -->
<main class="main-content flex-grow-1 p-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3 mb-0 text-gray-800">User Management</h1>
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addUserModal">
<i class="bi bi-plus-circle-fill me-2"></i>Add New User
</button>
</div>
<!-- Users Table -->
<div class="card shadow-sm">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead class="table-light">
<tr>
<th>Username</th>
<th>Email</th>
<th>Role</th>
<th>Status</th>
<th>Registered</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (empty($users)): ?>
<tr><td colspan="6" class="text-center">No users found.</td></tr>
<?php else: ?>
<?php foreach ($users as $user): ?>
<tr>
<td><strong><?= htmlspecialchars($user['username']) ?></strong></td>
<td><?= htmlspecialchars($user['email']) ?></td>
<td><span class="badge bg-secondary"><?= htmlspecialchars(ucfirst($user['role'])) ?></span></td>
<td>
<span class="badge rounded-pill <?= $user['status'] === 'active' ? 'bg-success' : 'bg-danger' ?>">
<?= htmlspecialchars(ucfirst($user['status'])) ?>
</span>
</td>
<td><?= date("M d, Y", strtotime($user['created_at'])) ?></td>
<td>
<button class="btn btn-sm btn-outline-secondary"><i class="bi bi-pencil-square"></i></button>
<button class="btn btn-sm btn-outline-warning"><i class="bi bi-slash-circle"></i></button>
<button class="btn btn-sm btn-outline-danger"><i class="bi bi-trash"></i></button>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</main>
</div>
<!-- Add User Modal -->
<div class="modal fade" id="addUserModal" tabindex="-1" aria-labelledby="addUserModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addUserModalLabel">Add New User</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form method="POST" action="admin.php">
<div class="modal-body">
<input type="hidden" name="add_user" value="1">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<select class="form-select" id="role" name="role">
<option value="subscriber">Subscriber</option>
<option value="reseller">Reseller</option>
<option value="superadmin">Superadmin</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save User</button>
</div>
</form>
</div>
</div>
</div>
<!-- Toast Container -->
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<?php if ($toast): ?>
<div id="liveToast" class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header text-white bg-<?= $toast['type'] ?>">
<strong class="me-auto">Notification</strong>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
<?= htmlspecialchars($toast['message']) ?>
</div>
</div>
<?php endif; ?>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

47
assets/css/custom.css Normal file
View File

@ -0,0 +1,47 @@
body {
font-family: 'Inter', sans-serif;
background-color: #f8f9fa;
}
.sidebar {
width: 280px;
min-height: 100vh;
}
.sidebar .nav-link {
font-size: 1rem;
padding: 0.75rem 1rem;
transition: all 0.2s ease-in-out;
}
.sidebar .nav-link.active {
background: linear-gradient(45deg, #0d6efd, #6f42c1) !important;
color: white !important;
border-radius: 0.375rem;
}
.sidebar .nav-link:not(.active):hover {
background-color: #495057;
}
.main-content {
background-color: #f8f9fa;
}
.card {
border: none;
border-radius: 0.5rem;
}
.table {
margin-bottom: 0;
}
.table th {
font-weight: 600;
color: #495057;
}
.badge.bg-secondary {
background-color: #6c757d !important;
}

7
assets/js/main.js Normal file
View File

@ -0,0 +1,7 @@
document.addEventListener('DOMContentLoaded', (event) => {
const toastEl = document.getElementById('liveToast');
if (toastEl) {
const toast = new bootstrap.Toast(toastEl);
toast.show();
}
});

39
db/db_setup.php Normal file
View File

@ -0,0 +1,39 @@
<?php
require_once __DIR__ . '/config.php';
function setup_database() {
try {
$pdo = db();
// Users table
$pdo->exec("CREATE TABLE IF NOT EXISTS `users` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(255) NOT NULL UNIQUE,
`email` VARCHAR(255) NOT NULL UNIQUE,
`password` VARCHAR(255) NOT NULL,
`role` ENUM('superadmin', 'reseller', 'subscriber') NOT NULL DEFAULT 'subscriber',
`status` ENUM('active', 'blocked') NOT NULL DEFAULT 'active',
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);");
// Check if a superadmin exists
$stmt = $pdo->query("SELECT COUNT(*) FROM `users` WHERE `role` = 'superadmin'");
if ($stmt->fetchColumn() == 0) {
// Create a default superadmin
$username = 'admin';
$email = 'admin@example.com';
$password = password_hash('password', PASSWORD_DEFAULT); // Change this!
$role = 'superadmin';
$insert_stmt = $pdo->prepare("INSERT INTO `users` (username, email, password, role) VALUES (?, ?, ?, ?)");
$insert_stmt->execute([$username, $email, $password, $role]);
}
} catch (PDOException $e) {
// In a real app, you'd log this error.
// For setup, we can die to see the error.
die("Database setup failed: " . $e->getMessage());
}
}
setup_database();
?>

154
index.php
View File

@ -4,147 +4,103 @@ declare(strict_types=1);
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'A powerful and lightweight IPTV management panel.';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
$projectName = $_SERVER['PROJECT_NAME'] ?? 'IPTV Panel';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<title><?= htmlspecialchars($projectName) ?> - Your IPTV Solution</title>
<!-- Meta tags -->
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
<meta property="og:title" content="<?= htmlspecialchars($projectName) ?>" />
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:title" content="<?= htmlspecialchars($projectName) ?>" />
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<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;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
min-height: 100vh;
}
.hero {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
overflow: hidden;
position: relative;
flex-grow: 1;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
.hero h1 {
font-size: 3.5rem;
font-weight: 700;
letter-spacing: -1px;
text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
.hero p {
font-size: 1.25rem;
max-width: 600px;
margin: 1rem auto 2rem;
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
.btn-gradient {
background: linear-gradient(45deg, #ff4b2b, #ff416c);
border: none;
color: white;
padding: 12px 30px;
font-weight: bold;
border-radius: 50px;
transition: transform 0.2s;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
.btn-gradient:hover {
transform: scale(1.05);
color: white;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
text-align: center;
padding: 1rem;
opacity: 0.8;
}
</style>
</head>
<body>
<main>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
</div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
<main class="hero">
<div class="container">
<h1 class="display-4"><?= htmlspecialchars($projectName) ?></h1>
<p class="lead"><?= htmlspecialchars($projectDescription) ?></p>
<a href="/admin.php" class="btn btn-gradient btn-lg">
<i class="bi bi-speedometer2 me-2"></i>Go to Admin Panel
</a>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
<p>&copy; <?= date('Y') ?> <?= htmlspecialchars($projectName) ?>. All rights reserved.</p>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>