alert('Access Denied or Timeout');"; } } function authenticateUser($username, $password) { $dbFile1 = 'database/users.db'; $db = new SQLite3($dbFile1); if (!$db) { die("Database connection failed: " . $db->lastErrorMsg()); } $query = "SELECT username, password FROM users"; $result = $db->query($query); if (!$result) { die("Error executing query: " . $db->lastErrorMsg()); } while ($row = $result->fetchArray()) { $storedUsername = $row['username']; $storedPassword = $row['password']; if ($storedUsername === $username && $storedPassword === $password) { return true; } } return false; } function authenticateApp($username) { if ($username == "Dewald"){ $url = "https://onesignal.com/api/v1/notifications"; $app_id = "86c8805b-2ce8-4c41-befd-c8c0a65fe1df"; $api_key = "os_v2_app_q3eiawzm5bgedpx5zdakmx7b35oil5op462uceuurghboc2ltbfqwwldixbsja5fiizsszetxr7trmzuyw5hgxmxthqp2mco75z5lgq"; $data = [ "app_id" => $app_id, "filters" => [ ["field" => "tag", "key" => "Blackhound", "relation" => "=", "value" => "DP"] ], "headings" => ["en" => "Dewald - Login Notice"], "contents" => ["en" => "Please authorise login!"] ]; $json_data = json_encode($data); $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Authorization: Basic $api_key" ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); $response = curl_exec($ch); curl_close($ch); } if ($username == "Hannes"){ $url = "https://onesignal.com/api/v1/notifications"; $app_id = "86c8805b-2ce8-4c41-befd-c8c0a65fe1df"; $api_key = "os_v2_app_q3eiawzm5bgedpx5zdakmx7b35oil5op462uceuurghboc2ltbfqwwldixbsja5fiizsszetxr7trmzuyw5hgxmxthqp2mco75z5lgq"; $data = [ "app_id" => $app_id, "filters" => [ ["field" => "tag", "key" => "Blackhound", "relation" => "=", "value" => "HG"] ], "headings" => ["en" => "Hannes - Login Notice"], "contents" => ["en" => "Please authorise login!"] ]; $json_data = json_encode($data); $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Authorization: Basic $api_key" ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); $response = curl_exec($ch); curl_close($ch); } $file = './Authoriser/access'; $timeout = 60; // 1 minute (in seconds) $startTime = time(); while (time() - $startTime < $timeout) { if (file_exists($file) && filesize($file) > 0) { $fileContent = file_get_contents($file); $firstLetterAccepted = substr($username, 0, 1) . "1"; $firstLetterDenied = substr($username, 0, 1) . "2"; if ($fileContent === $firstLetterAccepted) { return true; // ✅ Redirect to home.php } elseif ($fileContent === $firstLetterDenied) { return false; // ❌ Deny access } } sleep(2); // Check every 2 seconds } return false; // ❌ Timeout reached } ?>