Файл: forum/topic.php
Строк: 64
<?php
define('PROTECTOR', 1);
$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');
echo'<div class="gameBorder">';
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;
echo ' <a href="../search.php?nick='.$msg['login'].'&go=go">'.$msg['login'].'</a></b> <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 '<br/>'.smiles(AddBB(htmlspecialchars(addslashes($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);
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'Выбранной темы не существует!';
}
include('end.php');
?>