php파일xml파싱질문입니다. > 그누4 질문답변

그누4 질문답변

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

php파일xml파싱질문입니다. 정보

php파일xml파싱질문입니다.

본문

아래소스는 제로보드에서플래시연동할때xml 부분을 php로 파싱하는소스인데요 

그누보드로적용하려고 연습중입니다. ㅜㅜ 그누보드랑 호환되게 수정좀해주세요

주석하구요 ㅜㅜ 딸딸외울려고합니다.


<?
header('Content-type: application/xml');
header("Pragma: no-cache");  
header("Cache-Control: no-cache,must-revalidate");  

// 아래 수정하세요
$aj_host = "localhost";    // 호스트
$aj_id = "";        // 아이디
$aj_pass = "";  // 비밀번호
$aj_dbname = "";  // 디비명
mysql_connect("$aj_host","$aj_id","$aj_pass");
mysql_select_db("$aj_dbname");
$_zb_path = "/"; // 제로보드까지의 절대경로
$link_url = ""; // 기본 게시판 view주소
$bdid="story"; // 불러올 게시판 id
$limit_no="10"; // 몇개를 불러올것인지
// 수정 여기까지

$result=mysql_query("select * from zetyx_board_$bdid where is_secret!='1' order by no desc limit $limit_no"); // 비밀글 제외하고 $limit_no 수만큼 불러와라

function del_html( $str ) { // 제로평션
    $str = str_replace( ">", ">",$str );
    $str = str_replace( "<", "<",$str );
    return $str;
}

function cut_str($msg,$cut_size) { // 문자컷, utf-8도 잘 잘리게수정
    if($cut_size<=0) return $msg;
    if(ereg("\[re\]",$msg)) $cut_size=$cut_size+4;
    for($i=0;$i<$cut_size;$i++) if(ord($msg[$i])>127) $han++; else $eng++;
    $cut_size=$cut_size+(int)$han*0.3;
    $point=1;
    for ($i=0;$i<strlen($msg);$i++) {
            if ($point>$cut_size) return $pointtmp."...";
            if (ord($msg[$i])<=127) {
                $pointtmp.= $msg[$i];
                if ($point%$cut_size==0) return $pointtmp."...";
            } else {
                if ($point%$cut_size==0) return $pointtmp."...";
                $pointtmp.=$msg[$i].$msg[++$i].$msg[++$i];
                $point += 2;
            }
            $point++;
    }
    return $pointtmp;
}

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<events>";
while($data=mysql_fetch_array($result)) { // 돌려~
    $no = $data['no']; // 번호
    $date = date("Y/m/d", $data['reg_date']); // 날짜

    $data['subject']=trim($data['subject']);
    $data['subject']=strip_tags($data['subject']);
    $subject1 = str_replace('"', '',stripslashes(iconv("EUC-KR", "UTF-8",$data['subject']))); // 제목, 한글처리
    $subject= cut_str($subject1,30); // 제목자르기

    $data['memo']=trim($data['memo']);
    $data['memo']=strip_tags($data['memo']);
    $data['memo']=str_replace("\r","",$data['memo']);
    $data['memo']=str_replace("\n","",$data['memo']);
    $data['memo']=str_replace('"','"',$data['memo']);
    $data['memo']=str_replace("'","",$data['memo']);
    $memo1 = stripslashes(iconv("EUC-KR", "UTF-8",$data['memo'])); // 메모, 한글처리
    $memo= cut_str(del_html($memo1),300); // 메모자르기

    $img1 = $data['file_name1']; // 첨부파일1

    if(eregi("\.gif|\.png|\.bmp|\.jpg",str_replace("%2F", "/", urlencode($img1)))) {
        $ps_list_img1 ="/phpThumb_1.7.4/phpThumb.php?src=".$_zb_path."".$img1."&w=80&h=80&iar=1&q=100";
    }else{
        $ps_list_img1 = "noimg.jpg"; // 이미지가 없는것을 위해
    }

    echo "<item date=\"".$date."\">"; // 반복 시작
    echo "<title><![CDATA[ ".$subject."]]></title>"; // 제목 출력
    echo "<thumb>".$ps_list_img1."</thumb>"; // 이미지 출력
    echo "<text>".$memo."</text>"; // 메모 출력
    echo "<url>".$link_url."?id=".$bdid."&no=".$no."</url>"; // 링크걸고
    echo "</item>"; // 반복 끝
}// end while
echo "</events>";
?>

댓글 전체

<?
$_gnu_path = "/gnu"; //그누보드가 설치되어 있는 경로
$g4_path = "$_SERVER[DOCUMENT_ROOT]/gnu"; //그누보드가 설치되어 있는 경로
include_once("$g4_path/common.php");
include_once("$g4[path]/lib/thumb.lib.php"); ///불당썸 이용하세요
$noimg = $g4[path]."/img/_noimage.jpg"; ///불당썸 이미지가 없는것을 위해

$thumbx = 80;  /// 썸네일 가로
$thumby = 80;  /// 썸네일 세로
/* $ps_list_img1 ="/phpThumb_1.7.4/phpThumb.php?src=".$_zb_path."".$img1."&w=80&h=80&iar=1&q=100"; */
/* 원본의 위라인 참조 */
/* phpthumb를 이용해 가로세로 80픽셀 퀄리티 100의 썸네일을 만든다는 뜻 */

$bo_table = "story";// 불러올 게시판 id (원본과 동일한 게시판 id)
$rows=10; // 몇개를 불러올것인지
$subject_len=30; //제목 길이 /* $subject= cut_str($subject1,30); // 제목자르기 <--이 라인 참조 */

$list = array();// 배열 생성

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);// 보드 테이블의 정보를 가져 옵니다.

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름


$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows "; //순차적으로 가져오기

    $result = sql_query($sql);// 게시판의 목록을 가져와 배열에 저장합니다.
    for ($i=0; $row = sql_fetch_array($result); $i++)
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);


$str .= "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> \n
<events>\n
";



for($i=0; $i<count($list); $i++){ // 반복 시작
for($j=0; $j<$list[$i][file][count]; $j++){
if($list[$i][file][$j][view]){
$subject = iconv("EUC-KR", "UTF-8", stripslashes($list[$i][subject])); // 제목, 한글처리
$file = "$_gnu_path/data/file/$bo_table/{$list[$i][file][$j][file]}";

// 아래 불당썸 참조
$filter[type] = 99;
$filter[arg1] = 100;
$filter[arg2] = 1;
$filter[arg3] = 2;

$thumb = thumbnail($file, $thumbx, $thumby, 0, 1, 100, 0, "",  $filter, $noimg);
$memo= iconv("EUC-KR", "UTF-8", cut_str(strip_tags($list[$i][wr_content]),300));
$url = "$_gnu_path/bbs/board.php?bo_table=".$bo_table."&wr_id={$list[$i][wr_id]}";
$date = $list[$i][datetime2]; // 날짜
break;
}
}

$str .="<item date=\"".$date."\"> \r\n
<title><![CDATA[ ".$subject."]]></title>\r\n
<thumb>".$thumb."</thumb> \r\n
<title>".$subject."</title>\r\n
<text>".$memo."</text> \r\n
<url>".$url."</url>\r\n
</item>\r\n
";
} // 반복 끝


$str .= "</events>\n";
 
echo($str);

?>


허접한 실력으로 비슷하게 만들어 봤는데...안 될것 같긴합니다만...적용해 보세요.
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT