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.

95 lines
2.7 KiB

  1. <?php
  2. /**
  3. * @package Dynamic Script Forum
  4. * @file includes/cache/cache_topic.php
  5. * @version 1.0.x, 02-12-2007, 14:16
  6. * @copyright 2008(c) PioDer <pioder@wp.pl>
  7. * @link http://pioder.gim2przemysl.int.pl/dsf.html
  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 = @mysql_fetch_array(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['name']=$result['topic_name'];
  22. $topic['lock']=$result['topic_lock'];
  23. $topic['sticky']=$result['sticky'];
  24. $topic['f_id']=$result['f_id'];
  25. $fid = $topic['f_id'];
  26. $forum['name']=$result['name'];
  27. $forum['lock']=$result['lock'];
  28. $forum['moderate']=$result['moderate'];
  29. $sql = "SELECT `u_id`,`value` FROM `".WARNINGS_TABLE."`";
  30. $query = DataBase::sql_query($sql,'GENERAL','Could not obtain user warns information');
  31. $result = mysql_num_rows($query);
  32. while ($result = @mysql_fetch_array($query))
  33. {
  34. if(!isset($user_warnlevel[$result['u_id']]))
  35. {
  36. $user_warnlevel[$result['u_id']]=0;
  37. }
  38. if ($result['value']=='-')
  39. {
  40. $user_warnlevel[$result['u_id']] -=1;
  41. }
  42. else
  43. {
  44. $user_warnlevel[$result['u_id']] +=1;
  45. }
  46. }
  47. //check online for user
  48. $sql = "SELECT `s_id`, `u_id`, `time` FROM ".SESSIONS_TABLE." WHERE time+1250>".time();
  49. $query = DataBase::sql_query($sql, 'GENERAL', 'Could not read user active.');
  50. while($result = @mysql_fetch_array($query))
  51. {
  52. $user[$result['u_id']]['online']='1';
  53. }
  54. unset($sql, $query, $result);
  55. //
  56. //generate output pages
  57. //
  58. if ($_SESSION['uid']>0)
  59. {
  60. $limiter = $userdata['limit_tpid'];
  61. }
  62. else
  63. {
  64. $limiter = $forum_config['limit_tpid'];
  65. }
  66. if (isset($_GET['page'])&&($_GET['page']!=1))
  67. {
  68. if (!is_numeric($_GET['page']))
  69. {
  70. die('Hacking attempt');
  71. }
  72. $value = ($_GET['page']-1)*$limiter;
  73. $limit = 'LIMIT '.$value . ', '.$limiter;
  74. $page = $_GET['page'];
  75. }
  76. else
  77. {
  78. $limit = 'LIMIT 0, '.$limiter;
  79. $page=1;
  80. }
  81. $count = @mysql_fetch_array(DataBase::sql_query("SELECT COUNT(`p_id`) as `p_id`
  82. FROM ".POSTS_TABLE." WHERE `t_id`='$tid'",'GENERAL','Could not obtain count amout of posts'));
  83. $count = $count['p_id'];
  84. $count = ceil($count / $limiter);
  85. if(isset($_GET['page']) && ($_GET['page']>$count))
  86. {
  87. message_forum($lng['invalidpage'],'index.php');
  88. }
  89. //
  90. //end generating pages
  91. //
  92. ?>