function garenaGetConfiguration($service_id, $skip = true) { global $config; $parameters = garenaGetParameters($service_id); //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return false; } //read the configuration file $jail = jailEnabled($service_id); if ($jail) { jailFileOpen($service_id, "garena", "gcb.cfg"); } $fh = fopen($config['garena_path'] . $id . "/gcb.cfg", 'r'); $array = array(); while (($buffer = fgets($fh, 4096)) !== false) { $buffer = trim($buffer); if (strlen($buffer) > 3 && $buffer[0] != '#') { $index = strpos($buffer, " ="); if ($index !== false) { $key = trim(substr($buffer, 0, $index)); $val = ""; if (strlen($buffer) > $index + 3) { $val = trim(substr($buffer, $index + 3)); } if (!$skip || isset($parameters[$key])) { $array[$key] = $val; } } } } fclose($fh); if ($jail) { jailFileClose($service_id, "garena", "gcb.cfg", false); } return $array; }
function minecraftDisplayFile($service_id, $filename) { global $config, $minecraftUpdatableFiles; //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return "Error: failed to load file!"; } if (in_array($filename, $minecraftUpdatableFiles)) { $jail = jailEnabled($service_id); if ($jail) { jailFileOpen($service_id, "minecraft", $filename); } $str = file_get_contents($config['minecraft_path'] . $id . "/" . $filename); if ($jail) { jailFileClose($service_id, "minecraft", $filename, false); } return $str; } else { return "Error: failed to load file!"; } }
function ghostSetDatabase($service_id, $db_settings) { global $config; //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return false; } //read/write the configuration file $jail = jailEnabled($service_id); if ($jail) { jailFileOpen($service_id, "ghost", "default.cfg"); } $fin = fopen($config['ghost_path'] . $id . "/default.cfg", 'r'); $fout = fopen($config['ghost_path'] . $id . "/default.cfg_", 'w'); while (($buffer = fgets($fin, 4096)) !== false) { $buffer = trim($buffer); if (strpos($buffer, "db_mysql_database") !== false) { fwrite($fout, "db_mysql_database = {$db_settings['name']}\n"); } else { if (strpos($buffer, "db_mysql_server") !== false) { fwrite($fout, "db_mysql_server = {$db_settings['server']}\n"); } else { if (strpos($buffer, "db_mysql_user") !== false) { fwrite($fout, "db_mysql_user = {$db_settings['username']}\n"); } else { if (strpos($buffer, "db_mysql_password") !== false) { fwrite($fout, "db_mysql_password = {$db_settings['password']}\n"); } else { fwrite($fout, $buffer . "\n"); } } } } } fclose($fin); fclose($fout); rename($config['ghost_path'] . $id . "/default.cfg_", $config['ghost_path'] . $id . "/default.cfg"); if ($jail) { jailFileOpen($service_id, "ghost", "default.cfg", true); } }