#!/usr/pubsw/bin/perl -w use CGI; use DBI; my $query = new CGI; my $rid = $query->param("rid"); my $rev = $query->param("rev"); my $host="mysql-user.stanford.edu"; my $db = 'd_MSandE'; my $db_user = 'd_MSandE'; my $db_password = 'pheutuji'; my $dbh = DBI->connect("dbi:mysql:$db:$host", "$db_user", "$db_password") or die "Couldn't connect to database: " . DBI->errstr; my $sth = $dbh->prepare("SELECT pdf FROM revisions where report_id='$rid' and rev='$rev';") or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute(); my @data=$sth->fetchrow_array(); #print "Content-type: application/pdf\n\n"; #print "Content-Disposition: inline; filename=test"; print "Content-type: application/pdf\n"; print "Content-Disposition: attachment; filename=msanderpt-$rid.pdf\n\n"; #print "rid: ".$rid; #print "rev: ".$rev; print @data; $sth->finish(); my $rth = $dbh->prepare("update reports set numdownloads=numdownloads + 1 where report_id='$rid'"); $rth->execute(); $rth->finish(); open(LOGF, ">>restricted/log") || die "$!"; my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)=localtime(time); my $timestamp = $year."-".($mon + 1)."-".$mday." ".$hour.":".$min.":".$sec; print LOGF $ENV{REMOTE_HOST}.",".$ENV{REMOTE_ADDR}.",".$ENV{REMOTE_PORT}.",".$ENV{HTTP_USER_AGENT}.",".$ENV{HTTP_COOKIE}.",".$ENV{WEBAUTH_USER}.",".$ENV{REQUEST_URI}.",".$timestamp."\n"; close(LOGF);