If you are making a admin tool for your site you can add all the users into a table called e.g. "users" and automaticaly generate a .htpasswd file from it. This function uses MD5 encryption.
Download
View Source (print view)
Rating : 4.7
Views : 3747
function makehtaccess() {
global $Cfg;
connect();
$users = mysql_query("select username,pass from users where access > '0'") or die ("Can't get users (makehtaccess)");
$num = mysql_numrows($users);
$t = 0;
if ($num != 0) {
$f = fopen(".htpasswd", "w+");
while ($num>$t) {
unset($seed);
# generate random seed
$all = explode( " ",
"a b c d e f g h i j k l m n o p q r s t u v w x y z "
. "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
. "0 1 2 3 4 5 6 7 8 9");
for($i=0;$i<9;$i++) {
srand((double)microtime()*1000000);
$randy = rand(0, 61);
$seed .= $all[$randy];
}
$username = mysql_result($users,$t,"username");
$password = mysql_result($users,$t,"pass");
$crypt = crypt($password, "$1$$seed");
fputs($f,"$username:$cryptn");
$t++;
}
}
}
acl, php and 0=1 union select keywords and 0=1 union select, php script and char(124) (select cast(count(1) as varchar(8000)) char(124) from [sysobjects] where 1=1)>0, fft, form to mail, "web page design in php", php_tools, php file upload, php keywords and 0=1 union select, rapiodshare, p t test paired, read mysql field, ringtonescript, form_to_mail, api, ring tone script, 'php script, call php', sms script, "web_page_design_in_php", pntvts