PYBS (Personel Yönetim Bilgi Sistemi) / Ramsa/index.php
index.php 132 satır • 6.24 KB
<?php
// index.php
require_once 'config/db.php';
require_once 'config/functions.php';

// Oturum açık mı kontrol et?
if (isset($_SESSION['kullanici_id'])) {
    $rol = $_SESSION['rol'];
    header("Location: panels/{$rol}-panel.php");
    exit;
}

$hata = '';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    csrfKontrol($_POST['csrf_token']);

    $kullanici_adi = guvenlik($_POST['kullanici_adi']);
    $sifre = $_POST['sifre'];
    $captcha_cevap = (int)$_POST['captcha_cevap'];

    if ($captcha_cevap !== $_SESSION['captcha_sonuc']) {
        $hata = "Güvenlik sorusu hatalı!";
        logKaydet($pdo, 0, 'guvenlik_uyarisi', "Hatalı Captcha: $kullanici_adi");
    } else {
        $stmt = $pdo->prepare("SELECT * FROM kullanicilar WHERE kullanici_adi = :kadi");
        $stmt->execute([':kadi' => $kullanici_adi]);
        $uye = $stmt->fetch();

        if ($uye) {
            // Engelleme Mantığı (Kısaltıldı)
            $hata_sayisi = $uye['hatali_giris_sayisi'];
            $engel_kaldirildi = true;
            if ($hata_sayisi >= 5) { /* Süre kontrolü buraya */ }

            if ($engel_kaldirildi) {
                if (password_verify($sifre, $uye['sifre_hash'])) {
                    if ($uye['durum'] == 0) {
                        $hata = "Hesabınız pasif durumdadır.";
                    } else {
                        $pdo->prepare("UPDATE kullanicilar SET hatali_giris_sayisi = 0 WHERE id = :id")->execute([':id' => $uye['id']]);
                        $_SESSION['kullanici_id'] = $uye['id'];
                        $_SESSION['kullanici_adi'] = $uye['kullanici_adi'];
                        $_SESSION['rol'] = $uye['rol'];
                        $_SESSION['ad_soyad'] = $uye['ad'] . ' ' . $uye['soyad'];
                        logKaydet($pdo, $uye['id'], 'giris', 'Giriş yapıldı.');
                        header("Location: panels/{$uye['rol']}-panel.php");
                        exit;
                    }
                } else {
                    $pdo->prepare("UPDATE kullanicilar SET hatali_giris_sayisi = hatali_giris_sayisi + 1 WHERE id = :id")->execute([':id' => $uye['id']]);
                    $hata = "Kullanıcı adı veya şifre hatalı!";
                }
            }
        } else {
            $hata = "Kullanıcı adı veya şifre hatalı!";
        }
    }
}

$sayi1 = rand(1, 10);
$sayi2 = rand(1, 10);
$_SESSION['captcha_sonuc'] = $sayi1 + $sayi2;

// İletişim Bilgileri (Sayfa altında gösterilecek)
$firma_adres = "Mimar Sinan Mah. 148. Sk No : 93 Üzeri 2, Çorlu/Tekirdağ Çerkezköy- Çorlu Yolu, Işıklar, 59520 Kapaklı/Tekirdağ";
$firma_telefon = "(0282) 726 80 99";
?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Ramsa Makine PYBS</title>
    <link rel="icon" type="image/png" href="assets/img/logo.png">
    
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        :root { --ramsa-blue: #2A7BB8; --ramsa-yellow: #F3B01B; --bg-color: #F4F6F9; }
        body { background-color: var(--bg-color); display: flex; align-items: center; justify-content: center; height: 100vh; font-family: 'Segoe UI', sans-serif; }
        .login-card { background: white; border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); width: 100%; max-width: 400px; border-top: 5px solid var(--ramsa-blue); }
        .login-header { text-align: center; padding: 30px 20px 10px; }
        .login-header img { max-width: 180px; margin-bottom: 15px; }
        .login-header h4 { color: var(--ramsa-blue); font-weight: 700; font-size: 1.2rem; }
        .login-body { padding: 30px; }
        .btn-ramsa { background-color: var(--ramsa-blue); color: white; font-weight: 600; width: 100%; padding: 10px; }
        .btn-ramsa:hover { background-color: #1e5c8a; color: white; }
        .captcha-box { background-color: #eef5fa; padding: 10px; border-radius: 5px; border: 1px solid #dbe7f1; text-align: center; font-weight: bold; color: #333; }
        .footer-links { margin-top: 20px; padding-top: 15px; border-top: 1px solid #eee; text-align: center; }
    </style>
</head>
<body>
    <div class="login-card">
        <div class="login-header">
            <img src="assets/img/logo.png" alt="Ramsa Makine">
            <h4>Personel Yönetim Bilgi Sistemi</h4>
        </div>
        <div class="login-body">
            <?php if($hata): ?>
                <div class="alert alert-danger text-center p-2"><?php echo $hata; ?></div>
            <?php endif; ?>
            <form method="POST">
                <input type="hidden" name="csrf_token" value="<?php echo csrfTokenOlustur(); ?>">
                <div class="mb-3">
                    <label class="form-label">Kullanıcı Adı</label>
                    <input type="text" class="form-control" name="kullanici_adi" required autocomplete="off">
                </div>
                <div class="mb-3">
                    <label class="form-label">Şifre</label>
                    <input type="password" class="form-control" name="sifre" required>
                </div>
                <div class="mb-3">
                    <label class="form-label">Güvenlik: <?php echo $sayi1; ?> + <?php echo $sayi2; ?> = ?</label>
                    <input type="number" class="form-control" name="captcha_cevap" required>
                </div>
                
                <div class="form-text small text-start mb-3 border p-2 bg-light text-dark">
                    Bu sistemi kullanarak, <a href="kvkk.php" target="_blank" class="text-primary fw-bold">KVKK Aydınlatma Metnini</a> ve <a href="cerez.php" target="_blank" class="text-primary fw-bold">Çerez Politikası</a> hükümlerini okuduğunuzu ve kabul ettiğinizi beyan etmiş olursunuz.
                </div>

                <button type="submit" class="btn btn-ramsa">GÜVENLİ GİRİŞ</button>
            </form>
            
            <div class="mt-2 text-center small text-muted">
                Ramsa Makine PYBS & <a href="https://www.htbiltek.com.tr" target="_blank" class="fw-bold text-muted text-decoration-none">HT Biltek</a>
            </div>
        </div>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>