Viewing file: atdrop.pl (1.04 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/perl
require '/home/httpd/cgi-bin/atdot/test/config.pl';
$user = $ARGV[0];
while (<STDIN>) { $message .= $_ };
$passdb = $dbdir . "pass";
dbmopen(%pass, $passdb, 0600);
if ($pass{$user}) {
$foldir = $dbdir . "/folders";
mkdir $foldir, 0700;
$userdir = $foldir . "/" . $user;
mkdir $userdir, 0700;
$inbox = $userdir . "/INBOX";
dbmopen(%box, $inbox, 0600);
if (!($box{'MESSAGES'})) { $box{'MESSAGES'} = "0"; }
@messagelist = split(/\t/, $box{'MESSAGES'});
$nextmess = greatest(@messagelist);
$nextmess++;
$box{$nextmess} = $message;
$box{'MESSAGES'} .= "\t$nextmess";
dbmclose(%box);
} else {
die "No such user $user";
}
dbmclose(%pass);
###########################################################################
# greatest() - returns the largest number from an array
###########################################################################
sub greatest{
my @arr = @_;
$big = 0;
for ($i = 0; $i <= $#arr; $i++){
if ($arr[$i] > $big) { $big = $arr[$i]; }
}
return $big;
}
|