Skip to content

Commit 709638f

Browse files
author
Marius Burkard
committed
- Coding guidelines
1 parent d9c66dc commit 709638f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

server/scripts/ispconfig_patch

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ function simple_query($query, $answers, $default)
7979
}
8080

8181
function is_installed($appname) {
82-
exec('which '.escapeshellcmd($appname).' 2> /dev/null',$out,$returncode);
82+
$out = array();
83+
$returncode = null;
84+
exec('which '.escapeshellarg($appname).' 2> /dev/null',$out,$returncode);
8385
if(isset($out[0]) && stristr($out[0],$appname) && $returncode == 0) {
8486
return true;
8587
} else {
@@ -105,14 +107,18 @@ echo " _____ ___________ _____ __ _
105107
|___/ ";
106108
echo "\n".str_repeat('-',80)."\n";
107109
echo "\n\n>> Patch tool \n\n";
108-
if(!$auto) echo "Please enter the patch id that you want to be applied to your ISPConfig installation.\nPlease be aware that we take NO responsibility that this will work for you.\nOnly use patches if you know what you are doing.\n\n";
110+
if(!$auto) {
111+
echo "Please enter the patch id that you want to be applied to your ISPConfig installation.\nPlease be aware that we take NO responsibility that this will work for you.\nOnly use patches if you know what you are doing.\n\n";
112+
}
109113

110114
if(!is_installed('patch')) {
111115
swriteln("The program 'patch' is missing on your server. Please install it and try again.");
112116
exit;
113117
}
114118

115-
if(!$auto) $patch_id = simple_query('Enter patch id', false, '');
119+
if(!$auto) {
120+
$patch_id = simple_query('Enter patch id', false, '');
121+
}
116122
if($patch_id == '') {
117123
swriteln("Patch terminated by user.\n");
118124
die();
@@ -129,8 +135,12 @@ if(!$patch_data) {
129135

130136
$patch_text = @file_get_contents('http://ispconfig.org/downloads/patches/' . $patch_id . '.txt');
131137
if($patch_text) {
132-
if($auto) $ok = 'y'; else $ok = simple_query("Patch description:\n".str_repeat("-", 80)."\n".$patch_text."\n".str_repeat("-", 80)."\nDo you really want to apply this patch now?", array('y','n'), 'y');
133-
if($ok != 'y') {
138+
if($auto) {
139+
$ok = 'y';
140+
} else {
141+
$ok = simple_query("Patch description:\n" . str_repeat("-", 80) . "\n" . $patch_text . "\n" . str_repeat("-", 80) . "\nDo you really want to apply this patch now?", array('y', 'n'), 'y');
142+
}
143+
if($ok != 'y') {
134144
swriteln("Patch terminated by user.\n");
135145
die();
136146
}
@@ -146,5 +156,3 @@ passthru('patch -p0 < ' . escapeshellarg($temp_file));
146156
unlink($temp_file);
147157

148158
exit;
149-
150-
?>

0 commit comments

Comments
 (0)