#!/usr/bin/perl #11 May 1998 #by Robert Jones, kaosfere@conterra.com #You are free to distribute and modify this code, as long as my name #stays in the credits. It would be nice if I were notified of any #succesful use of this. ;) #Amended by ken Guest (root@linux.ie) as the first backend #tool for presenting information of ILUG NewsItems #Amended again by Ken, in a huge big tent at CCC, #on 7/Aug/1999 to handle ?d=js&e=5 cgi command line. #(js means wrap news in javascript so people with cgi disabled can include #news items in their webpages, and e is the maximum number of news items #to be displayed). ############################################################################ use CGI qw(:standard); #number of entries we want displayed, default to 3. $entries = param('e'); if ($entries eq "") { $entries = 3; } #get the delivery value, if js then wrap news in javascript. $delivery = param('d'); #address we want to get info from. #you probably don't want to change this $url = "http://www.linux.ie/ilugnews.txt"; #directory to work in. in some cases this may need to be world writable. $dir = "/tmp/"; #our work-file $outfile = "ILUGnews.out"; #how often we want to be able to refresh this. In seconds. $refresh = 1800; #check existence/age of data file #create if necessary $time = time; unless ((-e "$dir$outfile") && ($time-(stat "$dir$outfile")[10])<$refresh) { $data=0; @backend=`lynx -source $url`; open OUT, ">$dir$outfile"; foreach $line (@backend) { if($line =~ /^%%/) { $data=1; } elsif($data) { print OUT "$line"; } } close OUT; } #grab the times fir convenient display @time=gmtime(time); @filetime=gmtime((stat "$dir$outfile")[10]); #format and print our web page print "Content-type: text/plain\n\n"; #print out the details, no fancy formatting open IN, "$dir$outfile"; if ($delivery eq "js") { while ($entries) { unless(defined($line=)) { last; } chomp $line; $entries--; #$newsitem=; chomp $newsitem; $time=; chomp $time; $line =~ s/'/'/g; $time =~ s/'/'/g; print "document.writeln(\'$line\')\;\n"; print "document.writeln(\'$time
\')\;\n"; } } else { while ($entries) { unless(defined($line=)) { last; } chomp $line; $entries--; #$newsitem=; chomp $newsitem; $time=; chomp $time; print "

$line\n"; print " $time

\n"; } }