Commit 663caf85 authored by jwarnier's avatar jwarnier
Browse files

- replaced double quotes with single quotes whenever appropriate

- replaced "exec('/etc/init.d/" calls with "exec($conf['init_scripts'] . '/' ."
- fixed output wording (typos and more...)
parent 6f56718f
......@@ -76,7 +76,7 @@ class firewall_plugin {
$tcp_ports = '';
$udp_ports = '';
$ports = explode(',',$data["new"]["tcp_port"]);
$ports = explode(',',$data['new']['tcp_port']);
if(is_array($ports)) {
foreach($ports as $p) {
if(strstr($p,':')) {
......@@ -90,7 +90,7 @@ class firewall_plugin {
}
$tcp_ports = trim($tcp_ports);
$ports = explode(',',$data["new"]["udp_port"]);
$ports = explode(',',$data['new']['udp_port']);
if(is_array($ports)) {
foreach($ports as $p) {
if(strstr($p,':')) {
......@@ -106,21 +106,21 @@ class firewall_plugin {
$app->load('tpl');
$tpl = new tpl();
$tpl->newTemplate("bastille-firewall.cfg.master");
$tpl->newTemplate('bastille-firewall.cfg.master');
$tpl->setVar("TCP_PUBLIC_SERVICES",$tcp_ports);
$tpl->setVar("UDP_PUBLIC_SERVICES",$udp_ports);
$tpl->setVar('TCP_PUBLIC_SERVICES',$tcp_ports);
$tpl->setVar('UDP_PUBLIC_SERVICES',$udp_ports);
file_put_contents('/etc/Bastille/bastille-firewall.cfg',$tpl->grab());
$app->log('Writing firewall configuration /etc/Bastille/bastille-firewall.cfg',LOGLEVEL_DEBUG);
unset($tpl);
if($data["new"]["active"] == 'y') {
exec('/etc/init.d/bastille-firewall restart');
if($data['new']['active'] == 'y') {
exec($conf['init_scripts'] . '/' . 'bastille-firewall restart');
if(@is_file('/etc/debian_version')) exec('update-rc.d bastille-firewall defaults');
$app->log('Restarting the firewall',LOGLEVEL_DEBUG);
} else {
exec('/etc/init.d/bastille-firewall stop');
exec($conf['init_scripts'] . '/' . 'bastille-firewall stop');
if(@is_file('/etc/debian_version')) exec('update-rc.d -f bastille-firewall remove');
$app->log('Stopping the firewall',LOGLEVEL_DEBUG);
}
......@@ -131,7 +131,7 @@ class firewall_plugin {
function delete($event_name,$data) {
global $app, $conf;
exec('/etc/init.d/bastille-firewall stop');
exec($conf['init_scripts'] . '/' . 'bastille-firewall stop');
if(@is_file('/etc/debian_version')) exec('update-rc.d -f bastille-firewall remove');
$app->log('Stopping the firewall',LOGLEVEL_DEBUG);
......@@ -142,4 +142,4 @@ class firewall_plugin {
} // end class
?>
\ No newline at end of file
?>
......@@ -80,8 +80,8 @@ class mail_plugin {
global $app, $conf;
//* get the config
$app->uses("getconf,system");
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
$app->uses('getconf,system');
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
// convert to lower case - it could cause problems if some directory above has upper case name
// $data['new']['maildir'] = strtolower($data['new']['maildir']);
......@@ -110,7 +110,7 @@ class mail_plugin {
//* When the mail user dir exists but it is not a valid maildir, remove it
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail");
$app->log("Removed invalid maildir and rebuild it: ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
$app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
}
//* Create the maildir, if it doesn not exist, set permissions, set quota.
......@@ -120,7 +120,7 @@ class mail_plugin {
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']);
exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
$app->log("Set ownership on ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
$app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
//* This is to fix the maildrop quota not being rebuilt after the quota is changed.
if($mail_config['pop3_imap_daemon'] != 'dovecot') {
......@@ -161,8 +161,8 @@ class mail_plugin {
global $app, $conf;
// get the config
$app->uses("getconf,system");
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
$app->uses('getconf,system');
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
// convert to lower case - it could cause problems if some directory above has upper case name
// $data['new']['maildir'] = strtolower($data['new']['maildir']);
......@@ -170,8 +170,9 @@ class mail_plugin {
// Create the maildir, if it does not exist
/*
if(!is_dir($data['new']['maildir'])) {
exec('mkdir -p '.escapeshellcmd($data['new']['maildir']));
exec('chown '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
mkdir(escapeshellcmd($data['new']['maildir']), 0, true);
chown(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_name']);
chgrp(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_group']);
$app->log('Created Maildir: '.$data['new']['maildir'],LOGLEVEL_DEBUG);
}
*/
......@@ -198,7 +199,7 @@ class mail_plugin {
//* When the mail user dir exists but it is not a valid maildir, remove it
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail");
$app->log("Removed invalid maildir and rebuild it: ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
$app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
}
//* Create the maildir, if it doesn not exist, set permissions, set quota.
......@@ -208,7 +209,7 @@ class mail_plugin {
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']);
exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
$app->log("Set ownership on ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
$app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
//* This is to fix the maildrop quota not being rebuilt after the quota is changed.
if($mail_config['pop3_imap_daemon'] != 'dovecot') {
exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); // Avoid maildirmake quota bug, see debian bug #214911
......@@ -274,7 +275,7 @@ class mail_plugin {
// get the config
$app->uses("getconf");
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
//* Delete maildomain path
$old_maildomain_path = escapeshellcmd($mail_config['homedir_path'].'/'.$data['old']['domain']);
......@@ -298,7 +299,7 @@ class mail_plugin {
function transport_update($event_name,$data) {
global $app, $conf;
exec('/etc/init.d/postfix reload &> /dev/null');
exec($conf['init_scripts'] . '/' . 'postfix reload &> /dev/null');
$app->log('Postfix config reloaded ',LOGLEVEL_DEBUG);
}
......@@ -308,4 +309,4 @@ class mail_plugin {
} // end class
?>
\ No newline at end of file
?>
......@@ -66,16 +66,16 @@ class mysql_clientdb_plugin {
}
function process_host_list($action, $database_name, $database_user, $database_password, $host_list, $link, $database_rename_user = "") {
function process_host_list($action, $database_name, $database_user, $database_password, $host_list, $link, $database_rename_user = '') {
global $app;
$action = strtoupper($action);
// set to all hosts if none given
if(trim($host_list) == "") $host_list = "%";
if(trim($host_list) == '') $host_list = '%';
// process arrays and comma separated strings
if(!is_array($host_list)) $host_list = split(",", $host_list);
if(!is_array($host_list)) $host_list = split(',', $host_list);
$success = true;
......@@ -85,10 +85,10 @@ class mysql_clientdb_plugin {
// check if entry is valid ip address
$valid = true;
if($db_host == "%") {
if($db_host == '%') {
$valid = true;
} elseif(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $db_host)) {
$groups = explode(".", $db_host);
$groups = explode('.', $db_host);
foreach($groups as $group){
if($group<0 OR $group>255)
$valid=false;
......@@ -99,15 +99,15 @@ class mysql_clientdb_plugin {
if($valid == false) continue;
if($action == "GRANT") {
if($action == 'GRANT') {
if(!mysql_query("GRANT ALL ON ".mysql_real_escape_string($database_name,$link).".* TO '".mysql_real_escape_string($database_user,$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($database_password,$link)."';",$link)) $success = false;
} elseif($action == "REVOKE") {
} elseif($action == 'REVOKE') {
//mysql_query("REVOKE ALL PRIVILEGES ON ".mysql_real_escape_string($database_name,$link).".* FROM '".mysql_real_escape_string($database_user,$link)."';",$link);
} elseif($action == "DROP") {
} elseif($action == 'DROP') {
if(!mysql_query("DROP USER '".mysql_real_escape_string($database_user,$link)."'@'$db_host';",$link)) $success = false;
} elseif($action == "RENAME") {
} elseif($action == 'RENAME') {
if(!mysql_query("RENAME USER '".mysql_real_escape_string($database_user,$link)."'@'$db_host' TO '".mysql_real_escape_string($database_rename_user,$link)."'@'$db_host'",$link)) $success = false;
} elseif($action == "PASSWORD") {
} elseif($action == 'PASSWORD') {
if(!mysql_query("SET PASSWORD FOR '".mysql_real_escape_string($database_user,$link)."'@'$db_host' = PASSWORD('".mysql_real_escape_string($database_password,$link)."');",$link)) $success = false;
}
}
......@@ -118,13 +118,13 @@ class mysql_clientdb_plugin {
function db_insert($event_name,$data) {
global $app, $conf;
if($data["new"]["type"] == 'mysql') {
if($data['new']['type'] == 'mysql') {
if(!include(ISPC_LIB_PATH.'/mysql_clientdb.conf')) {
$app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR);
return;
}
if($data["new"]["database_user"] == 'root') {
if($data['new']['database_user'] == 'root') {
$app->log('User root not allowed for Client databases',LOGLEVEL_WARNING);
return;
}
......@@ -137,33 +137,33 @@ class mysql_clientdb_plugin {
}
// Charset for the new table
if($data["new"]["database_charset"] != '') {
$query_charset_table = ' DEFAULT CHARACTER SET '.$data["new"]["database_charset"];
if($data['new']['database_charset'] != '') {
$query_charset_table = ' DEFAULT CHARACTER SET '.$data['new']['database_charset'];
} else {
$query_charset_table = '';
}
//* Create the new database
if (mysql_query('CREATE DATABASE '.mysql_real_escape_string($data["new"]["database_name"]).$query_charset_table,$link)) {
$app->log('Created MySQL database: '.$data["new"]["database_name"],LOGLEVEL_DEBUG);
if (mysql_query('CREATE DATABASE '.mysql_real_escape_string($data['new']['database_name']).$query_charset_table,$link)) {
$app->log('Created MySQL database: '.$data['new']['database_name'],LOGLEVEL_DEBUG);
} else {
$app->log('Unable to create the database'.mysql_error($link),LOGLEVEL_WARNING);
$app->log('Unable to create the database: '.mysql_error($link),LOGLEVEL_WARNING);
}
// Create the database user if database is active
if($data["new"]["active"] == 'y') {
if($data['new']['active'] == 'y') {
if($data["new"]["remote_access"] == 'y') {
$this->process_host_list("GRANT", $data["new"]["database_name"], $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
if($data['new']['remote_access'] == 'y') {
$this->process_host_list('GRANT', $data['new']['database_name'], $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
}
$db_host = 'localhost';
mysql_query("GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* TO '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"],$link)."';",$link);
mysql_query("GRANT ALL ON ".mysql_real_escape_string($data['new']['database_name'],$link).".* TO '".mysql_real_escape_string($data['new']['database_user'],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data['new']['database_password'],$link)."';",$link);
}
mysql_query("FLUSH PRIVILEGES;",$link);
mysql_query('FLUSH PRIVILEGES;',$link);
mysql_close($link);
}
}
......@@ -171,13 +171,13 @@ class mysql_clientdb_plugin {
function db_update($event_name,$data) {
global $app, $conf;
if($data["new"]["type"] == 'mysql') {
if($data['new']['type'] == 'mysql') {
if(!include(ISPC_LIB_PATH.'/mysql_clientdb.conf')) {
$app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR);
return;
}
if($data["new"]["database_user"] == 'root') {
if($data['new']['database_user'] == 'root') {
$app->log('User root not allowed for Client databases',LOGLEVEL_WARNING);
return;
}
......@@ -185,79 +185,79 @@ class mysql_clientdb_plugin {
//* Connect to the database
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
if (!$link) {
$app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR);
$app->log('Unable to connect to the database: '.mysql_error($link),LOGLEVEL_ERROR);
return;
}
// Create the database user if database was disabled before
if($data["new"]["active"] == 'y' && $data["old"]["active"] == 'n') {
if($data['new']['active'] == 'y' && $data['old']['active'] == 'n') {
if($data["new"]["remote_access"] == 'y') {
$this->process_host_list("GRANT", $data["new"]["database_name"], $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
if($data['new']['remote_access'] == 'y') {
$this->process_host_list('GRANT', $data['new']['database_name'], $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
}
$db_host = 'localhost';
mysql_query("GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* TO '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"],$link)."';",$link);
mysql_query("GRANT ALL ON ".mysql_real_escape_string($data['new']['database_name'],$link).".* TO '".mysql_real_escape_string($data['new']['database_user'],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data['new']['database_password'],$link)."';",$link);
// mysql_query("GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* TO '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"],$link)."';",$link);
//echo "GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"]).".* TO '".mysql_real_escape_string($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"])."';";
}
// Remove database user, if inactive
if($data["new"]["active"] == 'n' && $data["old"]["active"] == 'y') {
if($data['new']['active'] == 'n' && $data['old']['active'] == 'y') {
if($data["old"]["remote_access"] == 'y') {
$this->process_host_list("DROP", "", $data["old"]["database_user"], "", $data["old"]["remote_ips"], $link);
if($data['old']['remote_access'] == 'y') {
$this->process_host_list('DROP', '', $data['old']['database_user'], '', $data['old']['remote_ips'], $link);
}
$db_host = 'localhost';
mysql_query("DROP USER '".mysql_real_escape_string($data["old"]["database_user"],$link)."'@'$db_host';",$link);
mysql_query("DROP USER '".mysql_real_escape_string($data['old']['database_user'],$link)."'@'$db_host';",$link);
//mysql_query("REVOKE ALL PRIVILEGES ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* FROM '".mysql_real_escape_string($data["new"]["database_user"],$link)."';",$link);
}
//* Rename User
if($data["new"]["database_user"] != $data["old"]["database_user"]) {
if($data['new']['database_user'] != $data['old']['database_user']) {
$db_host = 'localhost';
mysql_query("RENAME USER '".mysql_real_escape_string($data["old"]["database_user"],$link)."'@'$db_host' TO '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host'",$link);
if($data["old"]["remote_access"] == 'y') {
$this->process_host_list("RENAME", "", $data["new"]["database_user"], "", $data["new"]["remote_ips"], $link, $data["new"]["database_user"]);
mysql_query("RENAME USER '".mysql_real_escape_string($data['old']['database_user'],$link)."'@'$db_host' TO '".mysql_real_escape_string($data['new']['database_user'],$link)."'@'$db_host'",$link);
if($data['old']['remote_access'] == 'y') {
$this->process_host_list('RENAME', '', $data['new']['database_user'], '', $data['new']['remote_ips'], $link, $data['new']['database_user']);
}
$app->log('Renaming mysql user: '.$data["old"]["database_user"].' to '.$data["new"]["database_user"],LOGLEVEL_DEBUG);
$app->log('Renaming MySQL user: '.$data['old']['database_user'].' to '.$data['new']['database_user'],LOGLEVEL_DEBUG);
}
//* Remote access option has changed.
if($data["new"]["remote_access"] != $data["old"]["remote_access"]) {
if($data['new']['remote_access'] != $data['old']['remote_access']) {
//* revoke old priveliges
//mysql_query("REVOKE ALL PRIVILEGES ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* FROM '".mysql_real_escape_string($data["new"]["database_user"],$link)."';",$link);
//* set new priveliges
if($data["new"]["remote_access"] == 'y') {
$this->process_host_list("GRANT", $data["new"]["database_name"], $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
if($data['new']['remote_access'] == 'y') {
$this->process_host_list('GRANT', $data['new']['database_name'], $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
} else {
$this->process_host_list("DROP", "", $data["old"]["database_user"], "", $data["old"]["remote_ips"], $link);
$this->process_host_list('DROP', '', $data['old']['database_user'], '', $data['old']['remote_ips'], $link);
}
$app->log('Changing mysql remote access priveliges for database: '.$data["new"]["database_name"],LOGLEVEL_DEBUG);
} elseif($data["new"]["remote_access"] == 'y' && $data["new"]["remote_ips"] != $data["old"]["remote_ips"]) {
$app->log('Changing MySQL remote access privileges for database: '.$data['new']['database_name'],LOGLEVEL_DEBUG);
} elseif($data['new']['remote_access'] == 'y' && $data['new']['remote_ips'] != $data['old']['remote_ips']) {
//* Change remote access list
$this->process_host_list("DROP", "", $data["old"]["database_user"], "", $data["old"]["remote_ips"], $link);
$this->process_host_list("GRANT", $data["new"]["database_name"], $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
$this->process_host_list('DROP', '', $data['old']['database_user'], '', $data['old']['remote_ips'], $link);
$this->process_host_list('GRANT', $data['new']['database_name'], $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
}
//* Change password
if($data["new"]["database_password"] != $data["old"]["database_password"]) {
if($data['new']['database_password'] != $data['old']['database_password']) {
$db_host = 'localhost';
mysql_query("SET PASSWORD FOR '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host' = PASSWORD('".mysql_real_escape_string($data["new"]["database_password"],$link)."');",$link);
mysql_query("SET PASSWORD FOR '".mysql_real_escape_string($data['new']['database_user'],$link)."'@'$db_host' = PASSWORD('".mysql_real_escape_string($data['new']['database_password'],$link)."');",$link);
if($data["new"]["remote_access"] == 'y') {
$this->process_host_list("PASSWORD", "", $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
if($data['new']['remote_access'] == 'y') {
$this->process_host_list('PASSWORD', '', $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
}
$app->log('Changing mysql user password for: '.$data["new"]["database_user"],LOGLEVEL_DEBUG);
$app->log('Changing MySQL user password for: '.$data['new']['database_user'],LOGLEVEL_DEBUG);
}
mysql_query("FLUSH PRIVILEGES;",$link);
mysql_query('FLUSH PRIVILEGES;',$link);
mysql_close($link);
}
......@@ -266,7 +266,7 @@ class mysql_clientdb_plugin {
function db_delete($event_name,$data) {
global $app, $conf;
if($data["old"]["type"] == 'mysql') {
if($data['old']['type'] == 'mysql') {
if(!include(ISPC_LIB_PATH.'/mysql_clientdb.conf')) {
$app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR);
return;
......@@ -275,32 +275,32 @@ class mysql_clientdb_plugin {
//* Connect to the database
$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
if (!$link) {
$app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR);
$app->log('Unable to connect to the database: '.mysql_error($link),LOGLEVEL_ERROR);
return;
}
//* Get the db host setting for the access priveliges
if($data["old"]["remote_access"] == 'y') {
if($this->process_host_list("DROP", "", $data["old"]["database_user"], "", $data["old"]["remote_ips"], $link)) {
$app->log('Dropping mysql user: '.$data["old"]["database_user"],LOGLEVEL_DEBUG);
if($data['old']['remote_access'] == 'y') {
if($this->process_host_list('DROP', '', $data['old']['database_user'], '', $data['old']['remote_ips'], $link)) {
$app->log('Dropping MySQL user: '.$data['old']['database_user'],LOGLEVEL_DEBUG);
} else {
$app->log('Error while dropping mysql user: '.$data["old"]["database_user"].' '.mysql_error($link),LOGLEVEL_WARNING);
$app->log('Error while dropping MySQL user: '.$data['old']['database_user'].' '.mysql_error($link),LOGLEVEL_WARNING);
}
}
$db_host = 'localhost';
if(mysql_query("DROP USER '".mysql_real_escape_string($data["old"]["database_user"],$link)."'@'$db_host';",$link)) {
$app->log('Dropping mysql user: '.$data["old"]["database_user"],LOGLEVEL_DEBUG);
if(mysql_query("DROP USER '".mysql_real_escape_string($data['old']['database_user'],$link)."'@'$db_host';",$link)) {
$app->log('Dropping MySQL user: '.$data['old']['database_user'],LOGLEVEL_DEBUG);
} else {
$app->log('Error while dropping mysql user: '.$data["old"]["database_user"].' '.mysql_error($link),LOGLEVEL_WARNING);
$app->log('Error while dropping MySQL user: '.$data['old']['database_user'].' '.mysql_error($link),LOGLEVEL_WARNING);
}
if(mysql_query('DROP DATABASE '.mysql_real_escape_string($data["old"]["database_name"],$link),$link)) {
$app->log('Dropping mysql database: '.$data["old"]["database_name"],LOGLEVEL_DEBUG);
if(mysql_query('DROP DATABASE '.mysql_real_escape_string($data['old']['database_name'],$link),$link)) {
$app->log('Dropping MySQL database: '.$data['old']['database_name'],LOGLEVEL_DEBUG);
} else {
$app->log('Error while dropping mysql database: '.$data["old"]["database_name"].' '.mysql_error($link),LOGLEVEL_WARNING);
$app->log('Error while dropping MySQL database: '.$data['old']['database_name'].' '.mysql_error($link),LOGLEVEL_WARNING);
}
mysql_query("FLUSH PRIVILEGES;",$link);
mysql_query('FLUSH PRIVILEGES;',$link);
mysql_close($link);
}
......@@ -312,4 +312,4 @@ class mysql_clientdb_plugin {
} // end class
?>
\ No newline at end of file
?>
......@@ -76,8 +76,8 @@ class network_settings_plugin {
global $app, $conf;
// get the config
$app->uses("getconf");
$server_config = $app->getconf->get_server_config($conf["server_id"], 'server');
$app->uses('getconf');
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
// Configure the debian network card settings
if($server_config['auto_network_configuration'] == 'y') {
......@@ -89,15 +89,15 @@ class network_settings_plugin {
$app->load('tpl');
$network_tpl = new tpl();
$network_tpl->newTemplate("debian_network_interfaces.master");
$network_tpl->newTemplate('debian_network_interfaces.master');
$network_tpl->setVar('ip_address',$server_config["ip_address"]);
$network_tpl->setVar('netmask',$server_config["netmask"]);
$network_tpl->setVar('gateway',$server_config["gateway"]);
$network_tpl->setVar('broadcast',$this->broadcast($server_config["ip_address"],$server_config["netmask"]));
$network_tpl->setVar('network',$this->network($server_config["ip_address"],$server_config["netmask"]));
$network_tpl->setVar('ip_address',$server_config['ip_address']);
$network_tpl->setVar('netmask',$server_config['netmask']);
$network_tpl->setVar('gateway',$server_config['gateway']);
$network_tpl->setVar('broadcast',$this->broadcast($server_config['ip_address'],$server_config['netmask']));
$network_tpl->setVar('network',$this->network($server_config['ip_address'],$server_config['netmask']));
$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf["server_id"]) . " order by ip_address");
$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf['server_id']) . ' order by ip_address');
$ip_records = array();
$additionl_ip_records = 0;
$n = 0;
......@@ -106,15 +106,15 @@ class network_settings_plugin {
/*
* don't insert the main-ip again!
*/
if ($rec['ip_address'] != $server_config["ip_address"])
if ($rec['ip_address'] != $server_config['ip_address'])
{
$ip_records[$n] = array(
'id' => $n,
'ip_address' => $rec['ip_address'],
'netmask' => $server_config["netmask"],
'gateway' => $server_config["gateway"],
'broadcast' => $this->broadcast($rec['ip_address'],$server_config["netmask"]),
'network' => $this->network($rec['ip_address'],$server_config["netmask"])
'netmask' => $server_config['netmask'],
'gateway' => $server_config['gateway'],
'broadcast' => $this->broadcast($rec['ip_address'],$server_config['netmask']),
'network' => $this->network($rec['ip_address'],$server_config['netmask'])
);
$additionl_ip_records = 1;
$n++;
......@@ -131,23 +131,23 @@ class network_settings_plugin {
*/
if ($additionl_ip_records != 0)
{
$swap["ip_address"] = $ip_records[$n-1]["ip_address"];
$swap["netmask"] = $ip_records[$n-1]["netmask"];
$swap["gateway"] = $ip_records[$n-1]["gateway"];
$swap['ip_address'] = $ip_records[$n-1]['ip_address'];
$swap['netmask'] = $ip_records[$n-1]['netmask'];
$swap['gateway'] = $ip_records[$n-1]['gateway'];
$ip_records[$n-1] = array(
'id' => $n-1,
'ip_address' => $server_config['ip_address'],
'netmask' => $server_config["netmask"],
'gateway' => $server_config["gateway"],
'broadcast' => $this->broadcast($server_config['ip_address'],$server_config["netmask"]),
'network' => $this->network($server_config['ip_address'],$server_config["netmask"])
'netmask' => $server_config['netmask'],
'gateway' => $server_config['gateway'],
'broadcast' => $this->broadcast($server_config['ip_address'],$server_config['netmask']),
'network' => $this->network($server_config['ip_address'],$server_config['netmask'])
);
$network_tpl->setVar('ip_address',$swap["ip_address"]);
$network_tpl->setVar('netmask',$swap["netmask"]);
$network_tpl->setVar('gateway',$swap["gateway"]);
$network_tpl->setVar('broadcast',$this->broadcast($swap["ip_address"],$swap["netmask"]));
$network_tpl->setVar('network',$this->network($swap["ip_address"],$swap["netmask"]));
$network_tpl->setVar('ip_address',$swap['ip_address']);
$network_tpl->setVar('netmask',$swap['netmask']);
$network_tpl->setVar('gateway',$swap['gateway']);
$network_tpl->setVar('broadcast',$this->broadcast($swap['ip_address'],$swap['netmask']));
$network_tpl->setVar('network',$this->network($swap['ip_address'],$swap['netmask']));
}
$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
......@@ -155,7 +155,7 @@ class network_settings_plugin {
file_put_contents('/etc/network/interfaces',$network_tpl->grab());
unset($network_tpl);
$app->log("Changed Network settings",LOGLEVEL_DEBUG);
$app->log('Changed Network settings',LOGLEVEL_DEBUG);
exec($conf['init_scripts'] . '/' . 'networking force-reload');
}
elseif (is_file('/etc/gentoo-release'))
......@@ -165,14 +165,14 @@ class network_settings_plugin {
$app->load('tpl');
$network_tpl = new tpl();