What is your Pro Wrestling Name?
Enter your Real Name: (ex. Terry Bollea)
error_reporting(E_ALL);
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
// initialize a variable to
// put any errors we encounter into an array
$errors = array();
// test to see if the form was actually
// posted from our form
$page = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if (!ereg($page, $_SERVER['HTTP_REFERER']))
$errors[] = "Invalid referer\n";
// check to see if a name was entered
if (!$_POST['realname'])
// if not, add that error to our array
$errors[] = "Name is required";
// if there are any errors, display them
if (count($errors)>0){
echo "
ERROR:
\n";
foreach($errors as $err)
echo "$err
\n";
}
else {
// no errors, so we build our message
//print "Please input your Name";
$displayname = $_POST["realname"];
//make sure user doesnt try to insert any funky characters or html
$displayname = preg_replace('/[^a-z0-9 ]/i', '', $displayname);
$realname = strtolower($_POST["realname"]);
$realname = preg_replace('/[^a-z0-9 ]/i', '', $realname);
/*== generate seed number from name submitted ==*/
$len = strlen($realname);
$seed = 0; $s = 0;
for ($e=1; $e<=$len; $e++)
{
$chr = substr($realname,$s,$e);
$seed = $seed + ord($chr)*$e;
// Added the extra piece below because too many names were matching each other
// So now I add the ASCII value of a character to make it more unique
$seed = $seed + ord($chr);
$s=$e;
}
/*== read in the two files into the arrays ==*/
$adj_array = file("youradjs.txt");
$noun_array = file("yournouns.txt");
/*== set random seed ==*/
srand($seed);
/*== get the random numbers for each name first/last or adj/noun ==*/
$arnd = rand(0,sizeof($adj_array)-1);
$nrnd = rand(0,sizeof($noun_array)-1);
$wuadj = $adj_array[$arnd];
$wunoun = $noun_array[$nrnd];
/*== create name from random numbers ==*/
$wuadj = rtrim($wuadj);
$wunoun = rtrim($wunoun);
//I modified this because there was a linefeed between the adj and noun
$wngname = "$wuadj $wunoun";
//BEGIN_Specific_Name_Matches
if ($realname == "dwayne johnson")
{
$wngname = "The Rock";
}
if ($realname == "terry bollea")
{
$wngname = "Hulk Hogan";
}
if ($realname == "steve williams")
{
$wngname = "Stone Cold Steve Austin";
}
//Add more here
//END_Specific_Name_Matches
//BEGIN_DEBUG
//print "DEBUG: arnd value is $arnd
";
//print "DEBUG: nrnd value is $nrnd
";
//foreach ($_POST as $var => $value) {
//echo "$var = $value
";
//}
//END_DEBUG
//Lets capitalize the first letter of each word the user inputted
$displayname = ucwords(strtolower($displayname));
print " $displayname, your professional wrestling name is now:
\n";
print " $wngname\n
\n";
//BEGIN_WRITE
//We're logging all the entries here to a text file.
//It's fun to see what people type in
//More importantly, it's a good way to audit the generator to make sure
// we're getting good results and not too many duplicates
$ourFileName = "name_log.txt";
$fh = fopen($ourFileName, 'a') or die("Can't open file");
$ip = $_SERVER['REMOTE_ADDR'];
$wngdate = date('Y-m-d H:i:s');
$twuname = rtrim($wngname);
$wnguserinfo = "$ip\t$displayname\t$twuname\t$wngdate\n";
fwrite($fh, $wnguserinfo);
fclose($fh);
//END_WRITE
//BEGIN_DEBUG
//Uncomment the stuff below if you want to display the log we wrote
//$ourFileName = "name_log.txt";
//$fh = fopen($ourFileName, 'r') or die("Can't open file");
// Perform a "tail" on a growing logfile
//while( !feof($fh) ) {
// $log = fgets( $fh,10 );
// echo "$log
";
// }
//fclose($fh);
//END_DEBUG
//BEGIN_COUNTER
//I just want to see how many names are generated
//The counter will increase at every press of the Submit button
// or even a reload of the page.
//variable declarations
$counter_data = "count.txt"; //counter data file
//$image_dir = "/digits/1"; //image directory
$style = "text"; //enter text for text.Anything else for graphics
//check if file exists
if(!($fp = fopen($counter_data,"r+"))) die ("cannot open counter file");
//read in the current count from the file
$count = (int) fread($fp, 20);
//close the file
fclose($fp);
//increment count
$count++;
//text counter
if ($style == "text")
{
echo " $count";
}
//graphical counter
//else
//{
// $digit = strval($count);
// for ($i = 0; $i < strlen($count); $i++)
// {
// echo "
";
// }
//}
$fp = fopen($counter_data, "w");
fwrite($fp , $count);
//close the file
fclose($fp);
//END_COUNTER
}
}
?>
Wrestling Names Served since May 18 2006
By Jeff Kujath. Based on the Wu-Name Generator at www.blazonry.com.
PHP code was heavily modified to provide additional security and functionality.
Download my modified source code HERE.
My stylesheet is HERE.
Disclaimer: Use my code at your own risk. :-)
Questions/Comments/Suggestions, please go to my forums HERE.
Or email me: jeff@kujosoft.com
Check out other fun Generators at generatorblog.blogspot.com!
Check out my other sites: kujosoft.com .:. kujath.com .:. kumovies.com .:. sarahjo.com