2018-05-23 03:41:57 +02:00
|
|
|
<?php
|
2019-06-03 20:33:19 +02:00
|
|
|
define('MSZ_TOPIC_TITLE_LENGTH_MIN', 3);
|
2018-05-23 03:41:57 +02:00
|
|
|
define('MSZ_TOPIC_TITLE_LENGTH_MAX', 100);
|
2019-06-03 20:33:19 +02:00
|
|
|
define('MSZ_POST_TEXT_LENGTH_MIN', 1);
|
2018-05-23 03:41:57 +02:00
|
|
|
define('MSZ_POST_TEXT_LENGTH_MAX', 60000);
|
|
|
|
|
|
|
|
function forum_validate_title(string $title): string
|
|
|
|
{
|
2018-09-15 23:55:26 +02:00
|
|
|
$length = mb_strlen($title);
|
2018-05-23 03:41:57 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2018-09-15 23:55:26 +02:00
|
|
|
$length = mb_strlen($text);
|
2018-05-23 03:41:57 +02:00
|
|
|
|
|
|
|
if ($length < MSZ_POST_TEXT_LENGTH_MIN) {
|
|
|
|
return 'too-short';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($length > MSZ_POST_TEXT_LENGTH_MAX) {
|
|
|
|
return 'too-long';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|