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.

83 lines
2.4 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file includes/cache/cache_forums.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. //cache forums and posts - version v1.0 Alpha 2---------------------------------
  15. $default_skin = ViewSkinName();
  16. $sql = "SELECT `name`,`lock` FROM ".FORUMS_TABLE." WHERE `f_id`='$fid' LIMIT 1";
  17. $result = @mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain forum information'));
  18. if ($result['name']=='')
  19. {
  20. message_forum($lng['no_forum'],'index.php');
  21. }
  22. $forum = array(
  23. 'name'=>$result['name'],
  24. 'lock'=>$result['lock']
  25. );
  26. $sql = "SELECT COUNT(*) as `p_id`, `t_id` FROM ".POSTS_TABLE." GROUP BY `t_id`";
  27. $query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in forum');
  28. while($result = @mysql_fetch_array($query))
  29. {
  30. $count_topic[$result['t_id']]=$result['p_id'];
  31. }
  32. $sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `f_id`='$fid' ORDER BY `ptime`";
  33. $query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in forum');
  34. while($result = @mysql_fetch_array($query))
  35. {
  36. $lastpost[$result['t_id']]['tp_id']=$result['tp_id'];
  37. $lastpost[$result['t_id']]['u_id']=$result['u_id'];
  38. $lastpost[$result['t_id']]['time']=$result['ptime'];
  39. $lastpost[$result['t_id']]['user_nick']=$result['nick'];
  40. $lastpost[$result['t_id']]['user_rank']=$result['rank'];
  41. }
  42. //
  43. //generate output pages
  44. //
  45. if ($_SESSION['uid']>0)
  46. {
  47. $limiter = $userdata['limit_ftid'];
  48. }
  49. else
  50. {
  51. $limiter = $forum_config['limit_ftid'];
  52. }
  53. if (isset($_GET['page'])&&($_GET['page']!=1))
  54. {
  55. if (!is_numeric($_GET['page']))
  56. {
  57. die('Hacking attempt');
  58. }
  59. $value = ($_GET['page']-1)*$limiter;
  60. $limit = 'LIMIT '.$value . ', '.$limiter;
  61. $page = $_GET['page'];
  62. }
  63. else
  64. {
  65. $limit = 'LIMIT 0, '.$limiter;
  66. $page=1;
  67. }
  68. $count = @mysql_fetch_array(DataBase::sql_query("SELECT COUNT(`t_id`) as `t_id`
  69. FROM ".TOPICS_TABLE." WHERE `f_id`='$fid'",'GENERAL','Could not obtain count amout of topics'));
  70. $count = $count['t_id'];
  71. $count = ceil($count / $limiter);
  72. if ($count==0)
  73. {
  74. $count +=1;
  75. }
  76. if(isset($_GET['page']) && ($_GET['page']>$count))
  77. {
  78. message_forum($lng['invalidpage'],'index.php');
  79. }
  80. //
  81. //end generating pages
  82. //
  83. ?>