Файл: element_profile_ban_list.php
Строк: 311
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
    if (!$id) {
        $title = 'Персонаж не найден';
        $error1 = '<span class="small">Персонаж не найден</span>';
        require_once 'element_error_page.php';
        exit;
    }
    if ($id != $user['lost_id'] AND $user['lost_privilege'] == 0) {
        $title = 'Доступ закрыт';
        $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
        require_once 'element_error_page.php';
        exit;
    }
    
    $profile = (($id == $user['lost_id']) ? $user : cache_user($id));
    
    if (!$profile) {
        $title = 'Персонаж не найден';
        $error1 = '<span class="small">Персонаж не найден</span>';
        require_once 'element_error_page.php';
        exit;
    }
    
    $topic = (isset($_GET['topic']) AND is_numeric($_GET['topic'])) ? (int)$_GET['topic'] : false;
    $comment = (isset($_GET['comment']) AND is_numeric($_GET['comment'])) ? (int)$_GET['comment'] : false;
    $to = (isset($_GET['to'])) ? addslashes(htmlspecialchars($_GET['to'])) : false;
    
    function ReturnBanTime($ban_time) {
        if ($ban_time == 0) return false;
        else if ($ban_time < 3600) return ($ban_time / 60).' мин.';
        else if ($ban_time < 86400) return ($ban_time / 3600).' ч.';
        else return ($ban_time / 86400).' д.';
    }
    
    function ReturnBanTimeOst($time) {
        $ttt = $time - time();
        
        if ($ttt < 86400) {
            return date("Hч. iм. sс.", mktime(0, 0, $ttt));
        } else {
            $qqq = (int)($ttt / 86400);
            $ttt1 = $ttt - ($qqq * 86400);
            $qqq = $qqq.'д.';
            return date("$qqq Hч. iм. sс.", mktime(0, 0, $ttt1));
        }
    
    }
    
    if ($topic) {
        
        if ($user['lost_privilege'] == 0) {
            $title = 'Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        
        $topics = mysql_fetch_array(mysql_query("SELECT `lost_text`,`lost_user`,`lost_subforum` FROM `element_forum_topic_2` WHERE `lost_id` = '$topic' LIMIT 1"));
        
        if (!$topics) {
            $title = 'Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        
        $subforum = mysql_fetch_array(mysql_query("SELECT * FROM `element_forum_list_2` WHERE `lost_id` = '$topics[lost_subforum]' LIMIT 1"));
    
        if (!$subforum) {
            $title = 'Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
    
        if ($id != $topics['lost_user']) {
            $title = 'Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
    
        if ($subforum['lost_town'] > 0 AND $user['lost_privilege'] < 2) {
            $title = 'Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        
        $moderation = explode(" ", $subforum['lost_moderation']);     // Список модераторов
        $my_moder = (in_array($user['lost_id'], $moderation)) ? true : false;
        
        if (!$my_moder AND $user['lost_privilege'] < 2) {
            $title = 'Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        $text = $topics['lost_text'];
        $topic_id = $topic;
    } else if ($comment) {
        
        if ($user['lost_privilege'] == 0) {
            $title = '1Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        
        $comments = mysql_fetch_array(mysql_query("SELECT `lost_topic`, `lost_user`, `lost_text` FROM `element_forum_comment_2` WHERE `lost_id` = '$comment' LIMIT 1"));
    
        if (!$comments) {
            $title = '2Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        
        $topics = mysql_fetch_array(mysql_query("SELECT `lost_text`,`lost_subforum` FROM `element_forum_topic_2` WHERE `lost_id` = '$comments[lost_topic]' LIMIT 1"));
        
        if (!$topics) {
            $title = '3Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        
        $subforum = mysql_fetch_array(mysql_query("SELECT * FROM `element_forum_list_2` WHERE `lost_id` = '$topics[lost_subforum]' LIMIT 1"));
    
        if (!$subforum) {
            $title = '4Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
    
        if ($id != $comments['lost_user']) {
            $title = '5Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        
        if ($subforum['lost_town'] > 0 AND $user['lost_privilege'] < 2) {
            $title = '6Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        
        $moderation = explode(" ", $subforum['lost_moderation']);     // Список модераторов
        $my_moder = (in_array($user['lost_id'], $moderation)) ? true : false;
        
        if (!$my_moder AND $user['lost_privilege'] < 2) {
            $title = '7Доступ закрыт';
            $error1 = '<span class="small">Администрация игры ограничила доступ к этой странице</span>';
            require_once 'element_error_page.php';
            exit;
        }
        $text = $comments['lost_text'];
        $comment_id = $comment;
    } else if ($to) {
        $text = $to;
    } else {
        $text = '';
        $comment_id = 0;
        $topic_id = 0;
    }
    
    if ($go == 'cancel' AND $user['lost_privilege'] > 0) {
        $ban = (isset($_GET['ban']) AND is_numeric($_GET['ban'])) ? (int)$_GET['ban'] : false;
        if ($ban) {
            $query1 = mysql_fetch_array(mysql_query("SELECT * FROM `element_ban_list` WHERE `lost_id` = '$ban' LIMIT 1"));
            if ($query1) {
                if ($query1['lost_time_ban'] > time()) {
                    if ($user['lost_privilege'] > 1 OR $query1['lost_moderator'] == $user['lost_id']) {
                        mysql_query("UPDATE `element_ban_list` SET `lost_time_ban` = '".(time() - 5)."' WHERE `lost_id` = '$ban' LIMIT 1");
                        header('Location: /ban/list?id='.$id);
                        exit;
                    }
                }
            }
        }
    }
    
    $count_ban = mysql_result(mysql_query("SELECT COUNT(`lost_id`) FROM `element_ban_list` WHERE `lost_user` = '$id'"), 0);
    $title = 'История банов "'.$profile['lost_login'].'"';  
    require_once './element_include/element_head.php';
    require_once './element_include/element_header_user_true.php';
    
    if ($go == 'bans' AND $user['lost_privilege'] > 0) {
        $prichina = (isset($_POST['prichina'])) ? addslashes(htmlspecialchars($_POST['prichina'])) : false;
        $ban_time = $_POST['ban_time'];
    
        if (!$prichina) $error = 'Введите причину бана';
        if ($ban_time < 0 OR $ban_time > (86400 * 365)) $error = 'Неверное время бана';
        
        if (!isset($error)) {
            $text = addslashes(htmlspecialchars(trim($text)));
            mysql_query("INSERT INTO `element_ban_list` SET `lost_user` = '$id',
                                                            `lost_text` = '$text',
                                                            `lost_prichina` = '$prichina',
                                                            `lost_moderator` = '$user[lost_id]',
                                                            `lost_time_ban` = '".($ban_time + time())."',
                                                            `lost_type_time` = '$ban_time',
                                                            `lost_time` = '".time()."',
                                                            `lost_cancel` = '0'");
            header('Location: /ban/list?id='.$id.(($topic) ? '&topic='.$topic : (($comment) ? '&comment='.$comment : '')));
            exit;
        
        } else echo '<div class="nfl p5 mb5 cntr small error1 mlra">'.$error.'</div>';
    }
    
    echo '<div class="nfl p5 mb5 small mlra">';    
    echo ($user['lost_privilege'] > 0) ? '<div class="p5 cntr">
            <form method="post" action="/ban/list?id='.$id.(($topic) ? '&topic='.$topic : (($comment) ? '&comment='.$comment : (($to) ? '&to='.$to : ''))).'&go=bans">
                
                <div class="mb5 ccc">
                    <span class="small white">Выберите время молчания:</span><br/>
                    <select class="fdark mb5 w96" name="ban_time">
                        <option value="0" selected>Предупреждение</option>
                        <option value="'.(60 * 15).'">15 минут </option>
                        <option value="'.(60 * 60).'">1 час</option>
                        <option value="'.(60 * (60 * 6)).'">6 часов</option>
                        <option value="'.(60 * (60 * 12)).'">12 часов</option>
                        <option value="'.(86400 * 1).'">1 день</option>
                        <option value="'.(86400 * 3).'">3 дня</option>
                        <option value="'.(86400 * 7).'">7 дней</option>
                        <option value="'.(86400 * 15).'">15 дней</option>
                        <option value="'.(86400 * 30).'">30 дней</option>
                        <option value="'.(86400 * 365).'">365 дней</option>
                    </select>
                </div>
                
                <span class="small white">Причина бана:</span><br/>
                <textarea class="w96 mb5 fdark" rows="2" name="prichina">'.(($prichina) ? $prichina : '').'</textarea><br/>
                <span class="button w50 mt5"><input type="submit" class="ttl" name="submit" value="Влепить"/></span>
            </form>
          </div>' : '';
    
    
    if ($count_ban > 0) {
        require_once './element_function/element_function_pagination.php';
        $page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
        $pagination = pagination(4, $page, $count_ban);
    
        $query = mysql_query("SELECT * FROM `element_ban_list` WHERE `lost_user` = '$id' ORDER BY `lost_time` DESC LIMIT $pagination[start], $pagination[num]");
        while($myrrow = mysql_fetch_array($query)) {
            $odd = ($myrrow['lost_time_ban'] > time()) ? ' odd' : '';
            $cache_moder = cache_user($myrrow['lost_moderator']);
            
            $on_off_avtor = (!empty($online[$id])) ? 'online' : 'offline';
            $on_off_moder = (!empty($online[$myrrow['lost_moderator']])) ? 'online' : 'offline';    
                
            $type_ban = ReturnBanTime($myrrow['lost_type_time']);    
                
            echo '<div class="ml5 mr5">
                    <div class="bl p5 small white block'.$odd.'">
                        <div class="ccc">'.ikonka_user($profile['lost_race'], $on_off_avtor).' <a class="yellow1" href="">'.$profile['lost_login'].'</a>, написал:</div>
                        <div class="mt5 while">'.$myrrow['lost_text'].'</div>
                        <div class="hr mt5 mb5"></div>
                        <div class="mt5 ccc"><img src="/images/icons/1.gif"> Выдал: '.ikonka_user($cache_moder['lost_race'], $on_off_moder).' <a class="yellow1" href="">'.$cache_moder['lost_login'].'</a>, '.rdate("d M H:i", $myrrow['lost_time']).'</div>
                        <div class="mt5 ccc"><img src="/images/icons/1.gif"> Причина: '.$myrrow['lost_prichina'].'</div>
                        <div class="mt5"><img src="/images/icons/1.gif"> '.((!$type_ban) ? '<font color=yellow>Предупреждение</font>' : '<span class="error1">Молчание на '.$type_ban.'</span>').''.(($myrrow['lost_type_time'] > 0 AND $myrrow['lost_time_ban'] < time()) ? ', <span class="ccc">[Истек]</span>' : '').'</div>
                        '.(($myrrow['lost_time_ban'] > time()) ? '<div class="mt5"><img src="/images/icons/1.gif"> <span class="admin">[Осталось: '.ReturnBanTimeOst($myrrow['lost_time_ban']).'] '.(($user['lost_privilege'] > 1 OR $user['lost_privilege'] == 1 AND $myrrow['lost_moderator'] == $user['lost_id']) ? '<a href="/ban/list?id='.$id.'&ban='.$myrrow['lost_id'].'&go=cancel">[Отменить]</a>' : '').'</span></div>' : '').'
                    </div>
                </div>';
        }
        
        echo '<div>'.pagination_echo($pagination['page'],$pagination['total'], '/ban/list?id='.$id.'&page=').'</div>';    
    
    } else echo '<div class="cntr yellow1 bold">Вы кристальной души человек, таким и оставайтесь :-)</div>';
    
    echo '</div>';
    require_once './element_include/element_foot_user_true.php';
?>