function ghostAddBnet($service_id, $server) { global $bnetParameters; //get next bnet id $bnets = ghostGetBnet($service_id); if ($bnets === false) { return "Error: failed to find identifier. Perhaps this isn't a GHost service?"; } $next_bnet_id = 1; foreach ($bnets as $k => $v) { if ($k >= $next_bnet_id) { $next_bnet_id = $k + 1; } } if ($next_bnet_id > 9) { return "Error: too many Battle.net connections. Contact support."; } //decide what the prestring is $prestring = "bnet{$next_bnet_id}_"; if ($next_bnet_id == 1) { $prestring = "bnet_"; } //add the bnet id $array = array(); foreach ($bnetParameters as $k => $p_info) { if ($k == "server") { $array[$prestring . $k] = $server; } else { $array[$prestring . $k] = $p_info[1]; } } ghostReconfigure($service_id, $array); return true; }
} else { if ($_POST['action'] == "remove" && isset($_POST['bnet'])) { $bnet_id = $_POST['bnet']; ghostRemoveBnet($_REQUEST['id'], $bnet_id); } else { if ($_POST['action'] == "update" && isset($_POST['bnet'])) { //get parameters for this case $bnet_id = $_POST['bnet']; $array = ghostGetConfigFromRequest($bnetParameters, $_REQUEST); ghostReconfigureBnet($_REQUEST['id'], $bnet_id, $array); } } } if (!isset($_SESSION['noredirect'])) { header("Location: config_realm.php?id=" . $_REQUEST['id'] . "&bnet={$bnet_id}&message=" . urlencode($message)); return; } } if ($bnets === false) { $bnets = ghostGetBnet($_REQUEST['id']); } if (isset($_REQUEST['bnet']) && isset($bnets[$_REQUEST['bnet']]) && isset($bnets[$_REQUEST['bnet']])) { $bnet_id = $_REQUEST['bnet']; } if ($bnet_id != 0) { $bconfig = ghostGetBnetConfiguration($_REQUEST['id'], $bnet_id); } get_page("config_realm", "ghost", array('service_id' => $_REQUEST['id'], 'bconfig' => $bconfig, 'parameters' => $bnetParameters, 'bnets' => $bnets, 'bnet_id' => $bnet_id, 'message' => $message)); } else { header("Location: ../panel/"); }