RSS generator -> afbeelding verwerken
Hoe kan ik dit in valid RSS schrijven want ik had gekeken naar de rss van zoom.nl (een foto database -> http://gallery.zoom.nl/rss/) en daar werken ze wel valid en bij mij http://www.autodrome.net/news.xml is het niet valid.
Hoe kan dit en hoe fix ik dit?
Dit is de rss generator (niet letten op de rare database aanroep is tekstdb) :
Code (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
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
<?
$rssbestand = "../news.xml";
function accents($text) {
global $export;
$search = array ('ç', 'á', 'é', 'í', 'ó', 'ú', 'ã', 'õ', 'â', 'ê', 'î', 'ô', 'û', 'ë');
$replace = array ('c', 'a', 'e', 'i', 'o', 'u', 'a', 'o', 'a', 'e', 'i', 'o', 'u', 'e');
$export = str_replace($search, $replace, $text);
return $export;
}
$buffer = "";
$url = "http://www.autodrome.net"; // homepage url
$buffer .= "<?xml version=\"1.0\"? >\n"; //fout gemaakt voor phphulp
$buffer .= "\t<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
$buffer .= "\t xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
$buffer .= "\t\t<channel>\n";
$buffer .= "\t\t\t<title>Autodrome News</title>\n";
$buffer .= "\t\t\t<link>".htmlspecialchars($url."?p=news")."</link>\n";
$buffer .= "\t\t\t<description>Autodrome News</description>\n\n";
$buffer .= "\t\t\t<language>en-us</language>\n\n";
$buffer .= "\t\t\t<generator>http://www.autodrome.net</generator>\n\n";
$buffer .= "\t\t\t<image>\n\n";
$buffer .= "\t\t\t<url>".htmlspecialchars($url."/logo.gif")."</url>\n\n";
$buffer .= "\t\t\t<title>Autodrome News</title>\n\n";
$buffer .= "\t\t\t<link>".htmlspecialchars($url."?p=news")."</link>\n\n";
$buffer .= "\t\t\t<width>123</width>\n\n";
$buffer .= "\t\t\t<height>42</height>\n\n";
$buffer .= "\t\t\t</image>\n\n";
$db = new Database("autodrome");
$result = $db->executeQuery("SELECT * FROM news ORDER BY id DESC LIMIT 10");
while ($result->next()) {
$data = $result->getCurrentValuesAsHash();
$titel = $data['Titel'];
$id = accents($data['id']);
$rss_datum = $data['Datum'];
list($dag, $maand, $jaar) = explode('-', $rss_datum);
$rss_datum = gmdate("D, d M Y H:i:s", mktime(18, 0, 0, $maand, $dag, $jaar));
$datum = accents($rss_datum);
$tekst = str_replace('<br />','', $data['Tekst']);
$tekst = preg_replace("#<img (.*?)>#si","<img \\1 />", $tekst);
$tekst = preg_replace("#<a href=(.*?)>(.*?)</a>#si","\\2", $tekst);
$omschrijving = accents($tekst);
$buffer .= "\t\t\t<item>\n";
$buffer .= "\t\t\t<title>".htmlspecialchars($titel)."</title>\n";
$buffer .= "\t\t\t<link>".htmlspecialchars($url."?p=news&n=".$id)."</link>\n";
$buffer .= "\t\t\t<description>".$omschrijving."</description>\n";
//$buffer .= "\t\t\t<content:encoded><![CDATA[".$omschrijving."]]></content:encoded>\n";
$buffer .= "\t\t\t<pubDate>".$datum." GMT</pubDate>\n";
$buffer .= "\t\t\t<guid isPermaLink=\"false\">Article ".$id."</guid>\n";
$buffer .= "\t\t\t</item>\n";
}
$buffer .= "\n\t\t</channel>\n";
$buffer .= "\t</rss>\n";
if (is_writable($rssbestand))
{
if (!$handle = fopen($rssbestand, 'w+'))
{
echo "<b>Fout</b><br>Kan het bestand $rssbestand niet openen.<br><br>";
}
else
{
if (fwrite($handle, $buffer) === FALSE)
{
echo "<b>Fout</b><br>Kan het bestand $rssbestand niet schrijven.<br><br>";
}
else
{
echo "Het RSS nieuws is aangepast.<br><br>";
}
fclose($handle);
}
}
else
{
echo "<b>Fout</b><br>Het bestand $rssbestand is niet beschrijfbaar.<br><br>";
}
?>
$rssbestand = "../news.xml";
function accents($text) {
global $export;
$search = array ('ç', 'á', 'é', 'í', 'ó', 'ú', 'ã', 'õ', 'â', 'ê', 'î', 'ô', 'û', 'ë');
$replace = array ('c', 'a', 'e', 'i', 'o', 'u', 'a', 'o', 'a', 'e', 'i', 'o', 'u', 'e');
$export = str_replace($search, $replace, $text);
return $export;
}
$buffer = "";
$url = "http://www.autodrome.net"; // homepage url
$buffer .= "<?xml version=\"1.0\"? >\n"; //fout gemaakt voor phphulp
$buffer .= "\t<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
$buffer .= "\t xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
$buffer .= "\t\t<channel>\n";
$buffer .= "\t\t\t<title>Autodrome News</title>\n";
$buffer .= "\t\t\t<link>".htmlspecialchars($url."?p=news")."</link>\n";
$buffer .= "\t\t\t<description>Autodrome News</description>\n\n";
$buffer .= "\t\t\t<language>en-us</language>\n\n";
$buffer .= "\t\t\t<generator>http://www.autodrome.net</generator>\n\n";
$buffer .= "\t\t\t<image>\n\n";
$buffer .= "\t\t\t<url>".htmlspecialchars($url."/logo.gif")."</url>\n\n";
$buffer .= "\t\t\t<title>Autodrome News</title>\n\n";
$buffer .= "\t\t\t<link>".htmlspecialchars($url."?p=news")."</link>\n\n";
$buffer .= "\t\t\t<width>123</width>\n\n";
$buffer .= "\t\t\t<height>42</height>\n\n";
$buffer .= "\t\t\t</image>\n\n";
$db = new Database("autodrome");
$result = $db->executeQuery("SELECT * FROM news ORDER BY id DESC LIMIT 10");
while ($result->next()) {
$data = $result->getCurrentValuesAsHash();
$titel = $data['Titel'];
$id = accents($data['id']);
$rss_datum = $data['Datum'];
list($dag, $maand, $jaar) = explode('-', $rss_datum);
$rss_datum = gmdate("D, d M Y H:i:s", mktime(18, 0, 0, $maand, $dag, $jaar));
$datum = accents($rss_datum);
$tekst = str_replace('<br />','', $data['Tekst']);
$tekst = preg_replace("#<img (.*?)>#si","<img \\1 />", $tekst);
$tekst = preg_replace("#<a href=(.*?)>(.*?)</a>#si","\\2", $tekst);
$omschrijving = accents($tekst);
$buffer .= "\t\t\t<item>\n";
$buffer .= "\t\t\t<title>".htmlspecialchars($titel)."</title>\n";
$buffer .= "\t\t\t<link>".htmlspecialchars($url."?p=news&n=".$id)."</link>\n";
$buffer .= "\t\t\t<description>".$omschrijving."</description>\n";
//$buffer .= "\t\t\t<content:encoded><![CDATA[".$omschrijving."]]></content:encoded>\n";
$buffer .= "\t\t\t<pubDate>".$datum." GMT</pubDate>\n";
$buffer .= "\t\t\t<guid isPermaLink=\"false\">Article ".$id."</guid>\n";
$buffer .= "\t\t\t</item>\n";
}
$buffer .= "\n\t\t</channel>\n";
$buffer .= "\t</rss>\n";
if (is_writable($rssbestand))
{
if (!$handle = fopen($rssbestand, 'w+'))
{
echo "<b>Fout</b><br>Kan het bestand $rssbestand niet openen.<br><br>";
}
else
{
if (fwrite($handle, $buffer) === FALSE)
{
echo "<b>Fout</b><br>Kan het bestand $rssbestand niet schrijven.<br><br>";
}
else
{
echo "Het RSS nieuws is aangepast.<br><br>";
}
fclose($handle);
}
}
else
{
echo "<b>Fout</b><br>Het bestand $rssbestand is niet beschrijfbaar.<br><br>";
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Jurn
Er zijn nog geen reacties op dit bericht.