Вход Регистрация
Файл: modules/forum/category.php
Строк: 301
<?php
/****
* @package LiveCMS
* @link livecms.org
* @author MyZik
* @version See attached file VERSION.txt
* @license See attached file LICENSE.txt
* @copyright Copyright (C) LiveCMS Development Team
****/

$lang_forum load_lng('forum'); // Подключаем файл языка

$title $lang_forum['forum']; // Заголовок страницы
$module 'forum'// Модуль

  
$icons_dir '/design/icons/forum/'// папка и иконками

  /**
    * Проверяем, задан ли параметр
  **/
  
if (!isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id'])) {
    require_once(
HOME .'/incfiles/header.php');
    echo 
'<div class="error">' $lang['error_parameter'] . '</div>';
    echo 
'<div class="home">' .
    
'<img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="" /> <a href="/index.php">' $lang['back'] . '</a>' .
    
'</div>';
    require_once(
HOME .'/incfiles/footer.php');
      }

  
/**
    * Проверяем существование категории
  **/
  
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_categories` WHERE `id` = '" num($_GET['id']) . "'"), 0) == 0) {
    require_once(
HOME .'/incfiles/header.php');
    echo 
'<div class="error">' $lang_forum['category_not_exists'] . '</div>';
    echo 
'<div class="home">' .
    
'<img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="" /> <a href="index.php">' $lang['back'] . '</a>' .
    
'</div>';
    require_once(
HOME .'/incfiles/footer.php');
      }

  
$ID num($_GET['id']);
  
$category mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_categories` WHERE `id` = '$ID' LIMIT 1"));
  
$section mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_sections` WHERE `category_id` = '$ID' LIMIT 1"));

  
/**
    * Поднятие уровня раздела
  **/
  
if (isset($_GET['up']) && is_numeric($_GET['up']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_sections` WHERE `id` = '" num($_GET['up']) . "' AND `category_id` = '$ID'"), 0) != && ($user['rights'] >= || $user['rights'] == 3)) {
    
$res mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_sections` WHERE `id` = '" .num($_GET['up']) . "'"));
    
$position $res['position'] - 1;
    
mysql_query("UPDATE `cms_forum_sections` SET `position` = `position` + 1 WHERE `position` = '$position'");
    
mysql_query("UPDATE `cms_forum_sections` SET `position` = '$position' WHERE `id` = '" num($_GET['up']) . "'");
    
header("Location: category.php?id=$ID");
        }

  
/**
    * Понижение уровня раздела
  **/
  
if (isset($_GET['down']) && is_numeric($_GET['down']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_sections` WHERE `id` = '" num($_GET['down']) . "' AND `category_id` = '$ID'"), 0) != && ($user['rights'] >= || $user['rights'] == 3)) {
    
$res mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_sections` WHERE `id` = '" .num($_GET['down']) . "'"));
    
$position $res['position'] + 1;
    
mysql_query("UPDATE `cms_forum_sections` SET `position` = `position` - 1 WHERE `position` = '$position'");
    
mysql_query("UPDATE `cms_forum_sections` SET `position` = '$position' WHERE `id` = '" num($_GET['down']) . "'");
    
header("Location: category.php?id=$ID");
        }

  
/**
    * Добавление раздела
  **/
  
if (isset($_GET['add'])) {
    
/**
      * Проверяем права доступа
    **/
    
if ($user['rights'] < || $user['rights'] < 8) {
      require_once(
HOME .'/incfiles/header.php');
      echo 
'<div class="error">' $lang['error_rights'] . '</div>';
      echo 
'<div class="home">' .
      
'<img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="" /> <a href="index.php">' $lang['back'] . '</a>' .
      
'</div>';
      require_once(
HOME .'/incfiles/footer.php');
        }

    require_once(
HOME .'/incfiles/header.php'); // подключаем шапку

    /**
      * Небольшая панель навигации
    **/
    
echo '<div class="title"><a href="/forum/">' $lang['forum'] . '</a> | <a href="category.php?id=' $ID '">' txt($category['name']) . '</a></div>';

    if (isset(
$_POST['add'])) {
      
$name input(mb_substr($_POST['name'], 060));
      
$text input(mb_substr($_POST['text'], 0300));

      
/**
        * Проверяем длину названия раздела
      **/
      
if (strlen($name) < 2)
        
$err[] = $lang_forum['short_name_section'];

      
/**
        * Проверяем, существует ли раздел в БД
      **/
      
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_sections` WHERE `name` = '$name' AND `text` = '$text'"), 0) != 0)
        
$err[] = $lang_forum['section_exists'];

      
/**
        * Если не было ошибок, заносим данные
      **/
      
