Вход Регистрация
Файл: admin/rekla-niz.php
Строк: 130
<?php
define
('NTOP'1);
$title 'Админка - Управление Рекламой';
require_once(
'../system/connect.php');
require_once(
'../system/core.php');
require_once(
'../system/function.php');
require_once(
'../system/head.php');
require_once (
'../system/panel.php');
reg();
level(2);

switch(
$act)
    {
        default:
        echo 
'<div class="title2">Управление рекламой(низ)</div>';
        
$rekl mysql_query("SELECT * FROM `".$prefix."rekl_niz` ORDER BY `position` ASC");
        
        if(
mysql_num_rows($rekl) > 0)
            {
                while(
$row mysql_fetch_assoc($rekl))
                    {
                        echo 
'<div class="main"><a href="http://'.$row['link'].'"><strong>'.$row['name'].'</strong></a> ['.$row['position'].'] - <a href="http://'.$set['home'].'/admin/rekla-niz.php?act=del&id='.$row['id'].'">[x]</a> ';
                        
                        echo 
'- <a href="http://'.$set['home'].'/admin/rekla-niz.php?act=edit&id='.$row['id'].'">Изменить</a><br/>';
                        echo 
'</div>';
                    }
            }
        else
            {
echo 
'<div class="nav">Рекламы нету !!! </div>';
                
            }
            
echo 
'<div class="main">';
echo 
'<a href="http://'.$set['home'].'/admin/rekla-niz.php?act=add">Добавить ссылку</a><br/>';
echo 
'</div>';        
            
        break;

    
    case 
'add':
     echo 
'<div class="title2">Добавление ссылки</div>';
        if(!isset(
$_POST['ok']))
            {

                echo 
'
                <div class="title">
                <form action="rekla-niz.php?act=add" method="post">
                Имя ссылки [max.35]:<br/>
                <input type="text" name="name" maxlength="35" value=""/><br/>
                Сcылка [max.15]:<br/>
                <input type="text" name="link" maxlength="40" value=""/><br/>
                Цвет имени [max.6]:<br/>
                <input type="text" name="color" maxlength="6" value="000000"/><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']));
                
$link htmlspecialchars(trim($_POST['link']));
                
$color htmlspecialchars(trim($_POST['color']));
                
$poz abs(intval($_POST['poz']));
                
$error '';
                if(empty(
$name) OR empty($poz) OR empty($link) OR empty($color))
                    {
                        
$error .= 'Ошибка!Не заполнены поля!<br/>';
                    }
                if(
mb_strlen($name) > 35)
                    {
                        
$error .= 'Ошибка!Поле "Имя" больше 35 символов<br/>';
                    }
                if(
mb_strlen($link) > 40)
                    {
                        
$error .= 'Ошибка!Ссылка больше 40 символов<br/>';
                    }    
                if(
mb_strlen($color) > 6)
                    {
                        
$error .= 'Ошибка!Цвет больше 6 символов<br/>';
                    }
                if(
mb_strlen($poz) > 3)
                    {
                        
$error .= 'Ошибка!Поле "Позиция" больше 3 символов<br/>';
                    }
                if(!empty(
$error))
                    {
                        echo 
'<div class="nav">';
                        echo 
$error;
                        echo 
'</div>';
                    }
                else
                    {
            
$rekl mysql_query("INSERT INTO `".$prefix."rekl_niz` SET 
              `name` = '" 
mysql_real_escape_string($name) . "',
              `link` = '" 
mysql_real_escape_string($link) . "',
              `color` = '" 
mysql_real_escape_string($color) . "',
              `position` = '" 
$poz "'");
                        if(
$rekl)
                            {
                                echo 
'<div class="main">';
                                echo 
'Ссылка успешно Добавлена<br/>';
                                echo 
'</div>';
                            }
                        else
                            {
                                echo 
'<div class="nav">';
                                echo 
'Ссылка не добавлена<br/>';
                                echo 
'</div>';
                            }
                    }
            }
        break;    
        

    
case 
'edit':
        if(
$id)
            {
                
$isset mysql_query("SELECT * FROM `".$prefix."rekl_niz` WHERE `id` = '".$id."'");
                if(
mysql_num_rows($isset) > 0)
                    {
                        
$rekl mysql_fetch_array($isset);
                        echo 
'<div class="title2">Изменение рекламы</div>';
                        if(!isset(
$_POST['ok']))
                            {
                                echo 
'
                                <div class="title">
                                <form action="rekla-niz.php?act=edit&id='
.$id.'" method="post">
                                Имя ссылки [max.35]:<br/>
                                <input type="text" name="name" maxlength="35" value="'
.$rekl['name'].'"/><br/>
                                Ссылка [max.15]:<br/>
                                <input type="text" name="link" maxlength="15" value="'
.$rekl['link'].'"/><br/>
                                Цвет имени [max.6]:<br/>
                                <input type="text" name="color" maxlength="6" value="'
.$rekl['color'].'"/><br/>                                
                                Позиция [max.100]:<br/>
                                <input type="text" name="poz" maxlength="3" value="'
.$rekl['position'].'"/><br/>
                                <input type="submit" name="ok" value="Изменить"/>
                                </form></div>'
;
                            }
                        else
                            {
                                
$name htmlspecialchars(trim($_POST['name']));
                                
$link htmlspecialchars(trim($_POST['link']));
                                
$color htmlspecialchars(trim($_POST['color']));
                                
$poz abs(intval($_POST['poz']));
                                
$error '';
                                if(empty(
$name) OR empty($poz) OR empty($link) OR empty($color))
                                    {
                                        
$error .= 'Ошибка!Не заполнены поля!<br/>';
                                    }
                                if(
mb_strlen($name) > 35)
                                    {
                                        
$error .= 'Ошибка!Поле "Имя" больше 35 символов<br/>';
                                    }
                                if(
mb_strlen($link) > 15)
                                    {
                                        
$error .= 'Ошибка!Ссылка больше 30 символов<br/>';
                                    }
                                if(
mb_strlen($color) > 6)
                                    {
                                        
$error .= 'Ошибка!Цвет больше 6 символов<br/>';
                                    }                                    
                                if(
mb_strlen($poz) > 3)
                                    {
                                        
$error .= 'Ошибка!Поле "Позиция" больше 3 символов<br/>';
                                    }
                                if(!empty(
$error))
                                    {
                                        echo 
'<div class="nav">';
                                        echo 
$error;
                                        echo 
'</div>';
                                    }
                                else
                                    {
            
$up mysql_query("UPDATE `".$prefix."rekl_niz` SET 
          `name` = '" 
mysql_real_escape_string($name) . "', 
          `link` = '" 
mysql_real_escape_string($link) . "',
          `color` = '" 
mysql_real_escape_string($color) . "',          
          `position` = '" 
$poz "' 
          WHERE `id` = '" 
.$id"'");
                                        if(
$up)
                                            {
                                                echo 
'<div class="nav">';
                                                echo 
'Ссылка успешно изменена<br/>';
                                                echo 
'</div>';
                                            }
                                        else
                                            {
                                                echo 
'<div class="nav">';
                                                echo 
'Ссылка не изменена<br/>';
                                                echo 
'</div>';
                                            }
                                    }
                            }
                    }
                else
                    {
                        echo 
'<div class="nav">';
                        echo 
'Данной ссылки нет!<br/>';
                        echo 
'</div>';
                    }
            }
        else
            {
                echo 
'<div class="nav">';
                echo 
'Не выбрана ссылка!<br/>';
                echo 
'</div>';
            }
        break;        

case 
'del':
        echo 
'<div class="title2">Управление рекламой</div>';
        
$del mysql_query("DELETE FROM `".$prefix."rekl_niz` WHERE `id` = '".$id."'");
            if(
$del)
                {
                    echo 
'<div class="main">';
                    echo 
'Ссылка Успешно удалена<br/>';
                    echo 
'</div>';
                }
            else
                {
                    echo 
'<div class="nav">';
                    echo 
'Ссылка не удалена<br/>';
                    echo 
'</div>';
                }
        break;

    }    
    
echo 
'<div class="main">';
echo 
'<a href="http://'.$set['home'].'/admin/rekl.php">К управлению Рекламой</a><br/>';
echo 
'<a href="http://'.$set['home'].'/admin/index.php">В Админку</a><br/>';
echo 
'</div>';
    
    echo
'</div></div>';
    require_once(
'../modules/foot.php');
?>
Онлайн: 2
Реклама