Файл: monst/core/pag/forum/new_topic.php
Строк: 87
<?
$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');
}
upd_loc('create new topic, <a href="/forum/'.$forum_id.'">'.$forum_names[$forum_id]['name'].'</a>');
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 ( $user['id'] != 1 ) {
$find = $_forum_topic -> find(
[
'user_id' => $user['id']
]
);
$find -> sort(
[
'time' => -1
]
);
$find -> limit(1);
foreach ( $find as $f ) {
$last_time = $f['time'];
}
if ( $user['id'] != $admin_id ) {
if ( time() - @(int)$last_time < 60 * 5) {
$err .= $lang['forum.php']['error']['topic_flood'];
}
}
}
$find = $_forum_topic -> findOne(
[
'user_id' => $user['id'],
'name' => $topic_name,
'time' => [
'$gte' => time() - 60 * 60 * 2
]
]
);
if ( $find ) {
$err .= $lang['forum.php']['error']['topic_exist'];
}
if ( !empty($err) ) {
?>
<div class='padding'>
<?=$lang['forum.php']['Error']?><br/>
<?=$err?>
</div>
<div style='text-align: center;'>
<a class='bt_black' href='/forum/new_topic/<?=$forum_id?>'><?=$lang['forum.php']['retry']?></a>
<a class='bt_black' href='/forum/thread/<?=$forum_id?>'><< <?=str_replace('color', 'color2',$forum_names[$forum_id]['name'])?></a>
</div>
<?
} else {
$new_topic_id = new_id('_forum_topic');
$_forum_topic -> insert(
[
'id' => $new_topic_id,
'forum_id' => $forum_id,
'user_id' => $user['id'],
'name' => $topic_name,
'time' => time(),
'last_upd' => time(),
'warn' => 0,
'close' => 0,
'views' => 0,
'uniq_views' => 0,
]
);
$new_post_id = new_id('_forum_post');
$_forum_post -> insert(
[
'id' => $new_post_id,
'forum_id' => $forum_id,
'topic_id' => $new_topic_id,
'user_id' => $user['id'],
'time' => time(),
'text' => $text
]
);
$_users -> update(
[
'id' => $user['id']
],
[
'$set' => [
'forum_count' => $user['forum_count'] + 1
]
]
);
if ( $forum_id == 1 ) {
$key = md5('last_news');
$mem -> delete($key);
}
?>
<div><?=$lang['forum.php']['new_topic_ok']?></div>
<div style='text-align: center;'>
<a class='bt_black' href='/forum/topic/<?=$forum_id?>/<?=$new_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 {
?>
<div class='padding'>
<form method='post' action='/forum/new_topic/<?=$forum_id?>'>
<?=$lang['forum.php']['topic_name']?><br/>
<input name='topic_name' style='width: 70%;'/><br/>
<?=$lang['forum.php']['topic_text']?>
<div style='text-align: center;'>
<textarea id='text' name='text' rows='10' style='width: 90%;'></textarea><br/>
<br/>
<input type='submit' value='<?=$lang['forum.php']['topic_create']?>'/>
</div>
</form>
</div>
<br/>
<div style='text-align: center;'>
<a class='bt_black' href='/forum/thread/<?=$forum_id?>'><< <?=str_replace('color', 'color2',$forum_names[$forum_id]['name'])?></a>
</div>
<?
}