/news.php

https://github.com/Implying/tsukiboards · PHP · 89 lines · 45 code · 12 blank · 32 comment · 10 complexity · 5eb698c9d92b30a93c5c89359991d4c9 MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of arcNET
  4. *
  5. * arcNET uses core code from Kusaba X and Oneechan
  6. *
  7. * tsukihi.me kusabax.cultnet.net oneechan.org
  8. *
  9. * arcNET is free software; you can redistribute it and/or modify it under the
  10. * terms of the GNU General Public License as published by the Free Software
  11. * Foundation; either version 2 of the License, or (at your option) any later
  12. * version.
  13. *
  14. * kusaba is distributed in the hope that it will be useful, but WITHOUT ANY
  15. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  16. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * kusaba; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * credits to jmyeom for improving this
  23. *
  24. */
  25. /**
  26. * News display, which is the first page shown when a user visits a chan's index
  27. *
  28. * Any news added by an administrator in the manage panel will show here, with
  29. * the newest entry on the top.
  30. *
  31. * @package kusaba
  32. */
  33. // Require the configuration file
  34. require 'config.php';
  35. require KU_ROOTDIR . 'inc/functions.php';
  36. require_once KU_ROOTDIR . 'lib/dwoo.php';
  37. global $CURRENTLOCALE;
  38. $dwoo_tpl = new Dwoo_Template_File(KU_TEMPLATEDIR . '/news.tpl');
  39. $topads = $tc_db->GetOne("SELECT code FROM `" . KU_DBPREFIX . "ads` WHERE `position` = 'top' AND `disp` = '1'");
  40. $botads = $tc_db->GetOne("SELECT code FROM `" . KU_DBPREFIX . "ads` WHERE `position` = 'bot' AND `disp` = '1'");
  41. $dwoo_data->assign('topads', $topads);
  42. $dwoo_data->assign('botads', $botads);
  43. if (!isset($_GET['p'])) $_GET['p'] = '';
  44. if ($_GET['p'] == 'faq') {
  45. $entries = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "front` WHERE `page` = 1 ORDER BY `order` ASC");
  46. } elseif ($_GET['p'] == 'rules') {
  47. $entries = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "front` WHERE `page` = 2 ORDER BY `order` ASC");
  48. } elseif ($_GET['p'] == 'news') {
  49. $entries = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "front` WHERE `page` = 0 ORDER BY `timestamp` DESC");
  50. } else {
  51. $limitNews = 10;
  52. $entries = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "front` WHERE `page` = 0 ORDER BY `timestamp` DESC LIMIT $limitNews");
  53. }
  54. $limitposts = 5;
  55. $recentPosts = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "posts` WHERE `IS_DELETED` = 0 AND NOT `email` = 'sage' ORDER BY `timestamp` DESC LIMIT $limitposts");
  56. foreach ($recentPosts as $k=>$post) {
  57. $board = $tc_db->GetAll("SELECT `name`, `anonymous` FROM `".KU_DBPREFIX."boards` WHERE `id` = '".$post['boardid']."'");
  58. $board = $board[0];
  59. $dateEmail = (empty($board['anonymous'])) ? $post['email'] : 0;
  60. $post['message'] = stripslashes(formatLongMessage($post['message'], $board['name'], (($post['parentid'] == 0) ? ($post['id']) : ($post['parentid'])), true, 7));
  61. $post['timestamp_formatted'] = formatDate($post['timestamp'], 'post', $CURRENTLOCALE, $dateEmail);
  62. $threadId = (($post['parentid'] == 0) ? ($post['id']) : ($post['parentid']));
  63. $post['reflink'] = formatReflink($board['name'], $threadId, $post['id'], $CURRENTLOCALE);
  64. $post['refUrl'] = getPostUrl($board['name'], $threadId, $post['id']);
  65. $post['boardname'] = $board['name'];
  66. $post['boardUrl'] = KU_BOARDSFOLDER . $board['name'] . '/';
  67. $recentPosts[$k] = $post;
  68. }
  69. $styles = explode(':', KU_MENUSTYLES);
  70. $dwoo_data->assign('styles', $styles);
  71. $dwoo_data->assign('ku_webpath', getCWebPath());
  72. $dwoo_data->assign('entries', $entries);
  73. if ($_GET['p'] == '') {
  74. $dwoo_data->assign('recentPosts', $recentPosts);
  75. }
  76. $dwoo->output($dwoo_tpl, $dwoo_data);
  77. ?>