<?
include '../config.php';
include '../func.php';
head();
ban();

/////////////////////////////
if (! $id_session ) {
    
    echo 'Вы не авторизованы<br/>';
    echo '</div>';
    pod_navig();
    foot();
    exit();
}

if ( $id_session )
mysql_query("UPDATE `profile` SET `online` = 'forum' WHERE `id` = '".$id_session."'");


if ($_GET['mod'] == 'theme') {
    
   $theme = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_themes` WHERE `id` = '".num($_GET['theme'])."'"));
   
   if ($level_session >= 3 OR $level_forum_session >= 1) { 
    
   if ( empty($theme['id']) ) {
        echo link2 . 'Данной тему не существует' . div;
        pod_navig();
        foot();
        exit();
    }
    
    $result = mysql_query("DELETE FROM `forum_themes` WHERE `id` = '".$theme['id']."'");
    
    if ( $result != NULL ) header('Location: themes.php?razdel='.$theme['razdel_id'].'&pod_forum='.$theme['pod_forum'].'&mod=delete_good');
    else header('Location: themes.php?razdel='.$theme['razdel_id'].'&pod_forum='.$theme['pod_forum'].'&mod=delete_error');
    } else {
        echo link2 . 'Ошибка доступа' . div;
    }
    
    
}
    
    if ($_GET['a'] == 'post') {
    
   $post = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_msg` WHERE `id` = '".num($_GET['post'])."'"));
   $theme = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_themes` WHERE `id` = '".$post['theme']."'"));
   
   if ($post['user_id'] == $id_session OR $level_session >= 3 OR $level_forum_session >= 1) { 
    
   if ( empty($post['id']) ) {
        echo link2 . 'Данного поста не существует' . div;
        pod_navig();
        foot();
        exit();
    }
    
    $result = mysql_query("DELETE FROM `forum_msg` WHERE `id` = '".$post['id']."'");
    
    if ( $result != NULL ) header('Location: theme.php?razdel='.$theme['razdel_id'].'&pod_forum='.$theme['pod_forum'].'&theme='.$theme['id'].'&mod=delete_good');
    else header('Location: theme.php?razdel='.$theme['razdel_id'].'&pod_forum='.$theme['pod_forum'].'&theme='.$theme['id'].'&mod=delete_error');
    } else {
        echo link2 . 'Ошибка доступа' . div;
    }
    
    
}




echo '</div>';
pod_navig();
foot();
?>