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.

104 lines
2.7 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file includes/cache/cache_topic.php
  5. * @version $Id$
  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. //||topic.php script cache ------------------------------------------------------------------------------
  15. $sql = "SELECT ".TOPICS_TABLE.".*, ".TOPICS_TABLE.".name AS topic_name, ".TOPICS_TABLE.".lock AS topic_lock, ".FORUMS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".FORUMS_TABLE." ON ".TOPICS_TABLE.".f_id = ".FORUMS_TABLE.".f_id WHERE `t_id`='$tid' LIMIT 1";
  16. $result = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain forum information'));
  17. if ($result['t_id']=='')
  18. {
  19. message_forum($lng['no_topic'], 'index.php');
  20. }
  21. $topic = array(
  22. 'name' => $result['topic_name'],
  23. 'lock' => $result['topic_lock'],
  24. 'sticky' => $result['sticky'],
  25. 'f_id' => $result['f_id']
  26. );
  27. $forum = array(
  28. 'name' => $result['name'],
  29. 'lock' => $result['lock'],
  30. 'moderate' => $result['moderate']
  31. );
  32. $fid = $topic['f_id'];
  33. //user warnings level
  34. $sql = "SELECT `u_id`,`value` FROM `".WARNINGS_TABLE."`";
  35. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain user warns information');
  36. $result = DataBase::num_rows($query);
  37. while ($result = DataBase::fetch($query))
  38. {
  39. if(!isset($user_warnlevel[$result['u_id']]))
  40. {
  41. $user_warnlevel[$result['u_id']]=0;
  42. }
  43. if ($result['value']=='-')
  44. {
  45. $user_warnlevel[$result['u_id']] -=1;
  46. }
  47. else
  48. {
  49. $user_warnlevel[$result['u_id']] +=1;
  50. }
  51. }
  52. //check online for user
  53. $sql = "SELECT `s_id`, `u_id`, `time` FROM ".SESSIONS_TABLE." WHERE time+1250>".time();
  54. $query = DataBase::sql_query($sql, GENERAL, 'Could not read user active.');
  55. while($result = DataBase::fetch($query))
  56. {
  57. $user[$result['u_id']]['online']='1';
  58. }
  59. unset($sql, $query, $result);
  60. //
  61. //generate output pages
  62. //
  63. if ($_SESSION['uid']>0)
  64. {
  65. $limiter = $userdata['limit_tpid'];
  66. }
  67. else
  68. {
  69. $limiter = $forum_config['limit_tpid'];
  70. }
  71. if (isset($_GET['page'])&&($_GET['page']!=1))
  72. {
  73. if (!is_numeric($_GET['page']))
  74. {
  75. die('Hacking attempt');
  76. }
  77. $value = ($_GET['page']-1)*$limiter;
  78. $limit = 'LIMIT '.$value . ', '.$limiter;
  79. $page = $_GET['page'];
  80. }
  81. else
  82. {
  83. $limit = 'LIMIT 0, '.$limiter;
  84. $page=1;
  85. }
  86. $count = DataBase::fetch(DataBase::sql_query("SELECT COUNT(`p_id`) as `p_id`
  87. FROM ".POSTS_TABLE." WHERE `t_id`='$tid'",GENERAL,'Could not obtain count amout of posts'));
  88. $count = $count['p_id'];
  89. $count = ceil($count / $limiter);
  90. if(isset($_GET['page']) && ($_GET['page']>$count))
  91. {
  92. message_forum($lng['invalidpage'],'index.php');
  93. }
  94. //
  95. //end generating pages
  96. //
  97. ?>