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);
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
function forum_validate_title(string $title): string {
|
2019-07-03 02:03:32 +02:00
|
|
|
$length = mb_strlen(trim($title));
|
2018-05-23 03:41:57 +02:00
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if($length < MSZ_TOPIC_TITLE_LENGTH_MIN) {
|
2018-05-23 03:41:57 +02:00
|
|
|
return 'too-short';
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if($length > MSZ_TOPIC_TITLE_LENGTH_MAX) {
|
2018-05-23 03:41:57 +02:00
|
|
|
return 'too-long';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
function forum_validate_post(string $text): string {
|
2019-07-03 02:03:32 +02:00
|
|
|
$length = mb_strlen(trim($text));
|
2018-05-23 03:41:57 +02:00
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if($length < MSZ_POST_TEXT_LENGTH_MIN) {
|
2018-05-23 03:41:57 +02:00
|
|
|
return 'too-short';
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if($length > MSZ_POST_TEXT_LENGTH_MAX) {
|
2018-05-23 03:41:57 +02:00
|
|
|
return 'too-long';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|