File size: 2.91Kb
<?php
include_once("../incs/conf.php");
include_once("../incs/fmysql.php");
include_once("../incs/fnc2.php");
include_once("../incs/head2.php");
head("Админ панель - Новости",$meuser,$auth);
$a = fil($_GET['a']);
$p = fil($_GET['p']);
if($on==1 && $user[level]>=9){
echo "<div class='rowup'>";
include_once("../incs/title2.php");
echo "<a href=\"index.php\">Админ панель</a> - Новости</div>";
switch($a){
case 'dob':
$y=1;
$vop=mysql_query("SELECT * FROM `news` WHERE `id` != '0' ORDER BY id DESC LIMIT $y");
while ($p_m = mysql_fetch_array($vop))
{
$pov_msg = $p_m[msg];
}
if($pov_msg!=filtr($_POST['msg'])){
if($_POST['name']!="" && $_POST['msg']!=""){
$name=$_POST['name'];
$msg=$_POST['msg'];
$name=filtr($name);
$msg=filtr($msg);
$msg=bbcode(smiles($msg));
$time=time();
mysql_query("INSERT INTO `news` (`name`, `msg`, `data`, `time`, `sozdal`) values('$name', '$msg', '".date('Y.m.d/H:i')."', '$time', '$user[nick]')");
echo "Новость успешно добавлена!<br>";
}else{
echo "Вы не заполнили поле!<br>";
}
}else{
echo "Новость повторяетса!<br>";
}
break;
case 'del':
mysql_query("DELETE FROM `news` WHERE `id` = '$p'");
$news_del_post=mysql_query("SELECT * FROM `news_kom` WHERE `id_news` = '$p'");
while ($news_delete_post = mysql_fetch_array($news_del_post))
{
mysql_query("DELETE FROM `news_kom` WHERE `id_news` = '$p'");
}
break;
}
echo "<form method=\"post\" action=\"?a=dob\">";
echo "Заголовок новости:<br />\n<input type='text' name='name' maxlength='32' /><br />\n";
echo 'Текст новости:<br/><textarea name="msg" maxlength="1024"></textarea><br>';
echo '<input value="Добавить" type="submit"/></form>';
$k_post = mysql_num_rows(mysql_query("SELECT id FROM `news`"));
if ($k_post==0)
{
echo "Нет новостей<br/>\n";
}
if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($k_post/$end);
if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages){$page=1;}
}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}
$news_z=mysql_query("SELECT * FROM `news` WHERE `id` != '0' ORDER BY id DESC LIMIT $start,$end");
while ($news = mysql_fetch_array($news_z))
{
echo "<div class='rowap'>$news[name] ($news[data])<br>";
echo "$news[msg]<br>";
$news_user=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `nick` = '$news[sozdal]'"));
echo "Добавил: <b><a href=\"my.php?id=$news_user[id]\">$news[sozdal]</a></b>";
echo "<br>[<a href=\"news.php?a=del&p=$news[id]\">Удалить</a>]<br></div>";
}
if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?page=$i'>$i</a></span>";
}}}
}else{
echo "<div class='rowup'>";
include_once("../incs/title2.php");
echo "Админ панель - Новости</div>";
echo "Извени, но тебе здесь находитса нельзя!<br>";
}
include_once("../incs/down2.php");
?>