<?php
/*[_X3T4_N!CK_] Muellifdir Silenin Anasin Sikim*/
define('MKTOP', 1);
$title = 'Xeberler';
require_once('../system/connect.php');
require_once('../system/core.php');
require_once('../system/function.php');
level(3);
require_once('../head.php');
switch($act)
{
default:
$count = mysql_num_rows(mysql_query("SELECT * FROM `news`"));
if($count > 0)
{
$total=intval(($count-1)/$page_platforms)+1;
$page=abs(intval($_GET['page']));
if(empty($page) OR $page < 0)
{
$page = 1;
}
if($page > $total)
{
$page = $total;
}
$past=intval($count/$page_platforms);
$start=$page*$page_platforms-$page_platforms;
$news = mysql_query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT ".$start.",".$page_platforms."");
while($row = mysql_fetch_array($news))
{
$start++;
$count_comment = mysql_num_rows(mysql_query("SELECT * FROM `news_comments` WHERE `id` = '".$row['id']."'"));
echo '<div class="text">'.$start.'. Xeber Bashliqi: <b>'.$row['name'].'</b><br/> Tarix: ['.data($row['time']).']<br/> Xeber: ';
echo $row['text'].'<br/>';
echo 'Elave Etdi: '.$row['author'].'<br/>';
echo '<span class="stat" style="float:right"><a style="margin-right: 9px"><a href="news.php?act=comments&id='.$row['id'].'">Komments: </a>['.$count_comment.']</span>';
echo '<a href="news.php?act=del_news&id='.$row['id'].'">Sil</a> | <a href="news.php?act=edit_news&id='.$row['id'].'">Edit</a><br/>';
echo '</div>';
}
navigation($count,$page_platforms,$page,'news/',$total);
}
else
{
echo '<div class="text">';
echo 'Xeber elave edilmeyib!<br/>';
echo '</div>';
}
break;
case 'add':
if(!isset($_POST['ok']))
{
echo '
<div class="main">
<form action="news.php?act=add" method="post">
Xeber Basliqi (max. 50):<br/>
<input type="text" name="name" class="input" maxlength="30" /><br />
Xeber (max. 1000):<br/>
<textarea name="text" cols="38" rows="8"></textarea><br/>
<input name="ok" type="submit" value="Elave Et" />
</form>
</div>
';
}
else
{
$name = htmlspecialchars(trim($_POST['name']));
$text = htmlspecialchars(trim($_POST['text']));
$error = '';
if(empty($name) OR empty($text))
{
$error .= 'Butun bolmeleri doldurun! <br/>';
}
if(mb_strlen($name) > 50)
{
$error .= 'Xeber bashliqi max:50 simvoldan cox olmamalidir! <br/>';
}
if(mb_strlen($text) > 1000)
{
$error .= 'Xeber max:1000 simvoldan cox olmamalidir! <br/>';
}
if(!empty($error))
{
echo '<div class="text">';
echo $error;
echo '</div>';
}
else
{
$xeta = date("d-m-Y");
$insert = mysql_query("INSERT INTO `news` SET `name` = '" . mysql_real_escape_string($name) . "', `text` = '" . mysql_real_escape_string($text) . "', `time` = '" . time() . "', `xetanick` = '".$xeta."', `author` = '" . mysql_real_escape_string($user_data['login']) . "'");
if($insert)
{
echo '<div class="main">';
echo 'Xeber ugurla elave edildi! <br/>';
echo '</div>';
}
else
{
echo '<div class="topni">';
echo 'Xeber elave edilmedi! <br/>';
echo '</div>';
}
}
}
break;
case 'del_news':
if($id)
{
$del_comm = mysql_query("DELETE FROM `news_comments` WHERE `id` = '".$id."'");
$del_news = mysql_query("DELETE FROM `news` WHERE `id` = '".$id."'");
if($del_news AND $del_comm)
{
echo '<div class="text">';
echo 'Xeber ugurla silindi! <br/>';
echo '</div>';
}
else
{
echo '<div class="text">';
echo 'Xeber silinmedi! <br/>';
echo '</div>';
}
}
else
{
echo '<div class="text">';
echo 'Xeber movcud deyil!<br/>';
echo '</div>';
}
break;
case 'edit_news':
if($id)
{
$isset = mysql_query("SELECT * FROM `news` WHERE `id` = '".$id."'");
if(mysql_num_rows($isset) > 0)
{
$news = mysql_fetch_array($isset);
echo '<div class="top"><div class="clear"></div></div>';
if(!isset($_POST['ok']))
{
echo '
<div class="main">
<form action="news.php?act=edit_news&id='.$id.'" method="post">
Xeber bashliqi (max.50):<br/>
<input type="text" name="name" maxlength="30" value="'.$news['name'].'"/><br/>
Xeber (max.1000):<br/>
<textarea name="text" cols="38" rows="8">'.$news['text'].'</textarea><br/>
<input type="submit" name="ok" value="Edit"/>
</form></div>';
}
else
{
$name = htmlspecialchars(trim($_POST['name']));
$text = htmlspecialchars(trim($_POST['text']));
$error = '';
if(empty($name) OR empty($text))
{
$error .= 'Butun bolmeleri doldurun<br/>';
}
if(mb_strlen($name) > 50)
{
$error .= 'Xeber bashliqi max:50 simvoldan cox olmamalidir!<br/>';
}
if(mb_strlen($text) > 1000)
{
$error .= 'Xeber max:1000 simvoldan cox olmamalidir<br/>';
}
if(!empty($error))
{
echo '<div class="error">';
echo $error;
echo '</div>';
}
else
{
$up = mysql_query("UPDATE `news` SET
`name` = '" . mysql_real_escape_string($name) . "',
`text` = '" . mysql_real_escape_string($text) . "'
WHERE `id` = '" .$id. "'");
if($up)
{
echo '<div class="text">';
echo 'Xeber ugurla deyishdirildi!<br/>';
echo '</div>';
}
else
{
echo '<div class="text">';
echo 'Xeber deyishdirilmedi!<br/>';
echo '</div>';
}
}
}
}
else
{
echo '<div class="error">';
echo 'Bele Xeber Yoxdur!<br/>';
echo '</div>';
}
}
else
{
echo '<div class="error">';
echo 'Xeber Tapilmadi<br/>';
echo '</div>';
}
break;
case 'comments':
echo '<div class="top"><div class="title2"><font color="#fff">Kommentler</font></div><div class="clear"></div></div>';
$isset_news = mysql_num_rows(mysql_query("SELECT * FROM `news` WHERE `id` = '".$id."'"));
if($isset_news != 0)
{
$count = mysql_num_rows(mysql_query("SELECT * FROM `news_comments` WHERE `id_news` = '".$id."'"));
if($count > 0)
{
$total=intval(($count-1)/$page_nc)+1;
$page=abs(intval($_GET['page']));
if(empty($page) OR $page < 0)
{
$page = 1;
}
if($page > $total)
{
$page = $total;
}
$past=intval($count/$page_nc);
$start=$page*$page_nc-$page_nc;
$comments = mysql_query("SELECT * FROM `news_comments` WHERE `id_news` = '".$id."' ORDER BY `time` DESC LIMIT ".$start.",".$page_nc."");
while($row = mysql_fetch_array($comments))
{
$start++;
echo '<div class="navi3">'.$start.'.<strong>'.$row['name'].' ('.data($row['time']).')</strong></div>';
echo '<div class="main">';
echo $row['text'].'<br/>';
echo '---<br/>';
echo '<a href="http://'.$set['home'].'/adm_panel/news.php?act=del_comment&id='.$row['id'].'">Sil</a><br/>';
echo '</div>';
}
echo '---<br/>';
echo '<div class="main">';
echo '<a href="http://'.$set['home'].'/adm_panel/news.php?act=del_comments&id='.$id.'">Butun Kommentleri Sil</a><br/>';
echo '</div>';
navigation($count,$page_nc,$page,'http://'.$set['home'].'/adm_panel/news.php?act=comments/'.$id.'/',$total);
}
else
{
echo '<div class="text">';
echo 'Komment Yazan Olmayib!<br/>';
echo '</div>';
}
}
else
{
echo '<div class="error">';
echo 'Xeber tapilmadi!</br>';
echo '</div>';
}
break;
case 'del_comment':
echo '<div class="top"><div class="title2"><font color="#fff">Kommenti Silmek</font></div><div class="clear"></div></div>';
$del = mysql_query("DELETE FROM `news_comments` WHERE `id` = '".$id."'");
if($del)
{
echo '<div class="main">';
echo 'Komment ugurla silindi<br/>';
echo '</div>';
}
else
{
echo '<div class="error">';
echo 'Komment silinmedi<br/>';
echo '</div>';
}
break;
case 'del_comments':
echo '<div class="top"><div class="title2"><font color="#fff">Butun Kommenti Silmek</font></div><div class="clear"></div></div>';
$del = mysql_query("DELETE FROM `news_comments` WHERE `id_news` = '".$id."'");
if($del)
{
echo '<div class="main">';
echo 'Butun Kommentler Silindi!<br/>';
echo '</div>';
}
else
{
echo '<div class="error">';
echo 'Kommentler silinmedi!<br/>';
echo '</div>';
}
break;
}
echo '<div class="main">';
echo '<a href="news.php?act=add">Xeber Elave Et</a><br/>';
echo '<a href="news.php">Xeberler</a><br/>';
echo '<a href="index.php">Admin Panel</a><br/>';
echo '</div>';
require_once('../foot.php');
?>