xml 이놈이 뭔가요? 제가 어떻게 해야지 데이타 호환이 되는건가요? > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

xml 이놈이 뭔가요? 제가 어떻게 해야지 데이타 호환이 되는건가요? 정보

xml 이놈이 뭔가요? 제가 어떻게 해야지 데이타 호환이 되는건가요?

본문

작업해준 싸이트가 다른싸이트와 데이타(기사) 호환을 한다네요.
이게 뭔말인지..... 그 곳에서 제가 작업한 싸이트가 XML이 안되어있어서 가지고 갈수 없다고 하는데요.
네이버 검색을 해봐도.... 방법은 안나오고~
저는 일단 디자인만 해 봐서 언어나 자세한건 모르고,~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
html열면 첫줄에 있는 이거랑 상관있는건가요?
이거 거의 지우고 작업했었는데, 그러면 안되나요? 암튼,,,, 혹시 몰라서, 인쿠르트시킨 헤드부분만 다시 붙혀넣긴했는데,~
디자인만 하던 초짜가 싸이트 만들면 이런 불상사가 생기네요.~

그 업체에서는 XML 잠깐 작업하면 된다고, 했다면서, 이거 해결못하면, 제가 만들어준 업체에서 전 완전 바보 될듯한 상황이네요.
  • 복사

댓글 전체

게시판마다.. rss 버튼이 있지 않나요??

여기 sir 사이트 게시판에는 xml 이라고 있잖아요..

그거 누르면 해당 게시판의 데이터가 xml 형식으로 표시 되는데요...

주소는 아래와 같습니다..

http://도메인/bbs/rss.php?bo_table=게시판ID

예 ) http://미나.com/bbs/rss.php?bo_table=article
일단 하단의 것 하기전에
isen.kr/bbs/rss.php 하니까 잠겨있다고 하구요.
게시판 설정에서 rss 체크해져 있어요.
게시판 아이뒤로 들어가면,,,isen.kr/bbs/rss.php?bo_table=21
로 들어가면 rss페이지가 열리는것 같은데,
하단의 것으로 하면, 전체페이지가,, 되는걸까요?
아직 해보질 않아서.... 해보고 안되면, 쪽지로 다시 여쭤봐도 될까요?
네 아래 소스로 하면...

글내용 읽기 레벨이 2 이하로 되어 있는 모든 게시판의 rss를 가져옵니다..

상대업체에 isen.kr/rss.php 이 주소를 가르쳐 주시면 되고요..

아참.. 아래 소스 약간 수정한 부분 있었는데...

쪽지 드렸었거든요.. 확인 해 보셨는지..
게시판 하나만 xml 뽑아올려면.. 위 댓글처럼 하시고요!!
전체 게시물을 xml로 뽑아오시려면... 아래 소스를 이용하세요~
아래 소스는 제가 쓸려고 만들었던건데요...
미리보기는..
http://allfigure.com 에 가시면 페이지 하단 우측에 rss 버튼 누르시면 됩니다..
아래 링크로 가셔도 되고요..
http://allfigure.com/rss.php


<?
/* 전체 게시물 rss by 거니*/
include_once("./_common.php");

$cut_rows = 20; // 불러올 게시물 수
$update_time = 30;  // 갱신 시간/분단위

// 특수문자 변환
function specialchars_replace($str, $len=0) {
    if ($len) {
        $str = substr($str, 0, $len);
    }

    $str = preg_replace("/&/", "&amp;", $str);
    $str = preg_replace("/</", "&lt;", $str);
    $str = preg_replace("/>/", "&gt;", $str);
    return $str;
}


header("Content-Type: text/html; charset=$g4[charset]");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); 

$n_time = time();
$cachefile = "$g4[path]/data/rss.cache";
$f_time = @filemtime($cachefile);

if(file_exists($cachefile)&&($n_time-$f_time)<$update_time*60){
//캐쉬 파일이 존재하면 출력
echo implode(file($cachefile),'');
} else {
ob_start();

echo "<?xml version=\"1.0\" encoding=\"$g4[charset]\"?>\n";
echo "<rss version=\"2.0\">\n";
echo "<channel>\n";
echo "<title>".$config[cf_title]."</title>\n";
echo "<link>http://allfigure.com</link>\n";
echo "<description>allfigure RSS</description>\n";
echo "<language>ko</language>\n";
echo "<copyright>Copyright (c) allfigure All rights reserved.</copyright>\n";
echo "<webMaster>http://allfigure.com/</link>\n";
echo "</image>\n";


$que = mysql_query("SELECT bo_table,bo_subject FROM g4_board where bo_read_level<2");
while ($data = @mysql_fetch_array($que)){

$query = mysql_query("SELECT wr_id, wr_subject, wr_content, wr_name, wr_datetime, wr_option FROM g4_write_".$data[bo_table]." where wr_id=wr_parent and wr_option not like '%secret%' limit $cut_rows");
while ($row= @mysql_fetch_array($query)){
$bo_table[] = $data[bo_table];
$bo_subject[] = $data[bo_subject];
$wr_id[] = $row[wr_id];
$wr_subject[] = $row[wr_subject];
$wr_content[] = str_replace("<BR>","<br />",$row[wr_content]);
$wr_name[] = $row[wr_name];
$wr_datetime[] = $row[wr_datetime];
$wr_option[] = $row[wr_option];
if (strstr($row[wr_option], 'html'))
$html[] = 1;
else
$html[] = 0;
}

}

arsort($wr_datetime);
$repeat = 1;

foreach ($wr_datetime as $key => $value) {

echo "<item>\n";
echo "<title>".specialchars_replace($wr_subject[$key])."</title>\n";
echo "<link>".specialchars_replace("$g4[url]/$g4[bbs]/board.php?bo_table=$bo_table[$key]&wr_id=$wr_id[$key]")."</link>\n";
echo "<description><![CDATA[". conv_content($wr_content[$key], $html[$key])."]]></description>\n";
echo "<category>".$bo_subject[$key]."</category>\n";
echo "<author>".specialchars_replace($wr_name[$key])."</author>\n";
$date = $wr_datetime[$key];
$date = date('r', strtotime($date));
echo "<pubDate>$date</pubDate>\n";
echo "</item>\n";

if($repeat==$cut_rows) break;
$repeat++;
}

echo "</channel>\n";
echo "</rss>\n";



//결과를 파일에 저장
$f = fopen($cachefile,'w');
fwrite($f,ob_get_contents());
fclose($f);

//캐쉬 종료하고 결과를 출력
ob_end_flush();
}
@chmod($cachefile, 0606);
?>


