|
Here's a script I wrote (minus the read parse) that does the same thing, hope it helps:
#!/usr/bin/perl
MAIN:
{
&ReadParse(*input);
&ProcessRequest;
}
sub ProcessRequest
{
# Defines the output as plain text
print "Content-type: text/plain\n\n";
# Opens the database
open(DATABASE, "<pm.dat");
my @member_lines = <DATABASE>;
close(DATABASE);
# Sets the variable "user" to null
my $user = "";
# Defines that the database is pipe delimited
for(@member_lines)
{
@split_line = split(/\|/, $_);
# Defines the variable "user" as the first column in the database
$user = @split_line[0];
# Converts the input name to lowercase
$input{'name'} =~ tr/A-Z/a-z/;
# Returns "true" if any name contains "monitor" or "moderator"
if ($input{'name'} =~ /monitor/ || $input{'name'} =~/moderator/)
{
print "true";
return;
}
# If the membername exists, returns "true" and denies user the right to use that name.
if ($input{'name'} eq $user) {
print "true";
return;
}
}
# If the membername is null, returns an error message saying so
if ((!exists($input{'name'})) || ($input{'name'} eq ""))
{
print "error\nInput name is null.";
return;
}
# Returns an error if the database cannot be opened.
unless (open(DATABASE, "pm.dat"))
{
print "error\nUnable to open the database.";
return;
}
# If the above conditions were not met, it assumes that the membername is not
# reserved and returns "false" which grants the member access to the Volano
# Chat server.
close(DATABASE);
print "false";
}
__________________
Chris
Apple Certified iPhone Developer
|