add some missing files, complete separation of templates, factor common page wrapper...
[buildfarm-server.git] / cgi-bin / register.pl
index 7f8d6fc1d50647be9bbacece7f70889568420717..b15a0e24cf88862c4699a604aff695217f641617 100755 (executable)
@@ -7,61 +7,16 @@ use CGI;
 use Template;
 use Captcha::reCAPTCHA;
 
-use vars qw($dbhost $dbname $dbuser $dbpass $dbport $notifyapp $captcha_pubkey $captcha_privkey);
+use vars qw($dbhost $dbname $dbuser $dbpass $dbport $notifyapp $captcha_pubkey $captcha_privkey $template_dir);
 
 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 = <<EOS;
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-       <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-       <title>PostgreSQL BuildFarm Application</title>
-       <link rel="icon" type="image/png" href="/elephant-icon.png" />
-       <link rel="stylesheet" rev="stylesheet" href="/inc/pgbf.css" charset="utf-8" />
-       <style type="text/css"><!--
-       li#register a { color:rgb(17,45,137); background: url(/inc/b/r.png) no-repeat 100% -20px; } 
-       li#register { background: url(/inc/b/l.png) no-repeat 0% -20px; }
-       --></style>
-</head>
-<body class="application">
-<div id="wrapper">
-<div id="banner">
-<a href="/index.html"><img src="/inc/pgbuildfarm-banner.png" alt="PostgreSQL BuildFarm" width="800" height="73" /></a>
-<div id="nav">
-<ul>
-    <li id="home"><a href="/index.html" title="PostgreSQL BuildFarm Home">Home</a></li>
-    <li id="status"><a href="/cgi-bin/show_status.pl" title="Current results">Status</a></li>
-    <li id="members"><a href="/cgi-bin/show_members.pl" title="Platforms tested">Members</a></li>
-    <li id="register"><a href="/cgi-bin/register-form.pl" title="Join PostgreSQL BuildFarm">Register</a></li>
-    <li id="pgfoundry"><a href="http://pgfoundry.org/projects/pgbuildfarm/">PGFoundry</a></li>
-    <li id="postgresql.org"><a href="http://www.postgresql.org">PostgreSQL.org</a></li>
-</ul>
-</div><!-- nav -->
-</div><!-- banner -->
-<div id="main">
-EOS
-
-my $footer = <<EOS;
-</div><!-- main -->
-<hr />
-<p style="text-align: center;">
-Hosting for the PostgreSQL Buildfarm is generously 
-provided by: 
-<a href="http://www.commandprompt.com">CommandPrompt, 
-The PostgreSQL Company</a>
-</p>
-</div><!-- wrapper -->
-</body>
-</html>
-EOS
-
+my $template_opts = { INCLUDE_PATH => $template_dir};
+my $template = new Template($template_opts);
 my $query = new CGI;
 
 my $params = $query->Vars;
@@ -80,11 +35,9 @@ my $captcha_ok = $captcha->check_answer
 
 unless ($os && $osv && $comp && $compv && $arch && $email && $owner && $captcha_ok->{is_valid})
 {
-       print "Content-Type: text/html\n\n",
-       $header,
-       "<p>You need to complete all the form items. <a href=\"/cgi-bin/register-form.pl\">Please try again.</a></p>\n",
-       $footer;
-       exit;
+    print "Content-Type: text/html\n\n";
+    $template->process('register-incomplete.tt');
+    exit;
 }
 
 # some idiot has a script that tries to talk to me
@@ -157,12 +110,10 @@ my $sth=$db->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
-    , "<h1>PostgreSQL BuildFarm Application received</h1>\n"
-    , "<p>Thank you. You should hear from us shortly.</p>"
-    , $footer;
 
+# everything looks OK, so tell them so
+print "Content-type: text/html\n\n";
+$template->process('register-ok.tt');
 
 $sth->finish;
 $db->disconnect;