<?php
/*
Script made 100% by Colandus!
Remember: Names with length 4 - 8 gets best result!
It is very hard to find good names at length between 10 - 12, but I have found few!
*/
########## <CONFIG> ##########
//If you don't want random name lengths then write the same number on minimum and maximum.
$lengthMin = 5; //How many letter shall the word have as minimun? 2+
$lengthMax = 5; //How many letters shall the word have as maximum? 2+
$spChance = 0; //How much will the chance in percent be to get the character ' into the name? 0 - 100
$ucChance = 50; //How much will the chance in percent be to get a uppercase letter after the character ' into the name? 0 - 100
$bwChance = 0; //How much will the chance in percent be to get a name in reverse (backward) order? 0 - 100
$multiNames = 0; //How much will the chance in percent be to get a multiply name? 0 - 100
$displayNames = 1000; //How many names will be displayed at once? 1 - 10 000
$nameSize = 12; //How big shall the font size of the names be in pixels?
$showNum = true; //Should there be a number (list) before each name? true/false
########## </CONFIG> ##########
// Error messages.
if ($lengthMin < 3)
$errors[] = "Value of variable <b>\$lengthMin</b> is too low";
if ($lengthMin > 12)
$errors[] = "Value of varialbe <b>\$lengthMin</b> is too high";
if ($lengthMax > 12)
$errors[] = "Value of variable <b>\$lengthMax</b> is too high";
if ($lengthMax < $lengthMin)
$errors[] = "Value of variable <b>\$lengthMax</b> cannot be lower than value of variable \$lengthMin";
if (!$lengthMin)
$errors[] = "Missing variable <b>\$lengthMin</b>";
if (!$lengthMax)
$errors[] = "Missing variable <b>\$lengthMax</b>";
if ($nameSize < 8)
$errors[] = "Value of variable <b>\$nameSize</b> is too low";
if (!$nameSize)
$errors[] = "Missing variable <b>\$nameSize</b>";
if (!$showNum)
$errors[] = "Missing variable <b>\$showNum</b>";
if (!$displayNames)
$errors[] = "Missing variable <b>\$displayNames</b>";
if (!$errors) {
//Sets all consonats in a array.
$consonants = array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z");
//Sets all vowels in a array.
$vowels = array("a", "e", "i", "o", "u");
//Makes a random consonant.
function randomCons() {
global $consonants;
$consSize = sizeof($consonants) - 1;
$randCons = rand(0, $consSize);
$consonant = strtolower($consonants[$randCons]);
return $consonant;
}
//Makes a random vowel.
function randomVowe() {
global $vowels;
$voweSize = sizeof($vowels) - 1;
$randVowe = rand(0, $voweSize);
$vowel = strtolower($vowels[$randVowe]);
return $vowel;
}
function addChar($specOrder) {
global $bwChance;
if ($specOrder < $bwChance) {
$char = randomVowe() . randomCons();
} else {
$char = randomCons() . randomVowe();
}
return $char;
}
//Makes a random name.
function randomName($lengthMin, $lengthMax) {
global $spChance, $bwChance, $ucChance, $multiNames, $searchName;
$letters = rand($lengthMin, $lengthMax);
//Adds a position to the special character ' in the name.
$specCharRand = rand(0, 99);
if ($specCharRand < $spChance) {
if ($letters == 4 || $letters == 5) {
$charPos = 2;
} elseif ($letters == 6) {
$charPos = rand(2, 3);
} elseif ($letters >= 7) {
$charPos = rand(2, 4);
}
}
//Makes names throughout consonants and vowels.
$specOrder = rand(0, 99);
$start = 0;
for ($i=0;$i<floor($letters/2);$i++) {
$name .= addChar($specOrder);
}
if ($letters%2 == $start) {
if ($specOrder < $bwChance) {
$name .= randomVowe();
} else {
$name .= randomCons();
}
}
//Adds a special character into the name.
if ($charPos) {
$upperCaseRand = rand(0, 99);
if ($upperCaseRand < $ucChance) {
$afterChar = ucfirst(substr($name, $charPos));
} else {
$afterChar = substr($name, $charPos);
}
$name = substr($name, 0, $charPos) . "'" . $afterChar;
}
return ucfirst($name);
}
$names = array();
function makeName($lengthMin, $lengthMax) {
global $names;
$name = randomName($lengthMin, $lengthMax);
if (in_array($name, $names)) {
$name = makeName($lengthMin, $lengthMax);
}
$names[] = $name;
return $name;
}
if ($displayNames < 1) {
echo "<b>Warning:</b> Atleast one name has to be shown!";
}
echo "<table cellspacing='0' cellpadding='1' border='0'>";
$name = array();
for ($i=1; $i <= $displayNames; $i++) {
$name[$i] = makeName($lengthMin, $lengthMax);
$multiNameRand = rand(1, 100);
##echo $i . ". " . $multiNameRand . " " . $multiNames . "<br>";
if ($multiNameRand <= $multiNames) {
$name[$i] .= " " . makeName($lengthMin, $lengthMax);
}
}
foreach ($name as $id => $tname) {
echo "<tr>";
if ($showNum == true && $displayNames >= 1) {
echo "<td style='font-size: " . $nameSize . "px;' valign='bottom'>$id. ";
echo "<td style='font: bold " . $nameSize . "px verdana;'>" . $tname;
echo "<br />";
}
}
echo "</table>";
} else {
foreach ($errors as $key => $error) {
echo "$error!<br />";
}
}
?>