<?php require_once 'config.php'; class Auth { public static function check() { return isset($_SESSION['user_id']); } public static function login($username, $password) { $config = Config::load(); $users = $config['users']; foreach ($users as $user) { if ($user['id'] === $username && password_verify($password, $user['password'])) { $_SESSION['user_id'] = $user['id']; return true; } } return false; } public static function logout() { unset($_SESSION['user_id']); session_destroy(); } public static function verifyCurrentPassword($password) { $config = Config::load(); $userId = $_SESSION['user_id']; foreach ($config['users'] as $user) { if ($user['id'] === $userId) { return password_verify($password, $user['password']); } } return false; } }