Файл: modules/forum/replay.php
Строк: 57
<?php
define('R', $_SERVER['DOCUMENT_ROOT']);
define('S', R.'/system');
require_once(R.'/system/kernel.php');
$tmp->header('forum');
$tmp->title('title', Language::config('repl'));
User::panel();
$id = $db->guard($_GET['id']);
$p=$db->fass("select * from `forum_topic` where `id` = '".$id."' "); 
$s=$db->fass("select * from `forum_section` where `id` = '".$p['section']."'");
$r=$db->fass("select * from `forum_razdel` where `id` = '".$p['razdel']."'");
if(!User::aut()){
    header('location: /');
}
if(User::aut()){
    $o=my_int($_GET['replay']);
    $ot=$db->fass("SELECT * FROM `forum_message` where `id` = '".$o."'");
    
    if(!$ot){
        $tmp->div('error', Language::config('error'));
        $tmp->div('menu', '<a href="/forum/topic'.$id.'">'.img('link.png').' '.Language::config('back').'</a>');
        $tmp->footer();
        exit();
    }
    if($ot['kto'] != User::ID()){
        if(isset($_REQUEST['submit'])){
            $message = $db->guard($_POST['messages']);
        
            if(empty($_POST['messages']) || mb_strlen($_POST['messages'], 'UTF-8')<2) $error .= Language::config('no_message');
        
            if(!isset($error)) {
                if($p['is_close_topic'] != 1){
                    $db->query("insert into `forum_message` set `razdel` = '".$p['razdel']."', `section` = '".$p['section']."', `topic` = '".$id."', `kto` = '".User::ID()."', `message` = '[rep]".nickname($ot['kto'])."[/rep] ".$message."', `time` = '".time()."' ");
                    
                    $fc=$db->fass_c("SELECT COUNT(*) as count FROM `forum_message` where `topic` = '".$id."' ");
                    $num_us = User::settings('num', $ot['kto']);
                    if ($fc > $num_us) {
                        $pg = ceil($fc / $num_us);
                        $st = '?page='.$pg;
                    }else{
                        $st = '';
                    }
                    $db->query("INSERT INTO `journal` set `kto` = '".User::ID()."', `komy` = '".$ot['kto']."', `message` = 'replay_forum', `url`= '/forum/topic".$id.$st."', `time` = '".time()."', `readln` = '0' ");
                    $db->query("UPDATE  `users` set `money` = money + 5 where `id` = '".User::ID()."' ");
                    $db->query("UPDATE `forum_topic` set `last_message_time` = '".time()."' where `id` = '".$id."' ");
                    header('location: /forum/topic'.$id.$st);
                }
            }
        }
        if($p['is_close_topic'] != 1){
            error($error);
            $tmp->div('messages', '<div>'.bb(smile($ot['message'])).'</div><hr>' );
            bbcode();
            $tmp->div('main', '<form method="POST" name ="message" action="">
'.Language::config('message').':<br/>
<textarea name="messages"></textarea><br />
<input type="submit" name="submit" value="'.Language::config('send').'" /></form>');
        
            $tmp->div('menu', '<hr><a href="/forum/topic'.$id.'">'.img('link.png').' '.Language::config('back').'</a>');
            $tmp->footer();
            exit();
        }
    }
} else {
    header('location: /forum/topic'.$id);
}
$tmp->footer();
?>