OSSP CVS Repository

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

ossp-pkg/tabea/tabea.cgi 1.28 -> 1.29

--- tabea.cgi    2002/06/14 14:53:08     1.28
+++ tabea.cgi    2002/06/20 15:09:05     1.29
@@ -85,6 +85,7 @@
 my $dialog   = $cgi->param("dialog")   || "";
 my $username = $cgi->param("username") || "";
 my $password = $cgi->param("password") || "";
+my $akt_user = $cgi->param("akt_user") || "";
 my $old_password = $cgi->param("old_password") || "";
 my $new1_password = $cgi->param("new1_password") || "";
 my $new2_password = $cgi->param("new2_password") || "";
@@ -92,7 +93,8 @@
 
 my $form = '';
 
-for my $name (qw(mainw changepwd copyt view new copyc edit del run admin confr newf changer copy save)) {
+for my $name (qw(admin cfgedit changepwd changer chpwd confr copy copyc copyt del d2user duser \
+                 edit logout mainw new newf newuser nuser run save view )) {
     my $val = $cgi->param("dialog_$name") || "";
     if ($val ne '') {
         $form = $name;
@@ -148,10 +150,49 @@
     $page .= &run($cgi->param('configslist') );
 }
 elsif ($form eq 'admin' ) {
-    $page .= &admin($cgi->param('username') );
+    if ( $cgi->param('username') eq $cfghash{'TabeaUser'}) {
+        $page .= &admin($cgi->param('username') );
+    } else {
+        $page .= &chpwd($cgi->param('username') );
+    }
+}
+elsif ($form eq 'chpwd' ) {
+    if ( $cgi->param('username') eq $cfghash{'TabeaUser'}) {
+        $page .= &chpwd($cgi->param('akt_user') );
+    } else {
+        $page .= &chpwd($cgi->param('username') );
+    }
 }
 elsif ($form eq 'changepwd' ) {
-    $page .= &changepwd($cgi->param('username') );
+    if ( $cgi->param('username') eq $cfghash{'TabeaUser'}) {
+        $page .= &changepwd($cgi->param('akt_user') );
+    } else {
+        $page .= &changepwd($cgi->param('username') );
+    }
+}
+elsif ($form eq 'nuser' ) {
+   $page .= &nuser();
+}
+
+elsif ($form eq 'newuser' ) {
+   $page .= &newuser($cgi->param('akt_user'));
+}
+elsif ($form eq 'duser' ) {
+    $page .= &duser($cgi->param('akt_user') )
+}
+
+#elsif ($form eq 'duser' ) {
+#    $page .= &duser($cgi->param('akt_user') )
+#}
+
+elsif ($form eq 'cfgedit' ) {
+#    $page .= &run($cgi->param('configslist') );
+}
+elsif ($form eq 'logout' ) {
+    $cgi->param(-name => 'username', -value => "");
+    $cgi->param(-name => 'password', -value => "");
+    $form = '';
+    goto  NEXTFORM;
 }
 
 else {
@@ -159,6 +200,10 @@
 }
 
 $page .= $cgi->hidden(-name => 'password', -default => $password);
+$page .= $cgi->hidden(-name => 'username', -default => $username);
+
+# A special for admin section and chpw for tabea
+#$page .= $cgi->hidden(-name => 'akt_user', -default => $akt_user);
 $page .= $cgi->endform;
 
 my $out = $MY->{TEMPLATE};
@@ -218,8 +263,15 @@
 ########################################################################################
     my $text = '';
 
-    &validpassword($username, $password, $cfghash{'BaseDir'}.$cfghash{'PasswdFile'})
-        || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html");
+  # &validpassword($username, $password, $cfghash{'BaseDir'}.$cfghash{'PasswdFile'})
+  #      || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html");
+    
+    if (! &validpassword($username, $password, $cfghash{'BaseDir'}.$cfghash{'PasswdFile'}) ) {
+        $cgi->param(-name => 'username', -value => "");
+        $cgi->param(-name => 'password', -value => "");
+        $form = '';
+        goto NEXTFORM;
+    }
 
     my $templatesfiles = &get_name_files($cfghash{'BaseDir'} . $cfghash{'ConfigDir'}, $username, 4);
     my $configsfiles = &get_name_files($cfghash{'BaseDir'} . $cfghash{'ConfigDir'}, $username, 6);
@@ -234,12 +286,21 @@
 
     $text .=
     # Begin with templates part
+    "<br><br>" .
+    "<table>" .
+    "<tr>" .
+    "<td>" .
     "<font size=+1>" .
-    "<br> Active User: $username<br><br>\n" .
+    "Active User: $username<br><br>\n" .
     "</font>" .
+    "</td>" .
+    "<td>" .
+    $cgi->submit(-name => 'dialog_logout', -value => 'Logout') .
+    "</td>" .
+    "</tr>" .
+    "</table>".
     "<table> <caption>Templates</caption>" .
     "  <td>" .
-    "    <td>" .
     $cgi->scrolling_list(
         -name => 'templatelist',
         -value => [@templatesarray],
@@ -302,7 +363,7 @@
     "    </table>" .
     "  </td>" .
     "<td>" .
-    "</table>";
+    "</table>" ;
 
     return $text;
 }
@@ -340,6 +401,18 @@
 
 
 ########################################################################################
+sub get_userlist {
+########################################################################################
+    my ($dirname) = @_;
+    my $ulist = &readsubdir($dirname . "/");;
+
+    
+    return $ulist;
+}
+########################################################################################
+
+
+########################################################################################
 sub get_own_files {
 ########################################################################################
     my ($dirname, $user) = @_;
@@ -542,7 +615,7 @@
         $text .= "<font size=+2>" .
                  "Changing rights of file:<br><br>";
 
-        $namefile =~ m{^([a-zA-Z0-9!"£$%^&*()-_=+#~]+)/(.+)}sg;
+        $namefile =~ m{^([a-zA-Z0-9!"£\$%^&*()-_=+#~]+)/(.+)}sg;
         if ($1 eq $username) {
             $text .= "<table>" .
             "<tr>" .
@@ -765,10 +838,59 @@
 ########################################################################################
 sub admin {
 ########################################################################################
-    my $user = @_;
+    my ($user) = @_;
     my $text;
+    my $userlist = &get_userlist($cfghash{'BaseDir'} . $cfghash{'ConfigDir'});
+    my @userlistarray = split(/\s/, $userlist);
+   
+     
+    $text .= "Username: $username; User: $user"; 
+    $text .= "<table>" .
+    "<td>".
+    $cgi->popup_menu(
+        -name => 'akt_user',
+        -value => [@userlistarray],
+#        -default=>'ps',
+#        -default => 'ps',
+        -default => $username,
+#        -default => $cfghash{'TabeaUser'}
+    ) .
+    "</td>" .
+    "<td>" .
+
+    "<table>" .
+
+    "<tr>" .
+    "<td>" .
+    $cgi->submit(-name => 'dialog_nuser', -value => 'New User').
+    "</td>" .
+    "</tr>" .
+    "<tr>" .
+    "<td>" .
+    $cgi->submit(-name => 'dialog_duser', -value => 'Del User').
+    "</td>" .
+    "</tr>" .
+
+    "</table>" .
+    
+    "</td>" .
+    "</table>" .
+
+    "<br><br>" .
+    "<table>" .
+    "<td>" .
+    $cgi->submit(-name => 'dialog_cfgedit', -value => 'Edit Configuration') .
+    "</td>" .
+    "<td>" .
+    $cgi->submit(-name => 'dialog_chpwd', -value => 'Change Password') .
+    "</td>" .
+
+    "</table>" .
+
+
+    "<br><br>" .
+    $cgi->submit(-name => 'dialog_mainw', -value => 'Back') ;
 
-    $text .= &chpwd($user); 
 
 
     return $text;
@@ -779,54 +901,58 @@
 ########################################################################################
 sub chpwd {
 ########################################################################################
-    my $user = @_;
+    my ($user) = @_;
     my $ctext;
 
-    $ctext .=
-        "<table cellspacing=0 cellpadding=0>" .
-        "  <tr>" .
+    $ctext .= "<br>Aktueller User: $user<br>";
+    $ctext .= "<table cellspacing=0 cellpadding=0>" ;
+    if ( (($username eq $cfghash{'TabeaUser'}) && ($user eq $cfghash{'TabeaUser'}) )
+           || ($username ne $cfghash{'TabeaUser'}) ) { 
+    $ctext .= "  <tr>" .
         "    <td>Old Password:</td>" .
         "    <td>" .
-        "<input type=\"password\" name=\"old_password\"  -value=\"$old_password\" size=\"20\" maxlength=\"80\" readonly/>".
-#        $cgi->password_field(
-#            -name => 'old_password',
-#            -value => $old_password,
-#            -size => 20,
-#            -maxlength => 80
-#        ) .
-        "    </td>" .
-        "  </tr>" . 
-        "  <tr>" .
-        "    <td>New Password:</td>" .
-        "    <td>" .
-        $cgi->password_field(
-            -name => 'new1_password',
-            -value => $new1_password,
-            -size => 20,
-            -maxlength => 80
-        ) .
-        "    </td>" .
-        "  </tr>" . 
-        "  </tr>" . 
-        "  <tr>" .
-        "    <td>Repeat Password:</td>" .
-        "    <td>" .
         $cgi->password_field(
-            -name => 'new2_password',
-            -value => $new2_password,
+            -name => 'old_password',
+            -value => $old_password,
             -size => 20,
             -maxlength => 80
         ) .
         "    </td>" .
-        "  </tr>" . 
-        "  <tr>" .
-        "    <td colspan=2 align=right>" .
-        $cgi->reset() .
-        $cgi->submit(-name => 'dialog_mainw', -value => 'Back').
-        $cgi->submit(-name => 'dialog_changepwd', -value => 'Change') .
-        "    </td>" .
-        "  </tr>" . 
-        "</table>" ;
+        "  </tr>" ; 
+    }
+
+
+    $ctext .= "  <tr>" .
+    "    <td>New Password:</td>" .
+    "    <td>" .
+    $cgi->password_field(
+         -name => 'new1_password',
+         -value => $new1_password,
+         -size => 20,
+         -maxlength => 80
+    ) .
+    "    </td>" .
+    "  </tr>" . 
+    "  </tr>" . 
+    "  <tr>" .
+    "    <td>Repeat Password:</td>" .
+    "    <td>" .
+    $cgi->password_field(
+          -name => 'new2_password',
+          -value => $new2_password,
+          -size => 20,
+          -maxlength => 80
+    ) .
+    "    </td>" .
+    "  </tr>" . 
+    "  <tr>" .
+    "    <td colspan=2 align=right>" .
+    $cgi->reset() .
+    $cgi->submit(-name => 'dialog_mainw', -value => 'Back').
+    $cgi->submit(-name => 'dialog_changepwd', -value => 'Change') .
+    "    </td>" .
+    "  </tr>" . 
+    "</table>" ;
     
     return $ctext;
     
@@ -850,12 +976,12 @@
 
 
     $valid = &validpassword($user, $old_password, $cfghash{'BaseDir'}.$cfghash{'PasswdFile'});
-    if ( $username =~ $cfghash{'TabeaUser'}) {
-        if ( $user !~ $cfghash{'TabeaUser'}) { $valid = 0; }    
+    if ( ($username eq $cfghash{'TabeaUser'}) && ($user ne $cfghash{'TabeaUser'}) ) { 
+        $valid = 1; 
     }
     if ( !$valid ) {
         $cptext .= "<font color=red>The password is incorrect.<br><br>\n". 
-          $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
+        $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
     } else {
         if ($new1_password eq $new2_password) {
             $pwdfp = IO::File->new("<$pwdfile");
@@ -871,8 +997,8 @@
             $pwdfp = IO::File->new(">$pwdfile");
             print $pwdfp $pwfiletext;
             $pwdfp->close();
-            $form = 'mainw';
             if ( $user =~ $username) {$password=$new1_password;}
+            $form = 'mainw';
             goto NEXTFORM;
         } else {
           $cptext .= "<font color=red>The password you typed do not match. Type the same password. ".
@@ -886,6 +1012,130 @@
 }
 ########################################################################################
 
+
+########################################################################################
+sub nuser {
+########################################################################################
+    my $text;
+
+    $text .= 
+    "Akt User: $akt_user" .
+    "<table cellspacing=0 cellpadding=0>" .
+    "  <tr>" .
+    "    <td>New User:</td>" .
+    "    <td>" .
+    $cgi->textfield(
+        -name => 'akt_user',
+        -default => "",
+        -override => 1,
+        -size => 20,
+        -maxlength => 8
+    ) .
+    "    </td>" .
+    "  </tr>" .
+    "</table>" .
+  
+    "<br><br>" .
+ 
+    "<table>" . 
+
+    "<td>" .
+    $cgi->submit(-name => 'dialog_mainw', -value => 'Back').
+    "</td>" .
+    "<td>" .
+    $cgi->submit(-name => 'dialog_newuser', -value => 'Write User').
+    "</td>" .
+
+    "</table>" ;
+    
+    
+    return $text;
+}
+########################################################################################
+
+
+########################################################################################
+sub newuser {
+########################################################################################
+    my ($nuser) = @_;
+    my $ntext;
+    my $pwfile = $cfghash{'BaseDir'}.$cfghash{'PasswdFile'};
+    my $pwin;
+    my $pwfiletext;
+
+    $ntext .= "Here is newuser $nuser<br>";
+
+    if ( $nuser !~ /^[A-Za-z0-9]+$/ ) {
+        $nuser = "";
+    }
+
+    if ( $nuser eq  "" ) {
+        $ntext .= "<font color=red>" .
+        "<br>Username wrong<br><br>" .
+        "</font>" .
+        $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
+    } else {
+        $ntext .= "Writing new user";
+        $pwin = IO::File->new("<$pwfile");
+        if(defined $pwin) {
+            $pwfiletext .= $_ while <$pwin>;
+
+        }
+        $pwin->close();    
+        
+
+# Checken, ob User in pw
+# Checken, ob Subdir gleichen Namens existiert
+
+# Unterverzeichnis anlegen
+# PW Eintrag machen    
+
+    }
+
+    return $ntext;
+}
+########################################################################################
+
+########################################################################################
+sub duser {
+########################################################################################
+    my ($duser) = @_;
+    my $text;
+
+
+    $text .= 
+    
+    "<table>" .
+    "<td>" .
+    "<font color=red>" . 
+    "User to delete :" .
+    "</font>" .
+    "</td>".
+
+    "<td>" .
+    "$duser" .
+    "</td>" .
+
+    
+    "</table>" .
+    
+    "<br><br>" .
+
+    "<table>" .
+
+    "<td>" .
+    $cgi->submit(-name => 'dialog_mainw', -value => 'Back').
+    "</td>" .
+    "<td>" .
+    $cgi->submit(-name => 'dialog_d2user', -value => 'Del User').
+    "</td>" .
+
+    "</table>" ;
+
+    return $text;
+}
+########################################################################################
+
 
 ########################################################################################
 sub copy {

CVSTrac 2.0.1