Skip to content

Commit 663caf8

Browse files
author
jwarnier
committed
- 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...)
1 parent 6f56718 commit 663caf8

File tree

4 files changed

+164
-163
lines changed

4 files changed

+164
-163
lines changed

server/plugins-available/firewall_plugin.inc.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function update($event_name,$data) {
7676
$tcp_ports = '';
7777
$udp_ports = '';
7878

79-
$ports = explode(',',$data["new"]["tcp_port"]);
79+
$ports = explode(',',$data['new']['tcp_port']);
8080
if(is_array($ports)) {
8181
foreach($ports as $p) {
8282
if(strstr($p,':')) {
@@ -90,7 +90,7 @@ function update($event_name,$data) {
9090
}
9191
$tcp_ports = trim($tcp_ports);
9292

93-
$ports = explode(',',$data["new"]["udp_port"]);
93+
$ports = explode(',',$data['new']['udp_port']);
9494
if(is_array($ports)) {
9595
foreach($ports as $p) {
9696
if(strstr($p,':')) {
@@ -106,21 +106,21 @@ function update($event_name,$data) {
106106

107107
$app->load('tpl');
108108
$tpl = new tpl();
109-
$tpl->newTemplate("bastille-firewall.cfg.master");
109+
$tpl->newTemplate('bastille-firewall.cfg.master');
110110

111-
$tpl->setVar("TCP_PUBLIC_SERVICES",$tcp_ports);
112-
$tpl->setVar("UDP_PUBLIC_SERVICES",$udp_ports);
111+
$tpl->setVar('TCP_PUBLIC_SERVICES',$tcp_ports);
112+
$tpl->setVar('UDP_PUBLIC_SERVICES',$udp_ports);
113113

114114
file_put_contents('/etc/Bastille/bastille-firewall.cfg',$tpl->grab());
115115
$app->log('Writing firewall configuration /etc/Bastille/bastille-firewall.cfg',LOGLEVEL_DEBUG);
116116
unset($tpl);
117117

118-
if($data["new"]["active"] == 'y') {
119-
exec('/etc/init.d/bastille-firewall restart');
118+
if($data['new']['active'] == 'y') {
119+
exec($conf['init_scripts'] . '/' . 'bastille-firewall restart');
120120
if(@is_file('/etc/debian_version')) exec('update-rc.d bastille-firewall defaults');
121121
$app->log('Restarting the firewall',LOGLEVEL_DEBUG);
122122
} else {
123-
exec('/etc/init.d/bastille-firewall stop');
123+
exec($conf['init_scripts'] . '/' . 'bastille-firewall stop');
124124
if(@is_file('/etc/debian_version')) exec('update-rc.d -f bastille-firewall remove');
125125
$app->log('Stopping the firewall',LOGLEVEL_DEBUG);
126126
}
@@ -131,7 +131,7 @@ function update($event_name,$data) {
131131
function delete($event_name,$data) {
132132
global $app, $conf;
133133

134-
exec('/etc/init.d/bastille-firewall stop');
134+
exec($conf['init_scripts'] . '/' . 'bastille-firewall stop');
135135
if(@is_file('/etc/debian_version')) exec('update-rc.d -f bastille-firewall remove');
136136
$app->log('Stopping the firewall',LOGLEVEL_DEBUG);
137137

@@ -142,4 +142,4 @@ function delete($event_name,$data) {
142142

143143
} // end class
144144

145-
?>
145+
?>

server/plugins-available/mail_plugin.inc.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ function user_insert($event_name,$data) {
8080
global $app, $conf;
8181

8282
//* get the config
83-
$app->uses("getconf,system");
84-
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
83+
$app->uses('getconf,system');
84+
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
8585

8686
// convert to lower case - it could cause problems if some directory above has upper case name
8787
// $data['new']['maildir'] = strtolower($data['new']['maildir']);
@@ -110,7 +110,7 @@ function user_insert($event_name,$data) {
110110
//* When the mail user dir exists but it is not a valid maildir, remove it
111111
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
112112
exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail");
113-
$app->log("Removed invalid maildir and rebuild it: ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
113+
$app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
114114
}
115115

116116
//* Create the maildir, if it doesn not exist, set permissions, set quota.
@@ -120,7 +120,7 @@ function user_insert($event_name,$data) {
120120
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']);
121121

122122
exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
123-
$app->log("Set ownership on ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
123+
$app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
124124

125125
//* This is to fix the maildrop quota not being rebuilt after the quota is changed.
126126
if($mail_config['pop3_imap_daemon'] != 'dovecot') {
@@ -161,17 +161,18 @@ function user_update($event_name,$data) {
161161
global $app, $conf;
162162

163163
// get the config
164-
$app->uses("getconf,system");
165-
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
164+
$app->uses('getconf,system');
165+
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
166166

167167
// convert to lower case - it could cause problems if some directory above has upper case name
168168
// $data['new']['maildir'] = strtolower($data['new']['maildir']);
169169

170170
// Create the maildir, if it does not exist
171171
/*
172172
if(!is_dir($data['new']['maildir'])) {
173-
exec('mkdir -p '.escapeshellcmd($data['new']['maildir']));
174-
exec('chown '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
173+
mkdir(escapeshellcmd($data['new']['maildir']), 0, true);
174+
chown(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_name']);
175+
chgrp(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_group']);
175176
$app->log('Created Maildir: '.$data['new']['maildir'],LOGLEVEL_DEBUG);
176177
}
177178
*/
@@ -198,7 +199,7 @@ function user_update($event_name,$data) {
198199
//* When the mail user dir exists but it is not a valid maildir, remove it
199200
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
200201
exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail");
201-
$app->log("Removed invalid maildir and rebuild it: ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
202+
$app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
202203
}
203204

204205
//* Create the maildir, if it doesn not exist, set permissions, set quota.
@@ -208,7 +209,7 @@ function user_update($event_name,$data) {
208209
$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']);
209210

210211
exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
211-
$app->log("Set ownership on ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
212+
$app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
212213
//* This is to fix the maildrop quota not being rebuilt after the quota is changed.
213214
if($mail_config['pop3_imap_daemon'] != 'dovecot') {
214215
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 @@ function domain_delete($event_name,$data) {
274275

275276
// get the config
276277
$app->uses("getconf");
277-
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
278+
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
278279

279280
//* Delete maildomain path
280281
$old_maildomain_path = escapeshellcmd($mail_config['homedir_path'].'/'.$data['old']['domain']);
@@ -298,7 +299,7 @@ function domain_delete($event_name,$data) {
298299
function transport_update($event_name,$data) {
299300
global $app, $conf;
300301

301-
exec('/etc/init.d/postfix reload &> /dev/null');
302+
exec($conf['init_scripts'] . '/' . 'postfix reload &> /dev/null');
302303
$app->log('Postfix config reloaded ',LOGLEVEL_DEBUG);
303304

304305
}
@@ -308,4 +309,4 @@ function transport_update($event_name,$data) {
308309

309310
} // end class
310311

311-
?>
312+
?>

0 commit comments

Comments
 (0)