#!/usr/bin/perl
# This script copyright M. Mackey
# Use granted to UCD School of Mathematical Science
# This is a variation of news.cgi to print just press items
use strict;
no strict 'vars';
use CGI qw(:standard);
use DBI;
######################################################
### To produce news items from a database #######
######################################################
if (param()) {
$newsitem=param("newsitem");
$photo=param("photo");
} else
{$newsitem="none" ;
}
###
### Let's make the database connection
###
$db="sms";
$userid="webscript";
$passwd="bjFYJGRL8SKzXeJR";
$host="localhost";
$connectionInfo="dbi:mysql:$db;$host";
$dbh = DBI->connect($connectionInfo,$userid,$passwd);
if ($photo>0) {
my $jpg = $dbh->selectrow_array(qq{
select photo from news where id = $photo});
$dbh->disconnect();
binmode(STDOUT);
print header(-type=>'image/jpg').$jpg;
print img($jpg);
exit 0;
}
##
## Next, a html header
##
printheader();
##
## Newsitems
##
if ($newsitem=~'none') {
printlist();
}
else {
printitem($newsitem)
}
printfooter();
# disconnect from database
$dbh->disconnect;
###
### Wow! It was only a 5 liner.
### Ooops, forgot the subs...
sub printheader {
print <
$text"; if ($url){ print "
Further Information" }; }