#!/usr/bin/perl use strict; use CGI::Carp qw/fatalsToBrowser/; sub pad { my ($num, $length) = @_; ("0" x ($length - length($num))) . $num; } my %opts; if ($ENV{REQUEST_URI} =~ /^.*?\?(.*)/) { my $query = $1; map { /^([^=]+)(=(.*))/ && do { $opts{$1} = $3; 1; }; } split /&/, $query; } map { s/%([0-9A-F]{2})/chr hex $1/gie } values %opts; if ($opts{min} eq "" && $opts{url} !~ /%/) { if (($opts{url} =~ /^(.*\D)(\d+)(\D+)$/)) { $opts{url} = $1."%".$3; $opts{min} = int($2 / 20) * 20 + 1; $opts{min} = pad($opts{min}, length($2)); } } $opts{max} = $opts{min} + 19 unless $opts{max} =~ /./; $opts{max} = pad($opts{max}, length($opts{min})); if ($opts{next} eq "Next") { my $nm = $opts{max} + 1; $opts{max} = $nm + $opts{max} - $opts{min}; $opts{min} = pad($nm, length($opts{min})); } if ($opts{prev} eq "Prev") { my $nm = $opts{min} - ($opts{max} - $opts{min}) - 1; $opts{max} = $nm + $opts{max} - $opts{min}; $opts{min} = pad($nm, length($opts{min})); } $opts{max} = $opts{min} + 19 unless $opts{max} =~ /./; print "Content-type: text/html\n\n"; print '
'; printf ' \n"; printf ' ';