Вход Регистрация
Файл: adm_panel/platforms.php
Строк: 147
<?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');
$id = (isset($_GET['id'])) ? (int) $_GET['id'] : NULL;
reg();
level(2);
switch(
$act)
    {
        default:
        echo 
'<div class="top"><div class="title2"><font color="#fff">Управление площадками</font></div><div class="clear"></div></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="navi3">'.$start.'.<a href="http://'.$set['home'].'/out/'.$row['id'].'"><strong>'.$row['url'].'</a></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="top"><div class="title2"><font color="#fff">Изменение площадки</font></div><div class="clear"></div></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);
        if(
$platform_count 0)
            {
                if(!isset(
$_POST['ok']))
                    {
                        echo 
'<div class="main">';
                        echo 
'
                        <form action="platforms.php?act=edit_sait&id='
.$id.'" method="post">
                        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><br/>';
                                    }
                            }
                
                    
                        echo 
'<br/><br/><input name="ok" type="submit" value="Изменить" />
                        </form>
                        </div>'
;
                    }
                else
                    {
                        
$url htmlspecialchars(trim($_POST['url']));
                        
$about htmlspecialchars(trim($_POST['about']));
                        
$cat intval($_POST['cat']);
                        
$error '';
                        if(empty(
$cat) 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) > 200)
                            {
                                
$error .= 'Ошибка! Поле "Описание сайта" содержит больше 200 символов! <br/>';
                            }
                        if(!empty(
$error))
                            {
                                echo 
'<div class="error">';
                                echo 
$error;
                                echo 
'</div>';
                            }
                        else
                            {
                    
$edit mysql_query("UPDATE `".$prefix."sait` SET 
                     `category` = '"
.$cat."',
                     `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="top"><div class="title2"><font color="#fff">Удаление сайта <strong>'.$sait['url'].'</strong></font></div><div class="clear"></div></div>';
                if(!isset(
$_GET['ok']))
                    {
                        echo 
'<div class="main">';
                        echo 
'Вы действительно хотите удалить сайт <strong>'.$sait['url'].'</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>';
require_once(
'../m/foot.php');
?>
Онлайн: 1
Реклама