diff options
Diffstat (limited to 'apis/getconfig.inc.php')
-rw-r--r-- | apis/getconfig.inc.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/apis/getconfig.inc.php b/apis/getconfig.inc.php index 0a8db6be..84393dbc 100644 --- a/apis/getconfig.inc.php +++ b/apis/getconfig.inc.php @@ -1,8 +1,15 @@ <?php +/** + * Escape given string so it is a valid string in sh that can be surrounded + * by single quotes ('). This basically turns _'_ into _'"'"'_ + * + * @param string $string input + * @return string escaped sh string + */ function escape($string) { - return str_replace("'", "\\'", $string); + return str_replace("'", "'\"'\"'", $string); } // Dump config from DB @@ -12,12 +19,15 @@ $res = Database::simpleQuery('SELECT setting.setting, setting.defaultvalue, sett ORDER BY setting ASC'); // TODO: Add setting groups and sort order while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if (is_null($row['value'])) $row['value'] = $row['defaultvalue']; - echo $row['setting'] . "='" . str_replace("'", "'\"'\"'", $row['value']) . "'\n"; + echo $row['setting'] . "='" . escape($row['value']) . "'\n"; } + // Additional "intelligent" config // Remote log URL echo "SLX_REMOTE_LOG='http://" . escape($_SERVER['SERVER_ADDR']) . "/slxadmin/api.php?do=clientlog'\n"; +// vm list url +echo "SLX_VMCHOOSER_BASE_URL='http://" . escape($_SERVER['SERVER_ADDR']) . "/vmchooser/'\n"; // VMStore path and type $vmstore = Property::getVmStoreConfig(); |