OSSP CVS Repository

ossp - Difference in ossp-pkg/tabea/tabea.cgi versions 1.5 and 1.6
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/tabea/tabea.cgi 1.5 -> 1.6

--- tabea.cgi    2002/04/16 12:09:46     1.5
+++ tabea.cgi    2002/05/07 12:58:21     1.6
@@ -43,48 +43,106 @@
 $MY->{TEMPLATE} .= $_ while (<$fh>);
 $fh->close();
 
-
 #   establish CGI query object
-my $Q = new CGI;
+my $cgi = new CGI;
+
+#   activate a general error handler
+$SIG{__DIE__} = sub {
+    my ($err) = @_;
+
+    #$err =~ s|at\s+\S+\s+line\s+(\d+)|(line $1)|s;
+    $err =~ s|\n|<br>\n|sg;
+    print STDOUT $cgi->header(-expires => '+1s') .
+        "<title>Tabea :: ERROR</title>",
+        "<h1>Tabea :: ERROR</h1>\n" .
+        "<pre>$err</pre>\n";
+    exit(0);
+};
+
+
+#   fetch parameters
+my $form     = $cgi->param("form")     || "";
+my $username = $cgi->param("username") || "";
+my $password = $cgi->param("password") || "";
+
+#   update cookies
+my $cookies = [];
+foreach my $param (qw(username)) { # FIXME!
+    if ($cgi->param($param) ne '' and ($cgi->param($param) ne $cgi->cookie($param))) {
+        push(@{$cookies}, $cgi->cookie(
+             -name    => $param,
+             -value   => $cgi->param($param),
+             -expires => '+1d',
+             -path    => $cgi->url(-absolute => 1),
+             -secure  => 0
+        ));
+    }
+    if ($cgi->param($param) eq '' and $cgi->cookie($param) ne '') {
+         $cgi->param(-name => $param, -value => [$cgi->cookie($param)]);
+    }
+}
+
+sub validpassword {
+    my ($username, $password) = @_;
+    return "";
+}
 
 my $page = '';
-$page .= "fuck";
-my $page2 ='';
-$page2 .= "Welcher auch";
+
+if ($form eq '') {
+    $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
+        $cgi->hidden(-name => 'form', -default => ['login']) .
+        "<table cellspacing=0 cellpadding=0>" .
+        "  <tr>" .
+        "    <td>Username:</td>" .
+        "    <td>" .
+        $cgi->textfield(
+            -name => 'username',
+            -default => $username,
+            -size => 20,
+            -maxlength => 8
+        ) .
+        "    </td>" .
+        "  </tr>" .
+        "  <tr>" .
+        "    <td>Password:</td>" .
+        "    <td>" .
+        $cgi->password_field(
+            -name => 'password',
+            -value => $password,
+            -size => 20,
+            -maxlength => 80
+        ) .
+        "    </td>" .
+        "  </tr>" .
+        "  <tr>" .
+        "    <td colspan=2 align=right>" .
+        $cgi->reset() .
+        $cgi->submit(-name => 'dialog', -value => 'Login') .
+        "    </td>" .
+        "  </tr>" .
+        "</table>" .
+        $cgi->endform;
+}
+elsif ($form eq 'login') {
+    #   enter Select form
+    # &validpassword($username, $password) || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html");
+    $page .= "Dialog:   ".$cgi->param("dialog") ."<br>\n";
+    $page .= "Username: ".$cgi->param("username") ."<br>\n";
+    $page .= "Password: ".$cgi->param("password") ."<br>\n";
+}
+elsif ($form eq 'select') {
+    #   enter Edit form
+    &validpassword($username, $password) || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html");
+}
+else {
+    die "invalid form \"$form\"";
+}
 
 my $out = $MY->{TEMPLATE};
 $out =~ s|%%BODY%%|$page|s;
-$out =~ s|%%TITLE%%|$page2|s;
-
-
-
- #   generate "ADD" form
- $out .= $Q->startform( -method => "POST", -action => $Q->url()) .
-          "<tr bgcolor=\"#9999cc\">\n" .
-#          "<td align=right>" .
-#          "<b>" . $Q->submit(-name => 'form', -value => 'Add') . "</b>" .
-#          "</td>" .
-          "<td>" .
-          "Username:" .
-          $Q->textfield(
-              -name => 'username',
-              -default => '',
-              -size => 20,
-              -maxlength => 80
-           ) .
-          "<td>" .
-          "<p>&#013</p>" .
-          "</td>" .
-          "Password:" .
-          $Q->textfield(
-              -name => 'password',
-              -default => '',
-              -size => 20,
-              -maxlength => 80
-           ) .
-          "</td>" .
-         $Q->endform;
+$out =~ s|%%TITLE%%|Test|s;
 
-print $Q->header(-expires => '+1s') . $out;
+print $cgi->header(-cookie => $cookies, -expires => '+1s') . $out;
 
 exit (0);

CVSTrac 2.0.1