diff --git a/add_user.php b/add_user.php new file mode 100644 index 0000000..390373c --- /dev/null +++ b/add_user.php @@ -0,0 +1,22 @@ +prepare("INSERT INTO users (username, password) VALUES (?, ?)"); + $stmt->execute([$username, $hashed_password]); + + header('Location: admin.php'); + exit; +} +?> \ No newline at end of file diff --git a/admin.php b/admin.php index 7dec9fc..303fa2d 100644 --- a/admin.php +++ b/admin.php @@ -1,41 +1,116 @@ +prepare("SELECT * FROM users WHERE id != ?"); +$stmt->execute([$_SESSION['user_id']]); +$users = $stmt->fetchAll(); + +?> - + - Admin Panel + Admin Paneli + -
-
+
+
+

Admin Paneli

+ Ana Sayfaya Dön +
+ +
-
-
-

Admin Panel

-
+
+
Şifre Değiştir
-
Logo Management
-

Upload a new logo for the site. The current logo will be replaced. The file should be a PNG, JPG, or GIF.

- -
Logo uploaded successfully!
- -
Error uploading logo:
- -
+
- - + +
- +
- + +
+
Logo Yükle
+
+
+
+ + +
+ +
+
+
+
+ +
+
+
Kullanıcı Ekle
+
+
+
+ + +
+
+ + +
+ +
+ +
+
Kullanıcıları Yönet
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Kullanıcı AdıGörüntülemeEklemeSilmeDüzenleme
>>>>
+ +
+
+
- + \ No newline at end of file diff --git a/change_password.php b/change_password.php new file mode 100644 index 0000000..ec45868 --- /dev/null +++ b/change_password.php @@ -0,0 +1,21 @@ +prepare("UPDATE users SET password = ? WHERE id = ?"); + $stmt->execute([$hashed_password, $_SESSION['user_id']]); + + header('Location: admin.php'); + exit; +} +?> \ No newline at end of file diff --git a/index.php b/index.php index aa33734..53363b2 100644 --- a/index.php +++ b/index.php @@ -1,57 +1,23 @@ "C001", - "Ticari Unvan" => "Flatlogic Inc.", - "Sehir" => "New York", - "Ad" => "John", - "Soyad" => "Doe", - "Telefon" => "123-456-7890", - "E-posta" => "john.doe@example.com", - "Grup Adı" => "VIP", - ], - [ - "Cust.Code" => "C002", - "Ticari Unvan" => "Google LLC", - "Sehir" => "Mountain View", - "Ad" => "Jane", - "Soyad" => "Smith", - "Telefon" => "987-654-3210", - "E-posta" => "jane.smith@example.com", - "Grup Adı" => "Technology", - ], - [ - "Cust.Code" => "C003", - "Ticari Unvan" => "Microsoft Corp.", - "Sehir" => "Redmond", - "Ad" => "Peter", - "Soyad" => "Jones", - "Telefon" => "555-123-4567", - "E-posta" => "peter.jones@example.com", - "Grup Adı" => "Software", - ], - [ - "Cust.Code" => "C004", - "Ticari Unvan" => "Apple Inc.", - "Sehir" => "Cupertino", - "Ad" => "Mary", - "Soyad" => "Johnson", - "Telefon" => "555-987-6543", - "E-posta" => "mary.j@example.com", - "Grup Adı" => "Hardware", - ], - [ - "Cust.Code" => "C005", - "Ticari Unvan" => "Amazon.com, Inc.", - "Sehir" => "Seattle", - "Ad" => "David", - "Soyad" => "Williams", - "Telefon" => "555-555-5555", - "E-posta" => "david.w@example.com", - "Grup Adı" => "e-Commerce", - ] -]; +session_start(); +require_once 'db/config.php'; + +$is_logged_in = isset($_SESSION['user_id']); +$user_permissions = []; +$contacts = []; + +if ($is_logged_in) { + $pdo = db(); + $stmt = $pdo->prepare("SELECT can_view, can_add, can_delete, can_edit, is_admin FROM users WHERE id = ?"); + $stmt->execute([$_SESSION['user_id']]); + $user_permissions = $stmt->fetch(); + + if ($user_permissions['can_view']) { + $stmt = $pdo->query("SELECT * FROM contacts"); + $contacts = $stmt->fetchAll(); + } +} + ?> @@ -75,22 +41,22 @@ $contacts = [ + @@ -99,9 +65,11 @@ $contacts = [

Contact Directory

+ + @@ -143,8 +111,12 @@ $contacts = [ + + + + @@ -159,6 +131,41 @@ $contacts = [ Built with Flatlogic Generator + + + + + +
+
+
+

Seyidoğlu Asistan Rehber Sistemine Hoşgeldiniz

+
+
+
Giriş Yap
+ +
Kullanıcı adı veya şifre hatalı.
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+
+ + diff --git a/login.php b/login.php new file mode 100644 index 0000000..6819484 --- /dev/null +++ b/login.php @@ -0,0 +1,25 @@ +prepare("SELECT * FROM users WHERE username = ?"); + $stmt->execute([$username]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + $_SESSION['is_admin'] = $user['is_admin']; + header('Location: index.php'); + exit; + } else { + header('Location: index.php?error=1'); + exit; + } +} +?> \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..533ee6a --- /dev/null +++ b/logout.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/update_permissions.php b/update_permissions.php new file mode 100644 index 0000000..e9687c4 --- /dev/null +++ b/update_permissions.php @@ -0,0 +1,31 @@ + $perms) { + $can_view = isset($perms['can_view']) ? 1 : 0; + $can_add = isset($perms['can_add']) ? 1 : 0; + $can_delete = isset($perms['can_delete']) ? 1 : 0; + $can_edit = isset($perms['can_edit']) ? 1 : 0; + + $stmt = $pdo->prepare(" + UPDATE users + SET can_view = ?, can_add = ?, can_delete = ?, can_edit = ? + WHERE id = ? + "); + $stmt->execute([$can_view, $can_add, $can_delete, $can_edit, $user_id]); + } + + header('Location: admin.php'); + exit; +} +?> \ No newline at end of file diff --git a/upload.php b/upload.php deleted file mode 100644 index 20a30d0..0000000 --- a/upload.php +++ /dev/null @@ -1,54 +0,0 @@ - \ No newline at end of file