Compare commits

...

4 Commits

Author SHA1 Message Date
Flatlogic Bot
4cc7352047 adminli girişli 2025-10-03 08:23:05 +00:00
Flatlogic Bot
24c0e7b2b3 dfg 2025-10-01 07:01:16 +00:00
Flatlogic Bot
830133f4aa geliştirme 2025-10-01 06:57:10 +00:00
Flatlogic Bot
97ce69d5aa başlangıç 2025-10-01 06:53:37 +00:00
9 changed files with 511 additions and 142 deletions

22
add_user.php Normal file
View File

@ -0,0 +1,22 @@
<?php
session_start();
require_once 'db/config.php';
if (!isset($_SESSION['user_id']) || !$_SESSION['is_admin']) {
header('Location: index.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
$stmt->execute([$username, $hashed_password]);
header('Location: admin.php');
exit;
}
?>

116
admin.php Normal file
View File

@ -0,0 +1,116 @@
<?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>

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

@ -0,0 +1,69 @@
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
body {
background-color: #F8F9FA;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
color: #212529;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Georgia', serif;
}
.navbar {
box-shadow: 0 2px 4px rgba(0,0,0,.05);
}
.card {
border: none;
border-radius: 0.5rem;
box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.table {
--bs-table-bg: transparent;
--bs-table-striped-bg: rgba(13, 110, 253, 0.03);
}
.table th {
font-weight: 600;
}
.btn-primary {
transition: all 0.3s ease;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(13, 110, 253, 0.2);
}
.form-control:focus {
box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
border-color: #86b7fe;
}
.action-icon {
color: #6c757d;
text-decoration: none;
transition: color 0.2s ease;
}
.action-icon:hover {
color: #0d6efd;
}
.sortable-header {
cursor: pointer;
user-select: none;
}
.sortable-header:hover {
background-color: rgba(0,0,0,0.05);
}
.sortable-header .bi {
font-size: 0.8em;
margin-left: 4px;
}

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

@ -0,0 +1,56 @@
document.addEventListener('DOMContentLoaded', function () {
// Initialize tooltips
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
const tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
});
// Live search functionality
const searchInput = document.getElementById('searchInput');
const tableBody = document.getElementById('contactTableBody');
const tableRows = tableBody.getElementsByTagName('tr');
searchInput.addEventListener('keyup', function() {
const filter = searchInput.value.toLowerCase();
for (let i = 0; i < tableRows.length; i++) {
const row = tableRows[i];
const cells = row.getElementsByTagName('td');
let text = '';
for (let j = 0; j < cells.length; j++) {
const cell = cells[j];
if (cell) {
text += cell.textContent || cell.innerText;
}
}
if (text.toLowerCase().indexOf(filter) > -1) {
row.style.display = "";
} else {
row.style.display = "none";
}
}
});
// Table sorting functionality
const headers = document.querySelectorAll('.sortable-header');
headers.forEach(header => {
header.addEventListener('click', function() {
const table = this.closest('table');
const tbody = table.querySelector('tbody');
const columnIndex = parseInt(this.getAttribute('data-column-index'));
const rows = Array.from(tbody.querySelectorAll('tr'));
// Simple A-Z string sort
const sortedRows = rows.sort((a, b) => {
const aColText = a.querySelector(`td:nth-child(${columnIndex + 1})`).textContent.trim();
const bColText = b.querySelector(`td:nth-child(${columnIndex + 1})`).textContent.trim();
return aColText.localeCompare(bColText);
});
// Re-append sorted rows
while (tbody.firstChild) {
tbody.removeChild(tbody.firstChild);
}
tbody.append(...sortedRows);
});
});
});

21
change_password.php Normal file
View File

