function endsWith( $str, $sub )
{
return ( substr( $str, strlen( $str ) - strlen( $sub ) ) == $sub );
}
function toUp($name, $split)
{
$nom = explode($split, $name);
for($id = 0; $id < count($nom); $id++)
{
$nom[$id] = strtoupper(substr($nom[$id],0,1)) . substr($nom[$id],1);
}
return implode($split, $nom);
}
function toUpIgnore($name, $split)
{
$nom = explode($split, $name);
if($imp == null)
{
$imp = $split;
}
for($id = 0; $id < count($nom); $id++)
{
$nom[$id] = strtoupper(substr($nom[$id],0,1)) . substr($nom[$id],1);
}
return implode("", $nom);
}
$nameList = array();
$nameList["name_girl_dutch"] = "name_girl_dutch.txt";
$nameList["name_girl_hebrew"] = "name_girl_hebrew.txt";
$nameList["name_girl_hindu"] = "name_girl_hindu.txt";
$nameList["name_girl"] = implode(',', array(
$nameList["name_girl_dutch"],
$nameList["name_girl_hebrew"],
$nameList["name_girl_hindu"]
));
$nameList["videogames_games_capcom"] = "videogames_games_capcom.txt";
$nameList["videogames_games_indie"] = "videogames_games_indie.txt";
$nameList["videogames_games_nintendo"] = "videogames_games_nintendo.txt";
$nameList["videogames_games_sega"] = "videogames_games_sega.txt";
$nameList["videogames_games_square_enix"] = "videogames_games_square_enix.txt";
$nameList["videogames_games_valve"] = "videogames_games_valve.txt";
$nameList["videogames_games"] = implode(',', array(
$nameList["videogames_games_capcom"],
$nameList["videogames_games_indie"],
$nameList["videogames_games_nintendo"],
$nameList["videogames_games_sega"],
$nameList["videogames_games_square_enix"],
$nameList["videogames_games_valve"]
));
$nameList["videogames_characters_minecraft"] = "videogames_characters_minecraft.txt";
$nameList["videogames_other_minecraft"] = "videogames_other_minecraft.txt";
$nameList["videogames_mods_minecraft"] = "videogames_mods_minecraft.txt";
$nameList["videogames_minecraft"] = implode(',', array(
$nameList["videogames_characters_minecraft"],
$nameList["videogames_other_minecraft"],
$nameList["videogames_mods_minecraft"]
));
$nameList["location_dutch"] = "location_dutch.txt";
$nameList["location_us"] = "location_us.txt";
$nameList["location"] = implode(',', array(
$nameList["location_dutch"],
$nameList["location_us"]
));
$nameList["test"] = "test.txt";
if(isset($_GET['args']))
$args = $_GET['args'];
$list = 'test';
$count = '5';
$aslist = false;
$fulloutput = false;
$debug = false;
if(isset($_GET['list']))
{
$list = $_GET['list'];
}
if(isset($_GET['count']))
{
$count = $_GET['count'];
}
if(isset($_GET['aslist']) && $_GET['aslist'] != 'full' && $_GET['aslist'] != 'debug')
{
$aslist = true;
}
else if(isset($_GET['aslist']) && ($_GET['aslist'] == 'full' || $_GET['aslist'] == 'debug'))
{
$fulloutput = true;
$debug = ($_GET['aslist'] == 'debug');
}
$args = escapeshellcmd($args);
$lists = explode(",",$list);
$files = array();
for($idx = 0; $idx < count($lists); $idx++)
{
$curFile = "";
if(endsWith($lists[$idx], ".txt"))
{
$curFile = $lists[$idx];
}
else
{
$curFile = $nameList[$lists[$idx]];
}
array_push($files, $curFile);
}
$output = array();
//echo 'java -jar namegen.jar -bare -unweighted basic_settings_bare.txt,' . implode(',', $files) . ' list ' . $count;
exec('java -jar namegen.jar' . ($fulloutput ? '' : ' -bare') . ($debug ? ' -debug' : '') . ' -unweighted basic_settings_bare.txt,' . implode(',', $files) . ' list ' . $count, $output, $retVal);
//exec('java -jar namegen.jar -bare -unweighted basic_settings.txt,' . $nameList[$arg[0]] . ' list 1 ' . $arg[1], $output, $retVal);
//echo 'java -jar namegen.jar -bare -unweighted basic_settings.txt,' . $nameList[$arg[0]] . ' list 1 ' . $arg[1] . "
\n";
//print_r($output);
for($idx = 0; !$fulloutput && $idx < count($output); $idx++)
{
$name = $output[$idx];
$name = toUp($name, " ");
$name = toUp($name, "-");
$name = toUp($name, ":");
$name = toUp($name, "!");
$name = toUp($name, ",");
$name = toUp($name, ".");
$name = toUpIgnore($name, "[nc]");
$name = toUp($name, "(");
$name = toUp($name, ")");
$name = toUp($name, "[");
$name = toUp($name, "]");
$output[$idx] = $name;
}
if(!$fulloutput)
{
echo 'Your generated names: ' . ($aslist ? '
' . implode(PHP_EOL, $output) . ''; } ?>