From 15a5b584d5ee2c66b45fe651189d1b452573131e Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 7 Apr 2026 16:39:22 +0000 Subject: [PATCH] update landing page --- admin.php | 9 ++ admin_users.php | 281 ++++++++++++++++++++++++++++++++++++++++++ assets/css/custom.css | 51 ++++++++ includes/app.php | 28 ++++- index.php | 12 +- patch_nav.php | 16 --- 6 files changed, 371 insertions(+), 26 deletions(-) create mode 100644 admin_users.php delete mode 100644 patch_nav.php diff --git a/admin.php b/admin.php index 0036a89..6d8f7c2 100644 --- a/admin.php +++ b/admin.php @@ -133,6 +133,13 @@ render_head( + +
  • + > + + +
  • +
  • > @@ -326,6 +333,8 @@ render_head( + + diff --git a/admin_users.php b/admin_users.php new file mode 100644 index 0000000..e2231d5 --- /dev/null +++ b/admin_users.php @@ -0,0 +1,281 @@ + 0) { + // Prevent deleting oneself + if ($post_id !== (int)$_SESSION['user_id']) { + $stmt = db()->prepare("DELETE FROM users WHERE id = ?"); + $stmt->execute([$post_id]); + } + header('Location: ' . app_url('admin.php', ['page' => 'users'])); + exit; + } + + if ($post_action === 'edit' || $post_action === 'add') { + $name = trim($_POST['name'] ?? ''); + $email = trim($_POST['email'] ?? ''); + $phone = trim($_POST['phone'] ?? ''); + $role = $_POST['role'] ?? 'user'; + if (!in_array($role, ['admin', 'user'])) { + $role = 'user'; + } + + $raw_password = $_POST['password'] ?? ''; + $profile_picture = ''; + $existing_password = ''; + + if ($post_action === 'edit' && $post_id > 0) { + $stmt = db()->prepare("SELECT profile_picture, password FROM users WHERE id = ?"); + $stmt->execute([$post_id]); + $existing = $stmt->fetch(PDO::FETCH_ASSOC); + if ($existing) { + $profile_picture = $existing['profile_picture']; + $existing_password = $existing['password']; + } + } + + $upload_dir = __DIR__ . '/assets/images/uploads/'; + if (!is_dir($upload_dir)) { + mkdir($upload_dir, 0777, true); + } + + if (!empty($_FILES['photo']['tmp_name'])) { + $filename = 'user_' . time() . '_' . basename($_FILES['photo']['name']); + $target = $upload_dir . $filename; + if (move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { + $profile_picture = 'assets/images/uploads/' . $filename; + } + } + + if ($post_action === 'add') { + $final_password = $raw_password ? password_hash($raw_password, PASSWORD_DEFAULT) : ''; + } else { + if ($raw_password) { + $final_password = password_hash($raw_password, PASSWORD_DEFAULT); + } else { + $final_password = $existing_password; + } + } + + if ($post_action === 'edit' && $post_id > 0) { + $stmt = db()->prepare("UPDATE users SET name=?, email=?, phone=?, role=?, profile_picture=?, password=? WHERE id=?"); + $stmt->execute([$name, $email, $phone, $role, $profile_picture, $final_password, $post_id]); + } else { + $stmt = db()->prepare("INSERT INTO users (name, email, phone, role, profile_picture, password) VALUES (?, ?, ?, ?, ?, ?)"); + $stmt->execute([$name, $email, $phone, $role, $profile_picture, $final_password]); + } + header('Location: ' . app_url('admin.php', ['page' => 'users'])); + exit; + } +} + +$search = $_GET['search'] ?? ''; +$page_num = max(1, (int)($_GET['p'] ?? 1)); +$limit = 10; +$offset = ($page_num - 1) * $limit; + +$where = "1=1"; +$params = []; +if ($search) { + $where .= " AND (name LIKE ? OR email LIKE ?)"; + $params[] = "%$search%"; + $params[] = "%$search%"; +} + +$stmt = db()->prepare("SELECT COUNT(*) FROM users WHERE $where"); +$stmt->execute($params); +$total = $stmt->fetchColumn(); +$total_pages = ceil($total / $limit); + +$stmt = db()->prepare("SELECT * FROM users WHERE $where ORDER BY id DESC LIMIT ? OFFSET ?"); +$params[] = $limit; +$params[] = $offset; +foreach($params as $k => $v) { + $stmt->bindValue($k+1, $v, is_int($v) ? PDO::PARAM_INT : PDO::PARAM_STR); +} +$stmt->execute(); +$users = $stmt->fetchAll(PDO::FETCH_ASSOC); + +?> +
    +
    +

    +

    +
    + +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    + +
    +
    +
    +
    +
    + + + + + + +
    + + +
    + + + +
    + +
    +
    +
    +
    + + 1): ?> + + + + + + + diff --git a/assets/css/custom.css b/assets/css/custom.css index e3f9f09..2e31fcb 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -467,3 +467,54 @@ footer { .modal-header.bg-dark-blue .section-title { color: #ffffff !important; } + +/* Modern Additions */ +.hero-section { + background: linear-gradient(135deg, #f8f9fc 0%, #e2e8f0 100%); + position: relative; + overflow: hidden; +} +.hero-section::before { + content: ""; + position: absolute; + top: -50%; + left: -50%; + width: 200%; + height: 200%; + background: radial-gradient(circle, rgba(37,99,235,0.06) 0%, rgba(255,255,255,0) 70%); + z-index: 0; +} +.hero-section > .container { + position: relative; + z-index: 1; +} +.hero-section { + border-bottom: 0 !important; +} + +.plan-card, .subject-card, .workflow-card, .card { + transition: transform 0.2s ease, box-shadow 0.2s ease; + border: 1px solid rgba(0,0,0,0.06) !important; + background: rgba(255, 255, 255, 0.9); +} +.plan-card:hover, .subject-card:hover, .workflow-card:hover, .card:hover { + transform: translateY(-6px); + box-shadow: 0 20px 40px rgba(0,0,0,0.08) !important; +} +.metric-card { + background: rgba(255, 255, 255, 0.7); + backdrop-filter: blur(10px); + border: 1px solid rgba(255,255,255,0.8); + transition: transform 0.2s ease, box-shadow 0.2s ease; +} +.metric-card:hover { + transform: translateY(-2px); + box-shadow: 0 10px 20px rgba(0,0,0,0.05); +} +.btn { + transition: all 0.2s ease; +} +.btn:hover { + transform: translateY(-2px); + box-shadow: 0 8px 16px rgba(0,0,0,0.1); +} diff --git a/includes/app.php b/includes/app.php index 5aa34c5..5c63713 100644 --- a/includes/app.php +++ b/includes/app.php @@ -652,12 +652,32 @@ function render_nav(string $active = ''): void EN AR -
    +
    - - + prepare("SELECT * FROM users WHERE id = ?"); + $stmt->execute([$_SESSION['user_id']]); + $user = $stmt->fetch(PDO::FETCH_ASSOC) ?: null; + ?> + - +
    diff --git a/index.php b/index.php index eea1f2d..c7939a9 100644 --- a/index.php +++ b/index.php @@ -20,8 +20,8 @@ $metrics = ['subjects' => count($subjects), 'teachers' => db()->query("SELECT CO

    - - + +
    @@ -37,7 +37,7 @@ $metrics = ['subjects' => count($subjects), 'teachers' => db()->query("SELECT CO
    - Hero Image + Hero Image
    @@ -78,7 +78,7 @@ $metrics = ['subjects' => count($subjects), 'teachers' => db()->query("SELECT CO

    - +

    @@ -95,7 +95,7 @@ $metrics = ['subjects' => count($subjects), 'teachers' => db()->query("SELECT CO ?> - +
    @@ -212,7 +212,7 @@ $metrics = ['subjects' => count($subjects), 'teachers' => db()->query("SELECT CO
  • - + diff --git a/patch_nav.php b/patch_nav.php deleted file mode 100644 index fc0ac4c..0000000 --- a/patch_nav.php +++ /dev/null @@ -1,16 +0,0 @@ -">'; -$nav_new = <<<'EOD' - - - Logo - - - -EOD; - -$content = str_replace($nav_old, $nav_new, $content); -file_put_contents('includes/app.php', $content); -echo "Patched navbar\n"; -