|
|
- <?php
- /**
- * @package uForum
- * @file includes/classes/class_topic.php
- * @version $Id: classes/class_topic.php 15 2009-05-01 17:06:40Z pioder $
- * @copyright 2009(c) PioDer <pioder@wp.pl>
- * @link http://pioder.gim2przemysl.int.pl/
- * @license GNU GPL v3
- **/
- if ( !defined('IN_uF') )
- {
- die('Hacking attempt');
- }
- class Topic
- {
- function LastPostInTopic($topic)
- {
- global $lng;
- global $lastpost;
- global $forum_config;
- global $userdata;
- $id = $lastpost[$topic]['tp_id'];
- $userid = $lastpost[$topic]['u_id'];
- $un = $lastpost[$topic]['user_nick'];
- $rank = $lastpost[$topic]['user_rank'];
- 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($lastpost[$topic]['time']).'</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 $lastpost;
- global $record;
- global $default_skin;
- $time = time()-129600;
- if ($_SESSION['uid']>0)
- {
- if ($lastpost[$record['t_id']]['time']>$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;
- }
- }
- ?>
|