Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Classes | Functions
serverlib.php File Reference

--—XML-Envelope------------------------------— | | | Encrypted-Symmetric-key-------------— | | |_____________________________________| | | | | Encrypted data----------------------— | | | | | | | -XML-Envelope---------------— | | | | | | | | | | | –Signature----------— | | | | | | |______________________| | | | | | | | | | | | | –Signed-Payload-----— | | | | | | | | | | | | | | | XML-RPC Request | | | | | | | |______________________| | | | | | | | | | | | |_____________________________| | | | |_____________________________________| | | | |________________________________________________| More...

Classes

class  mnet_server_exception
 mnet server exception. More...
 

Functions

 mnet_keyswap ($function, $params)
 Accepts a public key from a new remote host and returns the public key for this host. More...
 
 mnet_server_dispatch ($payload)
 If security checks are passed, dispatch the request to the function/method. More...
 
 mnet_server_dummy_method ($methodname, $argsarray, $functionname)
 Dummy function for the XML-RPC dispatcher - use to call a method on an object or to call a function. More...
 
 mnet_server_fault ($code, $text, $param=null)
 Return the proper XML-RPC content to report an error in the local language. More...
 
 mnet_server_fault_xml ($code, $text, $privatekey=null)
 Return the proper XML-RPC content to report an error. More...
 
 mnet_server_invoke_dangerous_method ($includefile, $methodname, $method, $payload)
 Initialize the object (if necessary), execute the method or function, and return the response. More...
 
 mnet_server_invoke_plugin_method ($method, $callstack, $rpcrecord, $payload)
 Invoke a normal style plugin method This will verify permissions first. More...
 
 mnet_server_prepare_response ($response, $privatekey=null)
 Package a response in any required envelope, and return it to the client. More...
 
 mnet_server_strip_encryption ($rawpostdata)
 
 mnet_server_strip_signature ($plaintextmessage)
 
 mnet_setup_dummy_method ($method, $callstack, $rpcrecord)
 Figure out exactly what needs to be called and stashes it in $remoteclient Does some further verification that the method is callable. More...
 
 mnet_system ($method, $params, $hostinfo)
 Execute the system functions - mostly for introspection. More...
 
 mnet_verify_permissions ($rpcrecord)
 Verify that the requested xmlrpc method can be called This just checks the method exists in the rpc table and is enabled. More...
 

Detailed Description

--—XML-Envelope------------------------------— | | | Encrypted-Symmetric-key-------------— | | |_____________________________________| | | | | Encrypted data----------------------— | | | | | | | -XML-Envelope---------------— | | | | | | | | | | | –Signature----------— | | | | | | |______________________| | | | | | | | | | | | | –Signed-Payload-----— | | | | | | | | | | | | | | | XML-RPC Request | | | | | | | |______________________| | | | | | | | | | | | |_____________________________| | | | |_____________________________________| | | | |________________________________________________|

Function Documentation

◆ mnet_keyswap()

mnet_keyswap (   $function,
  $params 
)

Accepts a public key from a new remote host and returns the public key for this host.

If 'register all hosts' is turned on, it will bootstrap a record for the remote host in the mnet_host table (if it's not already there)

Parameters
string$functionXML-RPC requires this but we don't... discard!
array$paramsArray of parameters $params[0] is the remote wwwroot $params[1] is the remote public key
Return values
stringThe XML-RPC response

◆ mnet_server_dispatch()

mnet_server_dispatch (   $payload)

If security checks are passed, dispatch the request to the function/method.

The config variable 'mnet_dispatcher_mode' can be: strict: Only execute functions that are in specific files off: The default - don't execute anything

Parameters
string$payloadThe XML-RPC request
Exceptions
mnet_server_exception
Return values
Noreturn val - just echo the response

◆ mnet_server_dummy_method()

mnet_server_dummy_method (   $methodname,
  $argsarray,
  $functionname 
)

Dummy function for the XML-RPC dispatcher - use to call a method on an object or to call a function.

Translate XML-RPC's strange function call syntax into a more straightforward PHP-friendly alternative. This dummy function will be called by the dispatcher, and can be used to call a method on an object, or just a function

The methodName argument (eg. mnet/testlib/mnet_concatenate_strings) is ignored.

Exceptions
mnet_server_exception
Parameters
string$methodnameWe discard this - see 'functionname'
array$argsarrayEach element is an argument to the real function
string$functionnameThe name of the PHP function you want to call
Return values
mixedThe return value will be that of the real function, whatever it may be.

◆ mnet_server_fault()

mnet_server_fault (   $code,
  $text,
  $param = null 
)

Return the proper XML-RPC content to report an error in the local language.

Parameters
int$codeThe ID code of the error message
string$textThe full string of the error message (get_string will not be called)
string$paramThe $a param for the error message in the lang file
Return values
string::$textThe text of the error message

◆ mnet_server_fault_xml()

mnet_server_fault_xml (   $code,
  $text,
  $privatekey = null 
)

Return the proper XML-RPC content to report an error.

Parameters
int$codeThe ID code of the error message
string$textThe error message
resource$privatekeyThe private key that should be used to sign the response
Return values
string::$textThe XML text of the error message

◆ mnet_server_invoke_dangerous_method()

mnet_server_invoke_dangerous_method (   $includefile,
  $methodname,
  $method,
  $payload 
)

Initialize the object (if necessary), execute the method or function, and return the response.

Parameters
string$includefileThe file that contains the object definition
string$methodnameThe name of the method to execute
string$methodThe full path to the method
string$payloadThe XML-RPC request payload
string$classThe name of the class to instantiate (or false)
Exceptions
mnet_server_exception
Return values
stringThe XML-RPC response

◆ mnet_server_invoke_plugin_method()

mnet_server_invoke_plugin_method (   $method,
  $callstack,
  $rpcrecord,
  $payload 
)

Invoke a normal style plugin method This will verify permissions first.

Parameters
string$methodthe full xmlrpc method that was called eg auth/mnet/auth.php/user_authorise
array$callstackthe exploded callstack
stdclass$rpcrecordthe record from mnet_rpc
Return values
mixedthe response from the invoked method

◆ mnet_server_prepare_response()

mnet_server_prepare_response (   $response,
  $privatekey = null 
)

Package a response in any required envelope, and return it to the client.

Parameters
string$responseThe XMLRPC response string
resource$privatekeyThe private key to sign the response with
Return values
stringThe encoded response string

◆ mnet_setup_dummy_method()

mnet_setup_dummy_method (   $method,
  $callstack,
  $rpcrecord 
)

Figure out exactly what needs to be called and stashes it in $remoteclient Does some further verification that the method is callable.

Parameters
string$methodthe full xmlrpc method that was called eg auth/mnet/auth.php/user_authorise
array$callstackthe exploded callstack
stdclass$rpcrecordthe record from mnet_rpc
Exceptions
mnet_server_exception

◆ mnet_system()

mnet_system (   $method,
  $params,
  $hostinfo 
)

Execute the system functions - mostly for introspection.

Parameters
string$methodXMLRPC method name, e.g. system.listMethods
array$paramsArray of parameters from the XMLRPC request
string$hostinfoHostinfo object from the mnet_host table
Exceptions
mnet_server_exception
Return values
mixedResponse data - any kind of PHP variable

◆ mnet_verify_permissions()

mnet_verify_permissions (   $rpcrecord)

Verify that the requested xmlrpc method can be called This just checks the method exists in the rpc table and is enabled.

Parameters
stdclass$rpcrecordthe record from mnet_rpc
Exceptions
mnet_server_exception