Commit 709638f1 authored by Marius Burkard's avatar Marius Burkard

- Coding guidelines

parent d9c66dce
Pipeline #1263 failed with stage
in 2 minutes and 46 seconds
......@@ -79,7 +79,9 @@ function simple_query($query, $answers, $default)
}
function is_installed($appname) {
exec('which '.escapeshellcmd($appname).' 2> /dev/null',$out,$returncode);
$out = array();
$returncode = null;
exec('which '.escapeshellarg($appname).' 2> /dev/null',$out,$returncode);
if(isset($out[0]) && stristr($out[0],$appname) && $returncode == 0) {
return true;
} else {
......@@ -105,14 +107,18 @@ echo " _____ ___________ _____ __ _
|___/ ";
echo "\n".str_repeat('-',80)."\n";
echo "\n\n>> Patch tool \n\n";
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";
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";
}
if(!is_installed('patch')) {
swriteln("The program 'patch' is missing on your server. Please install it and try again.");
exit;
}
if(!$auto) $patch_id = simple_query('Enter patch id', false, '');
if(!$auto) {
$patch_id = simple_query('Enter patch id', false, '');
}
if($patch_id == '') {
swriteln("Patch terminated by user.\n");
die();
......@@ -129,8 +135,12 @@ if(!$patch_data) {
$patch_text = @file_get_contents('http://ispconfig.org/downloads/patches/' . $patch_id . '.txt');
if($patch_text) {
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');
if($ok != 'y') {
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');
}
if($ok != 'y') {
swriteln("Patch terminated by user.\n");
die();
}
......@@ -146,5 +156,3 @@ passthru('patch -p0 < ' . escapeshellarg($temp_file));
unlink($temp_file);
exit;
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment