2023-12-05 01:01:04 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Moderation;
|
|
|
|
|
|
|
|
use Chat;
|
|
|
|
use User;
|
|
|
|
|
|
|
|
class Announcement
|
|
|
|
{
|
|
|
|
public static function init(): void
|
|
|
|
{
|
|
|
|
self::printForm();
|
|
|
|
self::send();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function printForm(): void
|
|
|
|
{
|
|
|
|
echo <<<HTML
|
|
|
|
<div style="padding:0 10px 5px 10px; margin:5px; border-bottom:1px solid #cac9c7;">
|
2023-12-19 01:58:37 +00:00
|
|
|
<h4>Мегафон</h4>
|
2023-12-05 01:01:04 +00:00
|
|
|
<form method="post"></form>
|
2023-12-19 01:58:37 +00:00
|
|
|
<label for="announcementText">Сообщение</label>
|
2023-12-05 01:01:04 +00:00
|
|
|
<input name="announcementText" type="text" id="announcementText" size="70" maxlength="1000">
|
2023-12-19 01:58:37 +00:00
|
|
|
<input type="submit" name="announcementModeration" id="announcementModeration" class="btn" value="Написать"><br>
|
2023-12-05 01:01:04 +00:00
|
|
|
<input name="announcementIsSigned" type="checkbox" id="announcementIsSigned" value="1">
|
2023-12-19 01:58:37 +00:00
|
|
|
<label for="announcementIsSigned">от своего имени</label>
|
2023-12-05 01:01:04 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
HTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function send(): void
|
|
|
|
{
|
|
|
|
if (empty($_POST['announcementModeration'] || empty($_POST['announcementText']))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$strippedMessage = strip_tags($_POST['announcementText']);
|
|
|
|
|
|
|
|
if (empty($strippedMessage)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-12-19 01:58:37 +00:00
|
|
|
$sender = empty($_POST['announcementIsSigned']) ? '<b>Администрация</b>' : User::getLogin(User::start()->info['id']);
|
2023-12-05 01:01:04 +00:00
|
|
|
|
|
|
|
(new Chat())->sendsys("$sender: $strippedMessage");
|
2023-12-19 01:58:37 +00:00
|
|
|
echo '<span style="color: red; "><b>Сообщение успешно отправлено</b></span>';
|
2023-12-05 01:01:04 +00:00
|
|
|
}
|
|
|
|
}
|