Просмотр файла adm/addthema.php

Размер файла: 2.75Kb
<?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 {
    if ($kto == 'guest') {
        echo'Вы не можете добавлять темы <a href="forum.php">Форум</a>';
        include_once "../themes/$theme/foot.php";
        exit;
    } 
    $razd = (int)$razd;
    if ($razd == 0) {
        echo'Произошла ошибка. <a href="forum.php">Форум</a>';
        include_once "../themes/$theme/foot.php";
        exit;
    } 
    $query = "SELECT id FROM " . $pref . "forum WHERE id=" . $razd;
    $res = mysql_query($query);
    $res = implode(mysql_fetch_array($res, MYSQL_ASSOC));
    if ($res == '') {
        echo 'Произошла ошибка. <a href="forum.php">Форум</a>';
        include_once "../themes/$theme/foot.php";
        exit;
    } 
    $razd = htmlspecialchars(stripslashes($razd));
    $name_thema = htmlspecialchars(stripslashes($name_thema));
    $msg = htmlspecialchars(stripslashes($msg));
    $randtema = mt_rand(1000000, 2000000000);
    $zapros2 = 'INSERT INTO ' . $pref . 'tema (name_tema, in_razd, all_post, first_post, first_post_id, last_post, last_post_id, data_first, data_last, data_last_post, tema_nomer) VALUES ("' . $name_thema . '", ' . $razd . ', 1, "' . $login . '", ' . $usdata['id'] . ', "' . $login . '", ' . $usdata['id'] . ', ' . time() . ', ' . time() . ', ' . time() . ', ' . $randtema . ');';
    mysql_query($zapros2);
    $zapros = 'CREATE TABLE ' . $pref . 'tema_random_' . $randtema . ' (id int(50) NOT NULL auto_increment, login text NOT NULL, id_user int(50) NOT NULL default 0, data int(50) NOT NULL default 0, datatext text NOT NULL, msg text NOT NULL, ip text NOT NULL, brow text NOT NULL, PRIMARY KEY  (id)) ENGINE=MyISAM DEFAULT CHARSET=cp1251;';
    mysql_query($zapros);
    $zapros = 'INSERT INTO ' . $pref . 'tema_random_' . $randtema . ' (login , id_user , data , datatext , msg , ip , brow ) VALUES ("' . $login . '", ' . $usdata['id'] . ', ' . time() . ', "' . vrem() . ' - ' . data() . '", "' . $msg . '", "' . ip() . '", "' . brow() . '");';
    mysql_query($zapros);
    $zapros = 'SELECT id FROM ' . $pref . 'tema WHERE tema_nomer=' . $randtema;
    $aabb = mysql_fetch_array(mysql_query($zapros));
    $query = 'UPDATE ' . $pref . 'forum SET last_theme_id=' . $aabb[id] . ', last_theme="' . $name_thema . '", last_autor="' . $login . '", last_autor_id=' . (int)$usdata['id'] . ', last_time="' . data() . ' - ' . vrem() . '" WHERE id=' . $razd;
    mysql_query($query);
    header("Location: forum.php?thema=" . $aabb['id'] . "&info=themaok");
} 

?>