#!/usr/bin/perl
#
###########################################################################
#
# Basic script for displaying results. It's called in two ways,
# either to display a single record, or to display multiple
# records.
# Name: display.cgi
###########################################################################
# Basic script setup.
push(@INC,"/var/lib/httpd/cgi-bin");
use DBI;
require "cgi-lib.pl";
require "cookie.lib";
# Get variables from the post and from the cookies ready to go
&ReadParse(*input);
$startno = $input{'startnumber'}; # Start counting at
$endno = $input{'endnumber'}; # End counting at
$single = $input{'single'}; # We just displaying 1 record?
$id = $input{'id'}; # if so, which one?
&GetCookies;
$username = $Cookies{'userted'}; # Obvious
$password = $Cookies{'passwordted'}; # Obvious
$prepare = $Cookies{'prepared'}; # This is the SELECT clause
# Check to see if the username and password are okay by actually
# connecting to the database. If it fails we know they were
# invalid.
$dbh = DBI->connect("DBI:mysql:filmlib",$username,$password)
or die &ErrSpoiledCookie;
# Header starts
print "Content-type:text/html\n";
# Find out how we were called...
if ($single ne "True")
{
# We weren't called to display a single record...so it's multiple
# records we're looking for. Send it to Execute.
&Execute($prepare,$startno,$endno);
print &HtmlBot;
} else {
# We're just displaying one record...set it up and display it
if ($username eq "read")
{
# No filemods for user 'read'.
$filemod_menu = "";
} else {
# It isn't the only read-only user...so let them see
# the filemod menu (it won't work if they don't
# have permissions anyway.)
$filemod_menu = "
";
}
# Prepare in the SQL clause to get all the fields of that one
# record.
$cursor = $dbh->prepare("SELECT
ID, Title ,CATALOGNO,RUNTIME,ANNOTATION,LANGUAGE FROM Result3 WHERE ID=$id");
# And now execute it.
$cursor->execute;
# Gimme an array...
my @smatch;
# Now we'll stick our stuff in it (might not need this while loop.)
while ( @smatch = $cursor->fetchrow_array )
{
# Make sure the output looks nice.
if ($smatch[5] eq "")
{ $langee = "(Not given)" }
else
{ $langee = $smatch[5] }
$title = $smatch[1];
$title =~ s/"/"\;/g;
$annote = $smatch[4];
$annote =~ s/"/"\;/g;
# And then print out the whole mess in an HTML table.
print "Content-type:text/html\n\n";
print "