<?php
|
|
/**
|
|
* @package uForum
|
|
* @file includes/classes/class_topic.php
|
|
* @version $Id$
|
|
* @copyright 2007-2010 (c) PioDer <[email protected]>
|
|
* @link http://www.pioder.pl/
|
|
* @license see LICENSE.txt
|
|
**/
|
|
if ( !defined('IN_uF') )
|
|
{
|
|
die('Hacking attempt');
|
|
}
|
|
class Topic
|
|
{
|
|
function LastPostInTopic($topic)
|
|
{
|
|
global $lng;
|
|
global $last_post;
|
|
global $forum_config;
|
|
global $userdata;
|
|
|
|
$id = $last_post[0];
|
|
$userid = $last_post[1];
|
|
$un = $last_post[4];
|
|
$rank = $last_post[3];
|
|
|
|
switch($rank)
|
|
{
|
|
case '0':
|
|
{
|
|
$user_color_name = $un;
|
|
break;
|
|
}
|
|
case '1':
|
|
{
|
|
$user_color_name = '<font color="'.$forum_config['color_mod'].'"><b>'.$un.'</b></font>';
|
|
break;
|
|
}
|
|
case '2':
|
|
{
|
|
$user_color_name = '<font color="'.$forum_config['color_admin'].'"><b>'.$un.'</b></font>';
|
|
break;
|
|
}
|
|
}
|
|
if ($_SESSION['uid']>0)
|
|
{
|
|
$limiter = $userdata['limit_tpid'];
|
|
}
|
|
else
|
|
{
|
|
$limiter = $forum_config['limit_tpid'];
|
|
}
|
|
$count = ceil($id / $limiter);
|
|
if ($count >1)
|
|
{
|
|
$page= '&page='.$count;
|
|
}
|
|
else
|
|
{
|
|
$page='';
|
|
}
|
|
return '<p align="center"><span class="fverysmall"><b>'.GenerateTime($last_post[2]).'</b><br></span> <a href="topic.php?t='.$topic.$page.'#p'.$id.'" class="fverysmall"><b>Post #'.$id.'</b></a><a class="fsmall">: </a><a href="user.php?id='.$userid.'" class="fverysmall">'.$user_color_name.'</a></p>';
|
|
}
|
|
|
|
function LastPostImg()
|
|
{
|
|
global $last_post;
|
|
global $record;
|
|
global $default_skin;
|
|
$time = $_SERVER['REQUEST_TIME']-129600;
|
|
if ($_SESSION['uid']>0)
|
|
{
|
|
if ($last_post[2]>$time)
|
|
{
|
|
return 'folder_new_posts';
|
|
}
|
|
else
|
|
{
|
|
return 'folder_no_new_posts';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 'folder_no_new_posts';
|
|
}
|
|
}
|
|
|
|
function TopicAuthor($uid)
|
|
{
|
|
global $record;
|
|
global $forum_config;
|
|
$rank = $record['rank'];
|
|
$nick = $record['nick'];
|
|
switch($rank)
|
|
{
|
|
case '0':
|
|
{
|
|
$user_color_name = $nick;
|
|
break;
|
|
}
|
|
case '1':
|
|
{
|
|
|
|
$user_color_name = '<font color="'.$forum_config['color_mod'].'"><b>'.$nick.'</b></font>';
|
|
break;
|
|
}
|
|
case '2':
|
|
{
|
|
$user_color_name = '<font color="'.$forum_config['color_admin'].'"><b>'.$nick.'</b></font>';
|
|
break;
|
|
}
|
|
}
|
|
return '<a href="user.php?id='.$uid.'" class="fstandard">'.$user_color_name.'</a>';
|
|
}
|
|
|
|
function TopicInformation($tid, $mode)
|
|
{
|
|
$sql = "SELECT * FROM ".TOPICS_TABLE." WHERE t_id='$tid';";
|
|
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain topic information');
|
|
$result = DataBase::fetch($query);
|
|
$result = $result[$mode];
|
|
return $result;
|
|
}
|
|
|
|
function PostInformation($pid, $mode)
|
|
{
|
|
$sql = "SELECT * FROM ".POSTS_TABLE." WHERE p_id='$pid';";
|
|
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain topic information');
|
|
$result = DataBase::fetch($query);
|
|
$result = $result[$mode];
|
|
return $result;
|
|
}
|
|
|
|
function PostText($text,$postmoderate, $pid)
|
|
{
|
|
global $forum;
|
|
global $lng;
|
|
$text = stripslashes($text);
|
|
$text = Topic::TagsReplace($text);
|
|
if($forum['moderate']==1)
|
|
{
|
|
if ($postmoderate==1)
|
|
{
|
|
if ($_SESSION['uid']>0)
|
|
{
|
|
if (RANK>0)
|
|
{
|
|
return '<span class="fstandard"><b>'.$lng['moderated_post_text'].': </b></span><br>'.Topic::TagsReplace('[quote]'.$text.'[/quote]').'<br><a href="moderate.php?action=accept&id='.$pid.'"><span class="fstandard" style="color: red"><b>'.$lng['visible_of_post'].'</b></span></a>';
|
|
}
|
|
else
|
|
{
|
|
return '<span class="fstandard"><b><i>'.$lng['post_moderated'].'</i></b></span>';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return '<span class="fstandard"><b><i>'.$lng['post_moderated'].'</i></b></span>';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return $text;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return $text;
|
|
}
|
|
|
|
}
|
|
|
|
function UserName($nick, $rank)
|
|
{
|
|
global $forum_config;
|
|
switch($rank)
|
|
{
|
|
case '0':
|
|
{
|
|
return $nick;
|
|
break;
|
|
}
|
|
case '1':
|
|
{
|
|
return '<font color="'.$forum_config['color_mod'].'"><b>'.$nick.'</b></font>';
|
|
break;
|
|
}
|
|
case '2':
|
|
{
|
|
return '<font color="'.$forum_config['color_admin'].'"><b>'.$nick.'</b></font>';
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
function TagsReplace($text)
|
|
{
|
|
global $lng;
|
|
//quote
|
|
$text = preg_replace("#\[quote\](.*?)\[/quote]#si", "<table class=\"maintable\" width=\"450\"><tr><td bgcolor=\"silver\"><span class=\"fsmall\"><b>".$lng['quote2'].":</b></span></td></tr><tr><td bgcolor=\"lightgrey\"><span class=\"textquote\">\\1</span></td></tr></table>", $text);
|
|
//code
|
|
$text = preg_replace("#\[code\](.*?)\[/code]#si", "<table class=\"maintable\" width=\"450\"><tr><td bgcolor=\"lightgreen\"><font face=\"Verdana\" style=\"font-size: 8pt\" color=\"green\"><b>Code:</b></font></td></tr><tr><td bgcolor=\"#D4FFAA\"><span class=\"textquote\">\\1</span></td></tr></table>", $text);
|
|
return $text;
|
|
}
|
|
}
|
|
?>
|