Jump to content

Editing a XML file based upon string then assigning to string.


ChrisMartino

Recommended Posts

Hey there,

 

Thanks for taking the time to read my thread. My issue is that I can't think of a way to edit a XML file using PHP's XML functionality and then assign the edited contents to a string instead of saving the file. Because my issue is that I have to edit the XML file based upon a string brought from a remote location then give it back to that remote location using a string again, to be exact I am doing it via Linux command line utilizing SSH2.

 

This is what I managed to complete on my own.

 

function CheckIVMPConfig($ServerID)
{
	global $Panel;

	if(is_numeric($ServerID) && $this->IsValidServer($ServerID))
	{
		// We select the game server that the FTP account was created for.
		$Servers = mysql_query("SELECT * FROM control_servers WHERE server_id = '".mysql_real_escape_string($FTPAccount['ftp_server'])."'");
		$Server = mysql_fetch_array($Servers);

		// Here we select the Box ID that the game server is on.
		$Boxs = mysql_query("SELECT * FROM control_machines WHERE machine_id = '".$Server['server_machine']."'");
		$Box = mysql_fetch_array($Boxs);

		// Now we select the required package for the box.
		$Packages = mysql_query("SELECT * FROM control_packages WHERE package_id = '".$Server['server_package']."'");
		$Package = mysql_fetch_array($Packages);

		// Retrive the file.
		$Config = $CProtocol->exec("cat /home/{$Server['server_id']}/{$Package['package_config']}");

		$Parse = SimpleXMLElement($Config);

		foreach($Parse as $Entry) // loop through our books
		{
			if($Entry->port != $Server['server_port'])
			{
				// edit the value
			}
			else if($Entry->maxplayers > $Server['server_slots'])
			{
				// edit the value
			}
		}
	}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.