View file adm/delthema.php

File size: 1.91Kb
<?php
include_once "../config.php";
include_once "../inc/inc.php";
include_once "../inc/func.php";
include_once "../inc/user.php";

if ($dostup != '1') {
    echo "ПАШШШШШШШОЛНАХУЙ";
    include_once "../themes/$theme/foot.php";
    exit;
} else {
    $thema = (int)$thema;

    $query = 'DELETE FROM ' . $pref . 'tema WHERE id=' . $thema; //удаляем из таблицы с темами, тему
    $result = mysql_query($query);

    $query = "SELECT * FROM " . $pref . "tema WHERE id=" . $thema;
    $result = mysql_fetch_assoc(mysql_query($query));
    $zapros = 'DROP TABLE ' . $pref . 'tema_random_' . $result['tema_nomer'];
    mysql_query($zapros);

    $query = "SELECT * FROM " . $pref . "forum WHERE last_theme_id=" . $thema; //
    $res = mysql_fetch_array(mysql_query($query)); //
    // echo $res['last_theme_id'];                                             //
    $ggg = (int)$res['last_theme_id']; //
    if ($ggg == $thema) { // Если номер темы содержится в таблице форум, обновляем эту запись
        
        $query = "SELECT * FROM " . $pref . "tema ORDER BY data_last_post"; //
        $result = mysql_query($query); //
        while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $max = $line['data_last_post']; //
        } //
        // $max++;
        $query = "SELECT * FROM " . $pref . "tema WHERE data_last_post=" . $max;
        $res2 = mysql_fetch_array(mysql_query($query));

        $query = 'UPDATE ' . $pref . 'forum SET last_theme_id = ' . $res2['id'] . ', last_theme = "' . $res2['name_tema'] . '", last_autor = "' . $res2['last_post'] . '", last_autor_id = ' . $res2['last_post_id'] . ', last_time = "' . date("d-m-y - H:i:s", $res2['data_last_post']) . '" WHERE last_theme_id=' . $thema;
        $result25 = mysql_query($query);
    } 
    header("Location: forum.php");
} 

?>