Размер файла: 7.97Kb
<?php
define( 'WBCAT', 1 );
$loc = 'index';
require_once ('inc/head.php');
$mod = isset($_GET['mod']) ? $_GET['mod'] : '';
switch ($mod) {
# Выход из админки #
case 'logout' :
if (!$allow){ // если ошибка, то закрываем доступ
exit ('Доступ закрыт');
}
setcookie('adm', '');
session_destroy();
header('Location: '.$home.'/');
break;
# Создание новой категории #
case 'create' :
if (!$allow) {exit ('Доступ закрыт');}
if (isset($_POST['submit'])) {
if (empty($_POST['title'])) {
echo "Вы не ввели название<br/><br />
<a href='?act=create'>Еще раз</a><br/>
<a href='index.php'>К категориям</a>";
exit;
}
$title = htmlspecialchars(trim($_POST['title']));
$about = htmlspecialchars(trim($_POST['about']));
$req = mysql_query("SELECT `place` FROM `cat` ORDER BY `place` DESC LIMIT 1");
if (mysql_num_rows($req) > 0) {
$res = mysql_fetch_array($req);
$place = $res['place'] + 1;
} else {
$place = 1;
}
mysql_query("insert into `cat` SET
`title`='" . mysql_real_escape_string($title) . "',
`count`='0',
`place`=$place,
`about`='" . mysql_real_escape_string($about) . "';");
header('Location: '.$home.'/');
} else {
echo "<div class='zag'>
Добавление раздела</div><div class='title'>
<form action='".$home."/?mod=create' method='post'>Название:<br/>
<input type='text' name='title'/><br/>
Описание(не обязательно):<br/><input type='text' name='about'/><br/>
<input type='submit' name='submit' value='Создать'/><br/><a href='index.html'>Назад</a></div>";
}
break;
# Перемещение категории вниз #
case 'down':
if (!$allow) {exit ('Доступ закрыт');}
if ($id) {
$req = mysql_query("SELECT `place` FROM `cat` WHERE `id` = '$id'");
if (mysql_num_rows($req) > 0) {
$res = mysql_fetch_array($req);
$place = $res['place'];
$req = mysql_query("SELECT * FROM `cat` WHERE `place` > '$place' ORDER BY `place` ASC");
if (mysql_num_rows($req) > 0) {
$res = mysql_fetch_array($req);
$id2 = $res['id'];
$place2 = $res['place'];
mysql_query("UPDATE `cat` SET `place` = '$place2' WHERE `id` = '$id'");
mysql_query("UPDATE `cat` SET `place` = '$place' WHERE `id` = '$id2'");
}
}
}
header('Location: ' . $home);
break;
# Перемещение категории вверх #
case 'up':
if (!$allow) {exit ('Доступ закрыт');}
if ($id) {
$req = mysql_query("SELECT `place` FROM `cat` WHERE `id` = '$id'");
if (mysql_num_rows($req) > 0) {
$res = mysql_fetch_array($req);
$place = $res['place'];
$req = mysql_query("SELECT * FROM `cat` WHERE `place` < '$place' ORDER BY `place` DESC");
if (mysql_num_rows($req) > 0) {
$res = mysql_fetch_array($req);
$id2 = $res['id'];
$place2 = $res['place'];
mysql_query("UPDATE `cat` SET `place` = '$place2' WHERE `id` = '$id'");
mysql_query("UPDATE `cat` SET `place` = '$place' WHERE `id` = '$id2'");
}
}
}
header('Location: ' . $home);
break;
//-------------Модуль загрузок--------------------//
case 'download':
//Здесть функции из func.php
require_once(SKRIPT_DIR.'/modules/down.php');
break;
//------------End Модуль загрузок-----------------//
# Главная страница каталога #
default :
echo '<div class="main"><a href="stat.html">Статистика</a>'.($set_module['faq'] || $allow ? '|<a href="faq.html">FAQ</a>' : '').''.($settings['search'] || $allow ? '|<a href="search.html">Поиск</a>' : '').''.($settings['news'] || $allow ? '|<a href="news.html">Новости</a>' : '').'</div>';
//Новости
if ($set_news['view'] && $settings['news']) {
$query = mysql_query("SELECT * FROM `news` ORDER BY id DESC LIMIT 1");
$news = mysql_fetch_array($query);
if (mysql_num_rows($query) > 0) {
$news['text'] = tags($news['text']);
echo '<div class="zag">Новости</div>';
if($set_news['prew_news']){
$LAST_news=explode('[textbreak]',$news['text']);
$LAST_news=$LAST_news[0].'...<br />';}
else{ $LAST_news=str_replace('[textbreak]','',$news['text']); }
echo '<div class="title"><b>'.$news['name'].'</b> ['.date('d.m.y/H:i', $news['date']).']<br/>'.nl2br($LAST_news).'<a href="comments-'.$news['id'].'.html">подробнее</a>'.($set_news['komm'] == true ? '<br/><a href="comments-'.$news['id'].'.html">Комментарии</a> ('.$news['count'].')' : '').'</div>';
}
else {
echo '<div class="title">Новостей нет</div>';
}
}
$count_down_field = mysql_result(mysql_query('SELECT COUNT(*) FROM `down_fields`;'), 0);
$down_name = mysql_fetch_array(mysql_query("SELECT `title` FROM `down_set` WHERE `id` = '1' LIMIT 1"));
echo '<div class="title"><a href="'.$home.'/index.php?mod=download">'.$down_name['title'].'</a> ['.$count_down_field.']</div>';
$last = mysql_fetch_array(mysql_query("SELECT `url` FROM `sites` WHERE `type` = '1' ORDER BY id DESC LIMIT 1"));
$Widget->load_Widgets('main');
echo '<div class="zag">Каталог</div>';
echo ''.($last > 0 ? '<div class="title">Последний сайт <a href="http://'.$last['url'].'">http://'.$last['url'].'</a></div>' : '').'';
$count_site = mysql_result(mysql_query('SELECT COUNT(*) FROM `sites` WHERE `type` = "1";'), 0);
$count = mysql_result(mysql_query('SELECT COUNT(*) FROM `cat`;'), 0);
$result = mysql_query('SELECT * FROM `cat` ORDER BY `place` ASC');
if ($count >0) {
while ($m = mysql_fetch_assoc($result)) {
echo '<div class="title"><a href="cat-'.$m['id'].'.html">'.$m['title'].'</a> ['.$m['count'].']';
if (!empty($m['about'])) {echo '<br/>('.$m['about'].')';}
if ($allow) {
echo ' <div class="min"><a href="'.$home.'/?mod=up&id='.$m['id'].'">Вверх</a> | <a href="'.$home.'/?mod=down&id='.$m['id'].'">Вниз</a></div>';
}
echo '</div>';
}
}
else {
echo '<div class="title">Категорий нет</div>';
}
$count_book = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `book`"),0);
echo '<div class="main">• <a href="add.html">Добавить сайт</a></div>';
echo ''.($set_module['about'] || $allow ? '<div class="main">• <a href="about.html">Контакты</a></div>' : '').'';
echo ''.($set_book['status'] || $allow ? '<div class="main">• <a href="book.html">Книга отзывов/пожеланий</a> ['.$count_book.']</div>' : '').'';
// Админский блок
if ($allow) {
echo '<div class="func"><small>Управление :<br/></small>
<a href="'.$home.'/?mod=create">Создать раздел</a><br/>
<a href="'.$home.'/adm/">Админка</a><br/>
<a href="'.$home.'/?mod=logout">Выйти</a></div>';
}
echo '<div class="zag">Активных сайтов :'.$count_site.'<br/>На модерации : '.$count_mod.'</div>';
}
require_once ('inc/foot.php');
?>