if (!isset($err)) {
        
$position mysql_fetch_assoc(mysql_query("SELECT `position` FROM `cms_forum_sections` ORDER BY `position` DESC LIMIT 1"));
        
mysql_query("INSERT INTO `cms_forum_sections` (`category_id`, `position`, `name`, `text`) VALUES ('$ID', '" . ($position['position'] + 1) . "', '$name', '$text')");
        echo 
display_message($lang_forum['add_section_success']);
        
/**
          * Нижняя панель навигации
        **/
        
echo '<div class="home"><img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="<" /> <a href="category.php?id=' $ID '&amp;add">' $lang['back'] . '</a><br />' 
        
'<img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="<" /> <a href="category.php?id=' $ID '">' $category['name'] . '</a><br />' .
        
'<img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="<" /> <a href="index.php">' $lang_forum['forum'] . '</a>' .
        
'</div>';
        require_once(
HOME .'/incfiles/footer.php'); // подключаем ноги
          
} else {
        echo 
error($err); // показываем ошибки, если они имеются
          
}
            }

    
/**
      * Форма
    **/
    
echo '<div class="main"><form method="post" action="category.php?id=' $ID '&amp;add">' .
    
$lang_forum['section_name'] . '<br />' .
    
'<input type="text" name="name" value="" /><br />' .
    
$lang_forum['section_text'] . '<br />' .
    
'<textarea name="text"></textarea><br />' .
    
$lang_forum['section_text_info'] . '<br />' .
    
'<input type="submit" name="add" value="' $lang['add'] . '" />' .
    
'</form></div>';
    require_once(
HOME .'/incfiles/footer.php'); // подключаем ноги
    
}
  
/**
    * Редактирование раздела
  **/
  
