rss.php 파일 조금 수정 해봤습니다. > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

rss.php 파일 조금 수정 해봤습니다. 정보

rss.php 파일 조금 수정 해봤습니다.

본문

rss.php 파일 조금 수정 해봤습니다.
rss 서비스 할때 내용이 다 전송 되 길래 글자 제한.
로고 안 보여서 로고 보이게, 설명부분 ....  수정

이렇게
<?
include_once("./_common.php");

// 특수문자 변환
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;
}

$sql = " select gr_id, bo_subject, bo_page_rows, bo_read_level from $g4[board_table] where bo_table = '$bo_table' ";
$row = sql_fetch($sql);
$subj2 = specialchars_replace($row[bo_subject], 255);
$lines = $row[bo_page_rows];

// 비회원 읽기가 가능한 게시판만 RSS 지원
if ($row[bo_read_level] >= 2) {
    echo "비회원 읽기가 가능한 게시판만 RSS 지원합니다.";
    exit;
}

Header("Content-type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); 

$sql = " select gr_subject from $g4[group_table] where gr_id = '$row[gr_id]' ";
$row = sql_fetch($sql);
$subj1 = specialchars_replace($row[gr_subject], 255);

echo "<?xml version=\"1.0\" encoding=\"euc-kr\"?>\n";
echo "<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
echo "<channel>\n";
echo "<title>".specialchars_replace("$subj1 > $subj2")."</title>\n";
echo "<link>".specialchars_replace("$g4[url]/$g4[bbs]/board.php?bo_table=$bo_table")."</link>\n";
echo "<description>안녕하세요?\n $config[cf_title] rss 서비스 입니다. </description>\n";
echo "<language>ko</language>\n";

echo "<image>\n";
echo "<title>안녕하세요?\n $config[cf_title] rss 서비스 입니다. </title>\n";
echo "<url>".specialchars_replace("$g4[url]/img/rss_logo.gif")."</url>\n";
echo "<link>$g4[url]</link>\n";
echo "</image>\n";

$sql = " select wr_id, wr_subject, wr_content, wr_name, wr_datetime, wr_option
          from $g4[write_prefix]$bo_table
          where wr_is_comment = 0
            and wr_option not like '%secret%'
          order by wr_num, wr_reply limit 0, $lines ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
    $file = "";
    //$file .= view_file_link($row[wr_file1]);
    //$file .= view_file_link($row[wr_file2]);

    //$file = preg_replace("/\.\//", "$cfg[d_url]/", $file);

    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=$bo_table&wr_id=$row[wr_id]")."</link>\n";

$row[wr_content] = cut_str($row[wr_content],300," ....more ");

echo "<description><![CDATA[".$file . conv_content($row[wr_content], $html)."]]></description>\n";
    echo "<dc:creator>".specialchars_replace($row[wr_name])."</dc:creator>\n";
    $date = $row[wr_datetime];
//    $date = substr($date,0,10) . "T" . substr($date,11,8) . "+09:00";
    echo "<dc:date>$date</dc:date>\n";
    echo "</item>\n";
}

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

로고 보이시게 하려면 잘 만드셔서  /img  디렉토리에 넣으시면됩니다

로고명 : rss_logo.gif 맘에 안 들면 적당 맘데로 바꿔서 사용하세요.

적당히 잘라야 홈에도 .......

혹 몰라서 $row[wr_content1] = cut_str($row[wr_content],300," ....more ");

하고 이렇게 이렇게 해도됩니다.
추천
0

댓글 4개

전체 3,309 |RSS
그누4 팁자료실 내용 검색

회원로그인

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