#!/usr/bin/perl use strict; use DBI; use Template; use CGI; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $notifyapp); require "$ENV{BFConfDir}/BuildFarmWeb.pl"; #require "BuildFarmWeb.pl"; my $dsn="dbi:Pg:dbname=$dbname"; $dsn .= ";host=$dbhost" if $dbhost; $dsn .= ";port=$dbport" if $dbport; my $header = < PostgreSQL BuildFarm Application
EOS my $footer = <

Hosting for the PostgreSQL Buildfarm is generously provided by: CommandPrompt, The PostgreSQL Company

EOS my $query = new CGI; my $params = $query->Vars; my ($os, $osv, $comp, $compv, $arch, $email, $owner) = @{$params}{ qw(os osv comp compv arch email owner)}; unless ($os && $osv && $comp && $compv && $arch && $email && $owner) { print "Content-Type: text/html\n\n", $header, "

You need to complete all the form items. Please try again.

\n", $footer; exit; } # some idiot has a script that tries to talk to me # this should catch and dispose of him if ((grep {/rgergerger|\@pgbuildfarm\.org|Content-Type:|http:|mailto:|href=|None|Unknown/} $os,$osv,$comp,$compv,$arch,$email,$owner) || ($email =~ /john.*\@aol.com/) ) { print "Status: 403 Forbidden - go away idiot\n", "Content-Type: text/plain\n\n"; exit; } # count transitions to and from upper case my $trans = 1; my $counttrans = 0; foreach (split "" ,"$os$osv$comp$compv$arch$owner") { if (/[A-Z]/) { next if $trans; $trans = 1; $counttrans++; } else { next unless $trans; $trans = 0; $counttrans++; } } # reject junk with too many transitions into/outof upper case if ($counttrans > 20) { print "Status: 403 Forbidden - go away idiot\n", "Content-Type: text/plain\n\n"; exit; } my $secret = ""; my $dummyname=""; # we'll select an animal name when we approve it. foreach (1..8) { # 8 random chars is enough for the dummy name $secret .= substr("0123456789abcdefghijklmnopqrstuvwxyz",int(rand(36)),1); $dummyname .= substr("0123456789abcdef",int(rand(16)),1); } foreach (9..32) { $secret .= substr("0123456789abcdef",int(rand(16)),1); } my $db = DBI->connect($dsn,$dbuser,$dbpass); my $statement = <prepare($statement); my $rv=$sth->execute($dummyname,$secret,$os,$osv,$comp,$compv, $arch,$owner,$email); my $err=$db->errstr; print "Content-type: text/html\n\n"; print $header , "

PostgreSQL BuildFarm Application received

\n" , "

Thank you. You should hear from us shortly.

" , $footer; $sth->finish; $db->disconnect; use Mail::Send; my $msg = new Mail::Send; my $me = `id -un`; my $host = `hostname`; $msg->set('From',"PG Build Farm <$me\@$host>"); $msg->to(@$notifyapp); $msg->subject('New Buildfarm Application'); my $fh = $msg->open; print $fh "\n\nName: $dummyname\n", "OS: $os: $osv\n", "Arch: $arch\n", "Comp: $comp: $compv\n", "Owner: $owner <$email>\n"; $fh->close;