elseif (isset($_GET['edit'])) {
    
/**
      * Проверяем права доступа
    **/
    
if ($user['rights'] < || $user['rights'] < 8) {
      require_once(
HOME .'/incfiles/header.php');
      echo 
'<div class="error">' $lang['error_rights'] . '</div>';
      echo 
'<div class="home">' .
      
'<img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="" /> <a href="index.php">' $lang['back'] . '</a>' .
      
'</div>';
      require_once(
HOME .'/incfiles/footer.php');
        }

    require_once(
HOME .'/incfiles/header.php'); // подключаем шапку

    /**
      * Проверяем введенный параметр
    **/
    
if (empty($_GET['edit']) || !is_numeric($_GET['edit'])) {
      echo 
'<div class="error">' $lang['error_parameter'] . '</div>';
      require_once(
HOME .'/incfiles/footer.php');
        }

    
/**
      * Проверяем наличие раздела
    **/
    
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_sections` WHERE `id` = '" num($_GET['edit']) . "'"), 0) == 0)
      
$err[] = $lang_forum['section_not_exists'];

    
$editID num($_GET['edit']);
    
$section mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_sections` WHERE `id` = '$editID'"));

    
/**
      * Небольшая панель навигации
    **/
    
echo '<div class="title"><a href="/forum/">' $lang['forum'] . '</a> | <a href="category.php?id=' $ID '">' txt($category['name']) . '</a> | <b>' txt($section['name']) . '</b></div>';

    if (isset(
$_POST['save'])) {
      
$name input(mb_substr($_POST['name'], 060));
      
$text input(mb_substr($_POST['text'], 0300));

      
/**
        * Проверяем длину названия раздела
      **/
      
if (strlen($name) < 2)
        
$err[] = $lang_forum['short_name_section'];

      
/**
        * Проверяем, существует ли раздел в БД
      **/
      
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_sections` WHERE `name` = '$name' AND `text` = '$text'"), 0) != 0)
        
$err[] = $lang_forum['section_exists'];

      
/**
        * Если не было ошибок, заносим данные
      **/
      
if (!isset($err)) {
        
mysql_query("UPDATE `cms_forum_sections` SET `name` = '$name', `text` = '$text' WHERE `id` = '$editID' LIMIT 1");
        echo 
display_message($lang_forum['edit_section_success']);
      
/**
        * Нижняя панель навигации
      **/
        
echo '<div class="home"><img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="<" /> <a href="category.php?id=' $ID '&amp;edit=' $editID '">' $lang['back'] . '</a><br />' .
        
'<img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="<" /> <a href="category.php?id=' $ID '">' $category['name'] . '</a><br />' .
        
'<img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="<" /> <a href="index.php">' $lang_forum['forum'] . '</a>' .
        
'</div>';
        require_once(
HOME .'/incfiles/footer.php'); // подключаем ноги
          
} else {
        echo 
error($err); // показываем ошибки, если они имеются
          
}
            }

    
/**
      * Форма
    **/
    
echo '<div class="main"><form method="post" action="category.php?id=' $ID '&amp;edit=' $editID '">' .
    
$lang_forum['section_name'] . '<br />' .
    
'<input type="text" name="name" value="' $section['name'] . '" /><br />' .
    
$lang_forum['section_text'] . '<br />' .
    
'<textarea name="text">' $section['text'] . '</textarea><br />' .
    
$lang_forum['section_text_info'] . '<br />' .
    
'<input type="submit" name="save" value="' $lang['edit'] . '" />' .
    
'</form></div>';
    require_once(
HOME .'/incfiles/footer.php'); // подключаем ноги
      
}
  
/**
    * Удаление раздела
  **/
  
elseif (isset($_GET['delete'])) {
    
/**
      * Проверяем права доступа
    **/
    
if ($user['rights'] < || $user['rights'] < 8) {
      require_once(
HOME .'/incfiles/header.php');
      echo 
'<div class="error">' $lang['error_rights'] . '</div>';
      echo 
'<div class="home">' .
      
'<img src="/design/themes/' $set_user['theme'] . '/images/back.png" alt="" /> <a href="index.php">' $lang['back'] . '</a>' .
      
'</div>';
      require_once(
HOME .'/incfiles/footer.php');
        }

    require_once(
HOME .'/incfiles/header.php'); // подключаем шапку

    /**
      * Проверяем введенный параметр
    **/
    
if (empty($_GET['delete']) || !is_numeric($_GET['delete']))
      
$err[] = $lang['error_parameter'];

    
/**
      * Проверяем наличие раздела
    **/
    
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_sections` WHERE `id` = '" num($_GET['delete']) . "'"), 0) == 0)
      
$err[] = $lang_forum['section_not_exists'];

    
/**
      * Небольшая панель навигации
    **/
    
echo '<div class="title"><a href="/forum/">' $lang['forum'] . '</a> | <a href="category.php?id=' $ID '">' txt($category['name']) . '</a> | <b>' txt($section['name']) . '</b></div>';

    
$deleteID num($_GET['delete']);

    if (isset(
$_GET['yes'])) {
      
/**
        * Если не было ошибок, удаляем раздел
      **/
      
if (!isset($err)) {
        
mysql_query("DELETE FROM `cms_forum_sections` WHERE `id` = '$deleteID' LIMIT 1");
        
mysql_query("DELETE FROM `cms_forum_topics` WHERE `section_id` = '$deleteID'");
        
header("Location: category.php?id=$ID");
        exit;
          } else {
        echo 
error($err);
        require_once(
HOME .'/incfiles/footer.php'); // подключаем ноги
        
}
      } else {
        echo 
'<div class="error">' $lang_forum['delete_section_info'] . '<br />' .
        
'<a href="category.php?id=' $ID '&amp;delete=' $deleteID '&amp;yes"><input type="button" name="" value="' $lang['delete'] . '" /></a> | <a href="category.php?id=' $ID '">' $lang['cancel'] . '</a></div>';
        require_once(
HOME .'/incfiles/footer.php'); // подключаем ноги
     
}
   }
  
/**
    * Показываем разделы
  **/
  
else {
    require_once(
HOME .'/incfiles/header.php'); // подключаем шапку

    /**
      * Небольшая панель навигации
    **/
    
echo '<div class="title"><a href="/forum/">' $lang['forum'] . '</a> | <b>' txt($category['name']) . '</b></div>';

    
/**
      * Админские функции
    **/
    
if ($user['rights'] >= || $user['rights'] == 3)
      echo 
'<div class="home"><img src="/design/themes/' $set_user['theme'] . '/images/act.png" alt="" /> <a href="category.php?id=' $ID '&amp;add">' $lang_forum['section_add'] . '</a></div>';

    
/**
      * Настраиваем пагинацию
    **/
    
$total mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_sections` WHERE `category_id` = '$ID'"), 0);
    
$req mysql_query("SELECT * FROM `cms_forum_sections` WHERE `category_id` = '$ID' ORDER BY `position` ASC LIMIT $start$countMess"); 

    
/**
      * Если нет результатов, показываем уведомление
    **/
    
if ($total 1) {
      echo 
'<div class="error">' $lang_forum['sections_not_found'] . '</div>';
        }

    while (
$res mysql_fetch_assoc($req)) {
      echo (
$i 2) ? '<div class="list1">' '<div class="list2">';
      
$count mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_topics` WHERE `section_id` = '" $res['id'] . "' LIMIT 1"), 0);
      echo 
'<img src="' $icons_dir 'section.png" alt="[s]" /> <a href="section.php?id=' $res['id'] . '">' txt($res['name']) . '</a> [' $count '] ' . ($user['rights'] >= || $user['rights'] == ' [<a href="category.php?id=' $ID '&amp;up=' $res['id'] . '">' $lang_forum['up'] . '</a> | <a href="category.php?id=' $ID '&amp;down=' $res['id'] . '">' $lang_forum['down'] . '</a> | <a href="category.php?id=' $ID '&amp;edit=' $res['id'] . '">' $lang_forum['edit'] . '</a> | <a href="category.php?id=' $ID '&amp;delete=' $res['id'] . '">' $lang_forum['delete'] . '</a>]' '') .
      (!empty(
$res['text']) ? '<br /><span class="gray">' output(txt($res['text'])) . '</span>' '') . '</div>';
      
$i++;
         } 

    
/**
      * Пагинация
    **/
    
if ($total $countMess) {
      echo 
'<div class="home">' display_pagination('category.php?id=' $ID '&amp;'$start$total$countMess) . '</div>';
      }

      require_once(
HOME .'/incfiles/footer.php'); // подключаем ноги
        
}
?>
Онлайн: 4
Реклама