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.

140 lines
3.4 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file includes/classes/class_forum.php
  5. * @version $Id: classes/class_forum.php 15 2009-05-01 17:06:40Z pioder $
  6. * @copyright 2009(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/
  8. * @license GNU GPL v3
  9. **/
  10. if ( !defined('IN_uF') )
  11. {
  12. die('Hacking attempt');
  13. }
  14. class Forum
  15. {
  16. function AddForums($tid)
  17. {
  18. global $forum_config;
  19. $forum = Topic::TopicInformation($tid,'f_id');
  20. $all='';
  21. $query = DataBase::sql_query("SELECT `name`, `f_id` FROM `".FORUMS_TABLE."` ORDER BY `f_id`",'GENERAL','Could not obtain forum information');
  22. while($t = @mysql_fetch_array($query))
  23. {
  24. if ($t['f_id']==$forum)
  25. {
  26. $all .= '<option value="'.$t['f_id'].'" selected="selected">'.$t['name'].'</option>'."\n";
  27. }
  28. else
  29. {
  30. $all .= '<option value="'.$t['f_id'].'">'.$t['name'].'</option>'."\n";
  31. }
  32. }
  33. return $all;
  34. unset($t, $all);
  35. }
  36. function PostsInForum($forum_name)
  37. {
  38. $sql = "SELECT count(*) as `p_id` FROM ".POSTS_TABLE." WHERE f_id='$forum_name'";
  39. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain posts information.');
  40. $result = mysql_fetch_array($query);
  41. return $result['p_id'];
  42. }
  43. function LastPost($posts, $forum)
  44. {
  45. global $lng;
  46. global $user;
  47. global $last_post;
  48. global $userdata;
  49. global $forum_config;
  50. if ($posts==0) { return '<p align="center" class="fstandard">'.$lng['nopost'].'</p>';}
  51. else
  52. {
  53. $id = $last_post[$forum]['tp_id'];
  54. $topic = $last_post[$forum]['t_id'];
  55. $userid = $last_post[$forum]['u_id'];
  56. $un = $last_post[$forum]['user_nick'];
  57. $rank = $last_post[$forum]['user_rank'];
  58. switch($rank)
  59. {
  60. case '0':
  61. {
  62. $user_color_name = $un;
  63. break;
  64. }
  65. case '1':
  66. {
  67. $user_color_name = '<font color="'.$forum_config['color_mod'].'"><b>'.$un.'</b></font>';
  68. break;
  69. }
  70. case '2':
  71. {
  72. $user_color_name = '<font color="'.$forum_config['color_admin'].'"><b>'.$un.'</b></font>';
  73. break;
  74. }
  75. }
  76. if ($_SESSION['uid']>0)
  77. {
  78. $limiter = $userdata['limit_tpid'];
  79. }
  80. else
  81. {
  82. $limiter = $forum_config['limit_tpid'];
  83. }
  84. $count = ceil($id / $limiter);
  85. if ($count >1)
  86. {
  87. $page= '&amp;page='.$count;
  88. }
  89. else
  90. {
  91. $page='';
  92. }
  93. return '<p align="center"><span class="fverysmall"><b>'.GenerateTime($last_post[$forum]['time']).'</b><br></span> <a href="topic.php?t='.$topic.$page.'#p'.$id.'" class="fverysmall"><b>'.$lng['topic'].' #'.$topic.'</b></a><a class="fsmall">: </a><a href="user.php?id='.$userid.'" class="fverysmall">'.$user_color_name.'</a></p>';
  94. }
  95. }
  96. function LastPostImg($postsinforum)
  97. {
  98. global $last_post;
  99. global $i;
  100. global $forum;
  101. global $default_skin;
  102. $time = time()-129600;
  103. if ($_SESSION['uid']>0)
  104. {
  105. if ($postsinforum>0)
  106. {
  107. if ($last_post[$forum[$i]['f_id']]['time']>$time)
  108. {
  109. return 'folder_new_posts';
  110. }
  111. else
  112. {
  113. return 'folder_no_new_posts';
  114. }
  115. }
  116. else
  117. {
  118. return 'folder_no_new_posts';
  119. }
  120. }
  121. else
  122. {
  123. return 'folder_no_new_posts';
  124. }
  125. }
  126. function ForumInformation($fid, $inf)
  127. {
  128. $sql = "SELECT `f_id`, `$inf` FROM ".FORUMS_TABLE." WHERE f_id='$fid';";
  129. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain forum information.');
  130. $result = mysql_fetch_array($query);
  131. $result = $result[$inf];
  132. return $result;
  133. }
  134. }
  135. ?>