Редакция 140 | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
125 | alex-w | 1 | <?php |
2 | /* |
||
3 | * Project: Ant: sources.list generator |
||
4 | * File: feed.php |
||
5 | * |
||
6 | * This application is free software; you can redistribute it and/or |
||
7 | * modify it under the terms of the GNU Lesser General Public |
||
8 | * License as published by the Free Software Foundation; either |
||
9 | * version 2.1 of the License, or (at your option) any later version. |
||
10 | * |
||
11 | * This application is distributed in the hope that it will be useful, |
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
14 | * Lesser General Public License for more details. |
||
15 | * |
||
16 | * You should have received a copy of the GNU Lesser General Public |
||
17 | * License along with this library; if not, write to the Free Software |
||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
19 | * |
||
20 | */ |
||
21 | |||
126 | alex-w | 22 | require_once dirname(__FILE__)."/lib/init.php"; |
23 | |||
125 | alex-w | 24 | $mode = abs(intval($_GET["atom"])); |
25 | // RSS 2.0 - $mode = 0 |
||
26 | // Atom 1.0 - $mode = 1 |
||
27 | |||
28 | switch($mode) { |
||
29 | case '0': |
||
30 | $header = "application/rss+xml"; |
||
31 | $query =& $db->query("SELECT * FROM changelog ORDER BY log_id DESC LIMIT 1"); |
||
32 | $query->fetchInto($log, DB_FETCHMODE_ASSOC); |
||
33 | $lastbuilddate = date("r",strtotime($log["log_record"])); |
||
34 | $result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; |
||
130 | alex-w | 35 | $result .= "<rss version=\"2.0\"\n xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n xmlns:atom=\"http://www.w3.org/2005/Atom\"\n>\n"; |
125 | alex-w | 36 | $result .= "<channel>\n"; |
134 | alex-w | 37 | $result .= "<title>".$core->getSetting('codename',$db)." последние изменения</title>\n"; |
125 | alex-w | 38 | $result .= "<link>http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/</link>\n"; |
39 | $result .= "<description>Изменения списка поддерживаемых генератором sources.list дистрибутивов и репозиториев для них.</description>\n"; |
||
40 | $result .= "<language>ru</language>\n"; |
||
41 | $result .= "<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n"; |
||
42 | $result .= "<lastBuildDate>".$lastbuilddate."</lastBuildDate>\n"; |
||
130 | alex-w | 43 | $result .= "<atom:link href=\"http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/feed.php\" rel=\"self\" type=\"".$header."\" />\n"; |
125 | alex-w | 44 | $query =& $db->query("SELECT * FROM changelog ORDER BY log_id DESC LIMIT 10"); |
45 | if ($query->numRows()>0) { |
||
46 | while ($query->fetchInto($log, DB_FETCHMODE_ASSOC)) { |
||
47 | $result .= "<item>\n"; |
||
48 | $result .= "<title>".stripslashes($log["log_title"])."</title>\n"; |
||
127 | alex-w | 49 | $result .= "<link>http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/changelog.php?id=".$log["log_id"]."</link>\n"; |
125 | alex-w | 50 | $result .= "<pubDate>".date("r",strtotime($log["log_record"]))."</pubDate>\n"; |
51 | $result .= "<description><![CDATA[".stripslashes($log["log_desc"])."]]></description>\n"; |
||
52 | $result .= "<guid isPermaLink=\"false\">".md5("http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/changelog.php?id=".$log["log_id"])."</guid>\n"; |
||
53 | $result .= "</item>\n"; |
||
54 | } |
||
55 | } |
||
129 | alex-w | 56 | $result .= "</channel>\n</rss>"; |
125 | alex-w | 57 | break; |
58 | case '1': |
||
134 | alex-w | 59 | $header = "application/atom+xml"; |
60 | $query =& $db->query("SELECT * FROM changelog ORDER BY log_id DESC LIMIT 1"); |
||
61 | $query->fetchInto($log, DB_FETCHMODE_ASSOC); |
||
62 | $lastbuilddate = $log["log_record"]; |
||
63 | $lastbuilddate = str_replace(" ","T",$lastbuilddate); |
||
64 | $lastbuilddate .= "+06:00"; |
||
65 | $result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; |
||
66 | $result .= "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n"; |
||
67 | $result .= "<title>".$core->getSetting('codename',$db)." последние изменения</title>\n"; |
||
140 | alex-w | 68 | $result .= "<link href=\"http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/\" />\n"; |
69 | $result .= "<link href=\"http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/feed.php?atom=1\" rel=\"self\" />\n"; |
||
134 | alex-w | 70 | $result .= "<updated>".$lastbuilddate."</updated>\n"; |
71 | $result .= "<author>\n<name>\n".$core->getSetting('codename',$db)."</name>\n</author>\n"; |
||
138 | alex-w | 72 | $result .= "<id>urn:uuid:".$core->getUUID("http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/")."</id>\n"; |
134 | alex-w | 73 | $query =& $db->query("SELECT * FROM changelog ORDER BY log_id DESC LIMIT 10"); |
74 | if ($query->numRows()>0) { |
||
75 | while ($query->fetchInto($log, DB_FETCHMODE_ASSOC)) { |
||
76 | $result .= "<entry>\n"; |
||
77 | $result .= "<title type=\"html\">".stripslashes($log["log_title"])."</title>\n"; |
||
137 | alex-w | 78 | $result .= "<link href=\"http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/changelog.php?id=".$log["log_id"]."\" />\n"; |
135 | alex-w | 79 | $result .= "<summary type=\"html\"><![CDATA[".stripslashes($log["log_desc"])."]]></summary>\n"; |
138 | alex-w | 80 | $result .= "<id>urn:uuid:".$core->getUUID("http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/changelog.php?id=".$log["log_id"])."</id>\n"; |
134 | alex-w | 81 | $updated = str_replace(" ","T",$log["log_record"]); |
82 | $updated .= "+06:00"; |
||
83 | $result .= "<updated>".$updated."</updated>\n"; |
||
84 | $result .= "</entry>\n"; |
||
85 | } |
||
86 | } |
||
87 | $result .= "</feed>"; |
||
125 | alex-w | 88 | break; |
89 | } |
||
90 | |||
130 | alex-w | 91 | header("Content-type: ".$header."\n\n"); |
125 | alex-w | 92 | echo $result; |
93 | |||
94 | ?> |