Вход Регистрация
Файл: o5on.ru/admin.php
Строк: 224
<?php
$pass_ 
'пароль админки';
$login_ 'логин админа';
$avt "";
if (empty(
$_COOKIE["avt"])) {
    if (empty(
$_SERVER["QUERY_STRING"])) {
        
header("Location: index.php");
        exit;
    }

    
$text explode(","$_SERVER["QUERY_STRING"]);
    
$login $text[0];
    
$pass $text[1];
} else {
    
$text explode(","$_COOKIE["avt"]);
    
$login $text[0];
    
$pass $text[1];
}

if (
$login != $login_ && $pass != $pass_) {
    
setcookie("avt"''time()-3600 24 365);
    
header("Location: index.php");
    exit;
} else {
    
setcookie("avt"$login_ ',' $pass_time() + 3600 24);
    
$avt 1;
}

if (
$avt == 1) {
    include 
'./inc/config.inc.php';
    include 
'./inc/wap_tags.inc.php';
    include 
'./inc/functions.inc.php';
    
connect_to_db();
    
$uid intval($_GET["uid"]);

    if (
$_POST["top"] == "edit" && isset($_POST["uid"]) && isset($_POST["site_name"]) && isset($_POST["link"]) && isset($_POST["info"]) && isset($_POST["cat_id"])) {
        
$site_name htmlspecialchars(trim($_POST["site_name"]));
        
$uid intval(trim($_POST["uid"]));
        
$link htmlspecialchars(trim($_POST["link"]));
        
$info htmlspecialchars(trim($_POST["info"]));
        
$cat_id intval(trim($_POST["cat_id"]));

        
$url = @parse_url($link);
        
$link "http://" $url['host'];

        if (
utf8_strlen($info) > 70$error "Слишком РґР»РёРЅРѕРµ РѕРїРёСЃР°РЅРёРµ, РЅРµ РґРѕР»Р¶РЅРѕ РїСЂРµРІС‹С€Р°С‚СЊ 70 СЃРёРјРІРѕР»РѕРІ<br />n";
        if (
utf8_strlen($site_name) > 25$error "Слишком РґР»РёРЅРѕРµ РЅР°Р·РІР°РЅРёРµ, РЅРµ РґРѕР»Р¶РЅРѕ РїСЂРµРІС‹С€Р°С‚СЊ 25 СЃРёРјРІРѕР»РѕРІ<br />n";
        if (
strlen($link) > 25$error "Слишком РґР»РёРЅР°СЏ СЃСЃС‹Р»РєР°, РЅРµ РґРѕР»Р¶РЅР° РїСЂРµРІС‹С€Р°С‚СЊ 25 СЃРёРјРІРѕР»РѕРІ<br />n";
        if ((
$cat_id "17")or($cat_id "1"))$error "РќРµ РІРµСЂРЅРѕ СѓРєР°Р·Р°РЅР° РєР°С‚егория СЃР°Р№С‚Р°<br />n";
        if (!
eregi("^http://[-a-z0-9.]+.[a-z]{2,4}$"$link))$error "Неверно СѓРєР°Р·Р°РЅРЅР° СЃСЃС‹Р»РєР° СЃР°Р№С‚a<br />";

        
$result mysql_query("SELECT `uid` FROM `ban_user` WHERE `link`='" $url['host'] . "'");
        
$row mysql_fetch_row($result);
        if (!empty(
$row[0]))$error "Данный СЃР°Р№С‚ РІ Р±Р°РЅРµ!<br />";

        if (empty(
$uid))$error "РќРµ СѓРєР°Р·Р°РЅ <b>uid</b>!<br />n";

        if (empty(
$error)) {
            
mysql_query("UPDATE `users` SET `site_name` = '" $site_name "', `link` = '" $link "', `info` = '" $info "',`cat_id` = '" $cat_id "' WHERE `uid` =" $uid " LIMIT 1 ;");
            
mysql_query("UPDATE `weeks` SET `cat_id` = '" $cat_id "' WHERE `uid` =" $uid ";");
            
// $error = "UPDATE `users` SET `site_name` = '".$site_name."', `link` = '".$link."', `info` = '".$info."',`cat_id` = '".$cat_id."' WHERE `uid` =".$uid." LIMIT 1 ;";
            
$error "<b>Данные СѓСЃРїРµС€РЅРѕ СЃРѕС…ранены!</b><br />";
        }
    }
    
// Р’ыход
    
if ($_SERVER["QUERY_STRING"] == "exit") {
        
setcookie("avt"''time()-3600 24 365);
        
header("Location: index.php");
        exit;
    }

    include 
"./xhtml/inc/head.php";
    
$top trim($_GET["top"]);
    switch (
$top) {
        default:

            print 
"<a href="admin.php?top=list">РЎРїРёСЃРѕРє СЃР°Р№С‚РѕРІ</a><br />n";
            print 
"<a href="admin.php?top=banlist">Бан Р»РёСЃС‚</a><br />n";

            break;
        case 
'list':
            
$result mysql_query("SELECT * FROM `users` WHERE `uid`!='1' ORDER BY `uid` DESC;");
            
$num mysql_num_rows($result);

            for(
$i 0;$i $num;$i++) {
                
$row mysql_fetch_array($result);
                echo (
$i 1) . ") " $row["link"] . " (" $row["uid"] . ") <a href="admin.php?top=edit&amp;uid=" . $row["uid"] . "">Ред.</a> | <a href="admin.php?top=ban&amp;uid=" . $row["uid"] . "">Бан/Удал.</a><br />n";
            }

            break;
        case 
'banlist':
            if (empty(
$_GET["yes"])) {
                
$result mysql_query("SELECT * FROM `ban_user` ORDER BY `uid` DESC;");
                
$num mysql_num_rows($result);
                for(
$i 0;$i $num;$i++) {
                    
$row mysql_fetch_array($result);
                    echo (
$i 1) . ") " $row["link"] . " (uid=<b>" $row["uid"] . "</b>) <a href="admin.php?top=banlist&amp;uid=" . $row["uid"] . "&amp;yes=" . time() . "">Удалить</a><br />n";
                }
            } else {
                
mysql_query("DELETE FROM `ban_user` WHERE `uid` = '" $uid "';");
                print 
"Сайт uid=<b>" $uid "</b> Р±С‹Р» СѓСЃРїРµС€РЅРѕ СѓРґР°Р»РµРЅ СЃ Р±Р°РЅРё!<br />n";
            }

            break;
        case 
'ban':
            if (empty(
$_GET["yes"])) {
                echo 
"Р’С‹ РґРµР№СЃС‚вительно С…отите Р·Р°Р±Р°РЅРёС‚СЊ uid=<b>" $uid "</b>?<br />n";
                print 
"<a href="admin.php?top=ban&amp;uid=" . $uid . "&amp;yes=" . time() . "">Да</a> / <a href="admin.php">Нет</a><br />n";
            } else {
                
$query mysql_query("SELECT `link` FROM `users` WHERE `uid` = '" $uid "' LIMIT 1;");
                
$link mysql_fetch_row($query);
                
$link str_replace("http://"""$link[0]);
                if (!empty(
$link)) {
                    
mysql_query("INSERT INTO `ban_user` VALUES (" $uid ", '" $link "');");
                    
mysql_query("DELETE FROM `users` WHERE `uid` = '" $uid "';");
                    
mysql_query("DELETE FROM `count_24` WHERE `uid` = '" $uid "';");
                    
mysql_query("DELETE FROM `hits_ip` WHERE `uid` = '" $uid "';");
                    
mysql_query("DELETE FROM `hits_time` WHERE `uid` = '" $uid "';");
                    
mysql_query("DELETE FROM `months` WHERE `uid` = '" $uid "';");
                    
mysql_query("DELETE FROM `online_ip` WHERE `uid` = '" $uid "';");
                    
mysql_query("DELETE FROM `top_operators_stat` WHERE `uid` = '" $uid "';");
                    
mysql_query("DELETE FROM `weeks` WHERE `uid` = '" $uid "';");
                    
mysql_query ("OPTIMIZE TABLE `ban_user` , `cat` , `count_24` , `gener` , `hits_ip` , `hits_time` , `models_data` , `months` , `new_operators` , `online_ip` , `superadmin` , `top_ip` , `top_operators` , `top_operators_stat` , `users` , `users_reg` , `user_agents` , `weeks`;");
                    
mysql_query ("REPAIR TABLE `ban_user` , `cat` , `count_24` , `gener` , `hits_ip` , `hits_time` , `models_data` , `months` , `new_operators` , `online_ip` , `superadmin` , `top_ip` , `top_operators` , `top_operators_stat` , `users` , `users_reg` , `user_agents` , `weeks`;");

                    print 
"Сайт " $link " СѓСЃРїРµС€РЅРѕ Р·Р°Р±Р°РЅРµРЅ, РµРіРѕ СЃС‚атистика СѓРґР°Р»РµРЅР° СЃ Р±Р°Р·С‹!n";
                } else {
                    print 
"РќРµ СѓРґР°Р»РѕСЃСЊ РЅР°Р№С‚Рё РІ Р±Р°Р·Рµ СЃР°Р№С‚<br />n";
                }
            }
            break;
        case 
'edit':
            
$result mysql_query("SELECT * FROM `users` WHERE `uid`='" $uid "' LIMIT 1;");
            
$row mysql_fetch_array($result);
            if (!empty(
$error)) echo $error;
            echo 
"Редактируем uid=" $row["uid"] . "<br />n";
            echo 
"Логин Р°РґРјРёРЅР° <b>" $row["admin"] . "</b><br /><br />n";

            print 
"<form action="admin.php?top=edit&amp;uid=" . $uid . "" method="post">n";
            print 
"<b>Название СЃР°Р№С‚Р°:</b><br />n";
            print 
"<input class="itext" type="text" name="site_name" maxlength="25" value="" . htmlspecialchars($row["site_name"]) . ""/> <br /><br />n";
            print 
"<b>Адрес:</b><br />n";
            print 
"<input class="itext" type="text" name="link" maxlength="25" value="" . htmlspecialchars($row["link"]) . ""/> <br /><br />n";
            print 
"<b>Описание:</b><br />n";
            print 
"<input class="itext" type="text" name="info" maxlength="70" value="" . htmlspecialchars($row["info"]) . ""/> <br /><br />n";
            print 
"<b>Категория:</b><br />n";

            print 
"<select size="1" name="cat_id">n";
            print 
"<option value="" . $row["cat_id"] . "">РїРѕ СѓРјРѕР»С‡Р°РЅРёСЋ</option>n";
            
$result mysql_query("SELECT * FROM `cat` ORDER BY `id`;");
            for (
$i 0$i <= mysql_num_rows($result) - 1$i++) {
                if (!(
$row mysql_fetch_object($result)))continue;
                
$idurl $row->id;
                
$name $row->name;
                print 
"<option value="" . $idurl . "">" htmlspecialchars($name) . "</option>n";
            }
            print 
"</select><br /><br />n";
            print 
"<input type="hidden" value="" . $uid . "" name="uid" />n";
            print 
"<input type="hidden" value="edit" name="top" />n";

            print 
"<input class="ibutton" type="submit" value="Сохранить"/>n";
            print 
"</form>n";

            break;
    }

    print 
"<br /><a href="admin.php">Назад</a><br />n";
    print 
"<div class="rb"></div>n";

    print 
"<div class="rh">n";
    print 
"<a href="admin.php?exit"><b>Выход</b></a><br />n";
    print 
"</div>n";

    include 
"./xhtml/inc/foot.php";
} else {
    
header("Location: index.php");
    exit;
}

?>
Онлайн: 1
Реклама