@ -0,0 +1,21 @@
<?php
session_start();
require_once 'db/config.php';
if (!isset($_SESSION['user_id']) || !$_SESSION['is_admin']) {
header('Location: index.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$new_password = $_POST['new_password'];
$hashed_password = password_hash($new_password, PASSWORD_DEFAULT);
$pdo = db();
$stmt = $pdo->prepare("UPDATE users SET password = ? WHERE id = ?");
$stmt->execute([$hashed_password, $_SESSION['user_id']]);
header('Location: admin.php');
exit;
}
?>

298
index.php
View File

@ -1,150 +1,172 @@
<?php <?php
declare(strict_types=1); session_start();
@ini_set('display_errors', '1'); require_once 'db/config.php';
@error_reporting(E_ALL);
@date_default_timezone_set('UTC'); $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();
}
}
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?> ?>
<!doctype html> <!DOCTYPE html>
<html lang="en"> <html lang="tr">
<head> <head>
<meta charset="utf-8" /> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Style</title>
<?php <title>rehber</title>
// Read project preview data from environment <meta name="description" content="Built with Flatlogic Generator">
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? ''; <meta name="keywords" content="rehber, contact management, web application, user directory, online address book, contact list, php directory, Built with Flatlogic Generator">
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?> <meta property="og:title" content="rehber">
<?php if ($projectDescription): ?> <meta property="og:description" content="Built with Flatlogic Generator">
<!-- Meta description --> <meta property="og:image" content="">
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' /> <meta name="twitter:card" content="summary_large_image">
<!-- Open Graph meta tags --> <meta name="twitter:image" content="">
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<?php endif; ?> <link rel="stylesheet" href="assets/css/custom.css">
<?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 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">
<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;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
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;
}
@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 {
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;
}
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;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head> </head>
<body> <body>
<main>
<div class="card"> <?php if ($is_logged_in && $user_permissions['can_view']): ?>
<h1>Analyzing your requirements and generating your website…</h1> <nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top">
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes"> <div class="container-fluid">
<span class="sr-only">Loading…</span> <a class="navbar-brand" href="/">
<?php
$logo_path = 'assets/images/logo.png';
if (file_exists($logo_path)) {
echo '<img src="' . $logo_path . '?v=' . time() . '" alt="Logo" style="max-height: 40px; margin-right: 10px;">';
} else {
echo '<i class="bi bi-book-half me-2"></i>';
}
?>
rehber
</a>
<div class="d-flex">
<a href="logout.php" class="btn btn-outline-secondary">Çıkış Yap</a>
</div>
</div>
</nav>
<main class="container my-4">
<div class="d-flex justify-content-between align-items-center mb-4 flex-wrap">
<h1 class="h2">Contact Directory</h1>
<div class="d-flex gap-2">
<?php if ($user_permissions['can_add']): ?>
<button class="btn btn-primary">
<i class="bi bi-plus-circle me-2"></i>Add Record
</button>
<?php endif; ?>
<button class="btn btn-outline-secondary">
<i class="bi bi-box-arrow-up-right me-2"></i>Export
</button>
</div>
</div>
<div class="card p-3">
<div class="row mb-3">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-text"><i class="bi bi-search"></i></span>
<input type="text" id="searchInput" class="form-control" placeholder="Search contacts...">
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped table-hover align-middle">
<thead class="thead-light">
<tr>
<th class="sortable-header" data-column-index="0">Cust. Code <i class="bi bi-arrow-down-up"></i></th>
<th class="sortable-header" data-column-index="1">Ticari Unvan <i class="bi bi-arrow-down-up"></i></th>
<th class="sortable-header" data-column-index="2">Şehir <i class="bi bi-arrow-down-up"></i></th>
<th class="sortable-header" data-column-index="3">Ad Soyad <i class="bi bi-arrow-down-up"></i></th>
<th class="sortable-header" data-column-index="4">Telefon <i class="bi bi-arrow-down-up"></i></th>
<th class="sortable-header" data-column-index="5">E-posta <i class="bi bi-arrow-down-up"></i></th>
<th class="sortable-header" data-column-index="6">Grup <i class="bi bi-arrow-down-up"></i></th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody id="contactTableBody">
<?php foreach ($contacts as $contact): ?>
<tr>
<td><?php echo htmlspecialchars($contact['Cust.Code']); ?></td>
<td><?php echo htmlspecialchars($contact['Ticari Unvan']); ?></td>
<td><?php echo htmlspecialchars($contact['Sehir']); ?></td>
<td><?php echo htmlspecialchars($contact['Ad'] . ' ' . $contact['Soyad']); ?></td>
<td><?php echo htmlspecialchars($contact['Telefon']); ?></td>
<td><a href="mailto:<?php echo htmlspecialchars($contact['E-posta']); ?>"><?php echo htmlspecialchars($contact['E-posta']); ?></a></td>
<td><span class="badge bg-secondary bg-opacity-25 text-dark"><?php echo htmlspecialchars($contact['Grup Adı']); ?></span></td>
<td class="text-end">
<?php if ($user_permissions['can_edit']): ?>
<a href="#" class="action-icon me-2" data-bs-toggle="tooltip" title="Edit"><i class="bi bi-pencil-square"></i></a>
<?php endif; ?>
<?php if ($user_permissions['can_delete']): ?>
<a href="#" class="action-icon" data-bs-toggle="tooltip" title="Delete"><i class="bi bi-trash"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div> </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>
</div> </div>
</main> </main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC) <footer class="text-center text-muted py-4">
<small>&copy; <?php echo date("Y"); ?> rehber. All rights reserved.</small><br>
<small>Built with Flatlogic Generator</small>
</footer> </footer>
<?php if ($user_permissions['is_admin']): ?>
<div style="position: fixed; bottom: 10px; left: 10px; z-index: 1030;">
<a href="admin.php" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-gear"></i> Admin Panel
</a>
</div>
<?php endif; ?>
<?php else: ?>
<div class="container">
<div class="row justify-content-center align-items-center vh-100">
<div class="col-md-6 text-center">
<h1 class="mb-4">Seyidoğlu Asistan Rehber Sistemine Hoşgeldiniz</h1>
<div class="card">
<div class="card-body">
<h5 class="card-title">Giriş Yap</h5>
<?php if (isset($_GET['error'])): ?>
<div class="alert alert-danger">Kullanıcı adı veya şifre hatalı.</div>
<?php endif; ?>
<form action="login.php" method="post">
<div class="mb-3">
<input type="text" name="username" class="form-control" placeholder="Kullanıcı Adı" required>
</div>
<div class="mb-3">
<input type="password" name="password" class="form-control" placeholder="Şifre" required>
</div>
<button type="submit" class="btn btn-primary">Giriş</button>
</form>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
<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> </body>
</html> </html>

25
login.php Normal file
View File

@ -0,0 +1,25 @@
<?php
session_start();
require_once 'db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
$pdo = db();
$stmt = $pdo->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;
}
}
?>

7
logout.php Normal file
View File

@ -0,0 +1,7 @@
<?php
session_start();
session_unset();
session_destroy();
header('Location: index.php');
exit;
?>

31
update_permissions.php Normal file
View File

@ -0,0 +1,31 @@
<?php
session_start();
require_once 'db/config.php';
if (!isset($_SESSION['user_id']) || !$_SESSION['is_admin']) {
header('Location: index.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$permissions = $_POST['permissions'];
$pdo = db();
foreach ($permissions as $user_id => $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;
}
?>