[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] I have tried and failed...



"Jeff Jensen" <jeff@xxxxxxxxxxxxxxxxx> wrote:
> Does anyone have a script that can check if a username/mail alias is
already
> used on a RAQ? I can't use the cobalt scripts since they can only executed
> from the shell. I need a perl or PHP script.

No, but I can give you one in pseudo-code.  It should be easy to code in
PHP.

$file = fopen( "/etc/passwd")
while ( ! feof( $file ) )
{
$contents = fgets($file,1024)
explode( ":", $contents )
$users[] .= $contents[0]
}
fclose($file)

if ( in_array( $username_to_check, $users ) )
{
echo "Sorry, that name is taken."
}
else
{
echo "Congratulations, you have a name no one wanted until now."
}

Do something similar for virtusertable.  Use regular expressions if you need
to.  The PHP manual at php.net is your friend.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/