#!/usr/bin/perl use lib "../lib"; # Load MySpace blog RSS and display use CGI qw(param); use CGI::Carp qw(fatalsToBrowser); use XML::Simple; #use XML::Parser; use XML::SAX; use IO::Socket::INET; use LWP::Protocol::http; require LWP::UserAgent; use Data::Dumper; use strict; my $view = param('view'); # 1) download Feed my $url = "http://blog.myspace.com/blog/rss.cfm?friendID=67670064"; $url = "http://blogs.myspace.com/Modules/BlogV2/Pages/RssFeed.aspx?friendID=67670064"; my $rerror = sub { my $txt = join("",@_); die "HttpViewer Error: $txt\n" }; my $useragent = LWP::UserAgent->new or &$rerror("Could not create User-Agent: $!"); #$useragent->agent("HttpViewer/$VERSION/".$useragent->agent) $useragent->agent("kyuguild.com RSS reader") #Mozilla Perlding IE") or &$rerror("Could not set User-Agent name: $!"); $useragent->timeout(120) or &$rerror("Failed to set timeout to 120: $!"); my $request = HTTP::Request->new('GET', "$url") || die "Could not create request: $!"; my $response = $useragent->simple_request($request); $response = $response->as_string(); $response =~ s/^.+?\n\n//sg; print "Content-type: text/html\n\n"; print qq(
These messages are derived from our mySpace. On ourSpace you can respond to our messages as well...
); print qq(); # 2) Parse my $feed = XMLin($response); my @items = @{ $feed->{'channel'}->{'item'} }; my $dot = "."; if ($view eq "short") { # JavaScript righthand shortcuts print qq(
"; #print Dumper($feed); #print "\n"; } print "\n"; sub expand { =head2 expand my $html = expand($text); Filterd de gegeven $text zo dat emailadressen en URLs geexpandeerd worden tot HTML hyperlinks. Ook worden speciale karakters naar HTML geconverteerd. Antispam: Voorlopig doen we het met @ IPV @ =cut my ($text) = @_; my $email = '[\w\.\{\},\[\]\~\#\$\^\*]+'; #my $url = '[\w\.\{\},\[\]\~\#\$\^\*\\\/\;\:]+'; #my $test; # Jan 2007 we willen
DITwel in tact houden .... my @pre; while ($text =~ /
/
/gi;
$text =~ s/<\/p>/ <\/p> /gi;
$text =~ s/ *[\r\n]+ */ \n /gi;
for (my $i = 0; $i < @pre; $i++) {
$text =~ s/\$pre\[$i\]/ $pre[$i] /;
}
my @words = split (/ /,$text);
my $word;
foreach $word (@words) {
unless ($word =~ /[<>]/) {
if ($word =~ /^(\(?\n?)http:\/\//i) {
my $a = $1;
my $b = "";
if ($word =~ /(\.|,|\))$/) {
$b = $1;
}
$word =~ s/(?:^\(|\.$|,$|\)$|\n)//g;
$word = "$a".substr(lc($word),7)."$b";
}
elsif ($word =~ /^(\(?\n?)www\..+\.(?:nl|com|org|net|edu|be)(\.|,|\))?$/i) {
my ($a,$b) = ($1,$2);
$word =~ s/(?:^\(|\.$|,$|\)$|\n)//g;
$word = "$a".lc($word)."$b";
}
elsif ($word =~ /^(.*?)($email\@$email\.$email)(.*?)$/s){
my ($a,$b,$c) = ($1,$2,$3);
unless ($c) { unless ($b) { $b = $a; $a = ""; } }
while ($b =~ s/(\.|,)$//) {
$c = $1 . $c;
}
#$word =~ s/^\(*//g;
$word ="$a$b$c";
}
#elsif ($word =~ /^(\(*).*\@.*\..*/s){
# my $a = $1;
# my $b = "";
# while ($word =~ s/(\.|,|\))$//) {
# $b = $1 . $b;
# }
# $word =~ s/^\(*//g;
# $word ="$a$word$b";
# }
}
}
$text = join(" ",@words);
$text =~ s/\@/@/g;
#$text =~ s/
/
/g;
return $text;#.$test;
}