From d7a64844c46c3421beb6902bcdf9ac4a4b0fbd5a Mon Sep 17 00:00:00 2001 From: bye Date: Tue, 20 Feb 2024 19:49:42 +0000 Subject: [PATCH] yo waht's up --- .gitignore | 3 +- .idea/.gitignore | 5 - .idea/codeStyles/codeStyleConfig.xml | 5 - .idea/dataSources.local.xml | 19 - .idea/dataSources.xml | 12 - .../5bc27beb-c8ab-420d-bdbc-055b37ae9e39.xml | 1288 ----------------- .../storage_v2/_src_/schema/id.Gw0AAA.meta | 2 - .../schema/information_schema.FNRwLQ.meta | 2 - .../storage_v2/_src_/schema/mysql.osA4Bg.meta | 2 - .../schema/performance_schema.kIw0nw.meta | 2 - .idea/id.iml | 30 - .idea/modules.xml | 8 - .idea/php.xml | 47 - .idea/sqldialects.xml | 6 - .idea/vcs.xml | 6 - accounts_handler.php | 2 +- admin_apps_create.php | 6 +- admin_initdatabase.php | 39 +- forgot_password.php | 12 +- index.php | 8 +- profile.php | 2 +- 21 files changed, 45 insertions(+), 1461 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/dataSources.local.xml delete mode 100644 .idea/dataSources.xml delete mode 100644 .idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39.xml delete mode 100644 .idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/id.Gw0AAA.meta delete mode 100644 .idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/information_schema.FNRwLQ.meta delete mode 100644 .idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/mysql.osA4Bg.meta delete mode 100644 .idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/performance_schema.kIw0nw.meta delete mode 100644 .idea/id.iml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/sqldialects.xml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index a078a68..cf76f7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ config.php -vendor/ \ No newline at end of file +vendor/ +.idea/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index b58b603..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a1..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml deleted file mode 100644 index 9c2db00..0000000 --- a/.idea/dataSources.local.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - #@ - ` - - - master_key - bye - - - - - - - - \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml deleted file mode 100644 index dfaf86d..0000000 --- a/.idea/dataSources.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - mariadb - true - org.mariadb.jdbc.Driver - jdbc:mariadb://id.local:3306/id.local - $ProjectFileDir$ - - - \ No newline at end of file diff --git a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39.xml b/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39.xml deleted file mode 100644 index 627b796..0000000 --- a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39.xml +++ /dev/null @@ -1,1288 +0,0 @@ - - - - - - big5 - 1 - - - big5 - - - big5 - - - big5 - - - dec8 - 1 - - - dec8 - - - dec8 - - - dec8 - - - cp850 - 1 - - - cp850 - - - cp850 - - - cp850 - - - hp8 - 1 - - - hp8 - - - hp8 - - - hp8 - - - koi8r - 1 - - - koi8r - - - koi8r - - - koi8r - - - latin1 - - - latin1 - 1 - - - latin1 - - - latin1 - - - latin1 - - - latin1 - - - latin1 - - - latin1 - - - latin1 - - - latin1 - - - latin2 - - - latin2 - 1 - - - latin2 - - - latin2 - - - latin2 - - - latin2 - - - latin2 - - - swe7 - 1 - - - swe7 - - - swe7 - - - swe7 - - - ascii - 1 - - - ascii - - - ascii - - - ascii - - - ujis - 1 - - - ujis - - - ujis - - - ujis - - - sjis - 1 - - - sjis - - - sjis - - - sjis - - - hebrew - 1 - - - hebrew - - - hebrew - - - hebrew - - - tis620 - 1 - - - tis620 - - - tis620 - - - tis620 - - - euckr - 1 - - - euckr - - - euckr - - - euckr - - - koi8u - 1 - - - koi8u - - - koi8u - - - koi8u - - - gb2312 - 1 - - - gb2312 - - - gb2312 - - - gb2312 - - - greek - 1 - - - greek - - - greek - - - greek - - - cp1250 - 1 - - - cp1250 - - - cp1250 - - - cp1250 - - - cp1250 - - - cp1250 - - - cp1250 - - - gbk - 1 - - - gbk - - - gbk - - - gbk - - - latin5 - 1 - - - latin5 - - - latin5 - - - latin5 - - - armscii8 - 1 - - - armscii8 - - - armscii8 - - - armscii8 - - - utf8mb3 - 1 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - utf8mb3 - - - ucs2 - 1 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - ucs2 - - - cp866 - 1 - - - cp866 - - - cp866 - - - cp866 - - - keybcs2 - 1 - - - keybcs2 - - - keybcs2 - - - keybcs2 - - - macce - 1 - - - macce - - - macce - - - macce - - - macroman - 1 - - - macroman - - - macroman - - - macroman - - - cp852 - 1 - - - cp852 - - - cp852 - - - cp852 - - - latin7 - - - latin7 - 1 - - - latin7 - - - latin7 - - - latin7 - - - latin7 - - - utf8mb4 - 1 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - utf8mb4 - - - cp1251 - - - cp1251 - - - cp1251 - - - cp1251 - 1 - - - cp1251 - - - cp1251 - - - cp1251 - - - utf16 - 1 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16 - - - utf16le - 1 - - - utf16le - - - utf16le - - - utf16le - - - cp1256 - 1 - - - cp1256 - - - cp1256 - - - cp1256 - - - cp1257 - - - cp1257 - - - cp1257 - 1 - - - cp1257 - - - cp1257 - - - utf32 - 1 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - utf32 - - - binary - 1 - - - geostd8 - 1 - - - geostd8 - - - geostd8 - - - geostd8 - - - cp932 - 1 - - - cp932 - - - cp932 - - - cp932 - - - eucjpms - 1 - - - eucjpms - - - eucjpms - - - eucjpms - - - utf8mb3_general_ci - - - utf8mb4_general_ci - - - utf8mb3_general_ci - - - 1 - 2023-11-16.19:58:50 - utf8mb4_general_ci - - - utf8mb4_general_ci - - - utf8mb3_general_ci - - - localhost - - - localhost - - - localhost - - - - localhost - - - - 100.12.43.1 - - - InnoDB - utf8mb4_general_ci -
- - InnoDB - utf8mb4_general_ci -
- - InnoDB - utf8mb4_general_ci -
- - InnoDB - utf8mb4_general_ci -
- - InnoDB - utf8mb4_general_ci -
- - varchar(7)|0s - 1 - 1 - - - text|0s - 1 - 2 - - - date|0s - current_timestamp() - 1 - 3 - - - text|0s - 4 - - - text|0s - 1 - 5 - - - tinyint(1)|0s - 1 - 6 - - - tinyint(1)|0s - 0 - 1 - 7 - - - tinyint(1)|0s - 0 - 1 - 8 - - - id - btree - 1 - - - email - hash - 1 - - - 1 - 1 - PRIMARY - - - email - - - int(10)|0s - 1 - 1 - - - varchar(7)|0s - 2 - - - text|0s - 1 - 3 - - - text|0s - 4 - - - owner_id - set-null - cascade - id - accounts - - - id - btree - 1 - - - owner_id - btree - - - 1 - 1 - PRIMARY - - - 1 - int(11)|0s - 1 - 1 - - - int(11)|0s - 1 - 2 - - - text|0s - 1 - 3 - - - text|0s - 4 - - - text|0s - 1 - 5 - - - app_id - id - apps - - - id - btree - 1 - - - app_id - btree - - - 1 - 1 - PRIMARY - - - 8 - int(11)|0s - 1 - 1 - - - tinytext|0s - 1 - 2 - - - varchar(7)|0s - 1 - 3 - - - int(11)|0s - 1 - 4 - - - owner_id - id - accounts - - - id - btree - 1 - - - owner_id - btree - - - 1 - 1 - PRIMARY - - - varchar(7)|0s - 1 - 1 - - - text|0s - 2 - - - tinyint(1)|0s - 0 - 1 - 3 - - - tinyint(1)|0s - 0 - 1 - 4 - - - id - id - accounts - - - id - btree - 1 - - - 1 - 1 - PRIMARY - -
-
\ No newline at end of file diff --git a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/id.Gw0AAA.meta b/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/id.Gw0AAA.meta deleted file mode 100644 index d4880e4..0000000 --- a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/id.Gw0AAA.meta +++ /dev/null @@ -1,2 +0,0 @@ -#n:id -! [1700164719000, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/information_schema.FNRwLQ.meta b/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/information_schema.FNRwLQ.meta deleted file mode 100644 index 1ff3db2..0000000 --- a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/information_schema.FNRwLQ.meta +++ /dev/null @@ -1,2 +0,0 @@ -#n:information_schema -! [null, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/mysql.osA4Bg.meta b/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/mysql.osA4Bg.meta deleted file mode 100644 index 86a53f1..0000000 --- a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/mysql.osA4Bg.meta +++ /dev/null @@ -1,2 +0,0 @@ -#n:mysql -! [null, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/performance_schema.kIw0nw.meta b/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/performance_schema.kIw0nw.meta deleted file mode 100644 index 9394db1..0000000 --- a/.idea/dataSources/5bc27beb-c8ab-420d-bdbc-055b37ae9e39/storage_v2/_src_/schema/performance_schema.kIw0nw.meta +++ /dev/null @@ -1,2 +0,0 @@ -#n:performance_schema -! [null, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/id.iml b/.idea/id.iml deleted file mode 100644 index 7267852..0000000 --- a/.idea/id.iml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 9367315..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index a30690c..0000000 --- a/.idea/php.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml deleted file mode 100644 index 63772a3..0000000 --- a/.idea/sqldialects.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/accounts_handler.php b/accounts_handler.php index 9add2f5..5d862b9 100644 --- a/accounts_handler.php +++ b/accounts_handler.php @@ -25,7 +25,7 @@ function get_avatar_url($bcid):string { } -function get_display_name($bcid, $use_bcid_fallback=true, $put_bcid_in_parenthesis=false):string { +function get_display_name($bcid, $use_bcid_fallback=true, $put_bcid_in_parenthesis=false, $format_bcid=false):string { $display_name = db_execute("SELECT display_name FROM accounts WHERE id = ?", [$bcid])['display_name']; if (!empty($display_name)) { if ($put_bcid_in_parenthesis) { diff --git a/admin_apps_create.php b/admin_apps_create.php index 0de29ff..1e495fb 100644 --- a/admin_apps_create.php +++ b/admin_apps_create.php @@ -13,7 +13,7 @@ function check_app_id($app_id): bool if ($_SERVER['REQUEST_METHOD'] == "POST") { $app_id = generate_app_id(); - db_execute("INSERT INTO apps (id, owner_id, title, description, type) VALUES (?, ?, ?, ?, ?)", [$app_id, $_POST['owner'], $_POST['title'], $_POST['description'], $_POST['type']]); + db_execute("INSERT INTO apps (id, owner_id, title, description, type, callback) VALUES (?, ?, ?, ?, ?, ?)", [$app_id, $_POST['owner'], $_POST['title'], $_POST['description'], $_POST['type'], $_POST['callback']]); die(); } @@ -40,5 +40,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { - + + + \ No newline at end of file diff --git a/admin_initdatabase.php b/admin_initdatabase.php index fec3bb9..838580c 100644 --- a/admin_initdatabase.php +++ b/admin_initdatabase.php @@ -6,15 +6,15 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { echo "

