$message = $result; } } else { if ($_POST['action'] == "restart") { $result = ghostBotRestart($service_id); if ($result === true) { $message = "GHost instance restarted successfully."; } else { $message = $result; } } else { if ($_POST['action'] == "stop") { $result = ghostBotStop($service_id); if ($result === true) { $message = "GHost instance stopped successfully."; } else { $message = $result; } } } } if (!isset($_SESSION['noredirect'])) { header("Location: index.php?id=" . $service_id . "&message=" . urlencode($message)); } } $status = ghostGetStatus($service_id); $botStatus = getServiceParam($service_id, "pid") != 0 ? "Online" : "Offline"; get_page("status", "ghost", array('service_id' => $service_id, 'status' => $status, 'message' => $message, 'botStatus' => $botStatus)); } else { header("Location: ../panel/"); }
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]); } } } }