/
vws_rss.php
executable file
·74 lines (60 loc) · 2.02 KB
/
vws_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
<?php
include_once './inc/common.inc.php';
$site = 'http://' . $_SERVER['SERVER_NAME'] . substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
$rsshead =<<<XSL
<?xml version="1.0" encoding="UTF-8"?>
<!-- Create by Vayn@JxLab -->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title>$vw_sitename - Project VaynWords</title>
<atom:link href="$site/feed" rel="self" type="application/rss+xml" />
<link>http://lab.jixia.org/project_vws/</link>
<description>Project VaynWords - Study English with Twitter and RSS</description>
<lastBuildDate>$date</lastBuildDate>
<generator>http://elnode.com/</generator>
<language>en</language>
XSL;
header("Content-Type: application/rss+xml");
echo $rsshead;
$words = VWSCore::pullwords();
foreach ($words as $word) {
$id = $word['id'];
$key = $word['key'];
$date = date(DATE_RSS, $word['date']);
$pho = $word['pho'] ? "/{$word['pho']}/" : '';
$rssbody = "
<item>
<title>{$key}</title>
<link>{$site}/index.php#{$id}</link>
<description>
<p>{$key} {$pho}</p>";
$def = $word['def'];
$def_pos = $word['dpos'];
$rssbody .= "<p>$def_pos $def</p>";
$seno = $word['ses'];
$sent = $word['scs'];
$sen_pos = $word['pos'];
if ($seno != '' || $sent != '') {
if ($sen_pos != '') $sen_pos = ' [' . $sen_pos . ']';
$rssbody .= '<p>' . $seno . $sen_pos . '</p>';
$rssbody .= '<p>' . $sent . '</p>';
}
$rssbody .= "</description>
<pubdate>$date</pubdate>
<guid>$site/index.php#$id</guid>
</item>";
echo $rssbody;
}
$rssfooter =<<<XSL
</channel>
</rss>
XSL;
echo $rssfooter;
?>