Вход Регистрация
Файл: v-klub.tk/adm_panel/reklama.php
Строк: 120
<?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>';
        
$rekl mysql_query("SELECT * FROM `".$prefix."rekl` ORDER BY `position` ASC");
//////////////// Вывод         
        
if(mysql_num_rows($rekl) > 0)
            {
                while(
$row mysql_fetch_assoc($rekl))
                    {
                        echo 
'<div class="topni"><a href="http://'.$row['link'].'"><strong>'.$row['name'].'</strong></a> ['.$row['position'].'] - <a href="http://'.$set['home'].'/adm_panel/reklama.php?act=del&id='.$row['id'].'">[x]</a> <hr>';
                        
                        echo 
'- <a href="http://'.$set['home'].'/adm_panel/reklama.php?act=edit&id='.$row['id'].'">Изменить</a><br/>';
                        echo 
'</div>';
                    }
            }
        else
            {

            echo 
'<div class="topni">Ссылок нету !!! </div>';
                
            }
            
echo 
'<div class="main">';
echo 
'<a href="http://'.$set['home'].'/adm_panel/reklama.php?act=add">Добавить ссылку</a><br/>';
echo 
'</div>';        
            
        break;
        
////////////////////////    Добавление рекламмы 
    
    
case 'add':
     echo 
'<div class="title">Добавление ссылки</div>';
        if(!isset(
$_POST['ok']))
            {

                echo 
'
                <div class="main">
                <form action="reklama.php?act=add" method="post">
                Имя ссылки [max.35]:<br/>
                <input type="text" name="name" maxlength="35" value=""/><br/>
                Сылка [max.15]:<br/>
                <input type="text" name="link" maxlength="15" 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) > 15)
                    {
                        
$error .= 'Ошибка!Ссылка больше 15 символов<br/>';
                    }    
                if(
mb_strlen($color) > 6)
                    {
                        
$error .= 'Ошибка!Цвет больше 6 символов<br/>';
                    }
                if(
mb_strlen($poz) > 3)
                    {
                        
$error .= 'Ошибка!Поле "Позиция" больше 3 символов<br/>';
                    }
                if(!empty(
$error))
                    {
                        echo 
'<div class="topni">';
                        echo 
$error;
                        echo 
'</div>';
                    }
                else
                    {
            
$rekl mysql_query("INSERT INTO `".$prefix."rekl` 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="topni">';
                                echo 
'Ссылка не добавлена<br/>';
                                echo 
'</div>';
                            }
                    }
            }
        break;    
        
/////////////////// Изменерие Рекламы    
    
case 'edit':
        if(
$id)
            {
                
$isset mysql_query("SELECT * FROM `".$prefix."rekl` WHERE `id` = '".$id."'");
                if(
mysql_num_rows($isset) > 0)
                    {
                        
$rekl mysql_fetch_array($isset);
                        echo 
'<div class="title">Изменение рекламы</div>';
                        if(!isset(
$_POST['ok']))
                            {
                                echo 
'
                                <div class="main">
                                <form action="reklama.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="topni">';
                                        echo 
$error;
                                        echo 
'</div>';
                                    }
                                else
                                    {
            
$up mysql_query("UPDATE `".$prefix."rekl` 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="main">';
                                                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;        
///////////// Удаление реаламмы

case 'del':
        echo 
'<div class="title2">Управление рекламой</div>';
        
$del mysql_query("DELETE FROM `".$prefix."rekl` WHERE `id` = '".$id."'");
            if(
$del)
                {
                    echo 
'<div class="main">';
                    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/reklama.php">К управлению Рекламой</a><br/>';
echo 
'<a href="http://'.$set['home'].'/adm_panel/index.php">В Админку</a><br/>';
echo 
'</div>';
    
    
    require_once(
'../m/foot.php');
?>
Онлайн: 3
Реклама