--- tabea.cgi 2002/05/10 12:27:56 1.11
+++ tabea.cgi 2002/05/10 15:41:18 1.12
@@ -38,9 +38,6 @@
my $pwdfile = "./tabea.pw";
my $configsdir = "./tabea.d";
my $tabeauser = "tabea";
-my $dialog;
-my $copy;
-my $view;
# establish my configuration
my $MY = {};
@@ -67,10 +64,6 @@
};
-# fetch parameters
-my $form = $cgi->param("form") || "";
-my $username = $cgi->param("username") || "";
-my $password = $cgi->param("password") || "";
# update cookies
my $cookies = [];
@@ -89,11 +82,18 @@
}
}
+
+
+# fetch parameters
+my $dialog = $cgi->param("dialog") || "";
+my $username = $cgi->param("username") || "";
+my $password = $cgi->param("password") || "";
+
my $page = '';
-if ($form eq '') {
+if ($dialog eq "") {
$page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
- $cgi->hidden(-name => 'form', -default => ['login']) .
+# $cgi->hidden(-name => 'form', -default => ['login']) .
"<table cellspacing=0 cellpadding=0>" .
" <tr>" .
" <td>Username:</td>" .
@@ -120,13 +120,13 @@
" <tr>" .
" <td colspan=2 align=right>" .
$cgi->reset() .
- $cgi->submit(-name => 'dialog', -value => 'Login') .
+ $cgi->submit(-name => 'dialog', -value => 'login') .
" </td>" .
" </tr>" .
"</table>" .
$cgi->endform;
}
-elsif ($dialog eq 'login') {
+elsif (($dialog eq 'login') || ($dialog eq 'Back')) {
# enter Select form
@@ -135,29 +135,21 @@
my $templatesfiles = &readdir($configsdir."/".$tabeauser);
my $configsfiles = &readdir($configsdir."/".$username);
+ my @templatesarray = split(/ /,$templatesfiles);
+ my @configsarray = split(/ /,$configsfiles);
- my @templateshash = split(/ /,$templatesfiles);
- my $templateslist = "[";
- foreach (@templateshash) {
- $templateslist .= "'$_', ";
- }
- chop($templateslist);
- chop($templateslist);
- $templateslist .= "]";
-
#
$page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
$cgi->hidden(-name => 'form', -default => ['']) .
# Begin with templates part
+ "<br> Active User: $username<br>\n" .
"Templates: <br><br>\n" .
- " Templateslist: $templateslist <br>" .
"<table width=70%>" .
" <td>" .
" <td>" .
$cgi->scrolling_list(
-name => 'templatelist',
- # -value => ['default', 'sample'],
- -value => '\$templateslist',
+ -value => [@templatesarray],
-size => 2
) .
" </td>" .
@@ -166,12 +158,12 @@
" <td>" .
" <tr>" .
" <td>" .
- $cgi->submit(-name => 'copy', -value => 'Copy') .
+ $cgi->submit(-name => 'dialog', -value => 'Copy') .
" </td>" .
" </tr>" .
" <tr>" .
" <td>" .
- $cgi->submit(-name => 'view', -value => 'View') .
+ $cgi->submit(-name => 'dialog', -value => 'View') .
" </td>" .
" </tr>" .
" </td>" .
@@ -187,8 +179,8 @@
" <tr>" .
" <td>" .
$cgi->scrolling_list(
- -name => 'configlist',
- -value => ['xdefault', 'xsample'],
+ -name => 'configslist',
+ -value => [@configsarray],
-size => 5
) .
" </td>" .
@@ -196,53 +188,68 @@
" <table>" .
" <tr><td>" .
- $cgi->submit(-name => 'new', -value => 'New') .
+ $cgi->submit(-name => 'dialog', -value => 'New') .
" </td></tr>" .
" <tr><td>" .
- $cgi->submit(-name => 'copy', -value => 'Copy') .
+ $cgi->submit(-name => 'dialog', -value => 'Copy') .
" </td></tr>" .
" <tr><td>" .
- $cgi->submit(-name => 'edit', -value => 'Edit') .
+ $cgi->submit(-name => 'dialog', -value => 'Edit') .
" </td></tr>" .
" <tr><td>" .
- $cgi->submit(-name => 'del', -value => 'Del') .
+ $cgi->submit(-name => 'dialog', -value => 'Del') .
" </td></tr>" .
" <tr><td>" .
- $cgi->submit(-name => 'run', -value => 'Run') .
+ $cgi->submit(-name => 'dialog', -value => 'Run') .
" </td></tr>" .
" <tr><td>" .
- $cgi->submit(-name => 'conf_rights', -value => 'Config_rights') .
+ $cgi->submit(-name => 'dialog', -value => 'Config_rights') .
" </td></tr>" .
" </table>" .
" </td>" .
" </tr>" .
- "</table>" .
+ "</table>" ;
- $cgi->endform;
-# $dialog = $cgi->param($view) || $cgi->param($copy);
+ $page .= $cgi->endform;
+
}
elsif ($dialog eq 'Edit') {
# enter Edit form
- &validpassword($username, $password, $pwdfile) || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html");
-
- $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1));
-}
-
+# &validpassword($username, $password, $pwdfile) || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html");
+ if ($cgi->param('configslist')) {
+ my $filename = $configsdir . "/" . $username . "/" . $cgi->param('configslist');
+ &editconfig($filename, 'w', $username);
+ } else {
+ $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
+ "<font color=red>Missing filename<br><br>\n" .
+ $cgi->submit(-name => 'dialog', -value => 'Back') .
+ $cgi->endform;
+ }
+
+}
elsif ($dialog eq 'View') {
# enter View form
- &validpassword($username, $password, $pwdfile) || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html");
-} else
-
-{
- die "invalid form \"$form\"";
+# &validpassword($username, $password, $pwdfile) || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html");
+ if ($cgi->param('templatelist')) {
+ my $filename = $configsdir . "/" . $tabeauser . "/" . $cgi->param('templatelist');
+ &editconfig($filename, 'r', $username);
+ } else {
+ $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
+ "<font color=red>Missing filename<br><br>\n" .
+ $cgi->submit(-name => 'dialog', -value => 'Back') .
+ $cgi->endform;
+ }
+
+} else {
+ die "invalid dialog \"$dialog\"";
}
my $out = $MY->{TEMPLATE};
@@ -307,3 +314,45 @@
########################################################################################
+########################################################################################
+sub editconfig {
+########################################################################################
+ my ($file, $mode, $user) = @_;
+ my $text = '';
+ my $filein ;
+
+ $filein = IO::File->new("<$file");
+ while(<$filein>) { $text .= $_; }
+ $filein->close;
+ $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
+ "Edit window: <br><br>\n" ;
+ $page .= "Username: $username<br><br>\n" .
+ "File: $file<br><br>\n" .
+ "Mode: $mode<br><br>\n" .
+ $cgi->textarea(
+ -name => 'editwindow',
+ -default => $text,
+ -rows => 40,
+ -columns => 80
+ );
+ $page .= " <br><br>\n" .
+ "<table>" .
+ " <td>" .
+ " <td>" .
+ $cgi->submit(-name => 'dialog', -value => 'Back') .
+ " </td>";
+ if ($mode eq 'w') {
+ $page .= " <td>" .
+ $cgi->submit(-name => 'dialog', -value => 'Save') .
+ " </td>";
+ }
+ $page .= " <td>" .
+ " </td>" .
+ "</table>" .
+
+
+ $cgi->endform;
+
+
+}
+########################################################################################
|