diff --git a/accounts_handler.php b/accounts_handler.php index 5d862b9..34e6c0a 100644 --- a/accounts_handler.php +++ b/accounts_handler.php @@ -2,27 +2,14 @@ // This file carries functions related to accounts. function get_avatar_url($bcid):string { - global $pdo; - $sql = "SELECT has_pfp FROM `accounts` WHERE id = ?"; + $exists = db_execute('SELECT public FROM avatars WHERE id = ? LIMIT 1', [$bcid]); - try { - $stmt = $pdo -> prepare($sql); - $stmt->execute([$bcid]); - $has_pfp = $stmt->fetch(); - } catch (PDOException $e) { - http_response_code(500); - die($e); - } - - $appendix = "default.png"; - - if ($has_pfp['has_pfp']) { - $appendix = $bcid; - } - - return 'https://cdn.byecorps.com/id/profile/'.$appendix; + if (empty($exists)) { + return '/assets/default.png'; + } + return '/public/avatars/' . $bcid; } function get_display_name($bcid, $use_bcid_fallback=true, $put_bcid_in_parenthesis=false, $format_bcid=false):string { diff --git a/admin_apps_create.php b/admin_apps_create.php index 1e495fb..c769a22 100644 --- a/admin_apps_create.php +++ b/admin_apps_create.php @@ -23,11 +23,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
- + - - + + + + diff --git a/admin_initdatabase.php b/admin_initdatabase.php index 838580c..fb860c9 100644 --- a/admin_initdatabase.php +++ b/admin_initdatabase.php @@ -119,6 +119,23 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { echo('

An error occurred: '. $e->getMessage() .'. Most likely this is already set.'); } + echo '

Create the `tokens` table'; + + try { + db_query('CREATE TABLE `badge_owners` ( + `badge_id` int(11) NOT NULL, + `owner_id` varchar(7) NOT NULL, + `earned` timestamp NULL DEFAULT current_timestamp(), + `info` text DEFAULT NULL COMMENT \'App may attach more info about how the badge was won (Killed "CoolGamer69 in battle!")\', + + constraint badges_owners_badge + foreign key (badge_id) references badges (id), + constraint badges_owners_owner + foreign key (owner_id) references accounts (id) +);'); + } catch (PDOException $e) { + echo('

An error occurred: ' . $e->getMessage() . '. Most likely this is already set.'); + } echo "

Database initialised.

"; } diff --git a/api_handler.php b/api_handler.php index 64e3c59..34c5c5a 100644 --- a/api_handler.php +++ b/api_handler.php @@ -53,6 +53,19 @@ function api_health_check(): array return ["message" => "Science compels us to explode the sun!", "time" => time(), "response_code" => 200]; } +// Potentially authenticated image endpoints + +function get_avatar(): array +{ + if (!array_key_exists('id', $query)) { + return [ + 'response_code' => 404, + 'message' => 'ID not assigned/found' + ]; + } + $user_id = $query['id']; +} + // User (REQUIRES AUTHORISATION) function api_user_info() { @@ -94,7 +107,10 @@ $api_routes = [ // base url is base_url.'/api' "/status" => "api_health_check", // Account stuff - "/account/me" => "api_user_info" + "/account/me" => "api_user_info", + + // Get avatar + "/avatars/get" => "get_avatar" ]; $path = str_replace("/api", "", $path); @@ -107,7 +123,11 @@ if (isset($api_routes[$path])) { "message" => "Token expired or invalid." ])); } - echo json_encode($api_routes[$path]()); + $response = $api_routes[$path](); + if (array_key_exists('response_code', $response)) { + http_response_code($response['response_code']); + } + echo json_encode($response); } else { http_response_code(404); echo (json_encode([ diff --git a/assets/icons/apple-icon-180.png b/assets/icons/apple-icon-180.png new file mode 100644 index 0000000..f07b87c Binary files /dev/null and b/assets/icons/apple-icon-180.png differ diff --git a/assets/icons/apple-splash-1125-2436.png b/assets/icons/apple-splash-1125-2436.png new file mode 100644 index 0000000..50920b9 Binary files /dev/null and b/assets/icons/apple-splash-1125-2436.png differ diff --git a/assets/icons/apple-splash-1136-640.png b/assets/icons/apple-splash-1136-640.png new file mode 100644 index 0000000..235e1f9 Binary files /dev/null and b/assets/icons/apple-splash-1136-640.png differ diff --git a/assets/icons/apple-splash-1170-2532.png b/assets/icons/apple-splash-1170-2532.png new file mode 100644 index 0000000..c6cd4a1 Binary files /dev/null and b/assets/icons/apple-splash-1170-2532.png differ diff --git a/assets/icons/apple-splash-1179-2556.png b/assets/icons/apple-splash-1179-2556.png new file mode 100644 index 0000000..5f90799 Binary files /dev/null and b/assets/icons/apple-splash-1179-2556.png differ diff --git a/assets/icons/apple-splash-1242-2208.png b/assets/icons/apple-splash-1242-2208.png new file mode 100644 index 0000000..2e56b17 Binary files /dev/null and b/assets/icons/apple-splash-1242-2208.png differ diff --git a/assets/icons/apple-splash-1242-2688.png b/assets/icons/apple-splash-1242-2688.png new file mode 100644 index 0000000..45c72d4 Binary files /dev/null and b/assets/icons/apple-splash-1242-2688.png differ diff --git a/assets/icons/apple-splash-1284-2778.png b/assets/icons/apple-splash-1284-2778.png new file mode 100644 index 0000000..5d26b9d Binary files /dev/null and b/assets/icons/apple-splash-1284-2778.png differ diff --git a/assets/icons/apple-splash-1290-2796.png b/assets/icons/apple-splash-1290-2796.png new file mode 100644 index 0000000..cee06db Binary files /dev/null and b/assets/icons/apple-splash-1290-2796.png differ diff --git a/assets/icons/apple-splash-1334-750.png b/assets/icons/apple-splash-1334-750.png new file mode 100644 index 0000000..fb37712 Binary files /dev/null and b/assets/icons/apple-splash-1334-750.png differ diff --git a/assets/icons/apple-splash-1488-2266.png b/assets/icons/apple-splash-1488-2266.png new file mode 100644 index 0000000..657fcb3 Binary files /dev/null and b/assets/icons/apple-splash-1488-2266.png differ diff --git a/assets/icons/apple-splash-1536-2048.png b/assets/icons/apple-splash-1536-2048.png new file mode 100644 index 0000000..c313eec Binary files /dev/null and b/assets/icons/apple-splash-1536-2048.png differ diff --git a/assets/icons/apple-splash-1620-2160.png b/assets/icons/apple-splash-1620-2160.png new file mode 100644 index 0000000..7e08f6d Binary files /dev/null and b/assets/icons/apple-splash-1620-2160.png differ diff --git a/assets/icons/apple-splash-1640-2360.png b/assets/icons/apple-splash-1640-2360.png new file mode 100644 index 0000000..b400cd3 Binary files /dev/null and b/assets/icons/apple-splash-1640-2360.png differ diff --git a/assets/icons/apple-splash-1668-2224.png b/assets/icons/apple-splash-1668-2224.png new file mode 100644 index 0000000..f01df0b Binary files /dev/null and b/assets/icons/apple-splash-1668-2224.png differ diff --git a/assets/icons/apple-splash-1668-2388.png b/assets/icons/apple-splash-1668-2388.png new file mode 100644 index 0000000..41f4ca6 Binary files /dev/null and b/assets/icons/apple-splash-1668-2388.png differ diff --git a/assets/icons/apple-splash-1792-828.png b/assets/icons/apple-splash-1792-828.png new file mode 100644 index 0000000..2d7e312 Binary files /dev/null and b/assets/icons/apple-splash-1792-828.png differ diff --git a/assets/icons/apple-splash-2048-1536.png b/assets/icons/apple-splash-2048-1536.png new file mode 100644 index 0000000..a53ba1c Binary files /dev/null and b/assets/icons/apple-splash-2048-1536.png differ diff --git a/assets/icons/apple-splash-2048-2732.png b/assets/icons/apple-splash-2048-2732.png new file mode 100644 index 0000000..75dcd5f Binary files /dev/null and b/assets/icons/apple-splash-2048-2732.png differ diff --git a/assets/icons/apple-splash-2160-1620.png b/assets/icons/apple-splash-2160-1620.png new file mode 100644 index 0000000..760d67a Binary files /dev/null and b/assets/icons/apple-splash-2160-1620.png differ diff --git a/assets/icons/apple-splash-2208-1242.png b/assets/icons/apple-splash-2208-1242.png new file mode 100644 index 0000000..1b5012d Binary files /dev/null and b/assets/icons/apple-splash-2208-1242.png differ diff --git a/assets/icons/apple-splash-2224-1668.png b/assets/icons/apple-splash-2224-1668.png new file mode 100644 index 0000000..24d1b32 Binary files /dev/null and b/assets/icons/apple-splash-2224-1668.png differ diff --git a/assets/icons/apple-splash-2266-1488.png b/assets/icons/apple-splash-2266-1488.png new file mode 100644 index 0000000..fa7ff4e Binary files /dev/null and b/assets/icons/apple-splash-2266-1488.png differ diff --git a/assets/icons/apple-splash-2360-1640.png b/assets/icons/apple-splash-2360-1640.png new file mode 100644 index 0000000..74192f7 Binary files /dev/null and b/assets/icons/apple-splash-2360-1640.png differ diff --git a/assets/icons/apple-splash-2388-1668.png b/assets/icons/apple-splash-2388-1668.png new file mode 100644 index 0000000..2895613 Binary files /dev/null and b/assets/icons/apple-splash-2388-1668.png differ diff --git a/assets/icons/apple-splash-2436-1125.png b/assets/icons/apple-splash-2436-1125.png new file mode 100644 index 0000000..d4b6f87 Binary files /dev/null and b/assets/icons/apple-splash-2436-1125.png differ diff --git a/assets/icons/apple-splash-2532-1170.png b/assets/icons/apple-splash-2532-1170.png new file mode 100644 index 0000000..b8ca512 Binary files /dev/null and b/assets/icons/apple-splash-2532-1170.png differ diff --git a/assets/icons/apple-splash-2556-1179.png b/assets/icons/apple-splash-2556-1179.png new file mode 100644 index 0000000..44a462f Binary files /dev/null and b/assets/icons/apple-splash-2556-1179.png differ diff --git a/assets/icons/apple-splash-2688-1242.png b/assets/icons/apple-splash-2688-1242.png new file mode 100644 index 0000000..6c8da45 Binary files /dev/null and b/assets/icons/apple-splash-2688-1242.png differ diff --git a/assets/icons/apple-splash-2732-2048.png b/assets/icons/apple-splash-2732-2048.png new file mode 100644 index 0000000..6d325da Binary files /dev/null and b/assets/icons/apple-splash-2732-2048.png differ diff --git a/assets/icons/apple-splash-2778-1284.png b/assets/icons/apple-splash-2778-1284.png new file mode 100644 index 0000000..f3d1776 Binary files /dev/null and b/assets/icons/apple-splash-2778-1284.png differ diff --git a/assets/icons/apple-splash-2796-1290.png b/assets/icons/apple-splash-2796-1290.png new file mode 100644 index 0000000..e906f5e Binary files /dev/null and b/assets/icons/apple-splash-2796-1290.png differ diff --git a/assets/icons/apple-splash-640-1136.png b/assets/icons/apple-splash-640-1136.png new file mode 100644 index 0000000..1e8208d Binary files /dev/null and b/assets/icons/apple-splash-640-1136.png differ diff --git a/assets/icons/apple-splash-750-1334.png b/assets/icons/apple-splash-750-1334.png new file mode 100644 index 0000000..a9ae504 Binary files /dev/null and b/assets/icons/apple-splash-750-1334.png differ diff --git a/assets/icons/apple-splash-828-1792.png b/assets/icons/apple-splash-828-1792.png new file mode 100644 index 0000000..668f2f7 Binary files /dev/null and b/assets/icons/apple-splash-828-1792.png differ diff --git a/assets/icons/manifest-icon-192.maskable.png b/assets/icons/manifest-icon-192.maskable.png new file mode 100644 index 0000000..f7735bc Binary files /dev/null and b/assets/icons/manifest-icon-192.maskable.png differ diff --git a/assets/icons/manifest-icon-512.maskable.png b/assets/icons/manifest-icon-512.maskable.png new file mode 100644 index 0000000..ad7db2b Binary files /dev/null and b/assets/icons/manifest-icon-512.maskable.png differ diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..58d5592 --- /dev/null +++ b/dashboard.php @@ -0,0 +1,12 @@ + + +

Hey there !

diff --git a/database.php b/database.php index bd1fcbd..9d794f9 100644 --- a/database.php +++ b/database.php @@ -10,6 +10,15 @@ function db_execute($sql, $variables=[]) { } +function db_execute_all($sql, $variables=[]) { + global $pdo; + + $stmt = $pdo->prepare($sql); + $stmt->execute($variables); + return $stmt->fetchAll(); + +} + function db_query($sql) { global $pdo; diff --git a/head.php b/head.php index 2d5c655..37e681a 100644 --- a/head.php +++ b/head.php @@ -1,13 +1,55 @@ - - - + -<?php if (isset($doc_title)) { echo $doc_title." | "; } ?>ByeCorps ID + - + - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/image_grabber.php b/image_grabber.php new file mode 100644 index 0000000..ed82256 --- /dev/null +++ b/image_grabber.php @@ -0,0 +1,17 @@ + ["admin_accounts.php"], "/admin/list/apps" => ["admin_apps.php"], "/admin/create/app" => ["admin_apps_create.php"], + "/admin/signinas" => ["signinas.php"], "/admin/purge" => ["admin_purge.php"], - "/account" => ["account.php", "Your account"], + // Settings + "/dashboard" => ["dashboard.php", "Dashboard", true], + + "/account" => ["account.php", "Your account", true], "/signin" => ["signin.php", "Sign in"], "/signup" => ["signup.php", "Sign up"], - "/signout" => ["signout.php", "Signed out"], + "/signout" => ["signout.php", "Signed out". false, true], "/forgot/password" => ["forgot_password.php", "Forgot password"], - "/admin/signinas" => ["signinas.php"], "/reset/password" => ["reset_password.php", "Reset password"], "/docs" => ["docs.php", "Docs"], "/credits" => ["credits.php", "Credits"], @@ -139,6 +142,10 @@ if (!empty($uri) ) { // Go to jail. Go directly to jail. Do not pass Go. include("api_handler.php"); exit(); // fuck this shit i'm out } + if ($uri[0] == "public" && $uri[1] == "avatars") { + include("image_grabber.php"); + exit(); + } } if (isset($paths[$path])) { @@ -146,6 +153,11 @@ if (isset($paths[$path])) { if (isset($paths[$path][1])) { $doc_title = $paths[$path][1]; } + if (array_key_exists(3, $paths[$path])) { + if ($paths[$path][3]) { + goto skip_formalities; + } + } } else { @@ -167,8 +179,7 @@ if ($include == "login_external_basic.php") {
- + include($include); + ?>
- \ No newline at end of file + diff --git a/login_external_basic.php b/login_external_basic.php index 9169211..5b3d55b 100644 --- a/login_external_basic.php +++ b/login_external_basic.php @@ -96,9 +96,14 @@ login:
-

Sign into

+
+ <?= htmlspecialchars($user['display_name']) ?>'s avatar + × + <?= htmlspecialchars($user['title']) ?>'s avatar +
+

Sign into

Owned by

-

+ $badges); + } +} ?>
Avatar
-
+
@@ -48,6 +52,23 @@ if ($_SESSION['id'] != $profile['id']) {

Badges

+ This profile has no badges :(

'; + } else { + foreach ($badges as $badge) { + echo "
+". htmlspecialchars($badge[ +
+" . htmlspecialchars($badge['title']) . " +

". htmlspecialchars($badge['description']) ."

+

". htmlspecialchars($badge['description']) ."

+

Earned " . $badge['earned'] . "

+
+
"; + } + } + ?>
@@ -58,6 +79,10 @@ if ($_SESSION['id'] != $profile['id']) { Joined + + Badges earned + +
diff --git a/signin.php b/signin.php index a1904f5..88f8619 100644 --- a/signin.php +++ b/signin.php @@ -29,11 +29,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { // print_r($_POST); // echo(is_string($_POST['keep_logged_in'])); - if ($_POST['keep_logged_in'] == "on") { - $token = generate_cookie_access_token($user['id']); + if (array_key_exists('keep_logged_in', $_POST)) { + if ($_POST['keep_logged_in'] == "on") { + $token = generate_cookie_access_token($user['id']); // print_r($token); - setcookie("keep_me_logged_in", $token['access']); + setcookie("keep_me_logged_in", $token['access']); + } } + // if (isset($query['callback'])) { header("Location: ".$query['callback']); @@ -57,14 +60,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { echo "
$message
"; }?> - - + +

- Forgot password? • New? Register for a ByeCorps ID. + Forgot password? • New? Sign up for a ByeCorps ID.

-
\ No newline at end of file +
diff --git a/signup.php b/signup.php index 13fc42e..612426a 100644 --- a/signup.php +++ b/signup.php @@ -55,7 +55,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {

Sign up for ByeCorps ID

- - + +
\ No newline at end of file diff --git a/styles/design.css b/styles/design.css index c6748d9..0d5d2d8 100644 --- a/styles/design.css +++ b/styles/design.css @@ -15,9 +15,9 @@ button, .button { cursor: pointer; } -header a { - text-decoration: none; -} +/*header a {*/ +/* text-decoration: underline;*/ +/*}*/ /* inputs */ @@ -72,6 +72,23 @@ table > tbody > tr > td { padding: .5em; } +#connection_img { + display: flex; + gap: 1rem; + + justify-content: center; +} + +#connection_img img { + height:7.5rem; + border-radius: 50%; +} + +#connection_img .sep { + font-size: 4rem; + align-self: center; +} + @media screen and (prefers-color-scheme: dark) { table { background-color: var(--grey-9); diff --git a/styles/global.css b/styles/global.css index c689015..adf6fc5 100644 --- a/styles/global.css +++ b/styles/global.css @@ -9,10 +9,10 @@ } body::after { - content: "Development: Subject To Change"; + content: "BETA"; position: fixed; - top: 4.5rem; - right: -1rem; + top: 5rem; + right: 1rem; text-align: right; font-size: 2.5rem; diff --git a/styles/profiles.css b/styles/profiles.css index 147c159..01c8d67 100644 --- a/styles/profiles.css +++ b/styles/profiles.css @@ -32,6 +32,36 @@ grid-template-columns: 3fr 1fr; } +#badges { + display: grid; + grid-template-columns: repeat(auto-fit, 1fr); + gap: 0.5rem; +} + +#badges .badge { + display: flex; + align-items: center; + + gap: 1rem; +} + +.badge .details { + display: flex; + flex-direction: column; +} + +.badge img { + height: 7.5em; + width: 7.5em; + object-fit: contain; + border-radius: 1em; +} + +.badge .details .title { + font-size: 1.5rem; + font-weight: 700; +} + @media screen and (prefers-color-scheme: dark) { #profile { background: var(--grey-9); diff --git a/styles/types.css b/styles/types.css index 10cea60..2fec09e 100644 --- a/styles/types.css +++ b/styles/types.css @@ -1,7 +1,7 @@ /* This file deals with font types and font families. */ @import url(https://fonts.bunny.net/css?family=montserrat:400,400i,600,600i,700,700i,900,900i); -@import url(https://fonts.bunny.net/css2?family=courier+prime:wght@400;700&display=swap); /* for BCIDs */ +@import url(https://fonts.bunny.net/css2?family=Space+Mono:wght@400;700&display=swap); /* for BCIDs */ @import url(/fontawesome/css/all.css); @@ -39,10 +39,10 @@ h2.subheading + h1 { } .bcid { - font-family: 'Courier Prime', monospace; + font-family: 'Space Mono', monospace; } -p.subtitle { +.subtitle { font-size: 0.9rem; margin: 0; opacity: 0.8; @@ -59,3 +59,28 @@ p.subtitle { .icon-false::before { content: "\f00d"; } + +.space-mono-regular { + font-family: "Space Mono", monospace; + font-weight: 400; + font-style: normal; +} + +.space-mono-regular-italic { + font-family: "Space Mono", monospace; + font-weight: 400; + font-style: italic; +} + +.space-mono-bold { + font-family: "Space Mono", monospace; + font-weight: 700; + font-style: normal; +} + +.space-mono-bold-italic { + font-family: "Space Mono", monospace; + font-weight: 700; + font-style: italic; +} +