26 lines
939 B
PHP
26 lines
939 B
PHP
<?php
|
|
function insertEntry($conn, $userId, $service, $name) {
|
|
// Query vorbereiten
|
|
$stmt = $conn->prepare("INSERT INTO contracts (clientid, service, name) VALUES (?, ?, ?)");
|
|
$stmt->bind_param("iss", $userId, $service, $name); // i=int, s=string
|
|
|
|
if ($stmt->execute()) {
|
|
echo "Eintrag erfolgreich gespeichert!";
|
|
} else {
|
|
echo "Fehler: " . $stmt->error;
|
|
}
|
|
|
|
$stmt->close();
|
|
}
|
|
|
|
function getDiscordAvatarUrl($user) {
|
|
if ($user['avatar']) {
|
|
// Prüfen ob Animated Avatar (fängt mit "a_")
|
|
$format = str_starts_with($user['avatar'], 'a_') ? 'gif' : 'png';
|
|
return "https://cdn.discordapp.com/avatars/{$user['discord_id']}/{$user['avatar']}.$format?size=512";
|
|
} else {
|
|
// Standard-Avatar (User hat kein eigenes Profilbild)
|
|
$defaultAvatar = $user['discriminator'] % 5;
|
|
return "https://cdn.discordapp.com/embed/avatars/{$defaultAvatar}.png";
|
|
}
|
|
} |