116 lines
5.4 KiB
PHP
116 lines
5.4 KiB
PHP
<?php
|
||
session_start();
|
||
require_once 'db/config.php';
|
||
|
||
// Check if user is logged in and is an admin
|
||
if (!isset($_SESSION['user_id']) || !$_SESSION['is_admin']) {
|
||
header('Location: index.php');
|
||
exit;
|
||
}
|
||
|
||
$pdo = db();
|
||
|
||
// Fetch all users except the current admin
|
||
$stmt = $pdo->prepare("SELECT * FROM users WHERE id != ?");
|
||
$stmt->execute([$_SESSION['user_id']]);
|
||
$users = $stmt->fetchAll();
|
||
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="tr">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Admin Paneli</title>
|
||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/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">
|
||
</head>
|
||
<body>
|
||
<div class="container my-5">
|
||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||
<h1>Admin Paneli</h1>
|
||
<a href="index.php" class="btn btn-secondary">Ana Sayfaya Dön</a>
|
||
</div>
|
||
|
||
<div class="row">
|
||
<div class="col-md-6">
|
||
<div class="card mb-4">
|
||
<div class="card-header">Şifre Değiştir</div>
|
||
<div class="card-body">
|
||
<form action="change_password.php" method="post">
|
||
<div class="mb-3">
|
||
<label for="new_password" class="form-label">Yeni Şifre</label>
|
||
<input type="password" name="new_password" class="form-control" required>
|
||
</div>
|
||
<button type="submit" class="btn btn-primary">Şifreyi Güncelle</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<div class="card-header">Logo Yükle</div>
|
||
<div class="card-body">
|
||
<form action="admin.php" method="post" enctype="multipart/form-data">
|
||
<div class="mb-3">
|
||
<label for="logo" class="form-label">Logo seçin (PNG, JPG, GIF, SVG):</label>
|
||
<input class="form-control" type="file" id="logo" name="logo" accept="image/png,image/jpeg,image/gif,image/svg+xml" required>
|
||
</div>
|
||
<button type="submit" class="btn btn-primary">Yükle</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="col-md-6">
|
||
<div class="card">
|
||
<div class="card-header">Kullanıcı Ekle</div>
|
||
<div class="card-body">
|
||
<form action="add_user.php" method="post">
|
||
<div class="mb-3">
|
||
<label for="username" class="form-label">Kullanıcı Adı</label>
|
||
<input type="text" name="username" class="form-control" required>
|
||
</div>
|
||
<div class="mb-3">
|
||
<label for="password" class="form-label">Şifre</label>
|
||
<input type="password" name="password" class="form-control" required>
|
||
</div>
|
||
<button type="submit" class="btn btn-primary">Kullanıcı Ekle</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card mt-4">
|
||
<div class="card-header">Kullanıcıları Yönet</div>
|
||
<div class="card-body">
|
||
<form action="update_permissions.php" method="post">
|
||
<table class="table">
|
||
<thead>
|
||
<tr>
|
||
<th>Kullanıcı Adı</th>
|
||
<th>Görüntüleme</th>
|
||
<th>Ekleme</th>
|
||
<th>Silme</th>
|
||
<th>Düzenleme</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($users as $user): ?>
|
||
<tr>
|
||
<td><?php echo htmlspecialchars($user['username']); ?></td>
|
||
<td><input type="checkbox" name="permissions[<?php echo $user['id']; ?>][can_view]" <?php echo $user['can_view'] ? 'checked' : ''; ?>></td>
|
||
<td><input type="checkbox" name="permissions[<?php echo $user['id']; ?>][can_add]" <?php echo $user['can_add'] ? 'checked' : ''; ?>></td>
|
||
<td><input type="checkbox" name="permissions[<?php echo $user['id']; ?>][can_delete]" <?php echo $user['can_delete'] ? 'checked' : ''; ?>></td>
|
||
<td><input type="checkbox" name="permissions[<?php echo $user['id']; ?>][can_edit]" <?php echo $user['can_edit'] ? 'checked' : ''; ?>></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
<button type="submit" class="btn btn-primary">Yetkileri Kaydet</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|