Thursday, June 04, 2026 12:02:22 AM
> initializeServer.php
<?php
	/*
		Bryan
		Exile Server Manager
	*/
	require "config/config.php";

	// Make sure this is legit request
	if (!array_key_exists($_POST["key"], $SERVERS))
	{
		die("failed");
	}

	$serverKey = $_POST["key"];
	$serverName = $_POST["name"];
	$pricePerObject = $_POST["poptab_amount"];
	$territoryLifeTime = $_POST["ttl"];

	$result = mysqli_query($esm_db,
		"INSERT INTO
			servers (server_key, servers.name, servers.price_per_object, servers.territory_life_time)
			VALUES ('$serverKey', '$serverName', $pricePerObject, $territoryLifeTime)
			ON DUPLICATE KEY UPDATE
				servers.name = VALUES(servers.name),
				servers.price_per_object = VALUES(servers.price_per_object),
				servers.territory_life_time = VALUES(servers.territory_life_time)");

	// Remove the header so we can go ahead and process the rest
	array_splice($_POST, 0, 3);

	$currentLevel = 1;
	for ($i = 0; $i < count($_POST) - 1; $i += 3)
	{
		$currentPrice = $_POST["level_" . $currentLevel . "_price"];
		$currentRadius = $_POST["level_" . $currentLevel . "_radius"];
		$currentObjects = $_POST["level_" . $currentLevel . "_objects"];
		$id = $serverKey . "_" .$currentLevel;

		mysqli_query($esm_db,
			"INSERT INTO territory (id, server_key, level, price, radius, objects)
				VALUES ('$id', '$serverKey', $currentLevel, $currentPrice, $currentRadius, $currentObjects)
				ON DUPLICATE KEY UPDATE
				price = VALUES(price),
				radius = VALUES(radius),
				objects = VALUES(objects)");

		$currentLevel++;
	}

	echo ($result ? "success" : "failed");
?>
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 4294fb2