function garenaAddConnection($service_id, $roomname) { global $garenaConnectionParameters; //get next connection id $connections = garenaGetConnection($service_id); if ($connections === false) { return "Error: failed to find identifier. Perhaps this isn't a Garena service?"; } $next_connection_id = 1; foreach ($connections as $k => $v) { if ($k >= $next_connection_id) { $next_connection_id = $k + 1; } } //check if user has exceeded maximum permitted connections $connection_limit = getServiceParam($service_id, "climit"); if ($connection_limit !== false && $next_connection_id > $connection_limit) { return "Error: too many Garena room connections. Contact support."; } //decide what the prestring is $prestring = "garena{$next_connection_id}_"; //add the connection id $array = array(); foreach ($garenaConnectionParameters as $k => $p_info) { if ($k == "roomname") { $array[$prestring . $k] = $roomname; } else { $array[$prestring . $k] = $p_info[1]; } } garenaReconfigure($service_id, $array); return true; }
} else { if ($_POST['action'] == "remove" && isset($_POST['connection'])) { $connection_id = $_POST['connection']; garenaRemoveConnection($_REQUEST['id'], $connection_id); } else { if ($_POST['action'] == "update" && isset($_POST['connection'])) { //get parameters for this case $connection_id = $_POST['connection']; $array = garenaGetConfigFromRequest($garenaConnectionParameters, $_REQUEST); garenaReconfigureConnection($_REQUEST['id'], $connection_id, $array); } } } if (!isset($_SESSION['noredirect'])) { header("Location: config_connection.php?id=" . $_REQUEST['id'] . "&connection={$connection_id}&message=" . urlencode($message)); return; } } if ($connections === false) { $connections = garenaGetConnection($_REQUEST['id']); } if (isset($_REQUEST['connection']) && isset($connections[$_REQUEST['connection']])) { $connection_id = $_REQUEST['connection']; } if ($connection_id != 0) { $gconfig = garenaGetConnectionConfiguration($_REQUEST['id'], $connection_id); } get_page("config_connection", "garena", array('service_id' => $_REQUEST['id'], 'gconfig' => $gconfig, 'parameters' => $garenaConnectionParameters, 'connections' => $connections, 'connection_id' => $connection_id, 'message' => $message)); } else { header("Location: ../panel/"); }