diff --git a/includes/constants.php b/includes/constants.php index bb5d646..605fa56 100644 --- a/includes/constants.php +++ b/includes/constants.php @@ -34,6 +34,8 @@ 'HEIGHT' => 300 ]); +define('DESCRIPTION_MAX_LENGTH', 200); + define('HTTP_STATUS', [ 'OK' => 200, 'CREATED' => 201, diff --git a/index.php b/index.php index ca9b08b..1c1b388 100644 --- a/index.php +++ b/index.php @@ -79,7 +79,7 @@ class="modal fade"
- +
Please provide a valid description.
diff --git a/services/serverListManager.php b/services/serverListManager.php index 2f59707..f229e59 100644 --- a/services/serverListManager.php +++ b/services/serverListManager.php @@ -232,6 +232,12 @@ ); } + if (strlen($validData['description']) > DESCRIPTION_MAX_LENGTH) { + $validData['description'] = substr($validData['description'], 0, DESCRIPTION_MAX_LENGTH); + + $result['notice'] = 'The description provided was too long, truncated to ' . DESCRIPTION_MAX_LENGTH . ' characters.'; + } + $statement->bindValue('description' , $validData['description']); $statement->bindValue('hostname' , $validData['hostname']); $statement->bindValue('ip' , $validData['ipAddress']);