Вход Регистрация
Файл: pages/admin/redaktor.php
Строк: 149
<?php
declare(strict_types=1);
// Physical module map v50.6: public URL stays clean while code lives in /pages.
if (!defined('GAME_ROOT')) define('GAME_ROOT'dirname(__DIR__2));
chdir(GAME_ROOT);
if (
PHP_SAPI !== 'cli') { $_SERVER['PHP_SELF']='/redaktor.php'$_SERVER['SCRIPT_NAME']='/redaktor.php'; }
require_once 
'./system/common.php';
require_once 
'./system/functions.php';
require_once 
'./system/user.php';
if(!
$user || (int)($user['access']??0)<=0){ header('Location: /'); exit; }

$top=(int)($_GET['top']??$_POST['top']??0);
$forumTop=$top>db_fetch_one('SELECT * FROM `forum_topic` WHERE `id`=:id LIMIT 1',['id'=>$top]) : null;
if(!
$forumTop){ http_response_code(404); $title='Тема не найдена'; require './system/h.php'; echo '<div class="block_light center">Тема не найдена.</div>'; require './system/f.php'; exit; }
$author=db_fetch_one('SELECT `id`,`login`,`access`,`ip` FROM `users` WHERE `id`=:id LIMIT 1',['id'=>(int)$forumTop['user']]) ?: ['id'=>0,'login'=>'Удалённый игрок','access'=>0,'ip'=>''];

if((
$_SERVER['REQUEST_METHOD']??'GET')==='POST'){
    
security_require_csrf();
    
$action=(string)($_POST['action']??'');
    if(
$action==='edit'){
        
$name=trim(mb_substr(strip_tags((string)($_POST['top_n']??'')),0,40,'UTF-8'));
        
$text=trim(mb_substr((string)($_POST['top_r']??''),0,20000,'UTF-8'));
        if(
$name==='' || $text===''){ $_SESSION['err']='Название и текст темы не могут быть пустыми.'; }
        else{
            
db_execute('UPDATE `forum_topic` SET `text`=:text,`red_time`=:rt,`name`=:name,`red_login`=:login WHERE `id`=:id',[
                
'text'=>$text,'rt'=>time(),'name'=>$name,'login'=>(string)$user['login'],'id'=>(int)$forumTop['id']
            ]);
            
$_SESSION['ok']='Тема изменена.';
            
header('Location: /forum/topic/'.(int)$forumTop['id'].'/'); exit;
        }
    }elseif(
$action==='ban'){
        if(!
moderation_can_punish($user,$author)){
            
$_SESSION['err']='Недостаточно прав: нельзя блокировать равного или старшего сотрудника.';
        }else{
            
$until=time()+86400$reason='Нарушение правил форума';
            
db_pdo()->beginTransaction();
            try{
                
db_execute('DELETE FROM `ban` WHERE `user`=:u',['u'=>(int)$author['id']]);
                
db_execute('INSERT INTO `ban` (`user`,`time`,`ip`,`text`,`who`) VALUES (:u,:t,:ip,:text,:who)',[
                    
'u'=>(int)$author['id'],'t'=>$until,'ip'=>(string)($author['ip']??''),'text'=>$reason,'who'=>(string)$user['login']
                ]);
                
moderation_log((int)$user['id'],(int)$author['id'],'ban',$reason,$until,'apply');
                
db_pdo()->commit();
                
$_SESSION['ok']='Игрок заблокирован на 24 часа.';
            }catch(
Throwable $e){ if(db_pdo()->inTransaction()) db_pdo()->rollBack(); throw $e; }
        }
    }elseif(
$action==='delete'){
        
db_execute('DELETE FROM `forum_topic` WHERE `id`=:id',['id'=>(int)$forumTop['id']]);
        
$_SESSION['ok']='Тема удалена.';
        
header('Location: /forum/'); exit;
    }
    
header('Location: /forum/topic/red/'.(int)$forumTop['id'].'/'); exit;
}

$title='Редактирование темы';
require 
'./system/h.php';
?>
<div class="block_light center"><b>Топик от игрока <?=security_html((string)$author['login'])?></b></div>
<div class="block_zero">
<form method="post" action="/forum/topic/red/<?=(int)$forumTop['id']?>/">
<?=security_csrf_field()?>
<input type="hidden" name="top" value="<?=(int)$forumTop['id']?>">
<input type="hidden" name="action" value="edit">
<div>Название топика:<br>
<input class="text medium-text" name="top_n" maxlength="40" value="<?=security_html((string)$forumTop['name'])?>" type="text">
<br>Оглавление:<br>
<textarea name="top_r" class="text large" rows="8" cols="60"><?=security_html((string)$forumTop['text'])?></textarea><br>
<button class="btn" type="submit">Изменить</button></div>
</form>
</div>
<div class="block_zero">
<span class="green">Кто:</span> <a href="/user/<?=(int)$author['id']?>/"><?=security_html((string)$author['login'])?></a><hr>
Топ создан: <small><?=date('d.m',(int)$forumTop['time'])?> в <?=date('H:i:s',(int)$forumTop['time'])?></small>
</div>
<div class="menuList">
<?php if(moderation_can_punish($user,$author)): ?>
<form method="post" action="/forum/topic/red/<?=(int)$forumTop['id']?>/" onsubmit="return confirm('Заблокировать игрока на 24 часа?')"><?=security_csrf_field()?><input type="hidden" name="top" value="<?=(int)$forumTop['id']?>"><input type="hidden" name="action" value="ban"><button class="btn" type="submit">Заблокировать <?=security_html((string)$author['login'])?></button></form>
<?php endif; ?>
<form method="post" action="/forum/topic/red/<?=(int)$forumTop['id']?>/" onsubmit="return confirm('Удалить тему?')"><?=security_csrf_field()?><input type="hidden" name="top" value="<?=(int)$forumTop['id']?>"><input type="hidden" name="action" value="delete"><button class="btn" type="submit">Удалить топик</button></form>
</div>
<?php require './system/f.php'?>
Онлайн: 2
Реклама