Security
|
|
|
|
<?php 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++;
}
}
} ?>
|
|
|
Usage Example
|
Table layout:
CREATE TABLE users(
username varchar(30) NOT NULL,
pass varchar(40) NOT NULL,
access int(1) DEFAULT '0' NOT NULL,
);
|
|
|
Rate This Script
|
|
|
|