#!/bin/perl use warnings; use strict; use NDBM_File; use POSIX; use CGI; sub ftime { my ($time) = @_; return strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime($time)); } my %data; tie %data, "NDBM_File", "/home/azz/.irssrssi/db", O_RDONLY, 0644 or die "can't open"; my %items; my $latest = 0; foreach my $uri (keys %data) { my ($time, $topic) = split(":", $data{$uri}, 2); $latest = $time if ($time > $latest); $items{$time} = [ $uri, $topic ]; } print "Content-type: application/rdf+xml\r\n\r\n"; print < irssrssi http://localhost/ IRC topics EOF print "" . ftime($latest) . "\n"; foreach my $time (sort { $b <=> $a } keys %items) { my ($uri, $topic) = @{$items{$time}}; # Remove non-printing and non-ASCII characters. $topic =~ s/[\x00-\x1F\x80-\xFF]//g; # If there's more than 60 characters without a space, insert # one. $topic =~ s/([^ ]{60})/$1 /g; $uri =~ /^irc:\/\/(.*):(.*)\/(.*)$/; print "#$3 on $1:$2\n"; print "$uri\n"; # We escape the topic twice: once to turn it into HTML, and # again to embed the HTML in the RSS. print "" . CGI::escapeHTML(CGI::escapeHTML($topic)) . "\n"; print "\n"; } print < EOF untie %data;