Вход Регистрация
Файл: gigatop.tk/adm_panel/category.php
Строк: 103
<?php
define
('NTOP'1);
$title 'Админка - Управление категориями';
require_once(
'../system/connect.php');
require_once(
'../system/core.php');
require_once(
'../system/function.php');
require_once(
'../m/head.php');
reg();
level(2);
switch(
$act)
    {
        default:
        echo 
'<div class="title2">Управление категориями</div>';
        
$cat mysql_query("SELECT * FROM `".$prefix."cat` ORDER BY `position` ASC");
        if(
mysql_num_rows($cat) > 0)
            {
                while(
$row mysql_fetch_assoc($cat))
                    {
                        echo 
'<div class="topni"><img src="/img/index/icon.png" alt="*" /> <a href="http://'.$set['home'].'/m/category/view/'.$row['id'].'"><strong>'.$row['name'].'</strong></a> ['.$row['position'].']<hr>';
                        
                        echo 
'<a href="http://'.$set['home'].'/adm_panel/category.php?act=del&id='.$row['id'].'">Удалить</a> :: <a href="http://'.$set['home'].'/adm_panel/category.php?act=edit&id='.$row['id'].'">Изменить</a><br/>';
                        echo 
'</div>';
                    }
            }
        else
            {
                echo 
'Категорий в Рейтинге Нет! <br/>';
            }
        break;
        case 
'del':
        
$proverka mysql_query("SELECT * FROM `".$prefix."cat` WHERE `id` = '".$id."'");
        if(
mysql_num_rows($proverka) > 0)
            {
                
$array mysql_fetch_array($proverka);
            }
        else
            {
                echo 
'<div class="error">';
                echo 
'Данной категории нет!<br/>';
                echo 
'</div>';
            }
        if(!isset(
$_POST['ok']))
            {
                echo 
'
                <div class="main">
                <form action="category.php?act=del&id='
.$id.'" method="post">
                При удалении категории '
.$array['name'].' переместить все сайты в категорию:<br/>
                <select name="cid">'
;
                
$cats mysql_query("SELECT * FROM `".$prefix."cat` WHERE `id` != '".$id."' ORDER BY `position` ASC");
                if(
mysql_num_rows($cats) > 0)
                    {
                        while(
$cat mysql_fetch_array($cats))
                            {
                                echo 
'<option value="'.$cat['id'].'">'.$cat['name'].'</option>';
                            }
                    }
                echo 
'
                </select><br/>
                <input type="submit" name="ok" value="Удалить" />
                </form>
                </div>
                '
;
            }
            else
            {
                
$cat_id = isset($_POST['cid']) ? abs(intval($_POST['cid'])) : '';
                if(
$cat_id == 0)
                    {
                        echo 
'Не выбрана категория в которую перемещать сайты!<br/>';
                    }
                
$test_new_cat mysql_query("SELECT * FROM `".$prefix."cat` WHERE `id` = '".$cat_id."'");
                if(
mysql_num_rows($test_new_cat) == 0)
                    {
                        echo 
'Категории , в которую вы хотели переместить сайты нет!<br/>';
                    }
                    else
                    {
                        
$up mysql_query("UPDATE `".$prefix."sait` SET `category` = '".$cat_id."' WHERE `category` = '".$id."'");
                        
$del mysql_query("DELETE FROM `".$prefix."cat` WHERE `id` = '".$id."'");
                        if(
$up AND $del)
                            {
                                echo 
'<div class="topni">';
                                echo 
'Категория '.$array['name'].' удалена!<br/>';
                                echo 
'</div>';
                            }
                        else
                            {
                                echo 
'<div class="topni">';
                                echo 
'Категория '.$array['name'].' не удалена!<br/>';
                                echo 
'</div>';
                            }
                    }
            }
        break;
        case 
'add':
        echo 
'<div class="title">Добавление категории</div>';
        if(!isset(
$_POST['ok']))
            {
                echo 
'
                <div class="main">
                <form action="category.php?act=add" method="post">
                Имя категории (max.30):<br/>
                <input type="text" name="name" maxlength="30" value=""/><br/>
                Позиция (max.100):<br/>
                <input type="text" name="poz" maxlength="3" value=""/><br/>
                <input type="submit" name="ok" value="Добавить"/>
                </form></div>'
;
            }
        else
            {
                
$name htmlspecialchars(trim($_POST['name']));
                
$poz abs(intval($_POST['poz']));
                
$error '';
                if(empty(
$name) OR empty($poz))
                    {
                        
$error .= 'Ошибка!Не заполнены поля!<br/>';
                    }
                if(
mb_strlen($name) > 30)
                    {
                        
$error .= 'Ошибка!Поле "Имя категории" больше 30 символов<br/>';
                    }
                
                if(
mb_strlen($poz) > 3)
                    {
                        
$error .= 'Ошибка!Поле "Позиция" больше 3 символов<br/>';
                    }
                if(!empty(
$error))
                    {
                        echo 
'<div class="topni">';
                        echo 
$error;
                        echo 
'</div>';
                    }
                else
                    {
            
$create mysql_query("INSERT INTO `".$prefix."cat` SET 
              `name` = '" 
mysql_real_escape_string($name) . "', 
              `position` = '" 
$poz "'");
                        if(
$create)
                            {
                                echo 
'<div class="main">';
                                echo 
'Категория успешно создана<br/>';
                                echo 
'</div>';
                            }
                        else
                            {
                                echo 
'<div class="topni">';
                                echo 
'Категория не создана<br/>';
                                echo 
'</div>';
                            }
                    }
            }
        break;
        case 
'edit':
        if(
$id)
            {
                
$isset mysql_query("SELECT * FROM `".$prefix."cat` WHERE `id` = '".$id."'");
                if(
mysql_num_rows($isset) > 0)
                    {
                        
$cat mysql_fetch_array($isset);
                        echo 
'<div class="title">Изменение категории</div>';
                        if(!isset(
$_POST['ok']))
                            {
                                echo 
'
                                <div class="main">
                                <form action="category.php?act=edit&id='
.$id.'" method="post">
                                Имя категории (max.30):<br/>
                                <input type="text" name="name" maxlength="30" value="'
.$cat['name'].'"/><br/>
                                Позиция (max.100):<br/>
                                <input type="text" name="poz" maxlength="3" value="'
.$cat['position'].'"/><br/>
                                <input type="submit" name="ok" value="Добавить"/>
                                </form></div>'
;
                            }
                        else
                            {
                                
$name htmlspecialchars(trim($_POST['name']));
                                
$poz abs(intval($_POST['poz']));
                                
$error '';
                                if(empty(
$name) OR empty($poz))
                                    {
                                        
$error .= 'Ошибка!Не заполнены поля!<br/>';
                                    }
                                if(
mb_strlen($name) > 30)
                                    {
                                        
$error .= 'Ошибка!Поле "Имя категории" больше 30 символов<br/>';
                                    }
                                
                                if(
mb_strlen($poz) > 3)
                                    {
                                        
$error .= 'Ошибка!Поле "Позиция" больше 3 символов<br/>';
                                    }
                                if(!empty(
$error))
                                    {
                                        echo 
'<div class="topni">';
                                        echo 
$error;
                                        echo 
'</div>';
                                    }
                                else
                                    {
            
$up mysql_query("UPDATE `".$prefix."cat` SET 
            `name` = '" 
mysql_real_escape_string($name) . "', 
            `position` = '" 
$poz "' 
             WHERE `id` = '" 
.$id"'");
                                        if(
$up)
                                            {
                                                echo 
'<div class="topni">';
                                                echo 
'Категория успешно изменена<br/>';
                                                echo 
'</div>';
                                            }
                                        else
                                            {
                                                echo 
'<div class="topni">';
                                                echo 
'Категория не изменена<br/>';
                                                echo 
'</div>';
                                            }
                                    }
                            }
                    }
                else
                    {
                        echo 
'<div class="topni">';
                        echo 
'Данной категории нет!<br/>';
                        echo 
'</div>';
                    }
            }
        else
            {
                echo 
'<div class="topni">';
                echo 
'Не выбрана категория!<br/>';
                echo 
'</div>';
            }
        break;
    }

echo 
'<div class="main">';
echo 
'<a href="http://'.$set['home'].'/adm_panel/category.php?act=add">Добавить категорию</a><br/>';
echo 
'<a href="http://'.$set['home'].'/adm_panel/category.php">К управлению категориями</a><br/>';
echo 
'<a href="http://'.$set['home'].'/adm_panel/index.php">В Админку</a><br/>';
echo 
'</div>';

require_once(
'../m/foot.php');
?>
Онлайн: 1
Реклама