#!/usr/bin/perl -I /home/soundsoflaura/perl5/lib/perl5/x86_64-linux-thread-multi
use DBI;
use LWP::Simple;
$tpl = get('http://www.soundsoflaura.com/gallery-html/gallery-template.html');
$prevtpl = <<"PREV";
|
PREV
$nexttpl = <<"NEXT";
|
NEXT
$dbh = DBI->connect('DBI:mysql:soundsoflaura', 'laura_sql', 'hhTJVAsN3V{K', {PrintError => 0,RaiseError => 1});
($min,$max) = $dbh->selectrow_array("select min(place),max(place) from
gallery");
if (!$ENV{QUERY_STRING}) {
$tpl = get('http://www.soundsoflaura.com/gallery-html/index.html');
#$here = $min;
$next = $dbh->selectrow_array("select place from gallery where place > '$here'
order by place limit 1");
#$nexttpl =~ s/YYnext/$next/;
$nexttxt = qq||;
$tpl =~ s//$nexttxt/;
print "content-type: text/html\n\n$tpl";
$dbh->disconnect();
exit (1);
}
elsif ($ENV{QUERY_STRING} == $max) {
$nexttpl = ' | ';
$here = $max;
#get next to last
$ref = $dbh->selectcol_arrayref("select place from gallery where place < '$here' order by place");
$prev = $ref->[@{$ref} - 1];
$prevtpl =~ s/YYprev/$prev/;
}
else {
$here = $ENV{QUERY_STRING};
#get previous
$ref = $dbh->selectcol_arrayref("select place from gallery where place < '$here' order by place");
$prev = $ref->[@{$ref} - 1];
$prevtpl =~ s/YYprev/$prev/;
$next = $dbh->selectrow_array("select place from gallery where place > '$here'
order by place limit 1");
$nexttpl =~ s/YYnext/$next/;
}
($img,$place,$title,$credit) = $dbh->selectrow_array("select img,place,title,credit from gallery where place='$here'");
if (!$credit) {$credit = ' ';} else {$credit = "Photography by $credit";}
$tpl =~ s/XX(\w+)/${$1}/g;
print "content-type: text/html\n\n$tpl";
$dbh->disconnect();
1;