One Hat Cyber Team
Your IP :
104.23.243.59
Server IP :
172.67.218.182
Server :
Linux 128-201-239-36.cprapid.com 3.10.0-1160.41.1.el7.x86_64 #1 SMP Tue Aug 31 14:52:47 UTC 2021 x86_64
Server Software :
Apache
PHP Version :
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
juscatamarca
/
www
/
asuetos-feriados
/
app
/
View File Name :
auth.php
<?php require_once __DIR__ . '/config.php'; function current_user(): ?array { return $_SESSION['user'] ?? null; } function require_login(): void { if (!current_user()) { header('Location: ' . base_url() . '/login.php'); exit; } } function login_user(string $email, string $password): bool { global $pdo; $stmt = $pdo->prepare('SELECT id, name, email, password_hash, role FROM users WHERE email = ? LIMIT 1'); $stmt->execute([$email]); $u = $stmt->fetch(); if ($u && password_verify($password, $u['password_hash'])) { $_SESSION['user'] = [ 'id' => (int)$u['id'], 'name' => $u['name'], 'email' => $u['email'], 'role' => $u['role'], ]; return true; } return false; } function logout_user(): void { $_SESSION = []; if (ini_get('session.use_cookies')) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']); } session_destroy(); }