Вход Регистрация
Файл: adm_panel/platforms.php
Строк: 182
<?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>';

                
$count mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait`"));
                if(
$count 0)
                    {
                        
$total=intval(($count-1)/$page_sait)+1
                        
$page=abs(intval($_GET['page'])); 
                        if(empty(
$page) OR $page 0)
                            {
                                
$page 1
                            }
                        if(
$page $total)
                            {
                                
$page $total
                            }
                        
$past=intval($count/$page_sait);  
                        
$start=$page*$page_sait-$page_sait
                        
$saits mysql_query("SELECT * FROM `".$prefix."sait` ORDER BY `hosts` DESC LIMIT ".$start.",".$page_sait."");
                        while(
$row mysql_fetch_array($saits)) 
                            {
                                
$start++;
                                
$ban = ($row['ban'] == 0) ? '<a href = "http://'.$set['home'].'/adm_panel/platforms.php?act=ban&id='.$row['id'].'">Блокировать</a>' '<a href = "http://'.$set['home'].'/adm_panel/platforms.php?act=ban&id='.$row['id'].'">Разблокировать</a>';
                                echo 
'<div class="title2">'.$start.'.<strong>'.$row['name'].'</strong> [Хостов: <strong>'.$row['hosts'].'</strong> | Хитов: <strong>'.$row['hits'].'</strong>] <a href="http://'.$set['home'].'/stats/'.$row['id'].'"><strong> [Статистика]</strong></a><br/></div>';
                                echo 
'<div class="main">';
                                if(
mb_strlen($row['about']) > 50)
                                    {
                                        
$text substr($row['about'],0,50);
                                        echo 
''.$text.'...<br/>'
                                    }
                                else
                                    {
                                        echo 
''.$row['about'].'<br/>'
                                    }
                                echo 
'<a href="http://'.$set['home'].'/adm_panel/platforms.php?act=edit_sait&id='.$row['id'].'"><strong> Изменить</strong></a> | <a href="http://'.$set['home'].'/adm_panel/platforms.php?act=del_sait&id='.$row['id'].'"><strong> Удалить сайт</strong></a> | '.$ban.'<br/>';
                                echo 
'</div>';
                            }
                        
navigation($count,$page_sait,$page,'http://'.$set['home'].'/adm_panel/platforms.php/',$total);
                    }
                else
                    {
                        echo 
'<div class="main">';
                        echo 
'Площадок нет! <br/>';
                        echo 
'</div>';
                    }
            
        break;
        case 
'edit_sait':
        echo 
'<div class="title2">Изменение площадки</div>';
        
$platform mysql_query("SELECT * FROM `".$prefix."sait` WHERE `id` = '".$id."' LIMIT 1");
        
$platform_count mysql_num_rows($platform);
        
$user_platform mysql_fetch_array($platform);
        
$image_big mysql_query("SELECT * FROM `".$prefix."images` WHERE `type` = 'big'");
        
$image_small mysql_query("SELECT * FROM `".$prefix."images` WHERE `type` = 'small'");
        if(
$platform_count 0)
            {
                if(!isset(
$_POST['ok']))
                    {
                        echo 
'<div class="main">';
                        echo 
'
                        <form action="platforms.php?act=edit_sait&id='
.$id.'" method="post">
                        Название сайта(max. 35):<br/>
                        <input type="text"  class="input" name="name" maxlength="35" value="'
.$user_platform['name'].'" /><br/>
                        URL сайта(без http:// и т.п)(max. 35):<br/>
                        <input type="text"  class="input" name="url" maxlength="35" value="'
.$user_platform['url'].'" /><br/>
                        Описание сайта(max. 100):<br/>
                        <textarea name="about" cols="38" rows="8">'
.$user_platform['about'].'</textarea><br/>
                        Категория:<br/>
                        <select name="cat">
                        '
;
                        
$cats mysql_query("SELECT * FROM `".$prefix."cat` ORDER BY `position` ASC");
                        if(
mysql_num_rows($cats) > 0)
                            {
                                while(
$cat mysql_fetch_assoc($cats))
                                    {
                                        
$selected = ($user_platform['category'] == $cat['id']) ? ' selected="selected"' '';
                                        echo 
'<option value="'.$cat['id'].'"'.$selected.'>'.$cat['name'].'</option>';
                                    }
                            }
                        echo 
'</select><br/><br/>';
                        echo 
'Выберите счётчик:<br/>';
                
                echo 
'<small><strong>Для главной страницы сайта:</strong></small><br/>';
                        while(
$count_big mysql_fetch_array($image_big))
                            {
                                
$checked = ($user_platform['imagebig'] == $count_big['name']) ? ' checked="checked"' '';
                                echo 
'<input type="radio" name="imagebig" value="'.$count_big['name'].'"'.$checked.'>';
                                echo 
'<img src="http://'.$set['home'].'/images/'.$count_big['name'].'.gif" alt=""><br/>';
                            }
                        echo 
'<hr/>';
                echo 
'<small><strong>Для остальных страниц сайта <font size=2>*</font></strong></small><br/>';
                        while(
$count_small mysql_fetch_array($image_small))
                            {
                                
$checked = ($user_platform['imagesm'] == $count_small['name']) ? ' checked="checked"' '';
                                echo 
'<input type="radio" name="imagesm" value="'.$count_small['name'].'"'.$checked.'>';
                                echo 
'<img src="http://'.$set['home'].'/images/'.$count_small['name'].'.gif" alt=""><br/>';
                            }
                        echo 
'<font size=2>*</font></strong> - Для остальных страниц сайта, установка счётчика по вашему желанию.<br/><input name="ok" type="submit" value="Изменить" />
                        </form>
                        </div>'
;
                    }
                else
                    {
                        
$name htmlspecialchars(trim($_POST['name']));
                        
$url htmlspecialchars(trim($_POST['url']));
                        
$about htmlspecialchars(trim($_POST['about']));
                        
$cat intval($_POST['cat']);
                        
$image htmlspecialchars(trim($_POST['image']));
                        
$error '';
                        if(empty(
$cat) OR empty($image) OR empty($name) OR empty($url) OR empty($about))
                            {
                                
$error .= 'Ошибка! Не заполнены поля!<br/>';
                            }
                        if(
mb_strlen($name) > 35)
                            {
                                
$error .= 'Ошибка! Поле "Название сайта" содержит больше 35 символов! <br/>';
                            }
                        if(
mb_strlen($url) > 35)
                            {
                                
$error .= 'Ошибка! Поле "URL сайта" содержит больше 35 символов! <br/>';
                            }
                        if(
mb_strlen($about) > 100)
                            {
                                
$error .= 'Ошибка! Поле "Описание сайта" содержит больше 35 символов! <br/>';
                            }
                        if(!empty(
$error))
                            {
                                echo 
'<div class="error">';
                                echo 
$error;
                                echo 
'</div>';
                            }
                        else
                            {
                    
$edit mysql_query("UPDATE `".$prefix."sait` SET 
                     `category` = '"
.$cat."',
                     `image` = '" 
mysql_real_escape_string($image) . "',
                     `name` = '" 
mysql_real_escape_string($name) . "',
                     `about` = '" 
mysql_real_escape_string($about) . "',
                     `url` = '" 
mysql_real_escape_string($url) . "' 
                     WHERE `id` = '" 
.$id"'");
                                if(
$edit)
                                    {
                                        echo 
'<div class="main">';
                                        echo 
'Сайт успешно отредактирован!<br/>';
                                        echo 
'</div>';
                                    }
                                else
                                    {
                                        echo 
'<div class="error">';
                                        echo 
'Сайт не отредактирован , попробуйте снова!<br/>';
                                        echo 
'</div>';
                                    }
                            }
                    }
            }
        else
            {
                echo 
'<div class="error">';
                echo 
'Данного сайта не существует!<br/>';
                echo 
'</div>';
            }
        break;
        case 
'del_sait':
        
$sait_isset mysql_query("SELECT * FROM `".$prefix."sait` WHERE `id` = '".$id."' LIMIT 1");
        
$sait_isset_c mysql_num_rows($sait_isset);
        if(
$sait_isset_c 0)
            {
                
$sait mysql_fetch_array($sait_isset );
                echo 
'<div class="title2">Удаление сайта <strong>'.$sait['name'].'</strong></div>';
                if(!isset(
$_GET['ok']))
                    {
                        echo 
'<div class="main">';
                        echo 
'Вы действительно хотите удалить сайт <strong>'.$sait['name'].'</strong> из Топ-Рейтинга ?<br/>';
                        echo 
'<a href="http://'.$set['home'].'/adm_panel/platforms.php?act=del_sait&id='.$id.'&ok">Да</a> | <a href="http://'.$set['home'].'/adm_panel/index.php">Нет</a><br/>';
                        echo 
'</div>';
                    }
                else
                    {
                        
$del_hosts mysql_query("DELETE FROM `".$prefix."hosts` WHERE `id_sait` = '".$id."'");
                        
$del_hits mysql_query("DELETE FROM `".$prefix."hits` WHERE `id_sait` = '".$id."'");
                        
$del_online mysql_query("DELETE FROM `".$prefix."sait_online` WHERE `id_sait` = '".$id."'");
                        
$del_reputation mysql_query("DELETE FROM `".$prefix."reputation` WHERE `id_sait` = '".$id."'");
                        
$del_sait_comments mysql_query("DELETE FROM `".$prefix."sait_comments` WHERE `id_sait` = '".$id."'");
                        
$del_platform mysql_query("DELETE FROM `".$prefix."sait` WHERE `id` = '".$id."'");
                        if(
$del_hosts AND $del_hits AND $del_online AND $del_platform AND $del_reputation AND $del_sait_comments)
                            {
                                echo 
'<div class="main">';
                                echo 
'Сайт успешно удален!<br/>';
                                echo 
'</div>';
                            }
                        else
                            {
                                echo 
'<div class="error">';
                                echo 
'В процессе удаления произошла ошибка!<br/>';
                                echo 
'</div>';
                            }
                    }
            }
        else
            {
                echo 
'<div class="error">';
                echo 
'Нет такой площадки!<br/>';
                echo 
'</div>';
            }
        break;
        
        case 
'ban':
            if(
$id)
                {
                    
$checking mysql_query("SELECT * FROM `".$prefix."sait` WHERE `id` = '".$id."'");
                        if(
mysql_num_rows($checking) > 0)
                            {
                                
$check mysql_fetch_array($checking);
                                if(
$check['ban'] == 0)
                                    {
                                        if(!isset(
$_POST['ok']))
                                            {
                                                echo 
'
                                                <div class="main">
                                                <form action="platforms.php?act=ban&id='
.$id.'" method="post">
                                                Причина бана(max.50):<br/>
                                                <input type="text" name="reason" maxlength="30" value=""/><br/>
                                                <input type="submit" name="ok" value="Выдать БАН"/>
                                                </form></div>'
;
                                            }
                                        else
                                            {
                                
$reason htmlspecialchars(trim($_POST['reason']));
                                                
$error '';
                                                if(empty(
$reason))
                                                    {
                                        
$error .= 'Ошибка! Не заполнено поле !<br/>';
                                                    }
                                                if(
mb_strlen($reason) > 50)
                                                    {
                                
$error .= 'Ошибка! Поле "Причина" содержит больше 50 символов!<br/>';
                                                    }
                                                if(!empty(
$error))
                                                    {
                                                        echo 
'<div class="error">';
                                                        echo 
$error;
                                                        echo 
'</div>';                                                        
                                                    }
                                                else
                                                    {
                
$ban mysql_query("UPDATE `".$prefix."sait` SET 
               `ban` = '1', 
               `ban_reason` = '" 
mysql_real_escape_string($reason) . "', 
               `ban_who` = '" 
mysql_real_escape_string($user_data['login']) . "' 
                WHERE `id` = '" 
.$id"'");
                                                        if(
$ban)
                                                            {
                                    echo 
'<div class="main">Сайт успешно забанен! <br/></div>';
                                                            }
                                                        else
                                                            {
                                    echo 
'<div class="error">Сайт не забанен !<br/></div>';
                                                            }
                                                    }
                                            }
                                    }
                                    else
                                    {
            
$unban mysql_query("UPDATE `".$prefix."sait` SET 
                `ban` = '0', 
                `ban_reason` = '', 
                `ban_who` = '' 
                WHERE `id` = '" 
.$id"'");
                                        if(
$unban)
                                            {
                                                echo 
'<div class="main">';
                                                echo 
'Сайт успешно разбанен! <br/>';
                                                echo 
'</div>';
                                            }
                                        else
                                            {
                                                echo 
'<div class="error">';
                                                echo 
'Сайт не разбанен !<br/>';
                                                echo 
'</div>';
                                            }
                                    }
                            }
                        else
                            {
                                echo 
'<div class="error">';
                                echo 
'Ошибка! Данного сайта нет в базе !<br/>';
                                echo 
'</div>';
                            }
                }
        break;
    }

echo 
'<div class="main">';
echo 
'<a href="http://'.$set['home'].'/adm_panel/platforms.php">К управлению площадками</a><br/>';
echo 
'<a href="http://'.$set['home'].'/adm_panel/index.php">В Админку</a></div>';
echo 
'<div class = "title2"><a href="http://'.$set['home'].'/?">• Главная</a></div>';
require_once(
'../m/foot.php');
?>
Онлайн: 0
Реклама