View Full Version : [URGENT] Adding an htaccess user

09-04-2005, 07:33 AM
Is this possible? I have the code i need to update a password, but is there a way to create a new user using PHP, or exec, or anything I can put in a webpage, and feed information to from a form?

The server I am on also has cPanel BTW

I need this as soon as possible!!

Thank you.

09-04-2005, 03:06 PM
You could use the htpasswd program via exec to add users to your .htpasswd file

As long as .htaccess is set to require valid-user then it should allow any user in .htpasswd

09-04-2005, 03:15 PM
Another option would be to create these files yourself, as .htaccess will allow you to specify what file it will read for authentication. Of course, keep this above your web root directory.
Heres a perl example:

use DB_File;
tie %database, 'DB_File', "passwords.dat"
or die "Can't initialize database: $!\n";

$username = 'rbowen';
$password = 'mypassword';
$salt = $chars[int rand @chars] . $chars[int rand @chars];

$crypt = crypt($password, $salt);
$database{$username} = $crypt;

untie %database;

Looking at it seems easy enough, create a random two digit password salt containing alphanumeric characters, and crypt your password. Its been years since I've used perl, and frankly my perl skills were not great to start with, but so long as the crypt function is the same, you're good to go. No guarentees though.