49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?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;">
|
|
<h4>Мегафон</h4>
|
|
<form method="post"></form>
|
|
<label for="announcementText">Сообщение</label>
|
|
<input name="announcementText" type="text" id="announcementText" size="70" maxlength="1000">
|
|
<input type="submit" name="announcementModeration" id="announcementModeration" class="btn" value="Написать"><br>
|
|
<input name="announcementIsSigned" type="checkbox" id="announcementIsSigned" value="1">
|
|
<label for="announcementIsSigned">от своего имени</label>
|
|
</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;
|
|
}
|
|
|
|
$sender = empty($_POST['announcementIsSigned']) ? '<b>Администрация</b>' : User::getLogin(User::start()->info['id']);
|
|
|
|
(new Chat())->sendsys("$sender: $strippedMessage");
|
|
echo '<span style="color: red; "><b>Сообщение успешно отправлено</b></span>';
|
|
}
|
|
} |