<?php

define('_IN_JOHNCMS', 1);
require_once ('../incfiles/core.php');
$textl = 'Fan-klub';
require_once ('../incfiles/head.php');
if (!$user_id) {
    echo functions::display_error('Faqat sayt a\'zolari uchun!');
    require_once ('../incfiles/end.php');
    exit;
}
$req = mysql_query("SELECT * FROM `fanclub` WHERE `id`='" . $id . "'");
$res = mysql_fetch_assoc($req);

/*проверка на старшего в клубе*/
if ($res['user'] != $user_id && $rights != 9) {
    echo functions::display_error('Faqat liderlar uchun!');
    require_once ('../incfiles/end.php');
    exit;
}
if (!$id) {
    echo functions::display_error('Klub yo\'q');
    require_once ('../incfiles/end.php');
    exit;
}
echo '<div class="phdr">Yangiliklar lentasi</div>';

if (isset($_POST['submit']) != 0) {

    mysql_query("INSERT INTO `news_fanclub` 
SET 
`tema`='" . (isset($_POST['news_tema']) ? $_POST['news_tema'] : 0) . "', 
`text`='" . (isset($_POST['news_text']) ? $_POST['news_text'] : 0) . "',
`time` = '$realtime', `cid`='" . $id . "' ;");

    echo '<div class="rmenu"> <a href="titul_club.php?id=' . $id .
        '">Klubga</a></div> yangilik qo\'shildi';

} else {

    echo '<form method="post" action="create_news.php?id=' . $id . '">';

    echo '<div class="gmenu">Klub yangiliklari</div>';

    echo '<div class="gmenu">Mavzu: <br/><small>(klub sarlavhasida bo\'ladi)</small><br/><textarea name="news_tema" ></textarea><br/>';

    echo 'Yangilik:<br/><textarea name="news_text" ></textarea><br/>';

    echo '<p><input type="submit" name="submit" id="button" value="Saqlash" /></p>';
    echo '</div></form>';


    echo '<div class="phdr"><a href="titul_club.php?id=' . $id . '">Klub</a></div>';
}

require_once ('../incfiles/end.php');