Просмотр файла forum/active.php

Размер файла: 7.29Kb
<?php
#-----------------------------------------------------#
#          ********* ROTORCMS *********               #
#              Made by  :  VANTUZ                     #
#               E-mail  :  [email protected]         #
#                 Site  :  http://pizdec.ru           #
#             WAP-Site  :  http://visavi.net          #
#                  ICQ  :  36-44-66                   #
#  Вы не имеете право вносить изменения в код скрипта #
#        для его дальнейшего распространения          #
#-----------------------------------------------------#	
require_once ('../includes/start.php');
require_once ('../includes/functions.php');
require_once ('../includes/header.php');
include_once ('../themes/' . $config['themes'] . '/index.php');

if (empty($_GET['uz'])) {
  $uz = check($log);
} else {
  $uz = check($_GET['uz']);
} 
if (isset($_GET['start'])) {
  $start = abs(intval($_GET['start']));
} else {
  $start = 0;
} 
if (isset($_GET['act'])) {
  $act = check($_GET['act']);
} else {
  $act = 'themes';
} 

switch ($act):
# ###########################################################################################
# #                                        Вывод тем                                       ##
# ###########################################################################################
case "themes":
  show_title('site.png', 'Список всех тем');
  $config['newtitle'] = 'Список всех тем';

  $total = DB :: $dbh -> querySingle("SELECT count(*) FROM `topics` WHERE `topics_author`=?;", array($uz));

  if ($total > 0) {
    if ($start >= $total) {
      $start = 0;
    } 

    $querytopic = DB :: $dbh -> query("SELECT `topics`.*, `forums_title` FROM `topics` LEFT JOIN `forums` ON `topics`.`topics_forums_id`=`forums`.`forums_id` WHERE `topics_author`=? ORDER BY `topics_last_time` DESC LIMIT " . $start . ", " . $config['forumtem'] . ";", array($uz));

    while ($data = $querytopic -> fetch()) {
      echo '<div class="b">';

      if ($data['topics_locked'] == 1) {
        echo '<img src="../images/img/lock.gif" alt="image" /> ';
      } elseif ($data['topics_closed'] == 1) {
        echo '<img src="../images/img/closed.gif" alt="image" /> ';
      } else {
        echo '<img src="../images/img/forums.gif" alt="image" /> ';
      } 

      echo '<b><a href="topic.php?tid=' . $data['topics_id'] . '&amp;' . SID . '">' . $data['topics_title'] . '</a></b> (' . $data['topics_posts'] . ')</div>';
      echo '<div>Страницы: ';
      forum_navigation('topic.php?tid=' . $data['topics_id'] . '&amp;', $config['forumpost'], $data['topics_posts']);
      echo 'Форум: <a href="forum.php?fid=' . $data['topics_forums_id'] . '&amp;' . SID . '">' . $data['forums_title'] . '</a><br />';
      echo 'Автор: ' . $data['topics_author'] . ' / Посл.: ' . $data['topics_last_user'] . ' (' . date_fixed($data['topics_last_time']) . ')</div>';
    } 

    page_strnavigation('active.php?act=themes&amp;uz=' . $uz . '&amp;', $config['forumtem'], $start, $total);
  } else {
    show_error('Созданных тем не найдено!');
  } 
  break;
# ###########################################################################################
# #                                     Вывод сообщений                                    ##
# ###########################################################################################
case 'posts':
  show_title('site.png', 'Список всех сообщений');
  $config['newtitle'] = 'Список всех сообщений';

  $total = DB :: $dbh -> querySingle("SELECT count(*) FROM `posts` WHERE `posts_user`=?;", array($uz));

  if ($total > 0) {
    if ($start >= $total) {
      $start = 0;
    } 

    $querypost = DB :: $dbh -> query("SELECT `posts`.*, `topics_title` FROM `posts` LEFT JOIN `topics` ON `posts`.`posts_topics_id`=`topics`.`topics_id` WHERE `posts_user`=? ORDER BY `posts_time` DESC LIMIT " . $start . ", " . $config['forumpost'] . ";", array($uz));

    while ($data = $querypost -> fetch()) {
      echo '<div class="b">';

      echo '<img src="../images/img/forums.gif" alt="image" /> <b><a href="topic.php?act=viewpost&amp;tid=' . $data['posts_topics_id'] . '&amp;id=' . $data['posts_id'] . '&amp;' . SID . '">' . $data['topics_title'] . '</a></b>';

      if (is_admin(array(101, 102, 103, 105))) {
        echo ' — <a href="active.php?act=del&amp;id=' . $data['posts_id'] . '&amp;uz=' . $uz . '&amp;start=' . $start . '&amp;uid=' . $_SESSION['token'] . '&amp;' . SID . '">Удалить</a>';
      } 

      echo '</div>';
      echo '<div>' . bb_code($data['posts_text']) . '<br />';

      echo 'Написал: ' . nickname($data['posts_user']) . ' <small>(' . date_fixed($data['posts_time']) . ')</small><br />';

      echo '<span class="data">(' . $data['posts_brow'] . ', ' . $data['posts_ip'] . ')</span></div>';
    } 

    page_strnavigation('active.php?act=posts&amp;uz=' . $uz . '&amp;', $config['forumpost'], $start, $total);
  } else {
    show_error('Сообщения не найдены!');
  } 
  break;
# ###########################################################################################
# #                                    Удаление сообщений                                  ##
# ###########################################################################################
case 'del':

  $uid = check($_GET['uid']);
  if (isset($_GET['id'])) {
    $id = abs(intval($_GET['id']));
  } else {
    $id = 0;
  } 

  if (is_admin(array(101, 102, 103, 105))) {
    if ($uid == $_SESSION['token']) {
      $querytopic = DB :: $dbh -> query("SELECT * FROM `posts` WHERE `posts_id`=? LIMIT 1;", array($id));
      $topics = $querytopic -> fetch();
      if (!empty($topics)) {
        DB :: $dbh -> query("DELETE FROM `posts` WHERE `posts_id`=? AND `posts_topics_id`=?;", array($id, $topics['posts_topics_id']));
        DB :: $dbh -> query("UPDATE `topics` SET `topics_posts`=`topics_posts`-? WHERE `topics_id`=?;", array(1, $topics['posts_topics_id']));
        DB :: $dbh -> query("UPDATE `forums` SET `forums_posts`=`forums_posts`-? WHERE `forums_id`=?;", array(1, $topics['posts_forums_id']));

        $_SESSION['note'] = 'Сообщение успешно удалено!';
        header ("Location: active.php?act=posts&uz=$uz&start=$start&" . SID);
        exit;
      } else {
        show_error('Ошибка! Данного сообщения не существует!');
      } 
    } else {
      show_error('Ошибка! Неверный идентификатор сессии, повторите действие!');
    } 
  } else {
    show_error('Ошибка! Удалять сообщения могут только модераторы!');
  } 

  echo '<img src="../images/img/back.gif" alt="image" /> <a href="active.php?act=posts&amp;uz=' . $uz . '&amp;start=' . $start . '&amp;' . SID . '">Вернуться</a><br />';
  break;

default:
  header("location: active.php?" . SID);
  exit;
  endswitch;

  echo '<img src="../images/img/reload.gif" alt="image" /> <a href="index.php?' . SID . '">К форумам</a><br />';
  echo '<img src="../images/img/homepage.gif" alt="image" /> <a href="../index.php?' . SID . '">На главную</a>';

  include_once ('../themes/' . $config['themes'] . '/foot.php');

  ?>