-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss.php
147 lines (123 loc) · 5.08 KB
/
rss.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
# JSboard RSS Feed
# $Id: rss.php,v 1.13 2009-11-16 21:52:45 oops Exp $
#
# header file 삽입
#
if ( ! @file_exists ("include/header.php") ) {
echo "<script type=\"text/javascript\">\nalert('Don\'t exist header file');\n" .
"history.back();\nexit;\n</script>\n";
exit();
} else {
include 'include/header.php';
}
# RSS 사용 여부 체크 (user config file 로 부터)
#
if ( ! $rss['use'] ) {
echo "Don't rss support on this board\n";
exit();
}
# rss 에서 출력할 리스트의 수를 지정
#
$rss['default_article_number'] = '30';
# 게시판 주소
#
$rss['link'] = $board['path'] . "list.php?table=" . $table;
if (!$no)
$no = $rss['default_article_number'];
# DB 정보 가져오기
#
$c = sql_connect($db['server'], $db['user'], $db['pass'], $db['name']);
# Description 정보가 있게 할 것인지 아닌지 여부 체크 (config file 에서 체크)
#
if ($rss['is_des'])
$sql = "select no, date, name, rname, title, text from {$table} order by date DESC limit {$no}";
else
$sql = "select no, date, name, rname, title from {$table} order by date DESC limit $no";
$result = sql_query ($sql, $c);
$i = 0;
while( $rss_article[$i] = sql_fetch_array($result) ) {
$rss_article[$i]['title'] = htmlspecialchars ($rss_article[$i]['title'], ENT_QUOTES);
$rss_article[$i]['link'] = "{$board['path']}read.php?table={$table}&no={$rss_article[$i]['no']}";
$rss_article[$i]['date'] = date ("r", $rss_article[$i]['date']);
#$rss_article[$i]['date'] = date("Y-m-d",$rss_article[$i]['date'] ) . 'T' . date("H:i:sO", $rss_article[$i]['date']);
if ( $rss['is_des'] ) {
#$rss_article[$i]['text'] = preg_replace ("!\n!", "<br />\n", $rss_article[$i]['text']);
$rss_article[$i]['text'] = preg_replace ("!([0-9]+;[0-9]+m)?!", "", $rss_article[$i]['text']);
$rss_article[$i]['text'] = htmlspecialchars ($rss_article[$i]['text']);
$rss_article[$i]['text'] = auto_link ($rss_article[$i]['text']);
$_body = "<table width=\"100%\" border=0 cellpadding=0 cellspacing=1>\n" .
"<tr><td bgcolor=\"#000000\">\n" .
"<table width=\"100%\" border=0 cellpadding=3 cellspacing=1>\n" .
"<tr><td style=\"font-weight: bold; color: #ffffff\">\n" .
"REPLY : <a href={$board['path']}reply.php?table={$table}&no={$rss_article[$i]['no']} style=\"color: #ffffff; text-decoration: none;\">" .
"{$board['path']}reply.php?table={$table}&no={$rss_article[$i]['no']}</a><br />\n" .
"DELETE: <a href={$board['path']}delete.php?table={$table}&no={$rss_article[$i]['no']} style=\"color: #ffffff; text-decoration: none;\">" .
"{$board['path']}delete.php?table={$table}&no={$rss_article[$i]['no']}</a>\n" .
"</td></tr>\n" .
"</table>\n" .
"</td></tr>\n" .
"<tr><td bgcolor=\"#000000\">\n" .
"<table width=\"100%\" border=0 cellpadding=3 cellspacing=1>\n" .
"<tr><td bgcolor=\"#ffffff\" style=\"font-size: 11px;\"><pre>\n" .
"{$rss_article[$i]['text']}\n" .
"</pre></td></tr>\n" .
"</table>\n" .
"</td></tr>\n" .
"</table>\n";
$_body = htmlspecialchars ($_body, ENT_QUOTES);
$rss_article[$i]['text'] = $_body;
}
if (!$rss_article[$i]['name'])
$rss_article[$i]['name'] = $rss_article[$i]['rname'];
$i++;
}
$rss_article_num = $i;
unset($result, $i);
sql_close($c);
$now = time ();
$cYear = date ("Y", $now);
$bdate = date ("r", $now);
$_charset = strtolower ($_('charset'));
$gotoUTF8 = check_utf8_conv ($_charset);
$cset = $gotoUTF8 ? 'utf-8' : $_charset;
# 여기 까지 이상이 없으면, 실제 RSS 출력
#
header ('Cache-Control: no-cache, pre-check=0, post-check=0, max-age=0');
header ('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header ('Content-Type: text/xml; charset=' . $cset);
utf8_fallback ($rss['channel'], $_charset);
utf8_fallback ($board['title'], $_charset);
echo "<?xml version=\"1.0\" encoding=\"{$cset}\"?>\n";
?>
<rss version="2.0"
xml:base="<?=$board['path']?>"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="http://<?=$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']?>" rel="self" type="application/rss+xml" />
<title><?=$rss['channel']?></title>
<link><?=$rss['link']?></link>
<description><?=$board['title']?></description>
<language><?=$_code?></language>
<copyright>1999-<?=$cYear?> JSBoard Open Project</copyright>
<lastBuildDate><?=$bdate?></lastBuildDate>
<generator>JSBoard <?=$board['ver']?></generator>
<?php
for ( $i=0; $i<$rss_article_num; $i++ ) {
utf8_fallback ($rss_article[$i], $_charset);
echo "<item>\n" .
" <title>{$rss_article[$i]['title']}</title>\n" .
" <link>{$rss_article[$i]['link']}</link>\n" .
" <guid>{$rss_article[$i]['link']}</guid>\n";
if ( $rss['is_des'] ) {
echo " <description>{$rss_article[$i]['text']}</description>\n";
}
echo " <pubDate>{$rss_article[$i]['date']}</pubDate>\n" .
" <dc:creator>{$rss_article[$i]['name']}</dc:creator>\n" .
"</item>\n";
}
?>
</channel>
</rss>