base_url("/"), "lastmod" => date('Y-m-d'), "priority" => "0.8", "changefreq" => "daily" ); $list = $this->db->get('sitemap')->result_array(); if( count($list) > 0 ) { foreach($list as $row) { $data['list'][] = array( "loc" => base_url($row['sit_loc']), "lastmod" => date('Y-m-d'), "priority" => "{$row['sit_priority']}", "changefreq" => $row['sit_changefreq'] ); } } $this->layout = FALSE; $result = $this->load->view('tools/sitemap_pages', $data, TRUE); echo $result; } /** * 통합 사이트맵 */ function index() { $list = $this->db->where('brd_use_sitemap','Y')->where('brd_lv_read','0')->get('board')->result_array(); ob_start(); echo "\n"; echo "\n"; echo "".PHP_EOL; echo "".base_url('sitemap_1.xml')."".PHP_EOL; echo ""; foreach ($list as $row) { echo "".PHP_EOL; echo "" . base_url("sitemap_".$row['brd_key'].".xml") . "\n"; echo "\n"; } echo "\n"; $xml = ob_get_clean(); echo $xml; } /** * 게시판별 사이트맵 * @param $brd_key */ function board($brd_key) { $this->load->model('board_model'); if(empty($brd_key)) { die('잘못된 접근입니다.'); } $board = $this->board_model->get_board($brd_key, TRUE); if( !$board OR $board['brd_use_sitemap'] != 'Y' OR $board['brd_lv_read'] > 0 ) { die('이 게시판은 사이트맵을 사용하지 않습니다.'); } $list = $this->db->where('post_secret', 'N')->where('post_status','Y')->where('brd_key', $brd_key)->from('board_post')->get()->result_array(); $data['list'] = array(); // 게시판 자체 사이트맵 추가 // 게시판글 최종수정일 가져오기 $max_date = $this->db->select_max('post_modtime', 'max')->where('post_status','Y')->where('brd_key',$brd_key)->from('board_post')->get()->row(0)->max; $data['list'][] = array( "loc" => base_url("/board/{$brd_key}"), "lastmod" => date('Y-m-d', strtotime($max_date)), "priority" => "0.7", "changefreq" => "daily" ); foreach($list as $row) { $data['list'][] = array( "loc" => base_url("/board/{$brd_key}/{$row['post_idx']}"), "lastmod" => date('Y-m-d', strtotime($row['post_modtime'])), "priority" => "0.7", "changefreq" => "daily" ); } $this->layout = FALSE; $result = $this->load->view('tools/sitemap_pages', $data, TRUE); echo $result; } function __construct() { parent::__construct(); header('content-type: text/xml'); header('cache-control: no-cache, must-revalidate'); header('pragma: no-cache'); } }