Просмотр файла modules/diray/view.php

Размер файла: 8.14Kb
<?php
####################################################################################################
### Модуль блогов v 1.0 для SteamCMS                                                             ###
### ВЫ НЕ ИМЕЕТЕ ПРАВО РАСПРОСТРАНЯТЬ ДАННЫЙ МОДУЛЬ БЕЗ СОГЛАСИЯ С АВТОРОМ!!!!                   ###
### АВТОР: KpuTuK (wm-sait.ru)                                                                   ###
### ICQ: 2704406                                                                                 ###
### EMAIL: [email protected]                                                                       ###
####################################################################################################

if ((!isset($_GET['did']) || isset($_GET['cid'])) && mysql_result(mysql_query("SELECT COUNT(*) FROM `diray` WHERE `id` = '". num($_GET['did']) ."' LIMIT 1"), 0) == 0) {
header('Location: /');
}

$d = mysql_fetch_assoc(mysql_query("SELECT * FROM `diray` WHERE `id` = '". num($_GET['did']) ."' LIMIT 1"));
if (isset($_GET['did']) && isset($_GET['ddel']) && ($user['level'] == 7 || $user['level'] > 9 || mysql_result(mysql_query("SELECT COUNT(*) FROM `diray` WHERE `id` = '". num($_GET['did']) ."' AND `u_id` = '". num($user['id']) ."' LIMIT 1"), 0) != 0)) {
$us = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '". num($d['u_id']) ."' LIMIT 1"));
$balls = $us['balls'] - 5;
mysql_query("UPDATE `users` SET `balls`= '$balls' WHERE `id` = '$us[id]'");
mysql_query("DELETE FROM `diray` WHERE `id` = '". num($_GET['did']) ."'");
mysql_query("DELETE FROM `diray_comm` WHERE `did` = '". num($_GET['did']) ."'");
mysql_query("DELETE FROM `diray_raiting` WHERE `did` = '". num($_GET['did']) ."'");
header('Location: /diray/');
}
if (isset($user) && $user['id'] != $d['u_id']) {
$view = $d['view'] + 1;
mysql_query("UPDATE `diray` SET `view` = '". num($view) ."' WHERE `id` = '". num($d['id']) ."'");
}
if (isset($_GET['err'])) {
if ($_GET['err'] == 'noy_comm') {
$err = '<div class="err">Не введен коментарий.</div>';
}
}
$comm = mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_comm` WHERE `did` = '$d[id]'") ,0);
$reit = mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_raiting` WHERE `did` = '$d[id]' AND `type` = '1'"),0) - mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_raiting` WHERE `did` = '$d[id]' AND `type` = '2'"),0);
$system['page_title'] = ''. output($d['name']) .'';

# Шапка модуля
require_once(HOME .'/incfiles/header.php');
error($err);
if (isset($_GET['cid']) && isset($_GET['del']) && ($user['level'] == 7 || $user['level'] > 9 || mysql_result(mysql_query("SELECT COUNT(*) FROM `diray` WHERE `id` = '". num($_GET['did']) ."' AND `u_id` = '". num($user['id']) ."' LIMIT 1"), 0) != 0)) {
$com = mysql_fetch_assoc(mysql_query("SELECT * FROM `diray_comm` WHERE `id` = '". num($_GET['cid']) ."' LIMIT 1"));
$us = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '". num($com['u_id']) ."' LIMIT 1"));
$balls = $us['balls'] - 1;
mysql_query("UPDATE `users` SET `balls`= '$balls' WHERE `id` = '$us[id]'");
mysql_query("DELETE FROM `diray_comm` WHERE `id` = '". num($_GET['cid']) ."'");
echo '<div class="msg">Комментарий удален</div>';
}

