Modify gen.php, using scandir instead of dir for sorting ability