function minecraftRestoreWorld($service_id, $label) { global $config; $label = stripAlphaNumeric($label); //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return "Error: the identifier for this service is not set."; } //require stopped to restore $pid = getServiceParam($service_id, "pid"); if ($pid !== false && $pid != 0) { return "Error: please stop the server before restoring the world."; } //check for existence $jail = jailEnabled($service_id); $filename = $label . ".uxbakzip"; if ($jail) { $path = jailPath($service_id) . $filename; } else { $path = $config['minecraft_path'] . $id . "/" . $filename; } if ($jail && !jailFileExists($filename) || !$jail && !file_exists($path)) { return "Error: the requested backup doesn't appear to exist."; } //unzip and move the world directory if ($jail) { jailExecute($service_id, "unzip " . escapeshellarg(jailPath($service_id) . $label . ".uxbakzip") . " -d " . escapeshellarg(jailPath($service_id))); jailExecute($service_id, "rm -r " . escapeshellarg(jailPath($service_id) . "world")); jailFileMove($service_id, "world_tmp", "world"); } else { exec("unzip " . escapeshellarg($config['minecraft_path'] . $id . "/" . $label . ".uxbakzip") . " -d " . escapeshellarg($config['minecraft_path'] . $id)); delete_directory($config['minecraft_path'] . $id . "/world"); rename($config['minecraft_path'] . $id . "/world_tmp", $config['minecraft_path'] . $id . "/world"); } return true; }
function executeCronOther($service_id, $type, $params) { global $config, $db; if (!isset($params['id'])) { return; } echo "Executing for service {$service_id} ({$type})\n"; echo "logcron\n"; //log cron if (!isset($params['last_logcron']) || time() - $params['last_logcron'] > 3600 * 24) { $logname = "ghost"; if ($type == "channel") { $logname = "chop"; } else { if ($type == "garena") { $logname = "gcb"; } } if (isset($params['jail']) && $params['jail'] == 1) { require_once "include/jail.php"; jailFileMove($service_id, "{$logname}.log", "{$logname}.log_"); } else { rename($config['ghost_path'] . $params['id'] . "/{$logname}.log", $config['ghost_path'] . $params['id'] . "/{$logname}.log_"); } setServiceParam($service_id, "last_logcron", time()); } else { if ($type == "ghost") { require_once "include/ghost.php"; $statusArray = ghostGetStatus($service_id); } else { require_once "include/channel.php"; $statusArray = channelGetStatus($service_id); } if (!isset($GLOBALS['status_updates'])) { $GLOBALS['status_updates'] = array(); } $problems = $statusArray['err']; sort($problems); if (count($problems) > 0) { $problemString = implode("\n", $problems); $result = $db->query("SELECT id, message FROM cron_problems WHERE service_id = '{$service_id}'"); if ($result && ($row = $result->fetch_array())) { if ($row[1] != $problemString) { $db->query("UPDATE cron_problems SET message = '" . escape($problemString) . "' WHERE id = '{$row[0]}'"); foreach ($problems as $problem) { //$GLOBALS['status_updates'][] = $service_id . ": " . $problem; } } } else { foreach ($problems as $problem) { //$GLOBALS['status_updates'][] = $service_id . ": " . $problem; } $db->query("INSERT INTO cron_problems (service_id, message) VALUES ('{$service_id}', '" . escape($problemString) . "')"); } } else { $result = $db->query("SELECT id FROM cron_problems WHERE service_id = '{$service_id}'"); if ($result && ($row = $result->fetch_array())) { $db->query("DELETE FROM cron_problems WHERE id = '{$row[0]}'"); //$GLOBALS['status_updates'][] = "$service_id: recovery!"; } } } if ($type == "ghost") { echo "replaycron\n"; //replay cron $path = $config['ghost_path'] . $params['id'] . '/replays'; if (isset($params['replay_path'])) { $path = $params['replay_path']; } $info = dirInfo($path); //delete everything older than fourteen days foreach ($info as $filePath => $array) { if (getExtension($filePath) == "w3g" && time() - $array[1] > 14 * 60 * 60 * 24) { unlink($filePath); unset($info[$filePath]); } } } }