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) <d00p@froxlor.org>
This commit is contained in:
@@ -25,6 +25,7 @@ if ($userinfo['change_serversettings'] == '1') {
|
|||||||
'<SQL_UNPRIVILEGED_PASSWORD>' => 'MYSQL_PASSWORD',
|
'<SQL_UNPRIVILEGED_PASSWORD>' => 'MYSQL_PASSWORD',
|
||||||
'<SQL_DB>' => $sql['db'],
|
'<SQL_DB>' => $sql['db'],
|
||||||
'<SQL_HOST>' => $sql['host'],
|
'<SQL_HOST>' => $sql['host'],
|
||||||
|
'<SQL_SOCKET>' => isset($sql['socket']) ? $sql['socket'] : null,
|
||||||
'<SERVERNAME>' => Settings::Get('system.hostname'),
|
'<SERVERNAME>' => Settings::Get('system.hostname'),
|
||||||
'<SERVERIP>' => Settings::Get('system.ipaddress'),
|
'<SERVERIP>' => Settings::Get('system.ipaddress'),
|
||||||
'<NAMESERVERS>' => Settings::Get('system.nameservers'),
|
'<NAMESERVERS>' => Settings::Get('system.nameservers'),
|
||||||
@@ -122,6 +123,8 @@ if ($userinfo['change_serversettings'] == '1') {
|
|||||||
$commands = '';
|
$commands = '';
|
||||||
foreach ($confarr as $idx => $action) {
|
foreach ($confarr as $idx => $action) {
|
||||||
if ($lasttype != '' && $lasttype != $action['type']) {
|
if ($lasttype != '' && $lasttype != $action['type']) {
|
||||||
|
$commands = trim($commands);
|
||||||
|
$numbrows = count(explode("\n", $commands));
|
||||||
eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
|
eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
|
||||||
$lasttype = '';
|
$lasttype = '';
|
||||||
$commands = '';
|
$commands = '';
|
||||||
@@ -152,10 +155,12 @@ if ($userinfo['change_serversettings'] == '1') {
|
|||||||
$realname = $action['name'];
|
$realname = $action['name'];
|
||||||
$commands = trim($commands_pre);
|
$commands = trim($commands_pre);
|
||||||
if ($commands != "") {
|
if ($commands != "") {
|
||||||
|
$numbrows = count(explode("\n", $commands));
|
||||||
eval("\$commands_pre=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
|
eval("\$commands_pre=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
|
||||||
}
|
}
|
||||||
$commands = trim($commands_post);
|
$commands = trim($commands_post);
|
||||||
if ($commands != "") {
|
if ($commands != "") {
|
||||||
|
$numbrows = count(explode("\n", $commands));
|
||||||
eval("\$commands_post=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
|
eval("\$commands_post=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
|
||||||
}
|
}
|
||||||
eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_subfileblock") . "\";");
|
eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_subfileblock") . "\";");
|
||||||
@@ -167,6 +172,7 @@ if ($userinfo['change_serversettings'] == '1') {
|
|||||||
}
|
}
|
||||||
$commands = trim($commands);
|
$commands = trim($commands);
|
||||||
if ($commands != '') {
|
if ($commands != '') {
|
||||||
|
$numbrows = count(explode("\n", $commands));
|
||||||
eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
|
eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
|
||||||
}
|
}
|
||||||
eval("echo \"" . getTemplate("configfiles/configfiles") . "\";");
|
eval("echo \"" . getTemplate("configfiles/configfiles") . "\";");
|
||||||
@@ -182,9 +188,11 @@ if ($userinfo['change_serversettings'] == '1') {
|
|||||||
function getFileContentContainer($file_content, &$replace_arr, $realname)
|
function getFileContentContainer($file_content, &$replace_arr, $realname)
|
||||||
{
|
{
|
||||||
$files = "";
|
$files = "";
|
||||||
|
$file_content = trim($file_content);
|
||||||
if ($file_content != '') {
|
if ($file_content != '') {
|
||||||
$file_content = strtr($file_content, $replace_arr);
|
$file_content = strtr($file_content, $replace_arr);
|
||||||
$file_content = htmlspecialchars($file_content);
|
$file_content = htmlspecialchars($file_content);
|
||||||
|
$numbrows = count(explode("\n", $file_content));
|
||||||
eval("\$files=\"" . getTemplate("configfiles/configfiles_file") . "\";");
|
eval("\$files=\"" . getTemplate("configfiles/configfiles_file") . "\";");
|
||||||
}
|
}
|
||||||
return $files;
|
return $files;
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ class ConfigDaemon {
|
|||||||
*/
|
*/
|
||||||
private $xpath;
|
private $xpath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cache of sql-data if used
|
||||||
|
*/
|
||||||
|
private $_sqldata_cache = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Human - readable title of this service
|
* Human - readable title of this service
|
||||||
* @var string
|
* @var string
|
||||||
@@ -349,6 +354,16 @@ class ConfigDaemon {
|
|||||||
} else {
|
} else {
|
||||||
return '';
|
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);
|
}, $content);
|
||||||
return $content;
|
return $content;
|
||||||
|
|||||||
@@ -2913,6 +2913,11 @@ socket /var/run/mysqld/mysqld.sock
|
|||||||
]]>
|
]]>
|
||||||
</content>
|
</content>
|
||||||
</file>
|
</file>
|
||||||
|
<command>
|
||||||
|
<!-- if a socket is set for the db-server use it -->
|
||||||
|
<visibility mode="notempty">{{sql.socket}}</visibility>
|
||||||
|
<content><![CDATA[sed -i.bak \'s|^\\(socket\\).*$|\\1\\"{{sql.socket}}\\"|\' /etc/libnss-mysql.cfg]]></content>
|
||||||
|
</command>
|
||||||
<file name="/etc/libnss-mysql-root.cfg" chown="root:root"
|
<file name="/etc/libnss-mysql-root.cfg" chown="root:root"
|
||||||
chmod="0600" backup="true">
|
chmod="0600" backup="true">
|
||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
|
|||||||
@@ -2350,6 +2350,12 @@ password <SQL_UNPRIVILEGED_PASSWORD>
|
|||||||
]]>
|
]]>
|
||||||
</content>
|
</content>
|
||||||
</file>
|
</file>
|
||||||
|
<commands>
|
||||||
|
<!-- if a socket is set for the db-server use it -->
|
||||||
|
<visibility mode="notempty">{{sql.socket}}</visibility>
|
||||||
|
<command><![CDATA[sed -i.bak \'s/^#socket/socket/\' /etc/libnss-mysql.cfg]]></command>
|
||||||
|
<command><![CDATA[sed -i.bak \'s|^\\(socket\\).*$|\\1\\"{{sql.socket}}\\"|\' /etc/libnss-mysql.cfg]]></command>
|
||||||
|
</commands>
|
||||||
<file name="/etc/libnss-mysql-root.cfg" chown="root:root"
|
<file name="/etc/libnss-mysql-root.cfg" chown="root:root"
|
||||||
chmod="0600" backup="true">
|
chmod="0600" backup="true">
|
||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
|
|||||||
@@ -1455,6 +1455,11 @@ socket /var/run/mysqld/mysqld.sock
|
|||||||
]]>
|
]]>
|
||||||
</content>
|
</content>
|
||||||
</file>
|
</file>
|
||||||
|
<command>
|
||||||
|
<!-- if a socket is set for the db-server use it -->
|
||||||
|
<visibility mode="notempty">{{sql.socket}}</visibility>
|
||||||
|
<content><![CDATA[sed -i.bak \'s|^\\(socket\\).*$|\\1\\"{{sql.socket}}\\"|\' /etc/libnss-mysql.cfg]]></content>
|
||||||
|
</command>
|
||||||
<file name="/etc/libnss-mysql-root.cfg" chown="root:root"
|
<file name="/etc/libnss-mysql-root.cfg" chown="root:root"
|
||||||
chmod="0600" backup="true">
|
chmod="0600" backup="true">
|
||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
|
|||||||
@@ -4807,9 +4807,17 @@ database <SQL_DB>
|
|||||||
username <SQL_UNPRIVILEGED_USER>
|
username <SQL_UNPRIVILEGED_USER>
|
||||||
password <SQL_UNPRIVILEGED_PASSWORD>
|
password <SQL_UNPRIVILEGED_PASSWORD>
|
||||||
port 3306
|
port 3306
|
||||||
|
#socket /var/run/mysqld/mysqld.sock
|
||||||
]]>
|
]]>
|
||||||
</content>
|
</content>
|
||||||
</file>
|
</file>
|
||||||
|
<commands>
|
||||||
|
<!-- if a socket is set for the db-server use it -->
|
||||||
|
<visibility mode="notempty">{{sql.socket}}</visibility>
|
||||||
|
<command><![CDATA[sed -i.bak \'s/^port/#port/\' /etc/libnss-mysql.cfg]]></command>
|
||||||
|
<command><![CDATA[sed -i.bak \'s/^#socket/socket/\' /etc/libnss-mysql.cfg]]></command>
|
||||||
|
<command><![CDATA[sed -i.bak \'s|^\\(socket\\).*$|\\1\\"{{sql.socket}}\\"|\' /etc/libnss-mysql.cfg]]></command>
|
||||||
|
</commands>
|
||||||
<file name="/etc/libnss-mysql-root.cfg" chown="root:root"
|
<file name="/etc/libnss-mysql-root.cfg" chown="root:root"
|
||||||
chmod="0600" backup="true">
|
chmod="0600" backup="true">
|
||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
|
|||||||
Reference in New Issue
Block a user