#!/usr/opkg/bin/perl -w # # This program is for testing the possibilities # of creating an output in html # Later test the possibiliies to read in the values # from an cfg file and convert this to html # require 5.000; use strict; use CGI; $|++; # establish CGI query object 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|
\n|sg; print STDOUT $cgi->header(-expires => '+1s') . "TabeaTest :: ERROR", "

TabeaTest :: ERROR

\n" . "
$err
\n"; exit(0); }; my $username; my $form = ''; my $page; if ($form eq '') { $page .= "

We are testing
" ; $page .= "\n\nHere comes the text output:
\n" ; $page .= &text(); $page .= "

\n" ; $page .= "\n\nHere comes the password output:
\n" ; $page .= &password(); $page .= "

\n" ; $page .= "\n\nHere comes the checkbox output:
\n" ; $page .= &checkbox(); $page .= "

\n" ; $page .= "\n\nHere comes the radio output:
\n" ; $page .= &radio(); $page .= "

\n" ; $page .= "\n\nHere comes the image output:
\n" ; $page .= &image(); # $page .= &hidden(); $page .= "

\n" ; $page .= "\n\nHere comes the submit output:
\n" ; $page .= &submit(); $page .= "

\n" ; $page .= "\n\nHere comes the reset output:
\n" ; $page .= &reset(); $page .= "

\n" ; $page .= "\n\nHere comes the select output:
\n" ; $page .= &select(); $page .= "

\n" ; $page .= "\n\nHere comes the textaraea output:
\n" ; $page .= &textarea(); } else { die "no correct dialog found"; } $page .= $cgi->endform; #print STDOUT $cgi->header(-cookie => $cookies, -expires => '+1s') . $page; print STDOUT $cgi->header() . $page; sub text{ my $text; # Text Field: INPUT TYPE=TEXT #

Street Address:
# Postal City code:
# Zip Code:
$text .= "

Street Address:
" . "Postal City code:
" . "Zip Code:
" ; #item { # name street # visible "Street Address:" # type text #} #item { # name city # visible "Postal City code:" # type text[16][16] #} #item { # name zip # visible "Zip Code:" # type text[10][10] # value { # name "99999-9999" # } #} return $text; } sub password { my $text; # # Password Field: INPUT TYPE=PASSWORD #

Name: Password: $text .= "

Name: Password: " ; # item { # name login # visible "Name:" # type text # } # item { # name passwd # visible "Password:" # type password # } # # return $text; } sub checkbox { my $text; # # Check Box: INPUT TYPE=CHECKBOX # # #

What flavors do you like? ## # Vanilla
# Strawberry
# # Chocolate
$text .= "

What flavors do you like?\n" . "Vanilla
\n" . "Strawberry
\n" . "Chocolate
\n" ; # # item { # name flavor # visible "What flavors do you like?" # type checkbox # value { # name vanilla # visible "Vanilla" # checked # } # value { # name strawberry # visible "Strawberry" # } # value { # name chocolate # visible "Chocolate" # checked # } # } # return $text; } sub radio { my $text; # # Radio Button: INPUT TYPE=RADIO # # #

Which is your favorite? # # Vanilla
# # Strawberry
# # Chocolate
$text .= "

Which is your favorite?\n" . "Vanilla
\n" . "Strawberry
\n" . "Chocolate
\n" ; # # item { # name flavor # visible "Which is your favorite?" # type radio # value { # name vanilla # visible "Vanilla" # checked # } # value { # name strawberry # visible "Strawberry" # } # value { # name chocolate # visible "Chocolate" # } # } # # return $text; } sub image { my $text; # # Image Pixel: INPUT TYPE=IMAGE # # # # $text .= "\n" ; $text .= "\"gif\n"; # # item { # name point # visible "Choose a point on the map:" # type image # value { # name "map.gif" # } # } # # return $text; } sub hidden { my $text; # # Hidden Field: INPUT TYPE=HIDDEN (FIXME do we really need this?) # # # $text .= "\n" ; # # item { # name context # type hidden # value { # name "l2k3j4l2k3j4l2k3j4lk23" # } # } # # return $text; } sub submit { my $text; # # Submit Button: INPUT TYPE=SUBMIT # # #
# # $text .= "
\n" . "\n" ; # # item { # name recipient # type submit # value { # name internal # } # value { # name world # } # } # return $text; } sub reset { my $text; # # # Reset Button: INPUT TYPE=RESET # # # $text .= "\n" ; # # item { # description "You may clear the form and start over at any time:" # type reset # } return $text; } sub select { my $text; # # Selection: SELECT # # Option: OPTION # # # # $text .= "\n" ; # item { # name flavor # type select[2] //or type selectmultipe[2] # value { # name "Vanilla" # } # value { # name "Strawberry" # } # value { # name RumRasin # visible "Rum and Raisin" # } # value { # name "Peach and Orange" # selected # } # # } # # return $text; } sub textarea { my $text; # # Text Area: TEXTAREA # # # # $text .= "\n" ; # item { # name "address" # type textarea[64][6] # value { # name "HaL Computer Systems\n1315 Dell Avenue\nCampbell, California 95008" # } # } # return $text; }