OSSP CVS Repository

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

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

--- tabea.cgi    2002/06/20 15:09:05     1.29
+++ tabea.cgi    2002/06/27 15:57:10     1.30
@@ -28,6 +28,7 @@
 ##  tabea.cgi: Tabea CGI (syntax: Perl)
 ##
 
+
 require 5.000;
 use strict;
 use IO;
@@ -93,8 +94,8 @@
 
 my $form = '';
 
-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 )) {
+for my $name (qw(admin cfgedit changepwd changer chpwd confr copy copyc copyt del d2user d3user \
+                duser edit logout mainw new newf newuser nuser run save view )) {
     my $val = $cgi->param("dialog_$name") || "";
     if ($val ne '') {
         $form = $name;
@@ -178,12 +179,16 @@
    $page .= &newuser($cgi->param('akt_user'));
 }
 elsif ($form eq 'duser' ) {
-    $page .= &duser($cgi->param('akt_user') )
+    $page .= &duser($akt_user);
+}
+
+elsif ($form eq 'd2user' ) {
+    $page .= &d2user($akt_user);
 }
 
-#elsif ($form eq 'duser' ) {
-#    $page .= &duser($cgi->param('akt_user') )
-#}
+elsif ($form eq 'd3user' ) {
+    $page .= &d3user($akt_user);
+}
 
 elsif ($form eq 'cfgedit' ) {
 #    $page .= &run($cgi->param('configslist') );
@@ -201,6 +206,8 @@
 
 $page .= $cgi->hidden(-name => 'password', -default => $password);
 $page .= $cgi->hidden(-name => 'username', -default => $username);
+$page .= $cgi->hidden(-name => 'akt_user', -default => $akt_user);
+$page .= $cgi->hidden(-name => 'del_u_files', -default => $cgi->param('del_u_files'));
 
 # A special for admin section and chpw for tabea
 #$page .= $cgi->hidden(-name => 'akt_user', -default => $akt_user);
@@ -843,18 +850,29 @@
     my $userlist = &get_userlist($cfghash{'BaseDir'} . $cfghash{'ConfigDir'});
     my @userlistarray = split(/\s/, $userlist);
    
-     
+    $akt_user = $username; 
     $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'}
-    ) .
+
+
+#    $cgi->popup_menu(
+#        -name => 'akt_user',
+#        -value => [@userlistarray],
+#        -default => $username,
+#    ) .
+    "<select name=akt_user size=1>" ;
+    foreach (@userlistarray) {
+        if ($_ =~ $username) {
+            $text .= "<option selected>$_</option>" ;
+        } else {
+            $text .= "<option>$_</option>" ;
+        }
+
+    }
+
+    $text .= "</select>" .
+
     "</td>" .
     "<td>" .
 
@@ -1059,9 +1077,14 @@
 ########################################################################################
     my ($nuser) = @_;
     my $ntext;
-    my $pwfile = $cfghash{'BaseDir'}.$cfghash{'PasswdFile'};
-    my $pwin;
-    my $pwfiletext;
+    my $pwdfile = $cfghash{'BaseDir'}.$cfghash{'PasswdFile'};
+    my $pwdin;
+    my $pwdfiletext;
+    my $pwd;
+    my $uname;
+    my $dirlist;
+    my $nu_error = 1;
+    
 
     $ntext .= "Here is newuser $nuser<br>";
 
@@ -1076,22 +1099,66 @@
         $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();    
-        
+        $ntext .= "<br>Checking passwdord file<br>" ;
+        $pwdin = IO::File->new("<$pwdfile");
+        while (<$pwdin>) {
+            $_ =~ s|^(\w+):(.+)$|{$uname=$1}|eg;
+            ( $uname =~ $nuser ) && do { $nu_error = 0; };
+        } 
+        $pwdin->close();    
+
+        $ntext .= "<br>Checking subdir file<br>" ;
 
-# Checken, ob User in pw
-# Checken, ob Subdir gleichen Namens existiert
+        $dirlist = &readsubdir($cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/");
+       
+        $ntext .= "<br>$dirlist<br>" ; 
+        ( $dirlist =~ m|$nuser| ) && do { $nu_error = 0; };
+
+        if ($nu_error) {
+            $ntext .= "<br>Creatin subdir file<br>" ;
+            my $newdir = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $nuser;
+            system("mkdir  $newdir ") ;
+
+            $dirlist = &readsubdir($cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/");
+            my $dirok = 1;
+            ( $dirlist !~ m|$nuser| ) && do { $dirok = 0; };
+            if ($dirok) {
+                $ntext .= "<br>Reading password file<br>" ;
+                $pwdin = IO::File->new("<$pwdfile");
+                while (<$pwdin>) {
+                    $pwdfiletext .= $_;
+                    $_ =~ s|^(\w+):(.+)$|{$uname=$1; $pwd=$2}|eg;
+                    # I need an existing password as an example
+                }
+                $pwdin->close();    
+                $ntext .= "<br><br>" . "$pwdfiletext" . "<br><br>" ;
+            
+                $pwdfiletext .= $nuser . ":" . (crypt('foobar', $pwd)) ;
+
+
+                $ntext .= "<br><br>" . "$pwdfiletext" . "<br><br>" ;
+
+                $pwdin = IO::File->new(">$pwdfile");
+                print $pwdin $pwdfiletext;
+                $pwdin->close();    
+            }
 
-# Unterverzeichnis anlegen
-# PW Eintrag machen    
+           
+            $ntext .= "<font color=red>" .
+                "User $nuser created</font><br>" .
+                $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
+                
 
+        } else {
+            $ntext .= "<font color=red>" .
+            "<br>User exists <br><br>" .
+            "</font>" .
+            $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
+        }
     }
 
+
     return $ntext;
 }
 ########################################################################################
@@ -1101,9 +1168,75 @@
 ########################################################################################
     my ($duser) = @_;
     my $text;
+    my $derror = 0;
 
+    if ($duser =~ $cfghash{'TabeaUser'} ) {
+        $derror = 1;
+    }
 
-    $text .= 
+    if (! $derror ) {
+        $text .= 
+    
+        "<table>" .
+        "<td>" .
+        "<font color=red>" . 
+        "User to delete :" .
+        "</font>" .
+        "</td>".
+
+        "<td>" .
+        "$duser" .
+        "</td>" .
+
+    
+        "</table>" .
+
+        "<br><br>" .
+
+#    $cgi->checkbox(-name=>'del_u_files',
+#                   -value=>'del_files',
+#                   -checked=>'',
+#                   -label=>'Delete files of user',
+#                   -checked=> 
+#                  ) .
+        "<input type=\"checkbox\" name=\"del_u_files\" value=\"del_files\" />Delete files of user" .
+
+        "<br><br><br>" .
+
+        "<table>" .
+
+        "<td>" .
+        $cgi->submit(-name => 'dialog_mainw', -value => 'Back').
+        "</td>" .
+        "<td>" .
+        $cgi->submit(-name => 'dialog_d2user', -value => 'Del User').
+        "</td>" .
+
+        "</table>" ;
+
+    } else {
+        $text .=
+        "<font color=red>" .
+        "It is not allowed to delet tabea user!!!" .
+        "</font>" .
+        "<br><br>" .
+        $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
+    }
+
+
+    return $text;
+}
+########################################################################################
+
+
+
+########################################################################################
+sub d2user {
+########################################################################################
+    my ($duser) = @_;
+    my $dtext;
+
+    $dtext .= 
     
     "<table>" .
     "<td>" .
@@ -1115,29 +1248,107 @@
     "<td>" .
     "$duser" .
     "</td>" .
-
     
     "</table>" .
     
     "<br><br>" .
 
+    "And his files wil be " ;
+
+    $dtext .= $cgi->param('del_u_files') . "<br>";
+
+    if ($cgi->param('del_u_files')) {
+        $dtext .= "<br>The files of the user will be deleted" ;    
+    } else {
+        $dtext .= "<br>The files of the user will be copied" ;    
+    }
+    
+    $dtext .= "<br><br><br>" .
+
     "<table>" .
 
     "<td>" .
     $cgi->submit(-name => 'dialog_mainw', -value => 'Back').
     "</td>" .
     "<td>" .
-    $cgi->submit(-name => 'dialog_d2user', -value => 'Del User').
+    $cgi->submit(-name => 'dialog_d3user', -value => 'Really delete user').
     "</td>" .
 
     "</table>" ;
 
-    return $text;
+
+    return $dtext;
 }
 ########################################################################################
 
 
 ########################################################################################
+sub d3user {
+########################################################################################
+    my ($duser) = @_;
+    my $d3text;
+    my $delfiles = $cgi->param('del_u_files');
+    my $deldir = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $duser . "/" ;
+    my $pwdfile = $cfghash{'BaseDir'}.$cfghash{'PasswdFile'};
+    my $pwdin;
+    my $temptxt;
+    my $pwdfiletext;
+    my $uname;
+
+
+    $d3text .= 
+    
+    "<table>" .
+    "<td>" .
+    "<font color=red>" . 
+    "User to delete :" .
+    "</font>" .
+    "</td>".
+
+    "<td>" .
+    "$duser" .
+    "</td>" .
+    
+    "</table>" .
+
+    "<br>" ;
+
+    if ( ! $cgi->param('del_u_files')) {
+        
+        my $destdir = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $cfghash {'TabeaUser'} ."/" ;
+        my $copyfiles = &readdir($deldir);
+        my @copfilesarray = split(/ /,$copyfiles);
+
+        foreach (@copfilesarray) {
+
+            system("cp $deldir$_ $destdir$duser.$_") && die "Copy failed";
+        }
+    }
+
+    system("rm -rf $deldir");
+
+    $pwdin = IO::File->new("<$pwdfile");
+    while (<$pwdin>) {
+        $temptxt = $_ ;
+        $_ =~ s|^(\w+):(.+)$|{$uname=$1}|eg;
+        if ($uname !~ $duser) { $pwdfiletext .= $temptxt; }
+    }
+    $pwdin->close();
+    $pwdin = IO::File->new(">$pwdfile");
+    print $pwdin $pwdfiletext;
+    $pwdin->close();
+
+    $d3text .= "<br>" .
+
+    $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
+
+
+    return $d3text;
+}
+########################################################################################
+    
+
+########################################################################################
 sub copy {
 ########################################################################################
     my ($srcf, $dstf) = @_;

CVSTrac 2.0.1