Файл: library.php
Строк: 359
<?php
include 'inc/mysql.php';
include 'inc/check.php';
include ("inc/gzip.php");
if(isset($_SESSION['auth']) && $_SESSION['auth']==1){
include 'inc/shapka.php';
switch($_GET[go]){
default:
echo'<img src="/pic/main/name.png" alt="*"/> ';
echo'Здесь ты найдешь ответы на вопросы по игре...';
echo'<br>';
$qi = mysql_query("SELECT * FROM `library_forum` ORDER by `id` ASC");
$avto=mysql_num_rows($qi);
if($avto>=1){
while($row=mysql_fetch_array($qi))
{
$u=mysql_query("SELECT * FROM `library_forum_topik` WHERE `razdel`='$row[id]' ORDER by `id` DESC");
$dat=mysql_fetch_array($u);
$uids=$dat[tema];
$u2=mysql_query("SELECT * FROM `library_forum_msg` WHERE `topik`='$row[id]' and `tema`='$dat[id]' ORDER by `id` DESC");
$dat2=mysql_fetch_array($u2);
$uids2=$dat2[user];
$req1 = mysql_query("SELECT `id`,`status`,`login`,`sex` FROM `account` WHERE `id` = '$uids2'");
$_user = mysql_fetch_array($req1);
echo'<div class="ssl">';
echo"<a href="library.php?go=theme&id=$row[id]">  <img src="pic/library/$row[img]"> $row[name] ($row[tem])</a></div>";
}}else{
echo'<br><img src="/pic/main/!.png" alt="*"/> Нет разделов...<br>';
}
$kolic = mysql_query("SELECT COUNT(`id`) FROM `library_forum_msg`WHERE `user`='".intval($_GET['id'])."' ");
$kols = mysql_result($kolic, 0);
echo'<br><div class="ssl">';echo"<a href="library.php?go=admin">  <img src="pic/main/dr.png"> Администрация</a></div>";
echo'<div class="ssl">';echo"<a href="mails.php?act=mesg&user=1">  <img src="pic/main/otvet_podderjka.png"> Служба поддержки</a></div>";
echo'<div class="ssl">';echo"<a href="zakonu.php">  <img src="pic/main/forumtext.gif"> Правила игры</a></div>";
if($account['status']=="gm"){
echo "<br>- <a href="library.php?go=razdel">Создать раздел</a>";
echo "<br>- <a href="library.php?go=new">Создать статью</a><br>";
}
break;
case 'admin':
echo '<u>Администраторы:</u><br>';
$req = mysql_query("SELECT * FROM `account` WHERE `status`='gm' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req))
{
$w=explode("*",$mag[id]);
$req = mysql_query("SELECT `status`,`sex`,`login`,`id`,`last_active` FROM `account` WHERE `id` = '$mag[id]'");
$pic = mysql_fetch_array($req);
if($pic['status']=="gm"){
$nik = gradient(''.$pic[login].'','00FF00', '00CC00');
echo '<us><img src="pic/main/'.$pic[sex].'.png" alt="*"/><a href="infa.php?id='.$pic['id'].'"> '.$nik.'</us></a>';
$d = time()-7000;
if($pic[last_active]<$d){echo" - <font color=red>Off</font><br>";
}else{
echo" - <font color=lime>On</font><br>";
}
}}}else{
echo '<img src="pic/main/!.png" alt="*"/> Нет администраторов!<br>';
}
echo '<br>';
echo '<u>Модераторы:</u><br>';
$req = mysql_query("SELECT * FROM `account` WHERE `status`='moder' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req))
{
$w=explode("*",$mag[id]);
$req = mysql_query("SELECT `status`,`sex`,`login`,`id`,`last_active` FROM `account` WHERE `id` = '$mag[id]'");
$pic = mysql_fetch_array($req);
if($pic['status']=="moder"){
$nik = gradient(''.$pic[login].'','0066CC', 'AB82FF');
echo '<us><img src="pic/main/'.$pic[sex].'.png" alt="*"/><a href="infa.php?id='.$pic['id'].'"> '.$nik.'</us></a>';
$d = time()-7000;
if($pic[last_active]<$d){echo" - <font color=red>Off</font>";
}else{
echo" - <font color=lime>On</font>";
}
echo" (<a href="mails.php?act=mesg&user=$pic[id]">Написать сообщение</a>)<br>";
}}}else{
echo '<img src="pic/main/!.png" alt="*"/> Нет модераторов!<br>';
}
echo '<br>';
echo '<u>Системный робот:</u><br>';
$req = mysql_query("SELECT * FROM `account` WHERE `status`='bot' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req))
{
$w=explode("*",$mag[id]);
$req = mysql_query("SELECT `status`,`sex`,`login`,`id`,`last_active` FROM `account` WHERE `id` = '$mag[id]'");
$pic = mysql_fetch_array($req);
if($pic['status']=="bot"){
$nik = gradient(''.$pic[login].'','FFCC00', 'FF9933');
echo '<us><img src="pic/main/'.$pic[sex].'.png" alt="*"/><a href="infa.php?id='.$pic['id'].'"> '.$nik.'</us></a>';
$d = time()-7000;
if($pic[last_active]<$d){echo" - <font color=red>Off</font>";
}else{
echo" - <font color=lime>On</font>";
}
}}}else{
echo '<img src="pic/main/!.png" alt="*"/> Нет системных роботов!<br>';
}
echo'<div class="ssl">';
echo '<a class="navi" href="library.php?">  <img src="/pic/main/rotate.png" alt="*"/> Об игре</a></div>';
break;
case 'post':
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum` WHERE `id`='".intval($_GET['id'])."'"));
$topik=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum_topik` WHERE `id`='".intval($_GET['topik'])."'"));
$g=mysql_query("SELECT * FROM `library_forum_topik` WHERE `razdel`='$forum[id]' AND `id`='$topik[id]' and `status2`='on' LIMIT 1");
if(mysql_num_rows($g)==1){
$cop=10;
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `library_forum_msg` WHERE `topik`='$forum[id]' AND `tema`='$topik[id]' and `status2`='on' "),0);
$cp=ceil($ca/$cop);
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page = $_GET['page'];
if($_GET['page']>$cp) $page=$cp;
if($_GET['page']<1)$page=1;
}else{
$page=1;
}
$start=$page*$cop-$cop;
$dlist = 'list1';
$qi = mysql_query("SELECT * FROM `library_forum_msg` WHERE `topik`='$forum[id]' AND `tema`='$topik[id]' and `status2`='on' ORDER by `id` DESC LIMIT $start,$cop");
while($row=mysql_fetch_array($qi))
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$req = mysql_query("SELECT * FROM `library_golos` WHERE `account`='$account[id]' and `ids`='$forum[id]' and `topik`='$topik[id]' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto==0){
mysql_query("UPDATE `library_forum_topik` SET `proc`=`proc` + '1' WHERE `id`='$topik[id]'");
mysql_query("INSERT INTO `library_golos` SET `account` = '$account[id]', `ids` = '$forum[id]', `topik` = '$topik[id]'");
header('Location: library.php?go=post&id='.$forum[id].'&topik='.$topik[id].''); exit;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Голоса за топик
if($_GET['mod']=='up_minus'){
$req = mysql_query("SELECT * FROM `library_rating` WHERE `account`='$account[id]' and `ids`='$forum[id]' and `topik`='$topik[id]' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto==0){
mysql_query("UPDATE `library_forum_topik` SET `rating_minus`=`rating_minus` + '0.1' WHERE `id`='$topik[id]'");
mysql_query("INSERT INTO `library_rating` SET `account` = '$account[id]', `ids` = '$forum[id]', `topik` = '$topik[id]'");
mysql_query("INSERT INTO `forum_rating` SET `account` = '$account[id]', `ids` = '$forum[id]', `topik` = '$topik[id]'");
header('Location: library.php?go=post&id='.$forum[id].'&topik='.$topik[id].''); exit;
}else{
header('Location: library.php?go=post&id='.$forum[id].'&topik='.$topik[id].''); exit;
}
}
if($_GET['mod']=='up_plus'){
$req = mysql_query("SELECT * FROM `library_rating` WHERE `account`='$account[id]' and `ids`='$forum[id]' and `topik`='$topik[id]' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto==0){
mysql_query("UPDATE `library_forum_topik` SET `rating_plus`=`rating_plus` + '0.1' WHERE `id`='$topik[id]'");
mysql_query("INSERT INTO `library_rating` SET `account` = '$account[id]', `ids` = '$forum[id]', `topik` = '$topik[id]'");
header('Location: library.php?go=post&id='.$forum[id].'&topik='.$topik[id].''); exit;
}else{
header('Location: library.php?go=post&id='.$forum[id].'&topik='.$topik[id].''); exit;
}
}
echo "<img src="pic/library/forum.png"><a href="library.php">Помощь</a> / <a href="library.php?go=theme&id=$forum[id]">$forum[name]</a> / "; echo '<b>'.$topik[tema].'</b> (Дата изменения: <img src="/pic/main/timeniz.png" alt="*"/>'.$row[time].' | Автор: ';
$req1 = mysql_query("SELECT `id`,`status`,`login`,`sex` FROM `account` WHERE `id` = '".$row['user']."'");
$_user = mysql_fetch_array($req1);
if($_user['status']=="gm"){
$nik = gradient(''.$_user[login].'','00FF00', '00CC00');
echo '<img src="pic/main/'.$_user[sex].'.png" alt="*"/> '.$nik.' <a href="infa.php?id='.$_user['id'].'"><img src="/pic/main/info.gif" alt="*"/></a> | ';
}else{
if($_user['status']=="moder"){
$nik = gradient(''.$_user[login].'','0066CC', 'AB82FF');
echo '<img src="pic/main/'.$_user[sex].'.png" alt="*"/> '.$nik.' <a href="infa.php?id='.$_user['id'].'"><img src="/pic/main/info.gif" alt="*"/></a> | ';
}else{
if($_user['status']=="bot"){
$nik = gradient(''.$_user[login].'','FFCC00', 'FF9933');
echo '<img src="pic/main/'.$_user[sex].'.png" alt="*"/> '.$nik.' <a href="infa.php?id='.$_user['id'].'"><img src="/pic/main/info.gif" alt="*"/></a> | ';
}else{
echo '
<img src="pic/main/'.$_user[sex].'.png" alt="*"/> '.$_user['login'].' <a href="infa.php?id='.$_user['id'].'"><img src="/pic/main/info.gif" alt="*"/></a> | ';
}}}
echo 'ID статьи: '.$topik[id].' ';
if($account['status']=="gm"){
echo '(<a href="library.php?go=redakt_text&ids='.$forum[id].'&topik='.$topik[id].'">Red.</a>)';
}
echo ' | Прочитано: '.$topik[proc].' | Рейтинг: <a href="library.php?go=post&mod=up_plus&id='.$forum[id].'&topik='.$topik[id].'"><img src="/pic/main/oke.png" alt="*"/></a> <font color=lime>'.$topik[rating_plus].'</font> <a href="library.php?go=post&mod=up_minus&id='.$forum[id].'&topik='.$topik[id].'"><img src="/pic/main/nou.png" alt="*"/></a> <font color=red>'.$topik[rating_minus].'</font>)<br>';
$koment = strip_tags($row['msg']);
$koment = smiles(tags($koment));
echo '<br>';
echo bb($koment);
echo '<hr>';
}
echo '
<center>
Навигация:
';if($page-1>0){
echo '<a href="library.php?go=post&id='.$forum[id].'&topik='.$topik[id].'&page='.($page-1).'"><</a> ';
}
if($page-1>0){
echo ' <a href="library.php?go=post&id='.$forum[id].'&topik='.$topik[id].'&page='.($page-1).'">'.($page-1).'</a> ';
}
echo '<b>'.$page.'</b>';
if($page+1<=$cp){
echo ' <a href="library.php?go=post&id='.$forum[id].'&topik='.$topik[id].'&page='.($page+1).'">'.($page+1).'</a> ';
}
if($page+1<=$cp){
echo ' <a href="library.php?go=post&id='.$forum[id].'&topik='.$topik[id].'&page='.($page+1).'">></a> ';
}
echo '</center>';
}
break;
case 'theme':
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `library_forum` WHERE `id`='".intval($_GET['id'])."'"),0)){
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum` WHERE `id`='".intval($_GET['id'])."'"));
}else{
header('Location: library.php?');
exit;
}
echo "<img src="pic/library/forum.png"><a href="library.php">Помощь</a> / $forum[name]<br>";
$cop=10;
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `library_forum_topik` WHERE `razdel`='$forum[id]' and `status2`='on' "),0);
$cp=ceil($ca/$cop);
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page = $_GET['page'];
if($_GET['page']>$cp) $page=$cp;
if($_GET['page']<1)$page=1;
}else{
$page=1;
}
$start=$page*$cop-$cop;
$dlist = 'list1';
$req = mysql_query("SELECT * FROM `library_forum_topik` WHERE `razdel`='$forum[id]' and `status2`='on' ORDER by `lvl` DESC LIMIT $start,$cop ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req))
{
$w=explode("*",$mag[name]);
echo"<img src="pic/main/forum_2.png"> <a href="library.php?go=post&id=$forum[id]&topik=$mag[id]">$mag[tema]</a> ($mag[time])";
if($_GET['gos']=='delete' && ($account['status']=="gm")){
if(isset($_GET['ids'])){
$del = $_GET['ids'];
}
if($del){
mysql_query("DELETE FROM `library_forum_msg` WHERE `tema`='".$del."'");
mysql_query("DELETE FROM `library_forum_topik` WHERE `id`='".$del."'");
mysql_query("DELETE FROM `library_rating` WHERE `topik`='".$del."'");
mysql_query("DELETE FROM `library_golos` WHERE `topik`='".$del."'");
mysql_query("UPDATE `library_forum` SET `tem`=`tem` - '1' WHERE `id`='$forum[id]'");
header('Location: library.php?go=theme&id='.$forum[id].''); exit;
}else{
header('Location: library.php?go=theme&id='.$forum[id].''); exit;
}}
if ($account['status']=='gm'){
echo ' (<img src='pic/main/up.png'> '.$mag[lvl].' <a href="library.php?go=up&id='.$forum[id].'&ids='.$mag[id].'">Up.</a>) (<a href="library.php?go=redakt&ids='.$forum[id].'&topik='.$mag[id].'">Red.</a>) (<a href="library.php?go=theme&gos=delete&id='.$forum[id].'&ids='.$mag[id].'">Del.</a>)';
}
echo ' <br>';
}
echo '
<hr>
<center>
Навигация:
';if($page-1>0){
echo ' <a href="library.php?go=theme&id='.$forum[id].'&page='.($page-1).'"><</a> ';
}
if($page-1>0){
echo ' <a href="library.php?go=theme&id='.$forum[id].'&page='.($page-1).'">'.($page-1).'</a> ';
}
echo '<b>'.$page.'</b>';
if($page+1<=$cp){
echo ' <a href="library.php?go=theme&id='.$forum[id].'&page='.($page+1).'">'.($page+1).'</a> ';
}
if($page+1<=$cp){
echo ' <a href="library.php?go=theme&id='.$forum[id].'&page='.($page+1).'">></a> ';
}
echo '</center>';
}else{echo "<img src="pic/main/!.png"> В данном разделе пока нет статей.<br>";}
break;
case 'razdel':
if($account['status']=="gm"){
if(empty($_POST[name])){
echo "<form action="library.php?go=razdel" method="post">";
echo"Название раздела:<br><input class='input' type="text" size="25" name="name" maxlength="25"/><br/>";
echo"Картинка к разделу:<br><input class='input' type="text" size="25" name="img" maxlength="25"/><br/>";
echo '<input class="button" type="submit" value="Создать" /></form>';
echo'<div class="ssl">';
echo '<a class="navi" href="library.php">  <img src="/pic/main/rotate.png" alt="*"/> Вернуться</a></div>';
}else{
mysql_query("INSERT INTO `library_forum` SET `name` = '".mysql_real_escape_string($_POST['name'])."', `img` = '".mysql_real_escape_string($_POST['img'])."'");
header ("Location: library.php"); exit;
}
}else{
header ("Location: library.php"); exit;
}
break;
case 'new':
if($account['status']=="gm"){
if(empty($_POST[nazva]) or empty($_POST[msg])){
echo '<form name="form" action="library.php?go=new" method="post">';
echo "Название статьи:<br>";
echo "<input class="button" name="nazva" maxlength="50" title="Название темы" emptyok="true"/>";
echo "<br>Категория:<br>";
echo"<select name="kategory">
<option value="1">Вопросы новичков</option>
<option value="2">Функционал игры</option>
<option value="3">Игровое общение</option>
<option value="4">Игровые конкурсы</option>
<option value="5">Банды</option>
<option value="6">Разное</option>
</select>";
echo "<br>Текст:<br/>";
echo '<textarea name="msg" cols="20" rows="3"></textarea>
<br><input type="submit" class="submit" value="Создать">
</form>';
}else{
$nazva=htmlspecialchars($_POST[nazva]);
$msg=htmlspecialchars($_POST[msg]);
$time = date("d.m.y в H:i:s");
mysql_query("INSERT INTO `library_forum_topik` SET `razdel` = '".mysql_real_escape_string($_POST['kategory'])."',`tema` = '$nazva',`user` = '$account[id]',`status2` = 'on',`time` = '$time' ");
mysql_query("UPDATE `library_forum` SET `tem`=`tem` + '1' WHERE `id`='".intval($_POST['kategory'])."'");
$u=mysql_query("SELECT * FROM `library_forum_topik` ORDER by `id` DESC");
$dat=mysql_fetch_array($u);
$uids=$dat[id];
include ("inc/antireklama.php");
mysql_query("INSERT INTO `library_forum_msg` SET `topik` = '".mysql_real_escape_string($_POST['kategory'])."',`tema`='$uids',`msg` = '$msg',`user` = '$account[id]',`time` = '$time ',`status2` = 'on' ");
echo'<img src="/pic/main/!.png" alt="*"/> Статья добавлена';
}
echo'<div class="ssl">';
echo '<a class="navi" href="library.php">  <img src="/pic/main/rotate.png" alt="*"/> Вернуться</a></div>';
}else{header ("Location: library.php"); exit;}
break;
case 'up':
if($account['status']=="gm"){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `library_forum_topik` WHERE `status2`='on' and `id`='".intval($_GET['ids'])."'"),0)){
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum_topik` WHERE `status2`='on' and `id`='".intval($_GET['ids'])."'"));
}else{
header('Location: library.php?');
exit;
}
$topik=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum_topik` WHERE `id`='".intval($_GET['ids'])."'"));
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum` WHERE `id`='".intval($_GET['id'])."'"));
mysql_query("UPDATE `library_forum_topik` SET `lvl`=`lvl` + '1' WHERE `id`='".intval($_GET['ids'])."'");
header('Location: library.php?go=theme&id='.$forum[id].'');
}else{
header ("Location: library.php"); exit;
}
break;
case 'redakt':
if($account['status']=="gm"){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `library_forum_topik` WHERE `status2`='on' and `id`='".intval($_GET['topik'])."'"),0)){
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum_topik` WHERE `status2`='on' and `id`='".intval($_GET['topik'])."'"));
}else{
header('Location: library.php?');
exit;
}
$topik=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum_topik` WHERE `id`='".intval($_GET['topik'])."'"));
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum` WHERE `id`='".intval($_GET['ids'])."'"));
if(empty($_POST[tema])){
echo 'Название статьи:<br>';
echo '<form action="library.php?go=redakt&id2='.intval($forum['id']).'&topik='.intval($_GET['topik']).'&id='.intval($_GET['topik']).'" method="post">';
echo '<textarea name="tema" cols="30" rows="1">'.$topik[tema].'</textarea>';
echo '<br><input class="button" type="submit" value="Сохранить" /></form>';
}else{
$msg=htmlspecialchars($_POST[tema]);
$time = date("d.m.y в H:i:s");
mysql_query("UPDATE `library_forum_topik` SET `tema`='$msg', `time` = '$time' WHERE `id`='".intval($_GET['topik'])."'");
header('Location: library.php?go=post&id='.intval($_GET['id2']).'&topik='.$topik[id].'');
}
}else{
header ("Location: library.php"); exit;
}
break;
case 'redakt_text':
if($account['status']=="gm"){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `library_forum_msg` WHERE `status2`='on' and `id`='".intval($_GET['topik'])."'"),0)){
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum_msg` WHERE `status2`='on' and `id`='".intval($_GET['topik'])."'"));
}else{
header('Location: library.php?');
exit;
}
$topik=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum_msg` WHERE `id`='".intval($_GET['topik'])."'"));
$forum=mysql_fetch_assoc(mysql_query("SELECT * FROM `library_forum` WHERE `id`='".intval($_GET['ids'])."'"));
if(empty($_POST[msg])){
echo 'Текст статьи:<br>';
echo '<form action="library.php?go=redakt_text&id2='.intval($forum['id']).'&topik='.intval($_GET['topik']).'&id='.intval($_GET['topik']).'" method="post">';
echo '<textarea name="msg" cols="30" rows="1">'.$topik[msg].'</textarea>';
echo '<br><input class="button" type="submit" value="Сохранить" /></form>';
}else{
$msg=htmlspecialchars($_POST[msg]);
$time = date("d.m.y в H:i:s");
mysql_query("UPDATE `library_forum_msg` SET `msg`='$msg', `time` = '$time' WHERE `id`='".intval($_GET['topik'])."' and `tema`='".intval($_GET['topik'])."'");
header('Location: library.php?go=post&id='.intval($_GET['id2']).'&topik='.$topik[id].'');
}
}else{
header ("Location: library.php"); exit;
}
}
}else{
header ("Location: index.php"); exit;
}
include 'inc/nogi.php';
?>