How to create a random password generator with PHP
I found this cool snippet and I wanted to share it with you.
The code basically uses predefined characters to create a string.
You can set the length and the strength.
Now you just need to call the function wherever you want.
<?php
function generatePassword($length=9, $strength=0) {
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength & 1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength & 2) {
$vowels .= "AEUY";
}
if ($strength & 4) {
$consonants .= '23456789';
}
if ($strength & 8) {
$consonants .= '@#$%';
}
$password = '';
$alt = time() % 2;
for ($i = 0; $i < $length; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand() % strlen($consonants))];
$alt = 0;
} else {
$password .= $vowels[(rand() % strlen($vowels))];
$alt = 1;
}
}
return $password;
}
?>
Code language: HTML, XML (xml)
Nicole
Hey
I am looking at the categories on the right. Do you also write about a forum creation?
thanks
Nicole π
quicoto
Hmm not exacly.
What do you need?
(almost stable) WordPress Forum Plugin: http://wordpress.org/extend/plugins/bbpress/
SMF: great forum – http://www.simplemachines.org/
phpBB: Also a good forum. The admin area is a little bit messy: http://www.phpbb.com/
Regards
Nicole
hey
I need a forum that I can easily customize and manage. that would be great from the SEO perspective.
I have installed phpBB, and updated it to the newest version, but it is confusing, as i have no idea where to begin, I would like to customize it, but see no manuals.
SMf looks simpler. Thank you for the link.
I would use it.
best
N.
quicoto
Never did it on phpBB or SMF but shouldn’t be hard. Look for the template folder and happy coding π
Good luck π
Nicole
I have one more question.
I see in the SEO Quake panel the date when you website was created. It is showed by “Webarchive age”. Did you do anything so they have your website archived?
i have a few websites, but none of them has this feature structured.
quicoto
Using the extension you saw CodeGround’s creation date?
I didn’t do anything. It has to be something about WordPress.
Does the date match the first post date?
Nicole
it says February 7, 2008 . Is it the date when you created the site?
quicoto
Yeah could be π