위 소스를 rss.php 파일로 저장해서 그누보드 메인 폴더에 업로드 하시고요..

업로드 하시기전에.. echo 부분에서..

allfigure 라고 되어있는 부분이나... 이미지 파일부분...

해당 사이트에 맞게 알아서 수정하시면 되겠네요...

수정은 그다지 어렵지 않으니....

디비에서 union 으로 가져오려고 했는데... bo_table 값을 가져오지 못해서..

배열로 처리했네요... 소스가 그리 효율적이지는 못합니다만..

쓸만합니다...

30분 단위로 캐시파일 생성하니까 사용하시는데 무리는 없을거에요..

시간은 분단위로 알아서 수정 하시고요!

위 rss.php 파일을 사이트 아무데나 링크 시켜두시고요...

상대 업체쪽에.. rss.php 파일 경로만 가르쳐주시면 되겠네요....
잘못된 부분이 있어서.. 아래 소스로 바꿔드려요~~~

아래 소스로 사용하세요~~ 미나님..



<?
/* 전체 게시물 rss by 거니*/
include_once("./_common.php");

$cut_rows = 20; // 불러올 게시물 수
$update_time = 30;  // 갱신 시간/분단위

// 특수문자 변환
function specialchars_replace($str, $len=0) {
    if ($len) {
        $str = substr($str, 0, $len);
    }

    $str = preg_replace("/&/", "&amp;", $str);
    $str = preg_replace("/</", "&lt;", $str);
    $str = preg_replace("/>/", "&gt;", $str);
    return $str;
}


header("Content-Type: text/html; charset=$g4[charset]");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); 

$n_time = time();
$cachefile = "$g4[path]/data/rss.cache";
$f_time = @filemtime($cachefile);

if(file_exists($cachefile)&&($n_time-$f_time)<$update_time*60){
//캐쉬 파일이 존재하면 출력
echo implode(file($cachefile),'');
} else {
ob_start();

echo "<?xml version=\"1.0\" encoding=\"$g4[charset]\"?>\n";
echo "<rss version=\"2.0\">\n";
echo "<channel>\n";
echo "<title>".$config[cf_title]."</title>\n";
echo "<link>http://allfigure.com</link>\n";
echo "<description>allfigure RSS</description>\n";
echo "<language>ko</language>\n";
echo "<copyright>Copyright (c) allfigure All rights reserved.</copyright>\n";
echo "<webMaster>http://allfigure.com/</link>\n";
echo "</image>\n";



$que = mysql_query("select a.*,b.bo_subject from $g4[board_new_table] a, $g4[board_table] b where a.bo_table = b.bo_table and a.wr_id=a.wr_parent and b.bo_read_level<2 order by a.bn_datetime desc limit $cut_rows ");
while ($data = @mysql_fetch_array($que)){


$row = @mysql_fetch_array(mysql_query("select wr_id,wr_subject,wr_content,wr_name,wr_datetime,wr_option from g4_write_".$data[bo_table]." where wr_id='$data[wr_parent]' "));
if($row[0]) {
$row[wr_content] = str_replace("<BR>","<br />",$row[wr_content]);
if (strstr($row[wr_option], 'html'))
$html = 1;
else
$html = 0;

echo "<item>\n";
echo "<title>".specialchars_replace($row[wr_subject])."</title>\n";
echo "<link>".specialchars_replace("$g4[url]/$g4[bbs]/board.php?bo_table=$data[bo_table]&wr_id=$row[wr_id]")."</link>\n";

if(strstr($row[wr_option], 'secret')) {
echo "<description><![CDATA[비공개 글입니다.]]></description>\n";
} else {
echo "<description><![CDATA[". conv_content($row[wr_content], $html)."]]></description>\n";
}
echo "<category>".$data[bo_subject]."</category>\n";
echo "<author>".specialchars_replace($row[wr_name])."</author>\n";
$date = $row[wr_datetime];
$date = date('r', strtotime($date));
echo "<pubDate>$date</pubDate>\n";
echo "</item>\n";


}

}

echo "</channel>\n";
echo "</rss>\n";

//결과를 파일에 저장
$f = fopen($cachefile,'w');
fwrite($f,ob_get_contents());
fclose($f);

//캐쉬 종료하고 결과를 출력
ob_end_flush();
}
@chmod($cachefile, 0606);

?>
© SIRSOFT
현재 페이지 제일 처음으로