From b0279025d0166200142150a396c253a4ec8c8a58 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Wed, 11 Feb 2015 14:30:30 +0100 Subject: [PATCH] add numbrows to commands and files for BNoiZe's template magic; added possibility to use sql-data inside xml-config; updates xml-configs a bit when socket is used (not 100% done) Signed-off-by: Michael Kaufmann (d00p) --- admin_configfiles.php | 8 ++++++++ lib/classes/config/class.ConfigDaemon.php | 15 +++++++++++++++ lib/configfiles/gentoo.xml | 5 +++++ lib/configfiles/rhel_centos.xml | 6 ++++++ lib/configfiles/trusty.xml | 5 +++++ lib/configfiles/wheezy.xml | 8 ++++++++ 6 files changed, 47 insertions(+) diff --git a/admin_configfiles.php b/admin_configfiles.php index c59e80d6..0283ba1d 100644 --- a/admin_configfiles.php +++ b/admin_configfiles.php @@ -25,6 +25,7 @@ if ($userinfo['change_serversettings'] == '1') { '' => 'MYSQL_PASSWORD', '' => $sql['db'], '' => $sql['host'], + '' => isset($sql['socket']) ? $sql['socket'] : null, '' => Settings::Get('system.hostname'), '' => Settings::Get('system.ipaddress'), '' => Settings::Get('system.nameservers'), @@ -122,6 +123,8 @@ if ($userinfo['change_serversettings'] == '1') { $commands = ''; foreach ($confarr as $idx => $action) { if ($lasttype != '' && $lasttype != $action['type']) { + $commands = trim($commands); + $numbrows = count(explode("\n", $commands)); eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_commands") . "\";"); $lasttype = ''; $commands = ''; @@ -152,10 +155,12 @@ if ($userinfo['change_serversettings'] == '1') { $realname = $action['name']; $commands = trim($commands_pre); if ($commands != "") { + $numbrows = count(explode("\n", $commands)); eval("\$commands_pre=\"" . getTemplate("configfiles/configfiles_commands") . "\";"); } $commands = trim($commands_post); if ($commands != "") { + $numbrows = count(explode("\n", $commands)); eval("\$commands_post=\"" . getTemplate("configfiles/configfiles_commands") . "\";"); } eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_subfileblock") . "\";"); @@ -167,6 +172,7 @@ if ($userinfo['change_serversettings'] == '1') { } $commands = trim($commands); if ($commands != '') { + $numbrows = count(explode("\n", $commands)); eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_commands") . "\";"); } eval("echo \"" . getTemplate("configfiles/configfiles") . "\";"); @@ -182,9 +188,11 @@ if ($userinfo['change_serversettings'] == '1') { function getFileContentContainer($file_content, &$replace_arr, $realname) { $files = ""; + $file_content = trim($file_content); if ($file_content != '') { $file_content = strtr($file_content, $replace_arr); $file_content = htmlspecialchars($file_content); + $numbrows = count(explode("\n", $file_content)); eval("\$files=\"" . getTemplate("configfiles/configfiles_file") . "\";"); } return $files; diff --git a/lib/classes/config/class.ConfigDaemon.php b/lib/classes/config/class.ConfigDaemon.php index aa6e3673..df9e5b67 100644 --- a/lib/classes/config/class.ConfigDaemon.php +++ b/lib/classes/config/class.ConfigDaemon.php @@ -61,6 +61,11 @@ class ConfigDaemon { */ private $xpath; + /** + * cache of sql-data if used + */ + private $_sqldata_cache = null; + /** * Human - readable title of this service * @var string @@ -349,6 +354,16 @@ class ConfigDaemon { } else { return ''; } + } elseif (preg_match('/^sql\.(.*)$/', $matches[1], $match)) { + if (is_null($this->_sqldata_cache)) { + // read in sql-data (if exists) + if (file_exists(FROXLOR_INSTALL_DIR."/lib/userdata.inc.php")) { + require FROXLOR_INSTALL_DIR."/lib/userdata.inc.php"; + unset($sql_root); + $this->_sqldata_cache = $sql; + } + } + return isset($this->_sqldata_cache[$match[1]]) ? $this->_sqldata_cache[$match[1]] : ''; } }, $content); return $content; diff --git a/lib/configfiles/gentoo.xml b/lib/configfiles/gentoo.xml index 04e3d60a..3ad4e07b 100644 --- a/lib/configfiles/gentoo.xml +++ b/lib/configfiles/gentoo.xml @@ -2913,6 +2913,11 @@ socket /var/run/mysqld/mysqld.sock ]]> + + + {{sql.socket}} + + ]]> + + + {{sql.socket}} + + + + + + {{sql.socket}} + + username password port 3306 +#socket /var/run/mysqld/mysqld.sock ]]> + + + {{sql.socket}} + + + +