<?php
/*[_X3T4_N!CK_] Muellifdir Silenin Anasin Sikim*/
define('MKTOP', 1);
require_once('../system/connect.php');
require_once('../system/core.php');
require_once('../system/function.php');
level(3);
switch($act){
default:
$title = 'Kategoriya Panel';
require_once('../head.php');
$cat = mysql_query("SELECT * FROM `cat` ORDER BY `position` ASC");
if(mysql_num_rows($cat) > 0){
while($row = mysql_fetch_assoc($cat)){
$count_sites = mysql_num_rows(mysql_query("SELECT * FROM `sait` WHERE `category` = '".$row['id']."' AND `status` = '1'"));
echo '<a class="link" href="/cat.php?act=view&id='.$row['id'].'">'.$row['name'].' <span class="stat">'.$count_sites.'</span></a>
<div class="text"><a href="category.php?act=del&id='.$row['id'].'">Sil</a> | <a href="category.php?act=edit&id='.$row['id'].'">Deyiş</a></div>';
}
echo'<a class="link" href="category.php?act=add">Kategoriya Elave Et</a>';
}
else echo '<div class="text">Kategoriya Yoxdur!</div>';
break;
case 'del':
$title = 'Movcud Deyil!';
require_once('../head.php');
$proverka = mysql_query("SELECT * FROM `cat` WHERE `id` = '".$id."'");
if(mysql_num_rows($proverka) > 0) $array = mysql_fetch_array($proverka);
else echo '<div class="text">Bu kateqoriya movcud deyil</div>';
if(!isset($_POST['ok'])){
echo '<form action="category.php?act=del&id='.$id.'" method="post">
<div class="text">Bu Kategoriyani "'.$array['name'].'", Silen Zaman Butun Saytlarin Hereketi Duracaq:<br/><select name="cid">';
$cats = mysql_query("SELECT * FROM `cat` WHERE `id` != '".$id."' ORDER BY `id` ASC");
if(mysql_num_rows($cats) > 0){
while($cat = mysql_fetch_array($cats))
echo '<option value="'.$cat['id'].'">'.$cat['name'].'</option>';
}
echo '</select></div>
<div class="text"><input type="submit" name="ok" value="Sil" /></div></form>';
}
else{
$cat_id = isset($_POST['cid']) ? abs(intval($_POST['cid'])) : '';
if($cat_id == 0) echo '<div class="error">Saytin Kategoriyasin Deyiş</div>';
$test_new_cat = mysql_query("SELECT * FROM `cat` WHERE `id` = '".$cat_id."'");
if(mysql_num_rows($test_new_cat) == 0) echo '<spam class="error">Saytin Kategoriyasin Deyişmek istediyiniz Kategoriya Movcud Deil!</span>';
else{
$up = mysql_query("UPDATE `sait` SET `category` = '".$cat_id."' WHERE `category` = '".$id."'");
$del = mysql_query("DELETE FROM `cat` WHERE `id` = '".$id."'");
if($up AND $del) echo '<span class="text">Kategoriya ugurla silindi</span>';
else echo '<div class="text">Kategoriya silinmedi</div>';
}
}
echo'<a class="link" href="category.php">Kategoriya panel</a>';
break;
case 'add':
$title = 'Kategoriya elave et';
require_once('../head.php');
$pluscat = '<form action="category.php?act=add" method="post">
<div class="text">Kategoriya Adi:<br/><input type="text" name="name" maxlength="30" value=""/></div>
<div class="text">Kategroya ID Nomresi:<br/><input type="text" name="position" maxlength="200" value=""/></div>
<div class="text"><input type="submit" name="ok" value="Elave Et"/></div></form>';
if(!isset($_POST['ok'])) echo $pluscat;
else{
$name = filter($_POST['name']);
$position = (int)$_POST['position'];
$error = '';
if($name == null OR $position == null)
$error .= '<div class="error">Butun saheleri doldurun</div>';
else{
if(mb_strlen($name) > 30 OR mb_strlen($name) < 5)
$error .= '<div class="error">Kategoriya adi min:5 az ve max:30 simvoldan cox olmamalidir!</div>';
if($position > 200 )
$error .= '<div class="error">Kategoriya haqqinda Kategroya ID Nomresi max:200 simvoldan cox olmamalidir!</div>';
}
if(!empty($error)){
echo $error;
echo $pluscat;
}
else{
$create = mysql_query("INSERT INTO `cat` SET `name` = '".$name."', `position` = '".$position."'");
if($create) echo '<div class="text">Kateqoriya ugurla yaradıldı</div>';
else{
echo '<div class="text">Kateqoriya yaradılmadı</div>';
echo $pluscat;
}
}
}
echo'<a class="link" href="category.php">Kategoriya panel</a>';
break;
case 'edit':
$title = 'Kategoriya Edit';
require_once('../head.php');
if($id){
$isset = mysql_query("SELECT * FROM `cat` WHERE `id` = '".$id."'");
if(mysql_num_rows($isset) > 0){
$cat = mysql_fetch_array($isset);
$redkat = '<form action="category.php?act=edit&id='.$id.'" method="post">
<div class="text">Kategoriya Adi:<br/><input type="text" name="name" maxlength="30" value="'.$cat['name'].'"/></div>
<div class="text">Kategroya ID Nomresi:<br/><input type="text" name="position" maxlength="200" value="'.$cat['position'].'"/></div>
<div class="text"><input type="submit" name="ok" value="Deyiş"/></div></form>';
if(!isset($_POST['ok']))
echo $redkat;
else{
$name = filter($_POST['name']);
$position = (int)$_POST['position'];
$error = '';
if($name == null OR $position == null)
$error .= '<div class="error">Butun bolmeleri doldurun!</div>';
else{
if(mb_strlen($name) > 30 OR mb_strlen($name) < 5)
$error .= '<div class="error">Kategoriya adi min:5 az ve max:30 simvoldan cox olmamalidir!</div>';
if($position > 200 )
$error .= '<div class="error">Kategoriya haqqinda Kategroya ID Nomresi max:200 simvoldan cox olmamalidir!</div>';
}
if(!empty($error)){
echo $error;
echo $redkat;
}
else{
$up = mysql_query("UPDATE `cat` SET `name` = '".$name."', `position` = '".$position."' WHERE `id` = '".$id."'");
if($up)echo '<div class="text">Kateqoriya ugurla redaktə edildi</div>';
else echo '<div class="text">Kateqoriya redaktə edilmedi</div>';
}
}
}
else echo '<div class="error">Bu kateqoriya movcud deyil</div>';
}
else echo '<div class="error">Unselected Kateqoriyası</div>';
echo'<a class="link" href="category.php">Kategoriya panel</a>';
break;
}
if($user_data['level'] == 3) echo '<a class="link" href="index.php">Admin Panel</a>';
require_once('../foot.php');
?>