#!/usr/bin/perl use DBI; my $database = "pureftpd"; my $data_source = "DBI:mysql:$database;"; my $username = "purftpdphp"; my $password = "purephppw"; $usersfile = "/var/www/html/users.inc"; $afiandir = "/var/www/html/"; my $dbh =DBI->connect( $data_source, $username, $password) or die "Can't connect to $data_s ource: $dbh->errstr\n"; my $sth = $dbh->prepare("select User,Password,Dir from ftpd;"); $sth->execute or die "Unable execute query:$dbh->err, $dbh->errstr\n"; $users = $sth->rows; #print "there are: $users users \n"; open (OUTFILE, ">$usersfile"); print OUTFILE "a:$users:{"; $i = 0; while ($row = $sth->fetchrow_hashref) { $username = $row->{User}; $passwd = $row->{Password}; $homedir = $row->{Dir}; #print "USER: $username PW: $passwd DIR: $homedir \n"; $lenofu = length $username; #print "LENGHT: $lenofu \n"; print OUTFILE "i:$i;a:4:{i:0;s:"; print OUTFILE length $username; print OUTFILE ":\"$username\";i:1;s:"; print OUTFILE length $passwd; print OUTFILE ":\"$passwd\";i:2;s:"; print OUTFILE length $homedir; print OUTFILE ":\"$homedir\";i:3;s:0:\"\";}"; $seconds = `date +%s`; chomp $seconds; $seconds = $seconds + $i; $i++; $doit = "/bin/mkdir ".$afiandir."trash\/$username"; $mkdir = `$doit`; $doit = "/bin/mkdir ".$afiandir."clipboard\/$username"; $mkdir = `$doit`; $doit = "/bin/touch ".$afiandir."trashundo\/$username.txt"; $mkdir = `$doit`; $doit = "/bin/mkdir \/home\/$username"; $mkdir = `$doit`; $doit = `/bin/chown -R clintftp:clintftp $afiandir`; $doit = `/bin/chown -R clintftp:clintftp /home`; } print OUTFILE "}"; $sth->finish; $dbh->disconnect; close OUTFILE;