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 @@ + + +
+ + + +