diff --git a/alphacar-bg.png b/alphacar-bg.png new file mode 100644 index 0000000..8091f5f Binary files /dev/null and b/alphacar-bg.png differ diff --git a/alphacar-bg.png.bak b/alphacar-bg.png.bak new file mode 100644 index 0000000..291ab22 Binary files /dev/null and b/alphacar-bg.png.bak differ diff --git a/callback.php b/callback.php new file mode 100644 index 0000000..e28619b --- /dev/null +++ b/callback.php @@ -0,0 +1,103 @@ + $config['client_id'], + 'client_secret' => $config['client_secret'], + 'grant_type' => 'authorization_code', + 'code' => $_GET['code'], + 'redirect_uri' => $config['redirect_uri'], + 'scope' => 'identify guilds.members.read' +])); +$response = curl_exec($ch); +curl_close($ch); +$data = json_decode($response, true); + +if (!isset($data['access_token'])) { + die('Fehler beim Token-Austausch'); +} + +$access_token = $data['access_token']; + +// API Request Funktion +function apiRequest($url, $token) { + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + "Authorization: Bearer $token" + ]); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + curl_close($ch); + return json_decode($response, true); +} + +// User-Daten holen +$user = apiRequest('https://discord.com/api/users/@me', $access_token); + +// Mitgliedschaft prüfen +$guild_member = apiRequest("https://discord.com/api/users/@me/guilds/{$config['guild_id']}/member", $access_token); + +if (isset($guild_member['message'])) { + die('Du bist nicht auf dem Discord-Server.'); +} + +// 🆕 Rollen-ID → Rollenname Mapping +$role_names = [ + "1350944151381999666" => "Geschäftsführung", + "1350944244843544709" => "Stv. Geschäftsführung", + "1350943536891297914" => "Leitungsebene", + "1350945302395224206" => "Werkstattleiter", + "1350945473338544138" => "Ausbilder", + "1350945530519224320" => "Meister", + "1350945581194809376" => "Tuner", + "1350945688560861285" => "Stift" + +]; + +// 🆕 Rollen-Rang (höchste zuerst) +$role_order = [ + "1350944151381999666", + "1350944244843544709", + "1350943536891297914", + "1350945302395224206", + "1350945473338544138", + "1350945530519224320", + "1350945581194809376", + "1350945688560861285" +]; + +// 🆕 Höchste Rolle finden +$main_role_name = "Mitglied"; // Fallback +foreach ($role_order as $role_id) { + if (in_array($role_id, $guild_member['roles'])) { + $main_role_name = $role_names[$role_id]; + break; // erste gefundene Rolle nehmen + } +} + +// Rollen prüfen (ob die Person die „Adminrolle“ hat) +$hasRole = in_array($config['role_id'], $guild_member['roles']); + +// Session setzen +$_SESSION['user'] = [ + 'id' => $user['id'], + 'username' => $user['username'], + 'discriminator' => $user['discriminator'], + 'avatar' => $user['avatar'], + 'hasRole' => $hasRole, + 'nickname' => $guild_member['nick'] ?? $user['username'], // Nick wenn vorhanden + 'main_role' => $main_role_name // 🆕 höchster Rollenname +]; + +header('Location: index.php'); +exit; +?> diff --git a/config.php b/config.php index 3766dd8..ebbfc45 100644 --- a/config.php +++ b/config.php @@ -1,7 +1,9 @@ '1391359380879835146', + 'client_secret' => 'KUlkgzqI-JcLenAmxmFGwV_UroPWW6ZV', + 'redirect_uri' => 'http://localhost/alphacar/callback.php', + 'guild_id' => '1350913088827691129', + 'role_id' => '1350945581194809376' +]; +?> diff --git a/header.php b/header.php index e69de29..0070dee 100644 --- a/header.php +++ b/header.php @@ -0,0 +1,17 @@ + + + diff --git a/index.php b/index.php index d04bb2a..10e73af 100644 --- a/index.php +++ b/index.php @@ -1,24 +1,56 @@ - +
- - -Du bist als eingeloggt.
+ +Du hast nicht die erforderliche Rolle für Admin-Menüpunkte.
+ +