Файл: gazeta/cat.php
Строк: 78
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
include_once '../sys/inc/thead.php';
$set['title']='Статьи';
title();
$d = $_GET['d'];
aut();
//////// Создаем кейсы
$id=intval($_GET['id']);
if (!isset($_GET['d'])) {
header("Location: cat.php?id=$id&d".SID); }
switch ($d) {
case 'art':
{
$q=mysql_query("SELECT * FROM `gazeta_cat` WHERE `id`='".$id."' ");
while ($res = mysql_fetch_assoc($q)) {
echo '<div class="nav1"><a href="/gazeta">Все категории</a>
<a href="cat.php?id='.$id.'">| '.$res['name'].'</a><font color="black"> | Добавить статью</font></div>';
}
echo "<div class="p_t"><form action="cat.php?id=$id&d=add" method="post" name="message">Название статьи:<br/>
<input type="text" name="name"/><br>";
if (isset($set['web']) && is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php')){
echo "Статья:";
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';}
else
echo "Статья$tPanel<textarea name="msg"/> </textarea><br>";
echo"
<input type="checkbox" name="foto"> Добавить фото<br/>
<input type="submit" value="Добавить"/></form></div>";
}
break;
//////////////////////////
case 'add':
if (isset($_POST['msg']))
$msg=my_esc($_POST['msg']);
$name=my_esc($_POST['name']);
if($name != NULL and $msg != NULL){
if(!isset($_POST['foto'])){
mysql_query("INSERT INTO `gazeta` (`name`,`article`, `time`,`id_cat`,`id_user`) values('".$name."', '".$msg."', '".$time."', '".$id."', '".$user['id']."')");
$arts = mysql_fetch_assoc(mysql_query("SELECT * FROM `gazeta` order by `time` DESC "));
header("Location: article.php?id=$arts[id]".SID);
} else {
mysql_query("INSERT INTO `gazeta` (`name`,`article`, `time`,`id_cat`,`id_user`) values('".$name."', '".$msg."', '".$time."', '".$id."', '".$user['id']."')");
$arts = mysql_fetch_assoc(mysql_query("SELECT * FROM `gazeta` order by `time` DESC "));
header("Location: article.php?id=$arts[id]&d=img".SID); }
}
else
{
echo '<div class="err">ОШИБКА!<br />Одно из полей заполнено неправильно!<br /><a href="cat.php?id='.$id.'&d=art">Назад</a></div>';
}
break;
default:
$q=mysql_query("SELECT * FROM `gazeta_cat` WHERE `id`='".$id."' ");
while ($res = mysql_fetch_assoc($q)) {
echo '<div class="rekl"><a href="/gazeta">Все категории</a> <font color="black">| '.$res['name'].'</font></div>';
}
if (isset($user)) {echo '<div class="nav1"><img src="img/new.png">
<a href="cat.php?id='.$_GET['id'].'&d=art">Добавить статью</a></div>';}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gazeta` WHERE `id_cat`='".$id."' "), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
echo '<div class="err">Нет статей</div>';
}
$q=mysql_query("SELECT * FROM `gazeta` WHERE `id_cat`='".$id."' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($res = mysql_fetch_assoc($q)) {
if(is_file(H.'gazeta/images/'.$res['id'].'.png'))
{ $ft = '<img src="images/'.$res['id'].'.png" width="50" height="50" >'; }
else {
$ft = false;
}
echo '<div class="nav1">';
echo ''.$ft.'<a href="article.php?id='.$res['id'].'"> '.$res['name'].'</a> '.vremja($res['time']).'<br/>';
echo '</div>';
}
if ($k_page>1)str('?id='.$id.'&',$k_page,$page); // Вывод страниц
}
err();
include_once '../sys/inc/tfoot.php';
?>