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.

113 lines
4.4 KiB

7 years ago
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Helptool extends WB_Controller {
  4. public function index()
  5. {
  6. show_404();
  7. }
  8. public function lang()
  9. {
  10. header('Content-Type: application/javascript; charset=UTF-8');
  11. header('cache-control: no-cache, must-revalidate');
  12. header('pragma: no-cache');
  13. echo "var LANG = {};".PHP_EOL;
  14. $list = $this->db->get('localize')->result_array();
  15. foreach($list as $row) {
  16. $key = str_replace( array("게시판","공통","회원","팝업"), array('board','common','member','popup'), $row['loc_key'] );
  17. echo "LANG." . str_replace("/", "_", $key)." = '".$row['loc_value_'.LANG]."';".PHP_EOL;
  18. }
  19. exit;
  20. }
  21. /**
  22. * 네이버 신디케이션
  23. * @param $brd_key
  24. * @param $post_idx
  25. */
  26. public function naversyndi($brd_key, $post_idx)
  27. {
  28. $this->load->model('board_model');
  29. if ( empty($this->site->config('naver_syndication_key'))) {
  30. die('신디케이션 키가 입력되지 않았습니다');
  31. }
  32. $post_idx = (int) $post_idx;
  33. if (empty($post_idx) OR $post_idx < 1) {
  34. show_404();
  35. }
  36. $board = $this->board_model->get_board($brd_key, FALSE);
  37. if( ! element('brd_key', $board) )
  38. {
  39. show_404();
  40. }
  41. if ( $board['brd_use_naver_syndi'] != 'Y') {
  42. die('이 게시판은 신디케이션 기능을 사용하지 않습니다');
  43. }
  44. $post = $this->board_model->get_post($brd_key, $post_idx, FALSE);
  45. if ( ! element('post_idx', $post)) {
  46. show_404();
  47. }
  48. if( $post['post_status'] != 'Y' ) {
  49. show_404();
  50. }
  51. // 비회원 글읽기가 불가능한경우 리턴
  52. if( $board['brd_lv_read'] != 0 )
  53. {
  54. die('이 게시판은 신디케이션 기능을 사용하지 않습니다');
  55. }
  56. if ($post['post_secret'] == 'Y') {
  57. die('비밀글은 신디케이션을 지원하지 않습니다');
  58. }
  59. $base_url = rtrim(base_url("board/{$brd_key}"), '/');
  60. $post_content = str_replace(PHP_EOL,"", ($post['post_content']));
  61. //$content = str_replace(array('&amp;', '&nbsp;'), array('&', ' '), $post_content);
  62. $content = $post_content;
  63. $summary = str_replace(PHP_EOL,"", str_replace(array('&amp;', '&nbsp;'), array('&', ' '), html_escape(strip_tags(element('post_content', $post)))));
  64. header('content-type: text/xml');
  65. header('cache-control: no-cache, must-revalidate');
  66. header('pragma: no-cache');
  67. $xml = "";
  68. $xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
  69. $xml .= "<feed xmlns=\"http://webmastertool.naver.com\">\n";
  70. $xml .= "<id>".PHP_EOL . $base_url .PHP_EOL. "</id>\n";
  71. $xml .= "<title>{$post['post_title']}</title>\n";
  72. $xml .= "<author>\n";
  73. $xml .= "<name>webmaster</name>\n";
  74. $xml .= "</author>\n";
  75. $xml .= "<updated>" . date('Y-m-d\TH:i:s\+09:00') . "</updated>\n";
  76. $xml .= '<link rel="site" href="'.$base_url.'" title="'.html_escape($this->site->config('site_title')).'" />'.PHP_EOL;
  77. $xml .= "<entry>\n";
  78. $xml .= "<id>" . PHP_EOL . base_url('board/'.$brd_key.'/'.$post_idx) . PHP_EOL . "</id>\n";
  79. $xml .= "<title><![CDATA[" . html_escape(element('post_title', $post)) . "]]></title>\n";
  80. $xml .= "<author>\n";
  81. $xml .= "<name>" . html_escape(element('mem_nickname', $post)) . "</name>\n";
  82. $xml .= "</author>\n";
  83. $xml .= "<updated>" .date('Y-m-d\TH:i:s\+09:00', strtotime(element('post_modtime', $post))) . "</updated>\n";
  84. $xml .= "<published>" . date('Y-m-d\TH:i:s\+09:00', strtotime(element('post_regtime', $post))) . "</published>\n";
  85. $xml .= "<link rel=\"via\" href=\"" . base_url('board/'.$brd_key) . "\" title=\"" . html_escape(element('brd_title', $board)) . "\" />\n";
  86. $xml .= "<link rel=\"mobile\" href=\"" . base_url('board/'.$brd_key.'/'.$post_idx) . "\" />\n";
  87. $xml .= "<content type=\"html\"><![CDATA[{$content}]]></content>\n";
  88. $xml .= "<summary type=\"text\"><![CDATA[{$summary}]]></summary>\n";
  89. $xml .= "<category term=\"" . element('brd_key', $board) . "\" label=\"" . html_escape(element('brd_title', $board)) . "\" />\n";
  90. $xml .= "</entry>\n";
  91. $xml .= "</feed>";
  92. echo $xml;
  93. $this->layout = FALSE;
  94. }
  95. }