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 @@ - + - - - <?php$SITENAME?> + Willkommen + - + + +
+

Willkommen, !

+ + +

Du bist als eingeloggt.

+ +

Du hast nicht die erforderliche Rolle für Admin-Menüpunkte.

+ +
+ + - \ No newline at end of file + diff --git a/loginform.php b/loginform.php index e69de29..391c17b 100644 --- a/loginform.php +++ b/loginform.php @@ -0,0 +1,13 @@ + + + + +
+ + Discord Logo + Login mit Discord + +
\ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..00c92c3 --- /dev/null +++ b/logout.php @@ -0,0 +1,6 @@ + diff --git a/style.css b/style.css new file mode 100644 index 0000000..aff776f --- /dev/null +++ b/style.css @@ -0,0 +1,148 @@ +html, body { + height: 100%; /* Höhe auf 100% setzen */ + margin: 0; + font-family: Arial, sans-serif; + background: url("alphacar-bg.png") no-repeat center center fixed; + background-size: cover; + background-attachment: fixed; + color: #fff; +} + +body::before { + content: ""; + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + background: rgba(0, 0, 0, 0.6); /* Abdunkelung */ + z-index: -1; +} + +.main-content { + min-height: calc(100vh - 60px); /* Füllt den ganzen Bildschirm bis auf die Navbar */ + padding: 20px; +} + +/* Navbar */ +.navbar { + display: flex; + justify-content: space-between; + align-items: center; + background-color: rgba(31,31,31,0.9); + padding: 10px 20px; +} +.navbar a { + color: #fff; + text-decoration: none; + margin: 0 10px; + font-weight: bold; +} + +/* Dropdown */ +.dropdown { + position: relative; + display: inline-block; +} +.dropdown-content { + display: none; + position: absolute; + background-color: rgba(50, 50, 50, 0.95); + min-width: 160px; + box-shadow: 0px 8px 16px rgba(0,0,0,0.2); + z-index: 1; +} +.dropdown-content a { + color: #fff; + padding: 12px 16px; + text-decoration: none; + display: block; +} +.dropdown-content a:hover { + background-color: #5865F2; +} +.dropdown:hover .dropdown-content { + display: block; +} + +.user-info { + display: flex; + align-items: center; +} +.user-info img { + border-radius: 50%; + margin-right: 10px; + height: 35px; + width: 35px; +} +.logout-btn { + background-color: #5865F2; + border: none; + padding: 8px 12px; + border-radius: 5px; + color: #fff; + cursor: pointer; + margin-left: 10px; +} +.logout-btn:hover { + background-color: #4752C4; +} + +/* Burger für Mobile */ +.navbar .burger { + display: none; + cursor: pointer; + font-size: 1.5em; +} +@media (max-width: 768px) { + .navbar-links { + display: none; + flex-direction: column; + background-color: rgba(31,31,31,0.95); + position: absolute; + top: 60px; + left: 0; + width: 100%; + } + .navbar-links.show { + display: flex; + } + .navbar .burger { + display: block; + } + .dropdown-content { + position: static; + } +} +/*LOGIN FORM*/ +#loginform{ + position: fixed; + inset: 0px; + width: 12rem; + height: 5rem; + max-width: 100vw; + max-height: 100dvh; + margin: auto; +} + + +.discord-button{ + display: inline-flex; + align-items: center; + background-color: #5865F2; /* Discord Blau */ + color: #fff; + font-weight: 600; + font-size: 1.2em; + padding: 12px 20px; + border-radius: 8px; + text-decoration: none; + border: none; + cursor: pointer; + transition: background-color 0.2s ease-in-out; +} + +.discord-button:hover { + background-color: #4752C4; /* dunkleres Blau beim Hover */ +} + +.discord-button img { + height: 24px; + margin-right: 10px; +} \ No newline at end of file