#!/bin/perl -w use strict; use utf8; use CGI::Carp qw(fatalsToBrowser); use POSIX qw(strftime); use HTML::Entities; # Configuration my $PULKOCMS_ROOT = "/var/www/pulkocms/"; my $WEB_ROOT = ""; my $MY_TITLE = "PulkoMandy news"; my $MY_DESC = "PulkoMandy hacks and work and so on"; my $MY_LINK = "http://pulkomandy.tk"; my $MY_IMAGE = "http://pulkomandy.tk/favicon.ico"; my $now = time(); my $update = strftime("%a, %d %b %Y %H:%M:%S %z", localtime($now)) . "\n"; my @url; my @file; my $x; my $buffer; print "Content-Type: text/xml\n\n"; # TODO move this to common.pl ! sub Compare_date ($$) { my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$PULKOCMS_ROOT/cat/$_[0]"); my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtimeB,$ctime,$blksize,$blocks) = stat("$PULKOCMS_ROOT/cat/$_[1]"); return $mtimeB <=> $mtime; } opendir(CATDIR, "$PULKOCMS_ROOT/cat"); my @Cat = readdir(CATDIR); closedir(CATDIR); @url = grep(/\.article$/,@Cat); @url = sort Compare_date @url ; my @desc; for ($x=0;$x < 15;$x++) { last if not $url[$x]; open(ARTICLE,"$PULKOCMS_ROOT/cat/$url[$x]") or die("file not found"); $desc[$x] = ""; while (sysread ARTICLE, $buffer, 4096) { $desc[$x] = "$desc[$x]$buffer"; } close(ARTICLE); } map($_ = substr($_,0,length($_) - 8), @url); my @stuff = @url; map($_ = "http://pulkomandy.tk/_/_/_".$_, @url); print < $MY_TITLE $MY_DESC en $MY_LINK $update $MY_TITLE $MY_IMAGE $MY_LINK EOF for ($x=0; $x < 15 ; $x++) { last if not $url[$x]; print " $stuff[$x] ".encode_entities($desc[$x])." $url[$x] "; } print < $MY_TITLE $MY_IMAGE $MY_LINK EOF print "\n";