RemoteAdmin/de

From OpenSimulator

Revision as of 04:01, 1 July 2017 by Manni (Talk | contribs)

Jump to: navigation, search


INFO: Diese Seite ist noch nicht korrekt übersetzt, bitte fühlt euch frei dies zu ändern.


Contents

Einführung

RemoteAdmin ist eine Schnittstelle des OpenSimulator, die verschiedene Operationen können außerhalb des OpenSimulator ausgeführt werden. Operationen, die sich selbst auf den Simulator beziehen (zB teleport user) sind immer verfügbar. Diejenigen, die sich auf Griddienstleistungen (user creation und updating) beziehen, sind nur im Standalone-Modus Verfügbar. Im Gridmodus, muss man die ROBUST Ebene verwenden UserManipulation statt Fähigkeiten.

Das Remote Admin Interface Setup

Zuerst sollte man die Remote-Admin-Interface ermöglichen. Nur die folgenden Zeilen zu Ihrer OpenSim.ini FILE-Port hinzufügen sollte auf einen Wert ungleich null gesetzt werden, um die Remote-Admin auf einem anderen Port zu haben.

Ab Version r/16843 können Sie den Zugriff auf Remote-Admin auf bestimmte IP-Adressen beschränken, indem sie optionale access_ip_addresses verwenden. Sie können alle IP-Liste erlaubt durch RemoteAdmin für den Zugriff auf jede IP durch ein Komma trennt. Wenn access_ip_addresses nicht gesetzt ist, dann können alle IP-Adressen RemoteAdmin zugreifen.

[RemoteAdmin]
enabled = true
access_password = secret
enabled_methods = all

Siehe OpenSim.ini.example im opensim/bin/ Verzeichnis für weitere Details.

Weitere Optionen

Sie können auch einen anderen Port für die XMLRPCAdmin command listener aus dem Standard-Simulator HTTP-Port angeben.

[RemoteAdmin]
port = <port-number>

PHP Beispiele

RemoteAdminTest.php (ACHTUNG: $params nicht $parameters BEACHTEN!)

<?php
 
// Dieses Beispiel gibt eine Meldung heraus und fährt OpenSim herunter
//
// admin_broadcast ist das kommando für Nachrichten
// $params hier wird die Meldung hineingeschrieben
// 
// Das Kommando admin_shutdown fährt OpenSim herunter
 
 
 
include('RemoteAdmin.php'); // RemoteAdmin.php Ist der Name der PHP-Klasse
 
// Instanzieren der Klasse (IP oder Adresse, Port, Passwort)
$myRA = new RemoteAdmin('127.0.0.1', 9000, 'secret');
 
// RemoteAdmin-Befehle ausführen
$params = array('message' => 'Diese Nachricht wird an alle Regionen des OpenSimulators gesendet!');
 
$myRA->SendCommand('admin_broadcast', $params);
 
// Wenn für einen RemoteAdmin-Befehl keine Parameter benötigt, 
// müssen Sie den zweiten Parameter in der Funktion SendCommand nicht angeben.
$myRA->SendCommand('admin_shutdown'); 
 
?>

RemoteAdmin.php

<?php
 
/***********************************************************************
 
 
Copyright (c) 2008, The New World Grid Regents http://www.newworldgrid.com and Contributors 
All rights reserved.
 
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 
	* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
	* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 
	in the documentation and/or other materials provided with the distribution.
	* Neither the name of the New World Grid nor the names of its contributors may be used to endorse or promote products derived 
	from this software without specific prior written permission.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
***********************************************************************/
 
 
	// How to instantiate a RemoteAdmin object ?
	// $myremoteadmin = new RemoteAdmin("mySimulatorURL", Port, "secret password")
 
 
	// How to send commands to remoteadmin plugin ?
	// $myremoteadmin->SendCommand('admin_broadcast', array('message' => 'Message to broadcast to all regions'));
	// $myremoteadmin->SendCommand('admin_shutdown');
	// Commands like admin_shutdown don't need params, so you can left the second SendCommand functino param empty ;)
 
	// Example for error handling
	// 
	// include('classes/RemoteAdmin.php');
	// $RA = new RemoteAdmin('localhost', 9000, 'secret');
	// $retour = $RA->SendCommand('admin_shutdown');
	// if ($retour === FALSE)
	// {
	// 	echo 'ERROR';
	// }
 
 
 
	class RemoteAdmin
	{
 
		function RemoteAdmin($sURL, $sPort, $pass)
		{
 
			$this->simulatorURL = $sURL;		// String
			$this->simulatorPort = $sPort;	// Integer
			$this->password = $pass;
 
		}
 
		function SendCommand($command, $params=array())
		{
 
			$paramsNames = array_keys($params);
			$paramsValues = array_values($params);
 
			// Building the XML data to pass to RemoteAdmin through XML-RPC ;)
 
			$xml = '<methodCall>
						<methodName>' . htmlspecialchars($command) . '</methodName>
						<params>
							<param>
								<value>
									<struct>
										<member>
											<name>password</name>
											<value><string>' . htmlspecialchars($this->password) . '</string></value>
										</member>';
			if (count($params) != 0)
			{
 
				for ($p = 0; $p < count($params); $p++)
				{
 
					$xml .= '<member><name>' . htmlspecialchars($paramsNames[$p]) . '</name>';
					$xml .= '<value>' . htmlspecialchars($paramsValues[$p]) . '</value></member>';
 
				}
 
			}
 
			$xml .= '				</struct>
								</value>
							</param>
						</params>
					</methodCall>';
 
			//
			// echo $xml;
			//
 
 
			// Now building headers and sending the data ;)
			$host = $this->simulatorURL;
			$port = $this->simulatorPort;
			$timeout = 5; // Timeout in seconds
 
			error_reporting(0);
 
			$fp = fsockopen($host, $port, $errno, $errstr, $timeout);
			if (!$fp)
			{
				return FALSE; // If contacting host timeouts or impossible to create the socket, the method returns FALSE
			}
			else
			{
				fputs($fp, "POST / HTTP/1.1\r\n");
				fputs($fp, "Host: $host\r\n");
				fputs($fp, "Content-type: text/xml\r\n");
				fputs($fp, "Content-length: ". strlen($xml) ."\r\n");
				fputs($fp, "Connection: close\r\n\r\n");
				fputs($fp, $xml);
				$res = "";
				while(!feof($fp)) {
					$res .= fgets($fp, 128);
				}
				fclose($fp);
				$response = substr($res, strpos($res, "\r\n\r\n"));;
 
				// Now parsing the XML response from RemoteAdmin ;)
 
				$result = array();
				if (preg_match_all('#<name>(.+)</name><value><(string|int)>(.*)</\2></value>#U', $response, $regs, PREG_SET_ORDER)) {
				  foreach($regs as $key=>$val) {
					$result[$val[1]] = $val[3];
				  }
				}
				return $result;
			}
 
		}
 
	}
 
?>

RemoteAdmin Befehle

Vorsicht ! Alle Befehlsparameter die UUID einer Region nutzen "region_id" als Parameter. Alle anderen Parameter wie zB. region_uuid oder regionId sind nach Juni 2012 entfernt worden.

Agent management

User account management

Object management

Parcel management

Region management

Region file management