Create table `accounts`"; $stmt = $pdo->prepare('create table accounts ( - id varchar(7) not null + id varchar(7) not null primary key, - email text not null, - created_date date default current_timestamp() not null, - display_name text null, - password text not null, - verified tinyint(1) default 0 not null, - has_pfp tinyint(1) default 0 not null, - is_admin tinyint(1) default 0 not null, + email text not null, + created_date datetime default current_timestamp() not null, + display_name text null, + password text not null, + verified tinyint(1) default 0 not null, + has_pfp tinyint(1) default 0 not null, + is_admin tinyint(1) default 0 not null, constraint email unique (email) using hash );'); @@ -73,6 +73,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { title text not null, description text, image text default "https://id.byecorps.com/assets/default.png" not null, + type text null, + callback text null, constraint badges_ibfk_1 foreign key (app_id) references apps (id) );'); @@ -89,6 +91,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { description text null, public_avatar tinyint(1) default 0, public_display_name tinyint(1) default 0, + constraint profiles_ibfk_1 foreign key (id) references accounts (id) );'); @@ -96,6 +99,26 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { echo('

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

Create the `tokens` table'; + + try { + db_execute('create table tokens ( + id int auto_increment primary key, + access_token text unique, + refresh_token text null, + expiry int not null, + owner_id varchar(7), + application_id int(10) null, + + constraint tokens_application_id + foreign key (application_id) references apps (id), + constraint tokens_owner_id + 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/forgot_password.php b/forgot_password.php index f8180ea..bd02325 100644 --- a/forgot_password.php +++ b/forgot_password.php @@ -16,15 +16,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { // create a password reset $password_reset_link = create_password_reset($user['id']); - try { - $safe_display_name = format_bcid($user['id']); - } catch (Exception $e) { - die("Bad BCID."); - } - - if ($user['display_name'] != '') { - $safe_display_name = $user['display_name']; - } + $safe_display_name = get_display_name($user['id'], use_bcid_fallback: true); try { @@ -41,7 +33,7 @@ If you did not request this password reset, please ignore it (or tighten your ac // echo("This is a security issue."); } catch (Exception $e) { - echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; + echo "Message could not be sent. Mailer Error: $e"; } } diff --git a/index.php b/index.php index 3c9f9b9..7a6bd0b 100644 --- a/index.php +++ b/index.php @@ -176,10 +176,10 @@ if ($include == "login_external_basic.php") { echo "

Admin

"; } - if ($uri[0] == "admin" && !$user['is_admin']) { - http_response_code(401); - die("A cat standing in front of a door with a No Cats Allowed sign on it."); - } +// if ($uri[0] == "admin" && !$user['is_admin']) { +// http_response_code(401); +// die("A cat standing in front of a door with a No Cats Allowed sign on it."); +// } if ($uri[0] == "docs") { $include = "docs.php"; diff --git a/profile.php b/profile.php index 0c38e6c..9b365d2 100644 --- a/profile.php +++ b/profile.php @@ -11,7 +11,7 @@ $profile = db_execute("SELECT * FROM `profiles` WHERE id = ? LIMIT 1", [$user['i if (empty($profile)) { $profile = [ - "id" => "0000000", + "id" => "9999999", "public_display_name" => false, "public_avatar" => false, "description" => null,