#!/usr/bin/perl BEGIN { my $homedir = ( getpwuid($>) )[7]; my @user_include; foreach my $path (@INC) { if ( -d $homedir . '/perl' . $path ) { push @user_include, $homedir . '/perl' . $path; } } unshift @INC, @user_include; } use Date::Calc qw(Delta_DHMS); $posted_information=$ENV{QUERY_STRING}; if ($posted_information=~m|^us$|i) {$jurisdiction="us";} else { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "LegisLink: \n"; print "\n"; print "\n"; print "

Only works with US for now. http://legislink.org/browse?us

"; print ""; exit; } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print <

United States Congress (us)

http://legislink.org/us? . . .

Most Recent and Most Often Viewed LegisLinks    

US MENUHOMEPRIVACY NOTICECONTACT
Legislink logo
EOT print "\n"; print ""; print "
\n"; print "\n"; print "\n"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time); $year = $year + 1900; $mon = $mon + 1; my $timestamp=sprintf("%4d%02d%02d:%02d%02d%02d",$year,$mon,$mday,$hour,$min,$sec); $today=$year*10000+$mon*100+$mday; $now=$hour*10000+$min*100+$sec; undef %Hash; $logfile="log/us"; $logrecsize=699; # $logfilesize = -s $logfile; open(LOG,""; $Hash{$posted}=1; } seek(LOG,-1*$logrecsize,1); } } close(LOG); print "
Most Recent
".$posted."   "; $descript=~s| : | |; print "".$descript."\n"; $datedif=~s| | |g; print "   ".$datedif." ago\n"; print "
"; print "
\n"; print "
\n"; $masterrecsize=709; print "\n"; print "\n"; print "\n"; open(MASTER,"".$description; } print ""; } print "
Most Often
".$posted."  "; print $description; $datedif=TimeElapsedInWords($date,$time); $datedif=~s| | |g; print "   Last Viewed: ".$datedif." ago • Count: ".$popcount.""; print "
\n"; print "
"; print "
"; print "
"; print <Creative Commons License This work is in the Public Domain
SOURCE CODE - WIKISPACE - PRIVACY NOTICE (October 8, 2009) EOD print "\n"; print "\n"; print "\n"; exit; ######################## # TimeElapsedInWords ######################## # # Inspired by Twitter. # sub TimeElapsedInWords() { my $date=$_[0]; my $time=$_[1]; # $today and $now are global. my $datedif; $date=~m|(\d\d\d\d)(\d\d)(\d\d)|; $year1=$1; $mon1=$2; $day1=$3; $time=~m|(\d\d)(\d\d)(\d\d)|; $hr1=$1; $min1=$2; $sec1=$3; @diff = Delta_DHMS($year1, $mon1, $day1, $hr1, $min1, $sec1,$year,$mon,$mday, $hour,$min,$sec); $datedif=""; if ($diff[0]>31) { return("over one month ago"); } if ($diff[0]>0) { if ($diff[0]==1) { $datedif=$diff[0]." day "; } else { $datedif=$diff[0]." days "; } } if ($diff[1]>0) { if ($diff[1]==1) { $datedif.=$diff[1]." hour "; } else { $datedif.=$diff[1]." hours "; } } if ($diff[2]>0) { if ($datedif ne "") {$datedif.="and ";} if ($diff[2]==1) { $datedif.=$diff[2]." minute "; } else { $datedif.=$diff[2]." minutes "; } } if ($diff[0]==0 && $diff[1]==0 && $diff[3]>0) { if ($datedif ne "") {$datedif.="and ";} if ($diff[3]==1) { $datedif.=$diff[3]." second "; } else { $datedif.=$diff[3]." seconds "; } } # $datedif.="ago"; return($datedif); } ######################## # zTimeElapsedInWords ######################## # # Inspired by Twitter. # sub zTimeElapsedInWords() { my $date=$_[0]; $time=$_[1]; # $today and $now are global. my $datedif; if ($date ne $today) { $datedif=$today-$date; if ($datedif==1) { $datedif.=" day "; $timedif=$now-$time; if ($timedif > 5400) { $hrs=int($timedif/3600); if ($hrs==1) { $datedif=$datedif.$hrs." hour "; } else { $datedif=$datedif.$hrs." hours "; } } } else { $datedif=$datedif." days "; } } elsif ($now ne $time) { $datedif=$now-$time; if ($datedif < 120) { $datedif=$now-$time." seconds"; } elsif ($datedif < 5400) { $datedif=int($datedif/60)." minutes"; } else { my $hrs=int($datedif/3600); my $mns=int(($datedif - ($hrs * 3600))/60); $datedif=$hrs." hours and ".$mns." minutes "; } } return($datedif); }