| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /laragon4/www/bpkd_/admin/ |
Upload File : |
<?php
require_once 'config/database.php';
require_once 'config/security.php';
// Hanya untuk admin
if ($_SESSION['role'] != 'admin') {
redirect('dashboard.php');
}
$page_title = 'Security Check';
require_once 'includes/header.php';
// Cek aktivitas mencurigakan
$suspicious_logs = file_exists('../logs/suspicious_activity.log') ?
file('../logs/suspicious_activity.log') : [];
// Cek percobaan login gagal
$failed_logins = [];
if (isset($_SESSION['rate_limit'])) {
foreach ($_SESSION['rate_limit'] as $key => $data) {
if (strpos($key, 'login') !== false && $data['attempts'] > 3) {
$failed_logins[] = $key;
}
}
}
// Cek komentar pending
$pending_comments = $conn->query("SELECT COUNT(*) as total FROM comments WHERE status = 'pending'")->fetch_assoc()['total'];
// Cek pesan belum dibaca
$unread_messages = $conn->query("SELECT COUNT(*) as total FROM contacts WHERE status = 'unread'")->fetch_assoc()['total'];
// Cek struktur database
$tables = $conn->query("SHOW TABLES");
$table_count = $tables->num_rows;
?>
<div class="container-fluid">
<h1 class="h3 mb-4 text-gray-800">Security Check</h1>
<div class="row">
<div class="col-md-6 mb-4">
<div class="card shadow">
<div class="card-header bg-primary text-white">
<h6 class="m-0 font-weight-bold">Status Keamanan</h6>
</div>
<div class="card-body">
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
HTTPS
<?php if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'): ?>
<span class="badge bg-success">Aktif</span>
<?php else: ?>
<span class="badge bg-danger">Tidak Aktif</span>
<?php endif; ?>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Security Headers
<?php if(function_exists('get_headers')): ?>
<span class="badge bg-success">Terpasang</span>
<?php else: ?>
<span class="badge bg-warning">Perlu Dicek</span>
<?php endif; ?>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Session Security
<span class="badge bg-success">Aktif</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
CSRF Protection
<span class="badge bg-success">Aktif</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Rate Limiting
<span class="badge bg-success">Aktif</span>
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-6 mb-4">
<div class="card shadow">
<div class="card-header bg-warning text-white">
<h6 class="m-0 font-weight-bold">Aktivitas Mencurigakan</h6>
</div>
<div class="card-body">
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
Komentar Pending
<span class="badge bg-<?php echo $pending_comments > 0 ? 'warning' : 'success'; ?>">
<?php echo $pending_comments; ?>
</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Pesan Belum Dibaca
<span class="badge bg-<?php echo $unread_messages > 0 ? 'warning' : 'success'; ?>">
<?php echo $unread_messages; ?>
</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Login Gagal (24 jam)
<span class="badge bg-<?php echo count($failed_logins) > 0 ? 'danger' : 'success'; ?>">
<?php echo count($failed_logins); ?>
</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Log Mencurigakan
<span class="badge bg-<?php echo count($suspicious_logs) > 0 ? 'danger' : 'success'; ?>">
<?php echo count($suspicious_logs); ?>
</span>
</li>
</ul>
</div>
</div>
</div>
<div class="col-12">
<div class="card shadow">
<div class="card-header bg-danger text-white">
<h6 class="m-0 font-weight-bold">Log Aktivitas Mencurigakan</h6>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Timestamp</th>
<th>IP Address</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<?php if(!empty($suspicious_logs)): ?>
<?php
$logs = array_slice($suspicious_logs, -20);
foreach($logs as $log):
if(preg_match('/\[(.*?)\] IP: (.*?) \| Type: (.*?) \| Details: (.*?) \|/', $log, $matches)):
?>
<tr>
<td><?php echo $matches[1]; ?></td>
<td><?php echo $matches[2]; ?></td>
<td>
<span class="badge bg-danger"><?php echo $matches[3]; ?></span>
</td>
<td><?php echo $matches[4]; ?></td>
</tr>
<?php
endif;
endforeach;
?>
<?php else: ?>
<tr>
<td colspan="4" class="text-center">Tidak ada log mencurigakan</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>