Initial commit

This commit is contained in:
2026-06-10 20:22:46 +07:00
commit 240728285f
11 changed files with 2795 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
session_start();
function isLoggedIn() {
return !empty($_SESSION['user_id']);
}
function requireLogin() {
if (!isLoggedIn()) {
header('Location: login.php');
exit;
}
}
function requireApiLogin() {
if (!isLoggedIn()) {
header('Content-Type: application/json');
http_response_code(401);
echo json_encode([
'success' => false,
'message' => 'Belum login',
'redirect' => 'login.php'
]);
exit;
}
}
function isAdmin() { return ($_SESSION['role'] ?? '') === 'admin'; }
function isOperator() { return ($_SESSION['role'] ?? '') === 'operator'; }
function myIbadahId() { return (int)($_SESSION['id_ibadah'] ?? 0); }
function myUserId() { return (int)($_SESSION['user_id'] ?? 0); }