Файл: forum_top.php
Строк: 284
<?
define('PROTECTOR', 1);
$textl='Форум';
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
if(isset($_GET['del']))
{
if($udata['admin']==2 or $udata['id']==0)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
$chq=mysql_query("SELECT * FROM `forum_com` WHERE `id`='".$_GET['id']."'");
$chatqs=mysql_fetch_array($chq);
mysql_query("UPDATE `forum_com` SET `kom`='".mysql_real_escape_string($_POST['kom'])."', `del`='".$udata['id']."' WHERE `id`='".$chatqs['id']."'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
if(isset($_GET['vost']))
{
if($udata['admin']==2 or $udata['id']==0)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
$chq=mysql_query("SELECT * FROM `forum_com` WHERE `id`='".$_GET['id']."'");
$chatqs=mysql_fetch_array($chq);
mysql_query("UPDATE `forum_com` SET `kom`='', `del`='0' WHERE `id`='".$chatqs['id']."'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
if(isset($_GET['dell']))
{
if($udata['admin']<4)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
$chq=mysql_query("SELECT * FROM `forum_com` WHERE `id`='".$_GET['id']."'");
$chatqs=mysql_fetch_array($chq);
mysql_query("DELETE FROM `forum_com` WHERE `id`='".$chatqs['id']."'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
if(isset($_GET['save']))
{
$bans = mysql_query("SELECT * FROM `ban` WHERE `usr` = '".$udata['id']."' and `place`='2'");
$banq=mysql_num_rows($bans);
if($banq!=0)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
if($udata['lvl']<5)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
$cha=mysql_query("SELECT * FROM `forum_top` WHERE `id`='".$_GET['top']."'");
$chatq=mysql_fetch_array($cha);
if($chatq['close']==1)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}else
{
if($udata['admin']!=6)
{
$cm=mysql_query("SELECT * FROM `forum_com` WHERE `top`='".$chatq['id']."' ORDER BY `id` DESC LIMIT 1");
$com=mysql_fetch_array($cm);
if($com['usr']==$udata['id'])
{
mysql_query("INSERT INTO `user_log` SET `usr`='".$udata['id']."',
`text`='Вы неможете писать несколько смс подряд!'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
}
$time=time();
mysql_query("UPDATE `forum_top` SET `time`='".$time."' WHERE `id`='".$chatq['id']."'");
$text=nl2br($_POST['text']);
if($udata['admin']==6)
{
$text=html_entity_decode($text);
}
$data=date('d.m.Y H:i:s');
mysql_query("INSERT INTO `forum_com` SET
`id`='',
`usr`='".$udata['id']."',
`text`='".$text."',
`data`='".$data."',
`top`='".$chatq['id']."'
");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}}
}}
if(isset($_GET['kom_save']))
{
if($udata['admin']<3)
{}
else
{
$chatqs=mysql_fetch_array(mysql_query("SELECT * FROM `forum_com` WHERE `id`='".$_GET['id']."'"));
$test=nl2br($_POST['kom']);
if($udata['admin']>=5)
{
$test=html_entity_decode($test);
}
if($udata['admin']>0 and $udata['admin']<6)
{
$tr= '<img src=img/main/md.png> ';
}
elseif($udata['admin']>5)
{
$tr= '<img src=img/main/admin.png> ';
}
$t=''.$tr.' <img src=img/main/c'.$udata['klass'].'.png> <img src=img/main/r'.$udata['rasa'].'.png>
<a href=info.php?id='.$udata['id'].'>'.$udata['usr'].'</a>';
mysql_query("UPDATE `forum_com` SET
`kom`='<font color=#ff0000>Комментарий от: </font> ".$t."<br> <font color=ffff00>".$test."</font>'
WHERE `id`='".$chatqs['id']."'");
}
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
if(isset($_GET['close']))
{
if($udata['admin']==0 or $udata['andmin']==2)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
$cha=mysql_query("SELECT * FROM `forum_top` WHERE `id`='".$_GET['top']."'");
$chatq=mysql_fetch_array($cha);
mysql_query("UPDATE `forum_top` SET `close`='1' WHERE `id`='".$chatq['id']."'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
}
if(isset($_GET['open']))
{
if($udata['admin']==0 or $udata['andmin']==2)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
$cha=mysql_query("SELECT * FROM `forum_top` WHERE `id`='".$_GET['top']."'");
$chatq=mysql_fetch_array($cha);
mysql_query("UPDATE `forum_top` SET `close`='0' WHERE `id`='".$chatq['id']."'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
}
if(isset($_GET['pri']))
{
if($udata['admin']==0 or $udata['andmin']==2)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
$cha=mysql_query("SELECT * FROM `forum_top` WHERE `id`='".$_GET['top']."'");
$chatq=mysql_fetch_array($cha);
mysql_query("UPDATE `forum_top` SET `pri`='1' WHERE `id`='".$chatq['id']."'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
}
if(isset($_GET['otpri']))
{
if($udata['admin']==0 or $udata['andmin']==2)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
$cha=mysql_query("SELECT * FROM `forum_top` WHERE `id`='".$_GET['top']."'");
$chatq=mysql_fetch_array($cha);
mysql_query("UPDATE `forum_top` SET `pri`='0' WHERE `id`='".$chatq['id']."'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
}
if(isset($_GET['delest']))
{
if($udata['admin']<3)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
$cha=mysql_query("SELECT * FROM `forum_top` WHERE `id`='".$_GET['top']."'");
$chatq=mysql_fetch_array($cha);
mysql_query("DELETE FROM `forum_top` WHERE `id`='".$chatq['id']."'");
mysql_query("DELETE FROM `forum_com` WHERE `top`='".$chatq['id']."'");
header('location: forum.php');exit;
}
}
if(isset($_GET['edd']))
{
if($udata['admin']<5)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
$cha=mysql_query("SELECT * FROM `forum_top` WHERE `id`='".$_GET['top']."'");
$chatq=mysql_fetch_array($cha);
$test=nl2br($_POST['text']);
if($udata['admin']>=5)
{
$test=html_entity_decode($test);
}
$edd=nl2br($_POST['edd']);
if($udata['admin']>=5)
{
$edd=html_entity_decode($edd);
}
mysql_query("UPDATE `forum_top` SET `text`='".$test."', `edit`='".$udata['id']."', `edd`='".$edd."' WHERE `id`='".$chatq['id']."'");
header('location: ?top='.$_GET['top'].'');exit;
}
}
include($path.'files/head.php');
include($path.'files/zag.php');
$cha=mysql_query("SELECT * FROM `forum_top` WHERE `id`='".mysql_real_escape_string($_GET['top'])."'");
$ch=mysql_fetch_array($cha);
echo '<table width=100%>
<tr>
<td width=35%>
<a href=game.php><div style="background: #882222; border-radius: 7px 0 0 7px" class="m p bts bbs brs bls" align=center>Главная</div></a>
</td><td>';
echo '<a href=forum.php><div class="line bts brs bls bbs p m" style="border-radius: 0 7px 7px 0">
<font color=#ffffff>'.$ch['name'].'
</font>
</div></a></td></tr></table>';
echo '<div class="bat bts brs bls bbs p">';
$us =mysql_fetch_array( mysql_query("SELECT * FROM `users` WHERE `id` = '".$ch['usr']."' LIMIT 1"));
if($us['admin']>0 and $us['admin']<6)
{
echo '<img src=img/main/md.png> ';
}
elseif($us['admin']>5 )
{
echo '<img src=img/main/admin.png> ';
}
echo '<img src=img/main/c'.$us['klass'].'.png> <img src=img/main/r'.$us['rasa'].'.png>
<a href=info.php?id='.$us['id'].'>'.$us['usr'].'</a> <img src=img/main/p10.png>'.$us['lvl'].' | <font color=#009900>'.$ch['data'].'</font><br>
';
echo '<font color=#ff9900><b>'.$ch['text'].'</b></font><br>';
if($ch['edit']!=0)
{
echo '<div align=center>
<font color=#ff0000>Топ отредактирован: </font>';
$usx =mysql_fetch_array( mysql_query("SELECT * FROM `users` WHERE `id` = '".$ch['edit']."' LIMIT 1"));
if($usx['admin']>0 and $usx['admin']<6)
{
echo '<img src=img/main/md.png> ';
}
elseif($usx['admin']>5)
{
echo '<img src=img/main/admin.png> ';
}
echo '<img src=img/main/c'.$usx['klass'].'.png> <img src=img/main/r'.$usx['rasa'].'.png>
<a href=info.php?id='.$usx['id'].'>'.$usx['usr'].'</a> <font color=#ff0000>по причине: </font>
<font color=#ffff00>'.$ch['edd'].'</font>';
echo '</div>';
}
if(isset($_GET['edit']))
{
if($udata['admin']>4)
{
echo '<form action=?edd&top='.$ch['id'].' method=POST>
<textarea name=text rows="3" cols="20px">'.$ch['text'].'</textarea><br>
Причина:<br>
<input type=text name=edd><br>
<input type=submit value=сохранить class=line>
</form>';
}
}
if($udata['admin']==1 or $udata['admin']>2)
{
if($ch['pri']==0)
{
echo '<a href=?pri&top='.$ch['id'].'>прикрепить</a>';
}
if($ch['pri']!=0)
{
echo '<a href=?otpri&top='.$ch['id'].'>открепить</a>';
}
}
if($udata['admin']==1 or $udata['admin']>2)
{
if($ch['close']==0)
{
echo ' | <a href=?close&top='.$ch['id'].'>закрыть</a>';
}
if($ch['close']!=0)
{
echo ' | <a href=?open&top='.$ch['id'].'>открыть</a>';
}
}
if($udata['admin']>2)
{
echo ' | <a href=?delest&top='.$ch['id'].'>удалить</a>';
}
if($udata['admin']>4)
{
echo ' | <a href=?edit&top='.$ch['id'].'>редактировать</a>';
}
echo '</div></div><div class="v8">';
echo '<div class="line bbs p m bts brs bls">';
echo 'Коментарии
</div>';
echo '<div class="bat bts brs bls bbs p">';
if($udata['lvl']<5)
{
echo '<div align=center><font color=#ff0000>Оставлять тут сообщения, доступно с 5 уровня!</font></div>';
}
$bans = mysql_query("SELECT * FROM `ban` WHERE `usr` = '".$udata['id']."' and `place`='2'");
$banq=mysql_num_rows($bans);
if($banq!=0)
{
echo '<div align=center><font color=#ff0000>У вас бан форума! Вы не можете тут писать!</font></div>';
}
if($ch['close']==1)
{
echo '<div align=center><font color=#ff0000>Топ закрыт</font></div>';
}
function smiles($string){
$dir = opendir ("img/smiles");
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2:",'<img src="img/smiles/'.$file.'" alt="">',$string);
}}
closedir ($dir);
return $string; }
if ($_GET['page'] == "" || $_GET['page'] < 0 || $_GET['page'] == "0")
{
$_GET['page'] = 0;
}
$next = $_GET['page'] + 1;
$back = $_GET['page'] - 1;
$num = $_GET['page'] * 10;
if($_GET['page'] == "0")
{$i = 1;}
else{$i = ($_GET['page']*10)+1;}
$viso = mysql_num_rows(mysql_query("SELECT * FROM forum_com"));
$puslap = floor($viso/10);
$chq=mysql_query("SELECT * FROM `forum_com` WHERE `top`='".$ch['id']."' ORDER BY `id` DESC LIMIT $num,10");
while($chatqs=mysql_fetch_array($chq))
{
$chatqs['text'] = smiles($chatqs['text']);
$us =mysql_fetch_array( mysql_query("SELECT * FROM `users` WHERE `id` = '".$chatqs['usr']."' LIMIT 1"));
if($chatqs['usr']==1)
{
$us['admin']=0;
$us['usr']='Хранитель Ветров';
$us['id']=2;
$col='#78ccf0';
}
if($us['admin']>0 and $us['admin']<6)
{
echo '<img src=img/main/md.png> ';
}
elseif($us['admin']>5)
{
echo '<img src=img/main/admin.png> ';
}
echo '<img src=img/main/c'.$us['klass'].'.png> <img src=img/main/r'.$us['rasa'].'.png>
<font color=#ff9900><a href=info.php?id='.$us['id'].'>'.$us['usr'].'</a></font> | ';
echo ' <font color=#008800>'.$chatqs['data'].'</font><br>';
if($us['admin']>0 and $us['admin']<6)
{
$col='#00ee00';
}
elseif($us['admin']==0)
{
$col='#ffffff';
}
elseif($us['admin']==6)
{
$col='#ffff00';
}
if($chatqs['del']==0)
{
echo '<font color='.$col.'>'.$chatqs['text'].'</font><br>';
if($chatqs['kom']!='')
{
echo '<div align=center>'.$chatqs['kom'].'</div>';
}
if(isset($_GET['delas']))
{
if($udata['admin']==0 or $udata['admin']==2)
{}
else
{
if($chatqs['id']==$_GET['id'])
{
echo '
<form action=forum_top.php?del&top='.$chatq['id'].'&id='.$_GET['id'].' method=POST>
<input type=text name=kom><br>
<input type=submit value=удалить class=line>
</form>
';
}
}
}
if(isset($_GET['komas']))
{
if($udata['admin']<3)
{}
else
{
if($chatqs['id']==$_GET['id'])
{
echo '
<form action=forum_top.php?kom_save&top='.$chatq['id'].'&id='.$_GET['id'].' method=POST>
<input type=text name=kom><br>
<input type=submit value=сохранить class=line>
</form>
';
}
}
}
if($chatqs['kom']!=0)
{
echo '<div align=center>'.$chatqs['kom'].'</div>';
}
if($udata['admin']==1 or $udata['admin']>2)
{
echo '<a href=?delas&id='.$chatqs['id'].'&top='.$ch['id'].'>уд.</a>';
echo ' | <a href=?komas&id='.$chatqs['id'].'&top='.$ch['id'].'>коментировать</a>';
}
if($udata['admin']>3)
{
echo ' | <a href=?dell&id='.$chatqs['id'].'&top='.$ch['id'].'>удалить совсем</a>';
}
}
else
{
$usersz=mysql_query("SELECT * FROM `users` WHERE `id`='".$chatqs['del']."'");
$usz=mysql_fetch_array($usersz);
if($usz['admin']>0 and $us['admin']<6)
{
$md= '<img src=img/main/md.png> ';
}
elseif($usz['admin']>5)
{
$md= '<img src=img/main/admin.png> ';
}
echo '<div align=center><font color=#ff0000>комментарий удалён</font> '.$md.'
<img src=img/main/c'.$usz['klass'].'.png> <img src=img/main/r'.$usz['rasa'].'.png>
<a href=info.php?id='.$usz['id'].'>'.$usz['usr'].'</a> <font color=#ff0000>по причине:</font><br>
<font color=#ffff00>'.$chatqs['kom'].'</font>
</div>';
if($udata['admin']>3)
{
echo '<font color=#888888>('.$chatqs['text'].')</font><br>';
echo '<a href=?dell&id='.$chatqs['id'].'&top='.$ch['id'].'>удалить совсем</a>';
echo ' | <a href=?vost&id='.$chatqs['id'].'&top='.$ch['id'].'>востановить</a>';
}
}
echo '<hr>';
}
$kol_us=mysql_num_rows(mysql_query("SELECT * FROM `forum_com` WHERE `top`='".$ch['id']."'"));
$pag=ceil($kol_us/10);
$m_p=$_GET['page']-2;
$mx_p=$_GET['page']+6;
echo '<table width=100%><tr>';
for($k=0; $k<=$pag; $k++)
{
if($k>=$m_p and $k<=$mx_p and $k>0)
{
$i=$k-1;
if($_GET['page']==''){$_GET['page']=0;}
if($_GET['page']!=$i)
{
echo '<td><a href=?top='.$_GET['top'].'&page='.$i.'><div style="background: #000044; padding: 3px; margin-top: 3px;" class="bts bbs brs bls" align=center>'.$k.'</div></a></td>';
}
else
{
echo '<td><a href=?top='.$_GET['top'].'&page='.$i.'><div style="background: #044440; padding: 3px; margin-top: 3px;" class="bts bbs brs bls" align=center>'.$k.'</div></a></td>';
}
}
}
echo'</tr></table>';
if($ch['close']!=1)
{
if($udata['lvl']>4)
{
$bans = mysql_query("SELECT * FROM `ban` WHERE `usr` = '".$udata['id']."' and `place`='2'");
$banq=mysql_num_rows($bans);
if($banq==0)
{
echo '<br>
<form action=forum_top.php?save&top='.$ch['id'].' method=POST>
<center><textarea name=text rows="3" style="width: 85%"></textarea><br>
<input type=submit value=Отправить></center>
</form>
';
}}
}
echo '</div></div>';
include($path.'files/down.php');
?>