Give automatic access to protected directory

waldirlieb

Registered
Sep 18, 2007
4
0
51
Hi! I have a website which has a directory protected through the "Protect Directory" option of CPanel, in a remote host environment. I want new users, after going through a registration form written in PHP that will add the user to my MySQL database, to have automatic access to this protected directory. How could I achieve this? Thanks.
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
Hi! I have a website which has a directory protected through the "Protect Directory" option of CPanel, in a remote host environment. I want new users, after going through a registration form written in PHP that will add the user to my MySQL database, to have automatic access to this protected directory. How could I achieve this? Thanks.
Note that cPanel's Protect Directory functionality relies on .htaccess and .htpasswd files to store user credentials, not MySQL databases.
 

waldirlieb

Registered
Sep 18, 2007
4
0
51
Password protection

Yes, I have noticed that. The MYSQL is just to store my user data. When the user register, I need some script to add his login data to the .htpasswd file. The data in this file is stored in the format user : password, but the password is encrypted, and I don't know how it is supposed to be encrypted. I could make a script to write on this file, but how to encrypt the password? Is there any other method?
Thanks.
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
Yes, I have noticed that. The MYSQL is just to store my user data. When the user register, I need some script to add his login data to the .htpasswd file. The data in this file is stored in the format user : password, but the password is encrypted, and I don't know how it is supposed to be encrypted. I could make a script to write on this file, but how to encrypt the password? Is there any other method?
Thanks.
I'd highly recommend looking up a PHP tutorial for this as this isn't a cPanel-specific issue/script.
 

waldirlieb

Registered
Sep 18, 2007
4
0
51
I think it is

Hi, thanks for your replies. I still think it's a CPANEL issue because I need to encrypt the same way as CPANEL does, so it will be able to read the file and do the protection. Well, I will keep looking for it. Thanks.
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
Hi, thanks for your replies. I still think it's a CPANEL issue because I need to encrypt the same way as CPANEL does, so it will be able to read the file and do the protection. Well, I will keep looking for it. Thanks.
For password protected directories, cPanel is merely an interface for Apache's mechanisms. We do not employ our own specific type of encryption for such files.
 

waldirlieb

Registered
Sep 18, 2007
4
0
51
Thanks - You are right

It's not a CPanel issue. It's an Apache and PHP issue. I managed to solve it. I found a PHP class to manipulate htpasswd files in a way compatible with Apache. Thank you.
 

terrya

Registered
Apr 19, 2006
1
0
151
Password Encryption Class

I'm having the same problem in getting the encryption right. Would you mind sharing the class name and where you found it?
Thanks,