A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
4.9 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file includes/classes/class_topic.php
  5. * @version $Id: classes/class_topic.php 15 2009-05-01 17:06:40Z pioder $
  6. * @copyright 2007-2010 (c) PioDer <pioder@wp.pl>
  7. * @link http://www.pioder.pl/
  8. * @license see LICENSE.txt
  9. **/
  10. if ( !defined('IN_uF') )
  11. {
  12. die('Hacking attempt');
  13. }
  14. class Topic
  15. {
  16. function LastPostInTopic($topic)
  17. {
  18. global $lng;
  19. global $last_post;
  20. global $forum_config;
  21. global $userdata;
  22. $id = $last_post[0];
  23. $userid = $last_post[1];
  24. $un = $last_post[4];
  25. $rank = $last_post[3];
  26. switch($rank)
  27. {
  28. case '0':
  29. {
  30. $user_color_name = $un;
  31. break;
  32. }
  33. case '1':
  34. {
  35. $user_color_name = '<font color="'.$forum_config['color_mod'].'"><b>'.$un.'</b></font>';
  36. break;
  37. }
  38. case '2':
  39. {
  40. $user_color_name = '<font color="'.$forum_config['color_admin'].'"><b>'.$un.'</b></font>';
  41. break;
  42. }
  43. }
  44. if ($_SESSION['uid']>0)
  45. {
  46. $limiter = $userdata['limit_tpid'];
  47. }
  48. else
  49. {
  50. $limiter = $forum_config['limit_tpid'];
  51. }
  52. $count = ceil($id / $limiter);
  53. if ($count >1)
  54. {
  55. $page= '&amp;page='.$count;
  56. }
  57. else
  58. {
  59. $page='';
  60. }
  61. 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>';
  62. }
  63. function LastPostImg()
  64. {
  65. global $last_post;
  66. global $record;
  67. global $default_skin;
  68. $time = time()-129600;
  69. if ($_SESSION['uid']>0)
  70. {
  71. if ($last_post[2]>$time)
  72. {
  73. return 'folder_new_posts';
  74. }
  75. else
  76. {
  77. return 'folder_no_new_posts';
  78. }
  79. }
  80. else
  81. {
  82. return 'folder_no_new_posts';
  83. }
  84. }
  85. function TopicAuthor($uid)
  86. {
  87. global $record;
  88. global $forum_config;
  89. $rank = $record['rank'];
  90. $nick = $record['nick'];
  91. switch($rank)
  92. {
  93. case '0':
  94. {
  95. $user_color_name = $nick;
  96. break;
  97. }
  98. case '1':
  99. {
  100. $user_color_name = '<font color="'.$forum_config['color_mod'].'"><b>'.$nick.'</b></font>';
  101. break;
  102. }
  103. case '2':
  104. {
  105. $user_color_name = '<font color="'.$forum_config['color_admin'].'"><b>'.$nick.'</b></font>';
  106. break;
  107. }
  108. }
  109. return '<a href="user.php?id='.$uid.'" class="fstandard">'.$user_color_name.'</a>';
  110. }
  111. function TopicInformation($tid, $mode)
  112. {
  113. $sql = "SELECT * FROM ".TOPICS_TABLE." WHERE t_id='$tid';";
  114. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain topic information');
  115. $result = DataBase::fetch($query);
  116. $result = $result[$mode];
  117. return $result;
  118. }
  119. function PostInformation($pid, $mode)
  120. {
  121. $sql = "SELECT * FROM ".POSTS_TABLE." WHERE p_id='$pid';";
  122. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain topic information');
  123. $result = DataBase::fetch($query);
  124. $result = $result[$mode];
  125. return $result;
  126. }
  127. function PostText($text,$postmoderate, $pid)
  128. {
  129. global $forum;
  130. global $lng;
  131. $text = stripslashes($text);
  132. $text = Topic::TagsReplace($text);
  133. if($forum['moderate']==1)
  134. {
  135. if ($postmoderate==1)
  136. {
  137. if ($_SESSION['uid']>0)
  138. {
  139. if (RANK>0)
  140. {
  141. return '<span class="fstandard"><b>'.$lng['moderated_post_text'].': </b></span><br>'.Topic::TagsReplace('[quote]'.$text.'[/quote]').'<br><a href="moderate.php?action=accept&amp;id='.$pid.'"><span class="fstandard" style="color: red"><b>'.$lng['visible_of_post'].'</b></span></a>';
  142. }
  143. else
  144. {
  145. return '<span class="fstandard"><b><i>'.$lng['post_moderated'].'</i></b></span>';
  146. }
  147. }
  148. else
  149. {
  150. return '<span class="fstandard"><b><i>'.$lng['post_moderated'].'</i></b></span>';
  151. }
  152. }
  153. else
  154. {
  155. return $text;
  156. }
  157. }
  158. else
  159. {
  160. return $text;
  161. }
  162. }
  163. function UserName($nick, $rank)
  164. {
  165. global $forum_config;
  166. switch($rank)
  167. {
  168. case '0':
  169. {
  170. return $nick;
  171. break;
  172. }
  173. case '1':
  174. {
  175. return '<font color="'.$forum_config['color_mod'].'"><b>'.$nick.'</b></font>';
  176. break;
  177. }
  178. case '2':
  179. {
  180. return '<font color="'.$forum_config['color_admin'].'"><b>'.$nick.'</b></font>';
  181. break;
  182. }
  183. }
  184. }
  185. function TagsReplace($text)
  186. {
  187. global $lng;
  188. //quote
  189. $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);
  190. //code
  191. $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);
  192. return $text;
  193. }
  194. }
  195. ?>