5 Copyright (c) 2003-2010, Andrew Dunstan
6 Copyright (c) 2022, The Exim Maintainers
8 See accompanying License file for license details
16 use File::Temp qw(tempfile);
18 use vars qw($dbhost $dbname $dbuser $dbpass $dbport @log_file_names);
20 use FindBin qw($RealBin);
21 require "$RealBin/../BuildFarmWeb.pl";
23 die "no dbname" unless $dbname;
24 die "no dbuser" unless $dbuser;
26 my $dsn="dbi:Pg:dbname=$dbname";
27 $dsn .= ";host=$dbhost" if $dbhost;
28 $dsn .= ";port=$dbport" if $dbport;
32 my $system = $query->param('nm'); $system =~ s/[^a-zA-Z0-9_ -]//g;
33 my $logdate = $query->param('dt');$logdate =~ s/[^a-zA-Z0-9_ -]//g;
34 my $stage = $query->param('stg');$stage =~ s/[^a-zA-Z0-9._ -]//g;
35 my $brnch = $query->param('branch') || 'HEAD'; $brnch =~ s/[^a-zA-Z0-9._ -]//g;
39 if ($system && $logdate && $stage)
41 my $db = DBI->connect($dsn,$dbuser,$dbpass);
43 die $DBI::errstr unless $db;
45 if ($logdate =~ /^latest$/i)
51 and snapshot > now() - interval '30 days'
52 and log_stage = ? || '.log'
55 my $logs = $db->selectcol_arrayref($find_latest,undef,$system,$stage,$brnch);
56 $logdate = shift(@$logs);
61 select branch, log_text
63 where sysname = ? and snapshot = ? and log_stage = ? || '.log'
67 my $sth=$db->prepare($statement);
68 $sth->execute($system,$logdate,$stage);
69 my $row=$sth->fetchrow_arrayref;
70 my ($branch, $logtext) = ("unknown","no log text found");
79 print "Content-Type: text/plain\n\nSnapshot: $logdate\n\n", $logtext,
81 "-------------------------------------------------\n\n",
82 "Hosting for the Exim BuildFarm is generously ",
83 "provided by: Mythic Beasts Ltd";
89 print "Status: 460 bad parameters\n",
90 "Content-Type: text/plain\n\n";