Remove use of Safe.pm now all clients are sending a frozen version of their config.
[buildfarm-server.git] / trunk / cgi-bin / show_stage_log.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use DBI;
5 use Template;
6 use CGI;
7 use File::Temp qw(tempfile);
8
9 use vars qw($dbhost $dbname $dbuser $dbpass $dbport @log_file_names);
10
11
12 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
13 #require "BuildFarmWeb.pl";
14
15 die "no dbname" unless $dbname;
16 die "no dbuser" unless $dbuser;
17
18 my $dsn="dbi:Pg:dbname=$dbname";
19 $dsn .= ";host=$dbhost" if $dbhost;
20 $dsn .= ";port=$dbport" if $dbport;
21
22 my $query = new CGI;
23
24 my $system = $query->param('nm'); $system =~ s/[^a-zA-Z0-9_ -]//g;
25 my $logdate = $query->param('dt');$logdate =~ s/[^a-zA-Z0-9_ -]//g;
26 my $stage = $query->param('stg');$stage =~ s/[^a-zA-Z0-9._ -]//g;
27
28 use vars qw($tgz);
29
30 if ($system && $logdate && $stage)
31 {
32     my $db = DBI->connect($dsn,$dbuser,$dbpass);
33
34     die $DBI::errstr unless $db;
35
36     my $statement = q(
37
38         select branch, log_text
39         from build_status_log
40         where sysname = ? and snapshot = ? and log_stage = ? || '.log'
41
42         );
43
44
45     
46     my $sth=$db->prepare($statement);
47     $sth->execute($system,$logdate,$stage);
48     my $row=$sth->fetchrow_arrayref;
49     my ($branch, $logtext) = ("unknown","no log text found");
50     if ($row)
51     {
52         $branch = $row->[0];
53         $logtext =$row->[1];
54     }
55     $sth->finish;
56     $db->disconnect;
57
58     print "Content-Type: text/plain\n\n", $logtext,
59
60     "-------------------------------------------------\n\n",
61     "Hosting for the PostgreSQL Buildfarm is generously ",
62     "provided by: CommandPrompt, The PostgreSQL Company";
63
64 }
65
66 else 
67 {
68     print "Status: 460 bad parameters\n",
69     "Content-Type: text/plain\n\n";
70 }
71