Размер файла: 5.63Kb
<?
///////////////////////////
///by Kyber 2011
///Поддержка klybok.net
///ICQ 626-000-895
///Не для продажы!!!
///Потрачено 23 часа
///Реквизиты для помощи:
///R 191559143752
///Z 109983295073
///U 211922671748
///////////////////////////
include_once 'inc/fnc.php';
include_once 'inc/sys.php';
head('Новости');
switch ($_GET['act']) {
default:
$id = intval($_GET['id']);
$last = mysql_result(mysql_query("SELECT MAX(id) FROM `news`"),0);
$q = mysql_query("SELECT * FROM `news` WHERE `id` = '$id'");
if (mysql_num_rows($q) == 0) header('Location: index.php?');
$n = mysql_fetch_assoc($q);
$k = mysql_result(mysql_query("SELECT COUNT(*) FROM `n_komm` WHERE `nid` = '$n[id]'"),0);
echo R(3).'<div class="head">'.out($n['title']).'</div>'.P().'
<div class="cont">'.out($n['text'], true, true).'</div>
<div class="cont">
Создано: '.data($n['time']).'<br />';
if ($id == $last) echo '<a href="?act=komm&nid='.$id.'">Коментарии</a> ('.$k.')';
echo '</div><a href="?act=arhiv">Архив новостей</a><br />';
break;
case 'arhiv':
echo R(3).'<div class="head">Полный архив новостей</div>'.P();
$k = mysql_result(mysql_query("SELECT COUNT(*) FROM news"),0);
$k_page = ceil($k / $SET['k_p_s']);
$page = page();
$s = $page * $SET['k_p_s'] - $SET['k_p_s'];
$q = mysql_query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT $s, $SET[k_p_s]");
while ($n = mysql_fetch_assoc($q)) {
echo '<div class="cont"><a href="?id='.$n['id'].'">'.out($n['title']).'</a><br />
Создана: '.data($n['time']).'<br />
'.out(mb_substr($n['text'], 0, 30), true, true).'...</div>';
}
if ($k_page > 1) str('?act=arhiv&', $k_page, $page);
break;
case 'komm':
$id = intval($_GET['nid']);
$last = mysql_result(mysql_query("SELECT MAX(id) FROM `news`"),0);
if ($id != $last ) header('Location: index.php?');
$q = mysql_query("SELECT * FROM `news` WHERE `id` = '$id'");
if (mysql_num_rows($q) == 0) header('Location: index.php?');
$n = mysql_fetch_assoc($q);
if (isset($_GET['go']) AND mb_strlen(trim($_POST['msg'])) > 2 AND mb_strlen(trim($_POST['msg'])) > 2 )
{
if (mysql_query("INSERT INTO `n_komm` (nid ,autor, time, msg) VALUES ('$id', '$U[id]', '$time', '".in($_POST['msg'])."')"))
header('Location: ?act=komm&nid='.$id.'&ok');
else
echo 'Ошибка((<br />';
}
echo R(3).'<div class="head">'.out($n['title']).' | коментарии</div>'.P();
if (isset($_GET['ok'])) echo '<span class="err">Добавлено успешно</span><br />';
elseif (isset($_GET['okd'])) echo '<span class="err">Удалено успешно</span>';
elseif (isset($_GET['okr'])) echo '<span class="err">Изменено успешно</span>';
$k = mysql_result(mysql_query("SELECT COUNT(*) FROM `n_komm` WHERE `nid` = '$id'"),0);
if ($k > 0) {
$k_page = ceil($k / $SET['k_p_s']);
$page = page();
$s = $page * $SET['k_p_s'] - $SET['k_p_s'];
$q = mysql_query("SELECT * FROM `n_komm` WHERE `nid` = '$id' ORDER BY `time` DESC LIMIT $s, $SET[k_p_s] ");
while ($k = mysql_fetch_assoc($q)) {
$u = mysql_fetch_assoc(mysql_query("SELECT nick, pol, time, sess FROM `users` WHERE `id` = '$k[autor]'"));
echo '<div class="cont">';
if ($U['adm'] == 1) echo '<a href="?act=set&k='.$k['id'].'">';
if ($u['pol'] == 1) echo '<img src="/inc/img/man.gif" alt="" />';
elseif ($u['pol'] == 2) echo '<img src="/inc/img/woman.gif" alt="" />';
else echo '<img src="/inc/img/g.gif" alt="" />';
if ($U['adm'] == 1) echo '</a>';
echo ' <a href="anketa.php?id='.$k['autor'].'">'.$u['nick'].'</a> ';
if ($u['time'] > $time-600 AND $u['sess'] != '' )
echo '<span class="on">Он-лайн</span> ';
else
echo '<span class="off">Отсутствует</span> ';
if (isset($U) AND $U['id'] != $k['autor']) echo ' <a href="?act=komm&nid='.$id.'&uid='.$k['autor'].'">Отв</a><br />';
echo '('.data($k['time']).')<br />'.out($k['msg'], true, true).'</div>';
}
} else echo 'Пусто<br />';
if (isset($U)) {
if (is_numeric($_GET['uid'])) {
$otv1 = mysql_fetch_assoc(mysql_query("SELECT nick FROM `users` WHERE `id` = '".intval($_GET['uid'])."'"));
$otv = $otv1['nick'].', ';
}
else
$otv = '';
echo '<form action="?act=komm&nid='.$id.'&go" method="post">
Комент. (3-100):<br />
<textarea name="msg" rows="5" cols="20" wrap="off">'.$otv.'</textarea><br />
[<a href="info.php?act=smiles">Смайлы</a> / <a href="info.php?act=bbcode">BB-code</a>]<br />
<input type="submit" value="Написать" /></form>';
}
echo '<a href="?id='.$n['id'].'">Назад</a><br />';
break;
case 'set':
$kid = intval($_GET['k']);
$q = mysql_query("SELECT msg, nid FROM `n_komm` WHERE `id` = '$kid' ");
if (mysql_num_rows($q) == 0) header('Location: ?');
$k = mysql_fetch_assoc($q);
if (isset($_GET['go']) AND mysql_query("UPDATE `n_komm` SET `msg` = '".in($_POST['msg'])."' WHERE `id` = '$kid'"))
header('location: ?act=komm&nid='.$k['nid'].'&okr');
echo '<form action="?act=set&k='.$kid.'&go" method="post">
<textarea name="msg" rows="5" cols="20">'.out($k['msg']).'</textarea><br />
[<a href="?act=del&k='.$kid.'">Удалить</a>]<br />
<input type="submit" value="Изменить" /></form>
<a href="mini-chat.php">Назад</a><br />
<img src="inc/img/home.png" alt="" /> <a href="/">На главную</a>';
break;
case 'del':
if (mysql_query("DELETE FROM `n_komm` WHERE `id` = '".intval($_GET['k'])."' ")) header('Location: ?');
else echo'Ошибка<br />';
break;
}
echo '<img src="inc/img/home.png" alt="" /> <a href="/">На главную</a>';
foot();
?>