(root)/trunk/feed.php - Редакция 328
Редакция 140 |
К новейшей редакции |
Авторство |
Сравнить с предыдущей |
Последнее изменение |
Открыть журнал
| RSS
<?php
/*
* Project: Ant: sources.list generator
* File: feed.php
*
* This application is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
require_once dirname(__FILE__)."/lib/init.php";
$mode = $secure->wrapInt($_GET["atom"]);
// RSS 2.0 - $mode = 0
// Atom 1.0 - $mode = 1
switch($mode) {
case '0':
$header = "application/rss+xml";
$query =& $db->query("SELECT * FROM changelog ORDER BY log_id DESC LIMIT 1");
$query->fetchInto($log, DB_FETCHMODE_ASSOC
);
$lastbuilddate = date("r",strtotime($log["log_record"]));
$result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$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";
$result .= "<channel>\n";
$result .= "<title>".$core->getSetting('codename',$db)." последние изменения</title>\n";
$result .= "<link>http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/</link>\n";
$result .= "<description>Изменения списка поддерживаемых генератором sources.list дистрибутивов и репозиториев для них.</description>\n";
$result .= "<language>ru</language>\n";
$result .= "<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
$result .= "<lastBuildDate>".$lastbuilddate."</lastBuildDate>\n";
$result .= "<atom:link href=\"http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/feed.php\" rel=\"self\" type=\"".$header."\" />\n";
$query =& $db->query("SELECT * FROM changelog ORDER BY log_id DESC LIMIT 10");
if ($query->numRows()>0) {
while ($query->fetchInto($log, DB_FETCHMODE_ASSOC
)) {
$result .= "<item>\n";
$result .= "<title>".$secure->stripStr($log["log_title"])."</title>\n";
$result .= "<link>http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/changelog.php?id=".$log["log_id"]."</link>\n";
$result .= "<pubDate>".date("r",strtotime($log["log_record"]))."</pubDate>\n";
$result .= "<description><![CDATA[".$secure->stripStr($log["log_desc"])."]]></description>\n";
$result .= "<guid isPermaLink=\"false\">".md5("http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/changelog.php?id=".$log["log_id"])."</guid>\n";
$result .= "</item>\n";
}
}
$result .= "</channel>\n</rss>";
break;
case '1':
$header = "application/atom+xml";
$query =& $db->query("SELECT * FROM changelog ORDER BY log_id DESC LIMIT 1");
$query->fetchInto($log, DB_FETCHMODE_ASSOC
);
$lastbuilddate = $log["log_record"];
$lastbuilddate = str_replace(" ","T",$lastbuilddate);
$lastbuilddate .= "+06:00";
$result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$result .= "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n";
$result .= "<title>".$core->getSetting('codename',$db)." последние изменения</title>\n";
$result .= "<link href=\"http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/\" />\n";
$result .= "<link href=\"http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/feed.php?atom=1\" rel=\"self\" />\n";
$result .= "<updated>".$lastbuilddate."</updated>\n";
$result .= "<author>\n<name>\n".$core->getSetting('codename',$db)."</name>\n</author>\n";
$result .= "<id>urn:uuid:".$core->getUUID("http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/")."</id>\n";
$query =& $db->query("SELECT * FROM changelog ORDER BY log_id DESC LIMIT 10");
if ($query->numRows()>0) {
while ($query->fetchInto($log, DB_FETCHMODE_ASSOC
)) {
$result .= "<entry>\n";
$result .= "<title type=\"html\">".$secure->stripStr($log["log_title"])."</title>\n";
$result .= "<link href=\"http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/changelog.php?id=".$log["log_id"]."\" />\n";
$result .= "<summary type=\"html\"><![CDATA[".$secure->stripStr($log["log_desc"])."]]></summary>\n";
$result .= "<id>urn:uuid:".$core->getUUID("http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/changelog.php?id=".$log["log_id"])."</id>\n";
$updated = str_replace(" ","T",$log["log_record"]);
$updated .= "+06:00";
$result .= "<updated>".$updated."</updated>\n";
$result .= "</entry>\n";
}
}
$result .= "</feed>";
break;
}
header("Content-type: ".$header."\n\n");
echo $result;
?>