Files
wizzardRedux/admin/getmamenames.php
2016-03-18 01:42:48 -07:00

41 lines
936 B
PHP

<?php
if (!file_exists("../temp/mame/"))
{
mkdir("../temp/mame", "0777", true);
}
$softlists = scandir("../temp/mame/");
$outhandle = fopen("../css/mamelist.php", "w");
fwrite($outhandle, "<?php\n\n".
"/*\nAuto-generated by getmamenames.php\n*/\n\n".
"// MAME softlists to recognizable names/systems\n".
"\$mame_softlists = array (\n");
foreach ($softlists as $list)
{
if (preg_match("/^.*\.xml$/", $list))
{
$handle = fopen("../temp/mame/".$list, "r");
if ($handle)
{
while (($line = fgets($handle)) !== false)
{
if (strpos($line, "<softwarelist") !== false)
{
$xml = simplexml_load_string($line."</softwarelist>");
$name = $xml->attributes()["description"];
fwrite($outhandle, "\t'".$list."' => '".addslashes($name)."',\n");
}
}
}
fclose($handle);
}
}
fwrite($outhandle, ")\n\n?>");
fclose($outhandle);
echo "<script type='text/javascript'>window.location='?page='</script>";
?>