-   Linux - Server (
-   -   How to sync md5 password between php and htpasswd (

chobong 07-06-2010 10:57 PM

How to sync md5 password between php and htpasswd
Dear All,

I have built a subversion server (1.6.12 version) on Centos 5.4.
I created a database for the server for authentication user via database MySQL with mod_auth_mysql, but this make my subversion server is so slow when make a commit.

I think authentication through a file is fast , but I wish to connect the password in database (the password is created by PHP) to file.
I used a file like this
xxx is the password which is got from database. But it's not ok. :(

If anyone knows, please let me know how should I do that.
Thanks so much.

uko 07-15-2010 03:51 PM

You obviously want to create a password protected site and use php scripts to administrate users?

typically a password file for apache is created using htpasswd (for apache 1.x) or htpasswd2 for apache 2.

To add a new user you may execute htpasswd from your php session:
define("HT_PASSWD_ENCRYPT", "m");
// HT_PASSWD_ENCRYPT may be one of:
// d use crypt() encryption, not Win32
// m use MD5 encryption
// s use SHA encryption

function newUser($un, $pw)
$cmd = get_htpasswd() . ' -b' . HT_PASSWD_ENCRYPT . ' ' . escapeshellarg($pwFile) . ' ' . escapeshellarg($un) . ' ' . escapeshellarg($pw);
system($cmd, $rc);


You may basically do the same thing if you want to change the password.

Hope this helps.

All times are GMT -5. The time now is 04:38 PM.