Файл: playtox.tk/forum/topic.php
Строк: 120
<?php
define('PROTECTOR', 1);
$head = 'forum';//фикс. места
$path = '../'; //путь
$textl = 'Форум';
@include($path.'files/db.php');
@include($path.'files/auth.php');
@include($path.'files/func.php');
@include($path . 'files/core.php');
@include('head.php');
//если бан
$req = mysql_query("SELECT * FROM `ban` WHERE `usr` = '$log' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($req);
if ($avto == 1) {
$ban = mysql_fetch_array($req);
echo"$div <font color='red'> Ваш персонаж забанен! Доступ на форум закрыт!<br> Осталось: ";
$ban[ban_time]=$ban[ban_time]-time();
if($ban[ban_time]<60){
echo "$ban[ban_time] сек.</font>";
}elseif($ban[ban_time]>60 and $ban[ban_time]<3600){
$ban[ban_time]=round($ban[ban_time]/60);
echo "$ban[ban_time] мин.<br>";
}elseif($ban[ban_time]>3600 and $ban[ban_time]<86400){
$ban[ban_time]=round($ban[ban_time]/3600);
echo "$ban[ban_time] часов.<br>";}
else{
$ban[ban_time]=round($ban[ban_time]/86400);
echo "$ban[ban_time] суток.<br>";
}
echo "Забанил: $ban[admin]</br></font>";
include($path.'files/end.php');exit;}
//конец бана
echo'<div class="menu">';
$id = intval($_GET['id']);
$topic = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_topics` WHERE `id` = '$id'"));
if(isset($topic['id'])){
echo '<b>'.$topic['title'].'</b><br/>';
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_msg` WHERE `id_topic` = '$id'"), 0);
if($count > 0){
$pages = ceil($count/10);
if(isset($_GET['page'])){
$page = abs(intval($_GET['page']));
}else{
$page = 1;
}
$from = ($page-1)*10;
//start
function smiles($msg){
$dir = opendir ("../pic/smiles");
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$msg=str_replace(":$file2",'<img src="../pic/smiles/'.$file.'" alt="">',$msg);
}}
closedir ($dir);
return $msg; }
//end
//bb
function AddBB($var) {
$search = array(
'/[b](.*?)[/b]/is',
'/[i](.*?)[/i]/is',
'/[adm](.*?)[/adm]/is',
'/[u](.*?)[/u]/is',
'/[url](.*?)[/url]/is',
'/[url=(.*?)](.*?)[/url]/is'
);
$replace = array(
'<strong>$1</strong>',
'<em>$1</em>',
'<font color="red">$1</font>',
'<u>$1</u>',
'<a href="$1">$1</a>',
'<a href="$1">$2</a>'
);
$var = preg_replace ($search, $replace, $var);
return $var;
}
//
$result = mysql_query("SELECT * FROM `forum_msg` WHERE `id_topic` = '$id' ORDER BY `time` LIMIT $from, 10");
while($msg = mysql_fetch_assoc($result)){
if(!isset($num)) $num = 1;
$num++;
////////////////////////////
$laikas = 150;
$dabar = time();
$timeout = $dabar - $laikas;
$asd = mysql_num_rows(mysql_query("SELECT laikas, usr FROM online WHERE laikas > '$timeout' AND usr='$msg[login]'"));
if($asd == 0){
$status = "<font color='red'>Off </font>"; }
else
{
$status = "<font color='green'>On </font>"; }
echo $status;$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$msg[login]'");
$usdata = mysql_fetch_array($req);
if($usdata[prava]=="5"){$im=adm;$color=ff5445;}
if($usdata[prava]=="3"){$im=mod3;$color=DA70D6;}
if($usdata[prava]=="2"){$im=mod;$color=a5ff30;}
if($usdata[prava]=="0"){$im=gam;$color=f1d99a;}
echo '<a href="../search.php?nick='.$msg['login'].'&go=go">'; echo "<font color='$color'> ".$msg['login']."</a></b></font> ";
echo "<img src='../pic/main/status/$usdata[pol]$im.png' alt='*'/> ";
echo '<i>' .date('d.m.Y / H:i', $msg['time']).'</i>';
echo ' [<a href="posting.php?act=answer&id='.$msg['id'].'&page='.$pages.'">отв</a>]';
if($msg['login'] == $log or $udata['prava'] > 1){
if($msg['time']+900 > time() or $udata['prava'] > 1){
echo ' (<a href="posting.php?act=msg_edit&id='.$msg['id'].'">ред</a>)';
echo ' (<a href="posting.php?act=msg_del&id='.$msg['id'].'&page='.$page.'">удал.</a>)';
}
}
echo '<br/>'.smiles(AddBB(htmlspecialchars_decode(html_entity_decode($msg['text'])))).'<br/><hr>';
if(!empty($msg['edit_login']) && !empty($msg['edit_time'])){
echo '_____<br/><i><font color="#999999">посл. ред.: '.date('d.m.y / H:i', $msg['edit_time']).'</font></i><br/>';
}
}
}
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_msg` WHERE `id_topic` = '$id'"), 0);
echo '<a href="../smile.php?">Смайлы</a>|';
if($topic['authour'] == $log or $udata['prava'] > 1){
if($topic['closed'] == 0){
echo '<div><a href="posting.php?act=topic_close&id='.$id.'">Закр</a>|';
}
}
if($udata['prava'] > 1){
if($topic['closed'] == 1){
echo '<div><a href="posting.php?act=topic_open&id='.$id.'">Откр</a>|';
}
}
if($topic['authour'] == $log or $udata['prava'] > 1){
if($topic['closed'] == 0 or $udata['prava'] > 1){
echo '<a href="posting.php?act=topic_edit&id='.$id.'">Ред</a>';
}
}
if($udata['prava'] > 1){
echo '|<a href="posting.php?act=topic_del&id='.$id.'">Удал</a>';
}
if($topic['authour'] == $log or $udata['prava'] > 1){
echo '</div>';
}
navig($page, 'topic.php?id='.$id.'&', $pages);
if($topic['closed'] == 0){
echo 'Добавить сообщение:<br/>';
echo '<form action="posting.php?act=msg_add&id='.$topic['id'].'&page='.$page.'" method="post" name="form">';
echo '<textarea name="text" rows="3"></textarea><br/>';
echo '<input name="submit" type="submit" value="Добавить" /></form>';
}else{
echo 'Вы не можете добавить сообщение, т.к. тема закрыта!<br/><br/>';
}
}else{
echo'Выбранной темы не существует!';
}
echo'</div><div class="m_bg">';
echo '<a href="./">Форум</a><br/><a href="../">Главная</a></div>';
echo'</div>';
include($path . 'files/end.php');
?>