Gossamer Forum
Home : Products : Links 2.0 : Customization :

Help with RSS

Quote Reply
Help with RSS
Hello,

i have written a small script which extracts the new entrys from the db as an rss file.

I call it via cron this way:

/srv/www/htdocs/web8/html/cgi-bin/./rssoutput.pl>/srv/www/htdocs/web8/html/rss/rss.xml

Can someone help me by modifying it, so that i can call it via the browser on demand?


#!/usr/bin/perl -w
$rssdate = &get_rssdate;
$time = &get_time;
open (DATEI, "/srv/www/htdocs/web8/html/cgi-bin/links/admin/data/links.db");
flock (DATEI, 2);
@storeit = <DATEI>;
close DATEI;
# print "Content-type: text/plain\n\n";
print <<EOT;
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
<title>domain.de RSS Feed</title>
<link>http://www.domain.de</link>
<description>domain.de RSS Feed</description>
<language>de</language>
<lastBuildDate>$rssdate $time +0000</lastBuildDate>
<copyright>News</copyright>
EOT
foreach $entrys (@storeit){
chomp($entrys);
($id,$titel,$url,$datum,$kategorie,$description,$name,$email,$hits,$isNew)=split(/\|/,$entrys);
if ($isNew eq "Yes") {
$sponsor = "";
if ($entrys =~ m/Sponsor/) {
$sponsor = "(Werbung)";
}
$titel =~ s/&/&#38;/g;
$titel =~ s/</&#60;/g;
$titel =~ s/>/&#62;/g;
$titel =~ s/’/'/g;
$titel =~ s/€/Euro/g;
$titel =~ s/£/&#163;/g;
$titel =~ s/©/&#169;/g;
$titel =~ s/®/&#174;/g;
$titel =~ s/«/&#171;/g;
$titel =~ s/»/&#187;/g;
$titel =~ s/"/&quot;/g;
$titel =~ s/–/-/g;
$description =~ s/&/&#38;/g;
$description =~ s/</&#60;/g;
$description =~ s/>/&#62;/g;
$description =~ s/’/'/g;
$description =~ s/€/Euro/g;
$description =~ s/£/&#163;/g;
$description =~ s/©/&#169;/g;
$description =~ s/®/&#174;/g;
$description =~ s/«/&#171;/g;
$description =~ s/»/&#187;/g;
$description =~ s/"/&quot;/g;
$description =~ s/–/-/g;
$description =~ s/\015\012|\015|\012/ /sg;
$description =~ s/ / /g;
$description =~ s/`+/ /g;
print <<EOT;
<item>
<title>$titel</title>
<description>$description $sponsor - Eintrag vom $datum</description>
<link>http://www.domain.de/Detailed/$id.shtml</link>
<guid>http://www.domain.de/Detailed/$id.shtml</guid>
</item>
EOT
}
}
print <<EOT;
</channel>
</rss>
EOT
sub get_rssdate {
# --------------------------------------------------------
# Returns the current date.
#
my ($time1) = $_[0];
($time1) or ($time1 = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1-3600);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
my @days = qw!Sun Mon Tue Wed Thu Fri Sat!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$days[$dweek], $day $months[$mon] $year";
}
sub get_time {
# --------------------------------------------------------
# Returns the time in the format "hh-mm-ss".
#
my $time = shift;
$time ||= time();
my ($sec, $min, $hour, @junk) = localtime ($time-3600);
($sec < 10) and ($sec = "0$sec");
($min < 10) and ($min = "0$min");
($hour < 10) and ($hour = "0$hour");

return "$hour:$min:$sec";
}

Best, Karl
Subject Author Views Date
Thread Help with RSS Karl 6350 Jun 2, 2008, 4:38 AM
Thread Re: [Karl] Help with RSS
Andy 6295 Jun 2, 2008, 5:22 AM
Thread Re: [Andy] Help with RSS
Karl 6267 Jun 3, 2008, 3:21 AM
Thread Re: [Karl] Help with RSS
Andy 6272 Jun 3, 2008, 3:26 AM
Thread Re: [Andy] Help with RSS
Karl 6275 Jun 3, 2008, 4:05 AM
Thread Re: [Karl] Help with RSS
Andy 6276 Jun 3, 2008, 4:13 AM
Thread Re: [Andy] Help with RSS
Karl 6283 Jun 4, 2008, 1:45 AM
Post Re: [Karl] Help with RSS
Andy 6295 Jun 4, 2008, 1:53 AM