From 07663b1e7465f94eb54133a35db17b8391a77529 Mon Sep 17 00:00:00 2001 From: William Date: Sun, 22 Jan 2023 13:17:50 +0100 Subject: [PATCH] Not too janky --- routes/willychat.php | 16 ++++++++++++++- views/pages/willychat/error.php | 33 ++++++++++++++++++++++++++++++ views/pages/willychat/index.php | 4 +--- views/pages/willychat/messages.php | 1 + 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 views/pages/willychat/error.php diff --git a/routes/willychat.php b/routes/willychat.php index 0e53dc2..f1ab37d 100644 --- a/routes/willychat.php +++ b/routes/willychat.php @@ -36,6 +36,20 @@ Route::match('get|post','/willychat/', function() { $nick = $default_nick; } + if (strlen($nick) > 128) { + view('pages/willychat/error', [ + 'error' => 'You nickname is too long.' + ]); + die(); + } + + if (strlen($text) > 4096) { + view('pages/willychat/error', [ + 'error' => 'Do not send extremely long messages.' + ]); + die(); + } + if (count(WillyChat::$messages) > 10) { array_pop(WillyChat::$messages); } @@ -60,7 +74,7 @@ Route::match('get|post','/willychat/', function() { view('pages/willychat/index', [ 'nick' => $nick, - 'just_sent_message' => $just_sent_message + 'just_sent_message' => $just_sent_message, ]); }); diff --git a/views/pages/willychat/error.php b/views/pages/willychat/error.php new file mode 100644 index 0000000..43f9e84 --- /dev/null +++ b/views/pages/willychat/error.php @@ -0,0 +1,33 @@ + + + + + + + What are you doing? + + + + + +
+ +

+ + I understand. + +
+ + + \ No newline at end of file diff --git a/views/pages/willychat/index.php b/views/pages/willychat/index.php index db53fbb..b6f5952 100644 --- a/views/pages/willychat/index.php +++ b/views/pages/willychat/index.php @@ -4,6 +4,7 @@ + WillyChat @@ -16,9 +17,6 @@ display: flex; flex-flow: column; color: white; - font-size: 1rem; - font-family: Iowan Old Style, Apple Garamond, Baskerville, Times New Roman, Droid Serif, Times, Source Serif Pro, serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol; - } body .messages { flex: 1 1 auto; diff --git a/views/pages/willychat/messages.php b/views/pages/willychat/messages.php index 090aebd..f199986 100644 --- a/views/pages/willychat/messages.php +++ b/views/pages/willychat/messages.php @@ -14,6 +14,7 @@ padding: .5rem; background: rgba(0, 0, 0, 0.75); color: white; + word-break: break-all; } div > small { color: gray;