2018-05-23 03:41:57 +02:00
|
|
|
<?php
|
|
|
|
define('MSZ_TOPIC_TITLE_LENGTH_MIN', 5);
|
|
|
|
define('MSZ_TOPIC_TITLE_LENGTH_MAX', 100);
|
2018-08-23 22:06:48 +02:00
|
|
|
define('MSZ_POST_TEXT_LENGTH_MIN', 3);
|
2018-05-23 03:41:57 +02:00
|
|
|
define('MSZ_POST_TEXT_LENGTH_MAX', 60000);
|
|
|
|
|
|
|
|
function forum_validate_title(string $title): string
|
|
|
|
{
|
|
|
|
$length = strlen($title);
|
|
|
|
|
|
|
|
if ($length < MSZ_TOPIC_TITLE_LENGTH_MIN) {
|
|
|
|
return 'too-short';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($length > MSZ_TOPIC_TITLE_LENGTH_MAX) {
|
|
|
|
return 'too-long';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
function forum_validate_post(string $text): string
|
|
|
|
{
|
|
|
|
$length = strlen($text);
|
|
|
|
|
|
|
|
if ($length < MSZ_POST_TEXT_LENGTH_MIN) {
|
|
|
|
return 'too-short';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($length > MSZ_POST_TEXT_LENGTH_MAX) {
|
|
|
|
return 'too-long';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|