Файл: monst/core/pag/forum/edit_topic.php
Строк: 70
<?
if ( $user['id'] != $admin_id ) {
g('/forum');
}
$forum_id = (int)$index[2];
if ( $forum_id < 1 OR $forum_id > count($forum_names) ) {
g('/forum');
}
if ( $forum_id == 1 AND $user['id'] != $admin_id) {
g('/forum');
}
$topic_id = (int)$index[3];
$find = $_forum_topic -> findOne(
[
'id' => $topic_id
]
);
if ( !$find ) {
g('/forum?no_topic');
}
$topic = $find;
if ( !empty($_POST['topic_name']) AND !empty($_POST['text']) ) {
$topic_name = null_html($_POST['topic_name']);
$text = null_html($_POST['text']);
$err = '';
if ( mb_strlen($topic_name, 'UTF-8') > 100 ) {
$err .= $lang['forum.php']['error']['long_name'];
}
if ( mb_strlen($text, 'UTF-8') > 10000 ) {
$err .= $lang['forum.php']['error']['long_text'];
}
if ( !empty($err) ) {
?>
<div class='padding'>
<?=$lang['forum.php']['Error']?><br/>
<br/>
<?=$err?>
</div>
<div style='text-align: center;'>
<a class='bt_black' href='/forum/edit_topic/<?=$forum_id?>/<?=$topic_id?>'><?=$lang['forum.php']['retry']?></a><br/>
</div>
<?
} else {
$_forum_topic -> update(
[
'id' => $topic_id
],
[
'$set' => [
'name' => $topic_name
]
]
);
$find = $_forum_post -> find(
[
'topic_id' => $topic_id
]
);
$find -> sort(
[
'id' => -1
]
);
foreach ( $find as $f ) {
$first_post_id = $f['id'];
}
$_forum_post -> update(
[
'id' => $first_post_id,
'topic_id' => $topic_id
],
[
'$set' => [
'text' => $text
]
]
);
if ( $forum_id == 1 ) {
$key = md5('last_news');
$mem -> delete($key);
}
?>
<div class='padding'>
<?=$lang['forum.php']['edited']?>
</div>
<div style='text-align: center;'>
<a class='bt_black' href='/forum/topic/<?=$forum_id?>/<?=$topic_id?>'><?=$lang['forum.php']['go_topic']?></a>
<a class='bt_black' href='/forum/thread/<?=$forum_id?>'><< <?=str_replace('color', 'color2',$forum_names[$forum_id]['name'])?></a>
</div>
<?
}
} else {
$find = $_forum_post -> find(
[
'topic_id' => $topic_id
]
);
$find -> sort(
[
'id' => -1
]
);
foreach ( $find as $f ) {
$first_post = $f['text'];
}
?>
<span style='font-size: 30px;'><?=$lang['forum.php']['topic_edit']?></span><br/>
<form method='post' action='/forum/edit_topic/<?=$forum_id?>/<?=$topic_id?>/'>
<input name='topic_name' value="<?=$topic['name']?>" style='width: 70%;'/>
<br/>
<div style='text-align: center;'>
<textarea id='text' name='text' rows='10' style='width: 90%;'><?=$first_post?></textarea><br/>
<br/>
<input type='submit' value='<?=$lang['forum.php']['save']?>'/>
</div>
</form>
<br/>
<div style='text-align: center;'>
<a class='bt_black' href='/forum/topic/<?=$forum_id?>/<?=$topic_id?>'><< <?=$lang['forum.php']['go_topic']?></a>
<a class='bt_black' href='/forum/thread/<?=$forum_id?>'><< <?=str_replace('color', 'color2',$forum_names[$forum_id]['name'])?></a>
</div>
<?
}