This topic is locked

.htacces

1/17/2007 5:14:35 AM
PHPRunner General questions
D
dossi author

Hallo,
if somebody want's to protect folders with Apachesystem .htacces and .htpasswd.

Automatic creating new users , updating and changing the .htpasswd works with

following code:
//Put in Gobal Events and Table Events
//Registrationpage, Change Password Page , Edit Page etc
function AfterSuccessfulRegistration()

{

//** Custom code ****

$res = mysql_query("select * from tablename");

$safe= "../firewall"; // relativ Document Root
$htpasswd= fopen("$safe/.htpasswd", "w");

while($data=mysql_fetch_object($res))

{fputs($htpasswd, "$data->user:".crypt($data->Password,CRYPT_STD_DES)."\n");}

fclose($htpasswd);}
dossi (Germany)