function minecraftServerList($service_id, $source = "plugins") { global $config; //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return "Error: the identifier for this service is not set."; } //ok iterate through maps $extensions = array("jar"); if ($source == "backups") { $extensions = array("uxbakzip"); } if ($source == "repository") { $dir = new DirectoryIterator($config['minecraft_path'] . "plugins"); } else { if ($source == "plugins") { $jail = jailEnabled($service_id); if ($jail) { return jailDirList($service_id, "plugins", $extensions); } $dir = new DirectoryIterator($config['minecraft_path'] . $id . "/plugins"); } else { if ($source == "backups") { $jail = jailEnabled($service_id); if ($jail) { return jailDirList($service_id, ".", $extensions); } $dir = new DirectoryIterator($config['minecraft_path'] . $id); } else { if ($source == "versions") { $dir = new DirectoryIterator($config['minecraft_path'] . "versions"); } else { return "Error: bad source to minecraftPluginList."; } } } } $array = array(); foreach ($dir as $file) { if ($file->isFile()) { $ext = getExtension($file->getFilename()); if (in_array($ext, $extensions)) { array_push($array, $file->getFilename()); } } } sort($array); return $array; }
function ghostMapList($service_id, $source = "maps") { global $config; //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return "Error: the identifier for this service is not set."; } //ok iterate through maps $extensions = array("w3x", "w3m"); if ($source == "mapcfgs") { $extensions = array("cfg"); } if ($source == "repository") { $dir = new DirectoryIterator($config['ghost_path'] . "maps"); } else { if ($source == "maps") { $dir = new DirectoryIterator($config['ghost_path'] . $id . "/maps"); } else { if ($source == "mapcfgs") { $jail = jailEnabled($service_id); if ($jail) { return jailDirList($service_id, "mapcfgs", $extensions); } $dir = new DirectoryIterator($config['ghost_path'] . $id . "/mapcfgs"); } else { return "Error: bad source to ghostMapList."; } } } $array = array(); foreach ($dir as $file) { if ($file->isFile()) { $ext = getExtension($file->getFilename()); if (in_array($ext, $extensions)) { array_push($array, $file->getFilename()); } } } sort($array); return $array; }