forked from sergejey/majordomo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrss.php
More file actions
75 lines (55 loc) · 2.13 KB
/
rss.php
File metadata and controls
75 lines (55 loc) · 2.13 KB
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
<?php
/**
* RSS script
*
* @package MajorDoMo
* @author Serge Dzheigalo <jey@tut.by> http://smartliving.ru/
* @version 1.2
*/
include_once("./config.php");
include_once("./lib/loader.php");
// start calculation of execution time
startMeasure('TOTAL');
include_once(DIR_MODULES . "application.class.php");
$session = new session("prj");
// connecting to database
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
include_once("./load_settings.php");
$qry = "1";
if ($_GET['level'])
{
$qry .= " AND shouts.IMPORTANCE>=" . (int)$_GET['level'];
}
$res = SQLSelect("SELECT shouts.*, UNIX_TIMESTAMP(shouts.ADDED) as TM, users.NAME FROM shouts LEFT JOIN users ON shouts.MEMBER_ID=users.ID WHERE $qry ORDER BY shouts.ADDED DESC, ID DESC LIMIT 20");
$res = array_reverse($res);
$total = count($res);
if ($total)
{
$result = "<?xml version=\"1.0\" encoding=\"windows-1251\"?>";
$result .= "<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:annotate=\"http://purl.org/rss/1.0/modules/annotate/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">";
$result .= "<channel>";
$result .= "<title>" . PROJECT_TITLE . "</title>";
$result .= "<link>http://" . PROJECT_DOMAIN . "/</link>";
$result .= "<lastBuildDate>" . date('r') . "</lastBuildDate>";
$result .= "<description>" . PROJECT_TITLE . " RSS feed</description>";
for($i=0;$i<$total;$i++)
{
$res[$i]['LINK'] = 'http://' . PROJECT_DOMAIN . '/event' . $res[$i]['ID'];
$result .="<item>";
$rsult .="<title>" . substr($res[$i]['MESSAGE'], 0, 500)."</title>";
$result .="<pubDate>" . date('r', $res[$i]['TM']) . "</pubDate>";
$result .= "<description>" . str_replace("\r", '', $res[$i]['MESSAGE'])."</description>";
if ($res[$i]['NAME'])
{
$result .= "<dc:creator>" . $res[$i]['NAME' ] ."</dc:creator>";
}
$result .= "<link>".$res[$i]['LINK']."</link>";
$result .= "<guid>".$res[$i]['LINK']."</guid>\n";
$result .= "</item>";
}
$result .= "</channel>";
$result .= "</rss>";
Header("Content-type:text/xml; charset=utf-8");
echo $result;
}
?>