if (isset($_GET['did']) && isset($_GET['plus']) && (mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_raiting` WHERE `uid` = '". num($user['id']) ."' AND `did` = '". num($d['id']) ."' LIMIT 1"), 0) == 0)) {
mysql_query("INSERT INTO `diray_raiting` SET `did` = '". num($_GET['did']) ."', `uid` = '". num($user['id']) ."', `type` = '1'");
echo '<div class="msg">Спасибо за Ваш голос</div>';
}
if (isset($_GET['did']) && isset($_GET['minus']) && (mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_raiting` WHERE `uid` = '". num($user['id']) ."' AND `did` = '". num($d['id']) ."' LIMIT 1"), 0) == 0)) {
mysql_query("INSERT INTO `diray_raiting` SET `did` = '". num($_GET['did']) ."', `uid` = '". num($user['id']) ."', `type` = '2'");
echo '<div class="msg">Спасибо за Ваш голос</div>';
}
echo '<div class="title">'. output($d['name']) .'</div>
<div class="menu">
'. icon($d['user_id']) .' <a href="/user/user.php?user_id='. $d['u_id'] .'">'. nick($d['u_id']) .'</a> '. online($d['u_id']) .' '. vtime($c['time']) .'
<div align="right">'.($user['id'] == $d['u_id'] || $user['level'] == 7 || $user['level'] > 9?'[<a href="/diray/add.php?did='. $d['id'] .'&edit">Ред</a>]':NULL).''.($user['id'] == $d['u_id'] || $user['level'] == 7 || $user['level'] > 9?'[<a href="/diray/view.php?did='. num($d['id']) .'&ddel">Х</a>]':NULL).'</div>
'. output($d['text']) .'
</div>
<div class="menu">
'. (isset($user) && $settings['img_site'] == 2?NULL:'<img src="/design/icons/diray/reit.gif" alt="" /> ') .' 
Рейтинг '.(mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_raiting` WHERE `did` = '$d[id]' AND `type` = '1'"),0) < mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_raiting` WHERE `did` = '$d[id]' AND `type` = '2'"),0)?'<font color="red">'. $reit .'</font>':'<font color="green">'. $reit .'</font>') .' 
(<font color="green">'. mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_raiting` WHERE `did` = '$d[id]' AND `type` = '1'"),0) .'</font>
/<font color="red">'. mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_raiting` WHERE `did` = '$d[id]' AND `type` = '2'"),0).'</font>)
'.(isset($user) && (mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_raiting` WHERE `uid` = '". num($user['id']) ."' AND `did` = '". num($d['id']) ."' LIMIT 1"), 0) == 0)?'Вам нравится?
<a href="/diray/view.php?did='. $d['id'].'&plus"><font color="green">Да</font></a>|
<a href="/diray/view.php?did='. $d['id'].'&minus"><font color="red">Нет</font></a>':NULL).'<br /> 
'. (isset($user) && $settings['img_site'] == 2?NULL:'<img src="/design/icons/diray/wiew.gif" alt="" /> ') .' Просмотров '. $d['view'] .'
		</div>';
echo '<div class="title">Комментарии '. mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_comm` WHERE `did` = '$d[id]'") ,0) .'</div>';
$k_comm = mysql_result(mysql_query("SELECT COUNT(*) FROM `diray_comm` WHERE `did` = '$d[id]'"), 0);
nav_start($k_comm, 10);
if ($k_comm == 0)
{
    echo '<div class="err">Комментариев нет.</div>';
		if (isset($user)) {
echo '</div><form class="block" method="post" action="/diray/add.php?did='. num($d['id']) .'&comm">Сообщение:<br />
<textarea name="comm" rows="4" cols="20"></textarea><br />
<input type="submit" value="Ответить" /></form>';
echo '<a class="link2" href="/pages/bbcode.php"><img src="/design/icons/teg.png"> Список тегов</a>
<a class="link2" href="/pages/smiles.php"><img src="/design/icons/smile.png"> Список смайлов</a>';
}
}
else
{
    $sql_comm = mysql_query("SELECT * FROM `diray_comm` WHERE `did` = '$d[id]' ORDER BY id LIMIT $start, 10");
    while ($c = mysql_fetch_assoc($sql_comm))
    {
	echo '<div class="menu">
	'. icon($d['user_id']) .' <a href="/user/user.php?user_id='. $d['u_id'] .'">'. nick($d['u_id']) .'</a> '. online($d['u_id']) .' '. vtime($c['time']) .'
	<div align="right">'.($user['id'] == $d['u_id'] || $user['level'] == 7 || $user['level'] > 9?'[<a href="/diray/view.php?did='. num($d['id']) .'&cid='. $c['id'] .'&del">Х</a>]':NULL).'</div>
	'. output($c['text']) .'<br />
	</div>';
    	
    }
	if (isset($user)) {
echo '<form class="block" method="post" action="/diray/add.php?did='. num($d['id']) .'&comm">Сообщение:<br />
<textarea name="comm" rows="4" cols="20"></textarea><br />
<input type="submit" value="Ответить" /></form>';
echo '<a class="link2" href="/pages/bbcode.php"><img src="/design/icons/teg.png"> Список тегов</a>
<a class="link2" href="/pages/smiles.php"><img src="/design/icons/smile.png"> Список смайлов</a>';
}
    # Вывод навигации
    view_nav('?did='. num($_GET['did']) .'&amp;');
}
echo '</div><div class="block">
	&raquo; <a href="/diray/">Дневники</a><br />
    &raquo; <a href="/">На главную</a>
    </div>';
require_once(HOME .'/incfiles/footer.php');
?>