Jetzt verwenden wir die index.html als Template. draft
authorEric Schmalfuß (prakti) <eric.schmalfuss@schlittermann.de>
Tue, 05 Feb 2013 15:58:11 +0100
changeset 9 a915e7231d63
parent 8 73d827714711
child 10 0e2b0e64bc21
Jetzt verwenden wir die index.html als Template.
htdocs/cgi-bin/send_n
htdocs/index.html
htdocs/templates/index.html
--- a/htdocs/cgi-bin/send_n	Tue Feb 05 14:01:36 2013 +0100
+++ b/htdocs/cgi-bin/send_n	Tue Feb 05 15:58:11 2013 +0100
@@ -3,19 +3,40 @@
 use warnings;
 use strict;
 use LWP::UserAgent;
-use CGI;
+use CGI qw(-utf8);
 use CGI::Carp qw(fatalsToBrowser);
 use Net::SCP;
+use Template;
+use Cwd;
+use FindBin qw($RealBin);
+
+my $cgi = new CGI;
+
+if (!$cgi->param(".submit")) {
+   print CGI::header(-type => "text/html", -charset => "utf-8");
+
+   my $tt = Template->new({INCLUDE_PATH => "$RealBin/../templates"})
+      or die "Can't create template object: $Template::ERROR\n";
+
+   $tt->process("index.html", {
+         now => time(),
+         error => { firma => "xxx", 
+                    mail => "so nicht" },
+         firma => $cgi->param("firma"),
+   }) or die $tt->error();
+   exit 0;
+}
 
 my (
-    $uid,   $cgi, $feld, $feld4, $feld1, $feld2,
+    $uid,   $feld, $feld4, $feld1, $feld2,
     $feld3, $get, $url,  $ua,    $ub,    $req
 );
+
 my $x = 1;
 $uid = `uuidgen`;
 $uid =~ s/-//g;
 chomp $uid;
-$cgi = new CGI;
+
 
 #######################
 # Auswerten der Daten #
--- a/htdocs/index.html	Tue Feb 05 14:01:36 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-   <head>
-      <link rel="shortcut icon" href="favicon.ico" >
-      <link rel="icon" href="animated_favicon.gif" type="image/gif" >
-      <title>SSL-Zertifikat erneuern</title>
-      </head>
-      <body bgcolor="#00FFFF">
-         <h1>Zertifikat abgelaufen?</h1>
-         <p>Dann f&uuml;llen Sie doch einfach das Formular aus.</p>
-         <form action="./cgi-bin/send_n" enctype="multipart/form-data">
-            <table border="0" cellpadding="0" cellspacing="4">
-               <tr>
-                  <td align="right">Firma:</td>
-                  <td><input name="Firma" type="text" size="40">
-                  </tr>
-                  <tr>
-                     <td align="right">Mail:</td>
-                     <td><input name="Mail" size="40"></td>
-                  </tr>
-                  <tr>
-                     <td align="right">Firmenstandort:</td>
-                     <td><input name="Ort" type="text" size="40"></td>
-                  </tr>
-                  <tr>
-                     <td align="right">Request-Code:</td>
-                     <td><textarea name="req" cols="52" rows="10"></textarea></td>
-                  </tr>   
-                  <tr>
-                     <td></td>
-                     <td><p><input type="submit" value="Formulardaten absenden"> <input type="reset"></p></p>
-                  </tr>
-               </table>
-      </form>
-   </body>
-</html>                                                  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/templates/index.html	Tue Feb 05 15:58:11 2013 +0100
@@ -0,0 +1,43 @@
+[% USE date %]
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+   <head>
+      <link rel="shortcut icon" href="favicon.ico" >
+      <link rel="icon" href="animated_favicon.gif" type="image/gif" >
+      <title>SSL-Zertifikat erneuern</title>
+      </head>
+      <body bgcolor="#00FFFF">
+         <div align=right>[% date.format %]</div>
+         <div align=right>[% date.format(now) %]</div>
+         <h1>Zertifikat abgelaufen?</h1>
+         <p>Dann f&uuml;llen Sie doch einfach das Formular aus.</p>
+         <!--<form method=POST enctype="multipart/form-data">-->
+            <form method=POST>
+            <table border="0" cellpadding="0" cellspacing="4">
+               <tr>
+                  <td align="right">Firma:</td>
+                  <td> <input name="firma" type="text" size="40" value="[%firma%]">
+                  [% IF error.firma %]
+                  <td>Fehler: [%error.firma%]</td>
+                  [% END %]
+               </tr>
+                  <tr>
+                     <td align="right">Mail:</td>
+                     <td><input name="Mail" size="40"></td>
+                  </tr>
+                  <tr>
+                     <td align="right">Firmenstandort:</td>
+                     <td><input name="Ort" type="text" size="40"></td>
+                  </tr>
+                  <tr>
+                     <td align="right">Request-Code:</td>
+                     <td><textarea name="req" cols="52" rows="10"></textarea></td>
+                  </tr>   
+                  <tr>
+                     <td></td>
+                     <td><p><input type="submit" value="Formulardaten absenden"> <input type="reset"></p></p>
+                  </tr>
+               </table>
+      </form>
+   </body>
+</html>