#!/bin/perl
use CGI;
use Palm::PDB;
use Palm::Datebook;
#print "Content-type: text/plain\n\n";
print "Content-type: text/html\n\n";
my $cgi = new CGI;
$cgi->import_names("FORM");
$filename = $cgi->param('inputfile');
my $tmpfilename = $cgi->tmpFileName($filename);
my $mbox = $cgi->param('mbox');
if($mbox eq "" ){
print "\n
Oops!
";
print "\nsorry, you need to add _some_ sort of an identifier for this to work
\n";
}
else{
print "\nGenerated RDF for $mbox";
my $pdb = new Palm::PDB;
my $testfile="/usr/local/httpd/apache/htdocs/calendar/tmp/".$mbox.".pdb";
my $rdffile="/usr/local/httpd/apache/htdocs/calendar/tmp/".$mbox.".rdf";
my $rdfurl="http://swordfish.rdfweb.org/calendar/tmp/".$mbox.".rdf";
print "\n[add this to rdfweb database]
";
open(RDF, ">$rdffile");
$pdb ->Load($tmpfilename) || die print "oops! no $tmpfilename found\n";
$pdb->{sort};
my $label;
my $labelt;
my $dlabel="today";
if($dlabel eq "today"){
($sec, $min, $hour, $mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$m=$mon+1;
$y=$year+1900;
$d=$mday;
if($m<10){
$m="0".$m;
}
if($d<10){
$d="0".$d;
}
$dlabel=$y.$m.$d;
#print $dlabel;
}
my $buf;
$buf=" \n";
$buf=$buf."\n\t ";
my $i=0;
foreach $record (@{$pdb->{records}}){
my $record = {};
$record = $pdb->{records}[$i];
$i++;
my $time;
my $day;
my $date;
my $start;
my $end;
my $endm;
my $location;
my $desc;
chomp;
($time, $desc, $location, $note) = split /\n/, $_, 4;
my $m=$record->{"month"};
my $d=$record->{"day"};
if($m<10){
$m="0".$m;
}
if($d<10){
$d="0".$d;
}
$label=$record->{"year"}."-".$m."-".$d;
$labelt=$record->{"year"}.$m.$d;
#print "\nlabel is ".$label."\n";
#print "\nlabelt is ".$labelt."\n";
#print "\ndlabel is ".$dlabel."\n";
##don't want to print private ones
my $priv=$record->{"attributes"}{"private"};
if($priv!=1){
if( ($dlabel eq $labelt) || ($dlabel==undef)){
$buf=$buf."\n\t\t\n\t\t\t";
$buf=$buf."\n\t\t\t";
$buf=$buf."\n\t\t\t\t " . $record->{"description"} . "";
$buf=$buf."\n\t\t\t\t\n\t\t\t\t\t";
$buf=$buf."\n\t\t\t\t\t ".$record->{"start_hour"}."";
$buf=$buf."\n\t\t\t\t\t ".$record->{"start_minute"}."";
$buf=$buf."\n\t\t\t\t\t\n\t\t\t\t";
$buf=$buf."\n\t\t\t\t\n\t\t\t\t\t";
$buf=$buf."\n\t\t\t\t\t ".$record->{"end_hour"}."";
$buf=$buf."\n\t\t\t\t\t ".$record->{"end_minute"}."";
$buf=$buf."\n\t\t\t\t\t\n\t\t\t\t";
if($mbox ne "none"){
$buf=$buf."\n\t\t\t\t\n\t\t\t\t\t";
$buf=$buf."\n\t\t\t\t\t";
$buf=$buf."\n\t\t\t\t\t\n\t\t\t\t";
$buf=$buf."\n\t\t\t\t\n\t\t\t\t\t";
$buf=$buf."\n\t\t\t\t\t";
$buf=$buf."\n\t\t\t\t\t\n\t\t\t\t";
}
else{
#print "UNDEF";
}
$buf=$buf."\n\t\t\t\n\t\t";
}
}
}
$buf=$buf."\n\t\n";
print RDF $buf;
close RDF;
$buf=~ s/(.*)<(.*)/$1\<$2/g;
$buf=~ s/(.*)>(.*)/$1\>$2/g;
$buf=~ s/(.*)<(.*)>(.*)/$1\<$2\>$3/g;
print "\n\n";
print $buf;
print "\n |
\n";
}