8 use Captcha::reCAPTCHA;
10 use vars qw($dbhost $dbname $dbuser $dbpass $dbport $notifyapp $captcha_pubkey $captcha_privkey);
12 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
13 #require "BuildFarmWeb.pl";
15 my $dsn="dbi:Pg:dbname=$dbname";
16 $dsn .= ";host=$dbhost" if $dbhost;
17 $dsn .= ";port=$dbport" if $dbport;
20 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
21 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
22 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
24 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
25 <title>PostgreSQL BuildFarm Application</title>
26 <link rel="icon" type="image/png" href="/elephant-icon.png" />
27 <link rel="stylesheet" rev="stylesheet" href="/inc/pgbf.css" charset="utf-8" />
28 <style type="text/css"><!--
29 li#register a { color:rgb(17,45,137); background: url(/inc/b/r.png) no-repeat 100% -20px; }
30 li#register { background: url(/inc/b/l.png) no-repeat 0% -20px; }
33 <body class="application">
36 <a href="/index.html"><img src="/inc/pgbuildfarm-banner.png" alt="PostgreSQL BuildFarm" width="800" height="73" /></a>
39 <li id="home"><a href="/index.html" title="PostgreSQL BuildFarm Home">Home</a></li>
40 <li id="status"><a href="/cgi-bin/show_status.pl" title="Current results">Status</a></li>
41 <li id="members"><a href="/cgi-bin/show_members.pl" title="Platforms tested">Members</a></li>
42 <li id="register"><a href="/cgi-bin/register-form.pl" title="Join PostgreSQL BuildFarm">Register</a></li>
43 <li id="pgfoundry"><a href="http://pgfoundry.org/projects/pgbuildfarm/">PGFoundry</a></li>
44 <li id="postgresql.org"><a href="http://www.postgresql.org">PostgreSQL.org</a></li>
54 <p style="text-align: center;">
55 Hosting for the PostgreSQL Buildfarm is generously
57 <a href="http://www.commandprompt.com">CommandPrompt,
58 The PostgreSQL Company</a>
60 </div><!-- wrapper -->
67 my $params = $query->Vars;
69 my ($os, $osv, $comp, $compv, $arch, $email, $owner, $challenge, $response ) = @{$params}{
70 qw(os osv comp compv arch email owner recaptcha_challenge_field recaptcha_response_field)};
72 my $captcha = Captcha::reCAPTCHA->new;
73 my $captcha_ok = $captcha->check_answer
81 unless ($os && $osv && $comp && $compv && $arch && $email && $owner && $captcha_ok->{is_valid})
83 print "Content-Type: text/html\n\n",
85 "<p>You need to complete all the form items. <a href=\"/cgi-bin/register-form.pl\">Please try again.</a></p>\n",
90 # some idiot has a script that tries to talk to me
91 # this should catch and dispose of him
92 if ((grep {/rgergerger|\@pgbuildfarm\.org|Content-Type:|http:|mailto:|href=|None|Unknown/} $os,$osv,$comp,$compv,$arch,$email,$owner)
93 || ($email =~ /john.*\@aol.com/) )
96 "Status: 403 Forbidden - go away idiot\n",
97 "Content-Type: text/plain\n\n";
101 # count transitions to and from upper case
104 foreach (split "" ,"$os$osv$comp$compv$arch$owner")
120 # reject junk with too many transitions into/outof upper case
121 if ($counttrans > 20)
124 "Status: 403 Forbidden - go away idiot\n",
125 "Content-Type: text/plain\n\n";
132 my $dummyname=""; # we'll select an animal name when we approve it.
135 # 8 random chars is enough for the dummy name
136 $secret .= substr("0123456789abcdefghijklmnopqrstuvwxyz",int(rand(36)),1);
137 $dummyname .= substr("0123456789abcdef",int(rand(16)),1);
141 $secret .= substr("0123456789abcdef",int(rand(16)),1);
144 my $db = DBI->connect($dsn,$dbuser,$dbpass);
146 my $statement = <<EOS;
148 insert into buildsystems
149 (name, secret, operating_system, os_version, compiler, compiler_version,
150 architecture, status, sys_owner, owner_email)
151 values(?,?,?,?,?,?,?,'pending',?,?)
156 my $sth=$db->prepare($statement);
157 my $rv=$sth->execute($dummyname,$secret,$os,$osv,$comp,$compv,
158 $arch,$owner,$email);
160 print "Content-type: text/html\n\n";
162 , "<h1>PostgreSQL BuildFarm Application received</h1>\n"
163 , "<p>Thank you. You should hear from us shortly.</p>"
173 my $msg = new Mail::Send;
177 my $host = `hostname`;
179 $msg->set('From',"PG Build Farm <$me\@$host>");
181 $msg->to(@$notifyapp);
182 $msg->subject('New Buildfarm Application');
184 print $fh "\n\nName: $dummyname\n",
187 "Comp: $comp: $compv\n",
188 "Owner: $owner <$email>\n";