15
Hmm... I'm not the amazing one, luciano is
Now, I installed registration keys (works fine) but at the admin side I need to enter a username and a code. So, that won't work. I will have to hack the module so it doesn't require a username. Registration will also need a modification.
Another thing is the code generator I would need. Entering the codes manually is not really an option.
Generating codes
function ranpass($len = "8"){
$pass = NULL;
for($i=0; $i<$len; $i++) {
$char = chr(rand(48,122));
while (!ereg("[a-zA-Z0-9]", $char)){
if(strtoupper($char) == strtoupper($lchar)) continue;
$char = chr(rand(48,90));
}
$pass .= $char;
$lchar = $char;
}
return $pass;
}
function makeRandomPassword() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
Putting then into the database
$link = mysql_connect("localhost", "databaseuname", "databasepassword");
$db =mysql_select_db("databasename");
for($i=0; $i<$howmuch; $i++) {
$code = ranpass();
$result = mysql_query("INSERT INTO `codes` VALUES ('$code', '', '', '', '0000-00-00', '', '')");
if (!$result){
$fout = mysql_error();
echo $fout;
}
Whatdoyouthink