First commit / commit pertama

This commit is contained in:
Mr.Haruna
2026-06-13 11:24:58 +07:00
commit 522c4f7200
166 changed files with 13326 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
/**
* activity.php — Helper pencatatan log aktivitas (KF-04).
*
* logActivity($pdo, 'login');
* logActivity($pdo, 'create', 'warga_miskin', 12, 'Tambah warga baru');
*/
/**
* Catat satu baris aktivitas. Gagal mencatat tidak boleh memutus alur utama,
* jadi error ditangkap diam-diam.
*/
function logActivity(
PDO $pdo,
string $aksi,
?string $tabel = null,
?int $recordId = null,
?string $keterangan = null
): void {
try {
$stmt = $pdo->prepare(
"INSERT INTO activity_log
(user_id, username, aksi, tabel_target, record_id, keterangan, ip_address)
VALUES (?, ?, ?, ?, ?, ?, ?)"
);
$stmt->execute([
$_SESSION['user_id'] ?? null,
$_SESSION['username'] ?? null,
$aksi,
$tabel,
$recordId,
$keterangan,
$_SERVER['REMOTE_ADDR'] ?? null,
]);
} catch (Throwable $e) {
// Abaikan — logging tidak boleh menggagalkan request.
}
}