Commit 3da4e0f6 authored by Nigel McNie's avatar Nigel McNie
Browse files
parents 0ffa68fc 76e85d34
...@@ -39,7 +39,12 @@ function xmlrpc_exception (Exception $e) { ...@@ -39,7 +39,12 @@ function xmlrpc_exception (Exception $e) {
} }
function get_hostname_from_uri($uri = null) { function get_hostname_from_uri($uri = null) {
static $cache = array();
if (array_key_exists($uri, $cache)) {
return $cache[$uri];
}
$count = preg_match("@^(?:http[s]?://)?([A-Z0-9\-\.]+).*@i", $uri, $matches); $count = preg_match("@^(?:http[s]?://)?([A-Z0-9\-\.]+).*@i", $uri, $matches);
$cache[$uri] = $matches[1];
if ($count > 0) return $matches[1]; if ($count > 0) return $matches[1];
return false; return false;
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
// 6010 The function does not exist // 6010 The function does not exist
// 6011 The function does not exist // 6011 The function does not exist
// 6012 Networking is disabled // 6012 Networking is disabled
// 6013 Networking is not available at this address. You can access this service at get_config('wwwroot')api/xmlrpc/server.php'
define('INTERNAL', 1); define('INTERNAL', 1);
define('PUBLIC', 1); define('PUBLIC', 1);
...@@ -69,6 +70,10 @@ if (empty($networkenabled)) { ...@@ -69,6 +70,10 @@ if (empty($networkenabled)) {
exit; exit;
} }
if (get_hostname_from_uri($_SERVER['HTTP_HOST']) != get_hostname_from_uri(get_config('wwwroot'))) {
throw new XmlrpcServerException('Networking is not available at this address. You can access this service at '.get_config('wwwroot').'api/xmlrpc/server.php', 6013);
}
// Content type for output is never html: // Content type for output is never html:
header('Content-type: text/xml; charset=utf-8'); header('Content-type: text/xml; charset=utf-8');
ini_set('display_errors',0); ini_set('display_errors',0);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment