From 872de4e07609d8dae7660e467a73fc6f4061956a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 16 Jun 2016 16:14:42 +0200 Subject: [locations] Handle machine UUID param to determine location --- modules-available/baseconfig/api.inc.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'modules-available/baseconfig') diff --git a/modules-available/baseconfig/api.inc.php b/modules-available/baseconfig/api.inc.php index 000015f5..877ff4a7 100644 --- a/modules-available/baseconfig/api.inc.php +++ b/modules-available/baseconfig/api.inc.php @@ -5,10 +5,9 @@ if (substr($ip, 0, 7) === '::ffff:') { $ip = substr($ip, 7); } -// TODO: Handle UUID in appropriate modules (optional) -$uuid = Request::post('uuid', '', 'string'); -if (strlen($uuid) !== 36) { - // Probably invalid UUID. What to do? Set empty or ignore? +$uuid = Request::any('uuid', false, 'string'); +if ($uuid !== false && strlen($uuid) !== 36) { + $uuid = false; } /** @@ -31,6 +30,11 @@ function escape($string) */ $configVars = array(); +function handleModule($file, $ip, $uuid) // Pass ip and uuid instead of global to make them read only +{ + global $configVars; + include $file; +} // Handle any hooks by other modules first // other modules should generally only populate $configVars @@ -38,7 +42,7 @@ foreach (glob('modules/*/baseconfig/getconfig.inc.php') as $file) { preg_match('#^modules/([^/]+)/#', $file, $out); if (!Module::isAvailable($out[1])) continue; - include $file; + handleModule($file, $ip, $uuid); } // Rest is handled by module -- cgit v1.2.3-55-g7522