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.

89 lines
3.3 KiB

7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
5 years ago
7 years ago
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. /**
  4. * Class Rss
  5. * ------------------------------
  6. * RSS 보기 페이지
  7. */
  8. class Rss extends WB_Controller {
  9. function index($brd_key="")
  10. {
  11. $this->load->library('boardlib');
  12. $brd_array = array();
  13. // 통합 RSS 인 경우
  14. if( empty($brd_key) )
  15. {
  16. $board_list = $this->db->where('brd_lv_read', '0')->get('board')->result_array();
  17. foreach($board_list as $b)
  18. {
  19. $brd_array[] = $b['brd_key'];
  20. }
  21. }
  22. else
  23. {
  24. $board = $this->boardlib->get($brd_key, TRUE);
  25. if( $board['brd_use_rss'] != 'Y' OR $board['brd_lv_read'] > 0 )
  26. {
  27. die('해당 게시판은 RSS 사용 설정이 되어있지 않습니다.');
  28. }
  29. $brd_array[] = $brd_key;
  30. }
  31. if( count($brd_array) <= 0)
  32. {
  33. die('RSS를 사용할수 있는 게시판이 없습니다.');
  34. }
  35. $post_list = $this->db
  36. ->select('board_post.*,board.brd_title')
  37. ->join('board','board.brd_key=board_post.brd_key','inner')
  38. ->where_in('board_post.brd_key', $brd_array)
  39. ->where('post_status' ,'Y')
  40. ->where('post_secret', 'N')
  41. ->order_by('post_num DESC, post_reply ASC, post_idx DESC')
  42. ->limit(50)
  43. ->get('board_post')
  44. ->result_array();
  45. header('content-type: text/xml');
  46. header('cache-control: no-cache, must-revalidate');
  47. header('pragma: no-cache');
  48. $title = (empty($brd_key)) ? $this->site->config('site_title').' 통합 RSS': $board['brd_title'] . ' RSS';
  49. $url = (empty($brd_key)) ? base_url() : base_url('board/'.$brd_key);
  50. $copyright = $this->site->config('site_title');
  51. $description = (empty($brd_key)) ? $this->site->config('site_meta_description') : $board['brd_description'];
  52. ob_start();
  53. echo "<?xml version=\"1.0\" encoding=\"" . config_item('charset') . "\"?".">\n";
  54. echo "<rss version=\"2.0\">\n";
  55. echo "<channel>\n";
  56. echo "<title>" . html_escape(element('title', $title)) . "</title>\n";
  57. echo "<link>" . $url . "</link>\n";
  58. if ($copyright) {
  59. echo "<copyright><![CDATA[ " . html_escape($copyright) . "]]></copyright>";
  60. }
  61. if ($description) {
  62. echo "<copyright><![CDATA[ " . html_escape($description) . "]]></copyright>";
  63. }
  64. foreach ($post_list as $row) {
  65. echo "<item>\n";
  66. echo "<title><![CDATA[" . element('post_title', $row) . "]]></title>\n";
  67. echo "<link>" . base_url( "board/{$row['brd_key']}/{$row['post_idx']}") . "</link>\n";
  68. echo "<author>" . html_escape(element('post_nickname', $row)) . "</author>\n";
  69. echo "<pubDate>" . date('Y-m-d', strtotime($row['reg_datetime'])) . "</pubDate>\n";
  70. echo "<description><![CDATA[" . display_html_content($row['post_content']) . "]]></description>\n";
  71. echo "<category>" . html_escape($row['brd_title']) . "</category>\n";
  72. echo "</item>\n";
  73. }
  74. echo "</channel>\n";
  75. echo "</rss>\n";
  76. $xml = ob_get_clean();
  77. echo $xml;
  78. }
  79. }