Файл: mods/advice/index.php
Строк: 148
<?php
include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compess.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';
only_reg();
if(isset($_GET['delete']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `advice` WHERE `id` = '".intval($_GET['delete'])."'"),0)!=0 && isset($user) && $user['level']>=4){
mysql_query("DELETE FROM `advice` WHERE `id` = '".intval($_GET['delete'])."'");
mysql_query("DELETE FROM `advice_klass` WHERE `id_advice` = '".intval($_GET['delete'])."'");
msg("Уведомление удалено");
echo "<a href='?all'><div class='gmenu'><img src='/style/glavnaya.gif'> Ко всем уведомлениям</div></a>";
}
if (isset($_GET['all'])){
$set['title']="Уведомления от администрации ";
include_once '../../sys/inc/thead.php';
title();
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `advice`"), 0);
if ($k_post==0)msg("Пока нет уведомлений от администрации ");
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `advice` LIMIT $start, $set[p_str]");
while($post=mysql_fetch_assoc($q)){
echo '<a href="/mods/advice/?id=' . $post['id'] . '"><div class="forum"><img src="/style/i/news.png" alt="" /> '.htmlspecialchars($post['name']).' ('.vremja($post['time']).')</div></a>';
}
if ($k_page>1)str("?all&",$k_page,$page);
include_once '../../sys/inc/tfoot.php';
}
if (isset($_GET['add_vote'])){
$advice = mysql_fetch_assoc(mysql_query("SELECT * FROM `advice` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `advice` WHERE `id` = '$advice[id]' LIMIT 1"),0)==0){header("Location: /index.php?".SID);exit;}
$set['title']="Прикрепление опроса - ".htmlspecialchars($advice['name'])."";
include_once '../../sys/inc/thead.php';
title();
if (isset($_POST['ok'])){
$vot1=my_esc($_POST['vot1']);
$vot2=my_esc($_POST['vot2']);
$vot3=my_esc($_POST['vot3']);
$vot4=my_esc($_POST['vot4']);
$vot5=my_esc($_POST['vot5']);
if (strlen2($vot2)<1)$err[]="Второй вариант должен быть заполнен";
if (strlen2($vot1)<1)$err[]="Первый вариант должен быть заполнен";
if (!isset($err)){
mysql_query("INSERT INTO `advice_votes` (`id_advice`, `var`, `num`) VALUES ('$them[id]', '$vot1', '1')");
mysql_query("INSERT INTO `advice_votes` (`id_advice`, `var`, `num`) VALUES ('$them[id]', '$vot2', '2')");
mysql_query("INSERT INTO `advice_votes` (`id_advice`, `var`, `num`) VALUES ('$them[id]', '$vot3', '3')");
mysql_query("INSERT INTO `advice_votes` (`id_advice`, `var`, `num`) VALUES ('$them[id]', '$vot4', '4')");
mysql_query("INSERT INTO `advice_votes` (`id_advice`, `var`, `num`) VALUES ('$them[id]', '$vot5', '5')");
mysql_query("UPDATE `advice` SET `vote` = '1' WHERE `id` = '$advice[id]' LIMIT 1");
header("location: ?id=$advice[id]");
}
}
err();
echo "<form method='post' action='?id=$advice[id]&add_vote'>";
echo "<b>Варианты ответов:</b><br/>";
echo "1.<input type='text' name='vot1' value='' /><font color='red'>*</font><br />n";
echo "2.<input type='text' name='vot2' value='' /><font color='red'>*</font><br />n";
echo "3.<input type='text' name='vot3' value='' /><br />n";
echo "4.<input type='text' name='vot4' value='' /><br />n";
echo "5.<input type='text' name='vot5' value='' /><br />n";
echo "<input value='Создать' type='submit' name='ok'/><br />n";
echo "</form>";
include_once '../../sys/inc/tfoot.php';
}
if (isset($_GET['who'])){
$advice = mysql_fetch_assoc(mysql_query("SELECT * FROM `advice` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `advice` WHERE `id` = '$advice[id]' LIMIT 1"),0)==0){header("Location: /index.php?".SID);exit;}
$set['title']='Кто оценил уведомление '.htmlspecialchars($advice['name']).'';
include_once '../../sys/inc/thead.php';
title();
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `advice_klass` WHERE `id_advice` = '$advice[id]'"), 0);
if ($k_post==0)msg("Это уведомление пока никому не понравилось");
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `advice_klass` WHERE `id_advice` = '$advice[id]' LIMIT $start, $set[p_str]");
while($us=mysql_fetch_assoc($q)){
echo "<div class='forum'>";
echo "".us($us['id_user'])."";
echo "</div>";
}
if ($k_page>1)str("?id=$advicel[id]&who&",$k_page,$page);
include_once '../../sys/inc/tfoot.php';
}
if ($user['level']>=4){
if (isset($_GET['new_advice'])){
$set['title']="Новое уведомление";
include_once '../../sys/inc/thead.php';
title();
if (isset($_POST['ok'])){
$msg=my_esc($_POST['msg']);
$name=my_esc($_POST['name']);
mysql_query("INSERT INTO `forums_thems` (`idforum`, `idrazdel`, `msg`, `id_user`, `name`, `time`) values('11', '39', '$msg', '$user[id]', '$name', '$time')");
$them=mysql_insert_id();
mysql_query("INSERT INTO `advice` (`id_them`, `msg`, `id_user`, `name`, `time`) values('$them', '$msg', '$user[id]', '$name', '$time')");
$id=mysql_insert_id();
mysql_query("UPDATE `user` SET `advice_read` = '0'");
header("location:?id=$id");
}
echo "<form method='post' action='?new_advice&$passgen'>";
echo "<b>Заголовок уведомления:</b><br/><input type='text' name='name' style='width:95%'>";
echo "<b>Содержимое уведомления:</b><br/><textarea name='msg'></textarea>";
echo "<input type='submit' name='ok' value='Уведомить пользователей' style='width:95%'></form>";
include_once '../../sys/inc/tfoot.php';
}
}
$advice = mysql_fetch_assoc(mysql_query("SELECT * FROM `advice` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `advice` WHERE `id` = '$advice[id]' LIMIT 1"),0)==0){header("Location: /index.php?".SID);exit;}
$set['title']="".htmlspecialchars($advice['name'])."";
include_once '../../sys/inc/thead.php';
title();
if (isset($_GET['klass']) && isset($user) && mysql_result(mysql_query("SELECT SUM(`klass`) FROM `advice_klass` WHERE `id_user` = '$user[id]' AND `id_advice` = '$advice[id]'"),0)!=1){
mysql_query("INSERT INTO `advice_klass` (`klass`, `id_advice`, `id_user`) VALUES ('1','$advice[id]','$user[id]')");
mysql_query("UPDATE `advice` SET `klass` = '".($advice['klass']+1)."' WHERE `id` = '$advice[id]' LIMIT 1");
}
echo "<div class='forum'>";
echo "".us($advice['id_user'])."";
echo "".vremja($advice['time'])."";
echo "</div>";
echo "<div class='forum'>".output_text($advice['msg'])."";
/*
$op=mysql_query("SELECT * FROM `advice_votes` WHERE `id_advice` = '$advice[id]' ORDER BY `id` ASC");
while ($vot = mysql_fetch_assoc($op)){
$zavse=mysql_result(mysql_query("SELECT COUNT(*) FROM `advice_vote` WHERE `id_advice` = '$advice[id]' ",$db), 0);
$zaet=mysql_result(mysql_query("SELECT COUNT(*) FROM `advice_vote` WHERE `id_advice` = '$advice[id]' AND `id_var` = '$vot[id]' ",$db), 0);
$prov=mysql_result(mysql_query("SELECT COUNT(*) FROM `advice_vote` WHERE `id_advice` = '$advice[id]' AND `id_user` = '$user[id]'",$db), 0);
if($zaet==0 || $zavse==0)$p=0;else $p=$zaet/$zavse*100;
$p = (int)$p;
if($vot['var']!=NULL){
echo "<a href='?id=$advice[id]&golos=$vot[id]'><div style='border-bottom:1px solid skyblue;background:whitesmokd;display:block;border-radius:4px;'><img src='img/vot.png' alt='!'> ".htmlspecialchars($vot['var'])." - $zaet<span style='color:darkblue;font-size:small;'> ($p%)</span></div></a>";
}
}
*/
echo "<table>";
echo "<td class='w'><a href='/forums/them.php?id=$advice[id_them]'><img src='/status/img/komm.png' alt='' /> Обсудить $komm</a></td>";
if (mysql_result(mysql_query("SELECT SUM(`klass`) FROM `advice_klass` WHERE `id_user` = '$user[id]' AND `id_advice` = '$advice[id]'"),0)!=1) echo "<td class='w'><a href='?id=$advice[id]&klass'><img src='/style/icons/like.png' alt='' /> Нравиться $advice[klass]</a></td>";
else
echo "<td class='w'><a href='?id=$advice[id]&who'> <img src='/style/icons/like.png' alt='' /> Понравилось $advice[klass] чел.</a></td>";
if ($user['level']>=4)echo "<td class='w'><a href='?delete=$advice[id]'> <img src='/style/icons/del.png' alt='' /> Удалить</a></td>";
echo "</table></div>";
echo "<a href='?all'><div class='gmenu'><img src='/style/glavnaya.gif'> Ко всем уведомлениям</div></a>";
include_once '../../sys/inc/tfoot.php';
?>