@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
| 42 | 42 | */ |
| 43 | 43 | |
| 44 | -chdir(__DIR__); // to enable relative pathes to work |
|
| 44 | +chdir(__DIR__); // to enable relative pathes to work |
|
| 45 | 45 | |
| 46 | 46 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
| 47 | 47 | { |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | $argv = $_SERVER['argv']; |
| 57 | 57 | $cmd = array_shift($argv); |
| 58 | 58 | |
| 59 | -foreach($argv as $n => $arg) |
|
| 59 | +foreach ($argv as $n => $arg) |
|
| 60 | 60 | { |
| 61 | 61 | if ($arg[0] === '-') |
| 62 | 62 | { |
| 63 | - switch($arg) |
|
| 63 | + switch ($arg) |
|
| 64 | 64 | { |
| 65 | 65 | case '-v': |
| 66 | 66 | case '--verbose': |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | case '--git-apps': |
| 82 | 82 | $run_git = $arg; |
| 83 | 83 | unset($argv[$n]); |
| 84 | - break 2; // no further argument processing, as they are for git |
|
| 84 | + break 2; // no further argument processing, as they are for git |
|
| 85 | 85 | |
| 86 | 86 | default: // pass unknown arguments to composer install |
| 87 | 87 | $composer_args[] = $arg; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | if (!$run_git && count($argv) > 1) usage("Too many arguments!"); |
| 95 | 95 | |
| 96 | -function usage($err=null) |
|
| 96 | +function usage($err = null) |
|
| 97 | 97 | { |
| 98 | 98 | global $cmd; |
| 99 | 99 | |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | 119 | // check if the necessary binaries are installed |
| 120 | -foreach($bins as $name => $binaries) |
|
| 120 | +foreach ($bins as $name => $binaries) |
|
| 121 | 121 | { |
| 122 | - foreach((array)$binaries as $bin) |
|
| 122 | + foreach ((array)$binaries as $bin) |
|
| 123 | 123 | { |
| 124 | 124 | if (file_exists($bin) && is_executable($bin)) |
| 125 | 125 | { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | $bins[$name] = $$name = false; |
| 144 | 144 | error_log("Could not find $name command!"); |
| 145 | - if (!in_array($name, ['npm','grunt'])) |
|
| 145 | + if (!in_array($name, ['npm', 'grunt'])) |
|
| 146 | 146 | { |
| 147 | 147 | exit(1); |
| 148 | 148 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -if ($verbose) echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 157 | +if ($verbose) echo "Using following binaries: ".json_encode($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 158 | 158 | |
| 159 | 159 | if (!extension_loaded('curl')) die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n"); |
| 160 | 160 | |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | if (!exec($git.' branch --no-color', $output, $ret) || $ret) |
| 176 | 176 | { |
| 177 | - foreach($output as $line) |
|
| 177 | + foreach ($output as $line) |
|
| 178 | 178 | { |
| 179 | 179 | error_log($line); |
| 180 | 180 | } |
| 181 | 181 | exit($ret); |
| 182 | 182 | } |
| 183 | -foreach($output as $line) |
|
| 183 | +foreach ($output as $line) |
|
| 184 | 184 | { |
| 185 | 185 | if ($line[0] == '*') |
| 186 | 186 | { |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | // Update EGroupware itself and further apps installed via git |
| 230 | 230 | $failed = array(); |
| 231 | 231 | $succieded = 0; |
| 232 | -foreach(scandir(__DIR__) as $dir) |
|
| 232 | +foreach (scandir(__DIR__) as $dir) |
|
| 233 | 233 | { |
| 234 | 234 | if ($dir !== '..' && file_exists(__DIR__.'/'.$dir.'/.git') && |
| 235 | 235 | // these apps / dirs are managed by composer, no need to run manual updates |
@@ -313,14 +313,14 @@ discard block |
||
| 313 | 313 | * @param booelan $main_too =true true: run in main-dir too, false: only app-dirs |
| 314 | 314 | * @return int exit-code of last git command, breaks on first non-zero exit-code |
| 315 | 315 | */ |
| 316 | -function run_git(array $argv, $main_too=true) |
|
| 316 | +function run_git(array $argv, $main_too = true) |
|
| 317 | 317 | { |
| 318 | 318 | global $git; |
| 319 | 319 | |
| 320 | 320 | $git_cmd = $git.' '.implode(' ', array_map('escapeshellarg', $argv)); |
| 321 | 321 | |
| 322 | 322 | $ret = 0; |
| 323 | - foreach(scandir(__DIR__) as $dir) |
|
| 323 | + foreach (scandir(__DIR__) as $dir) |
|
| 324 | 324 | { |
| 325 | 325 | if (!($dir === '..' || $dir === '.' && !$main_too || |
| 326 | 326 | !file_exists(__DIR__.'/'.$dir.'/.git'))) |
@@ -343,9 +343,9 @@ discard block |
||
| 343 | 343 | * @param boolean $return_name =true true: just return name, false: full release object |
| 344 | 344 | * @return array|string|null null if no release found |
| 345 | 345 | */ |
| 346 | -function get_latest_release($prerelease=false, $return_name=true) |
|
| 346 | +function get_latest_release($prerelease = false, $return_name = true) |
|
| 347 | 347 | { |
| 348 | - foreach(github_api('/repos/egroupware/egroupware/releases', [], 'GET') as $release) |
|
| 348 | + foreach (github_api('/repos/egroupware/egroupware/releases', [], 'GET') as $release) |
|
| 349 | 349 | { |
| 350 | 350 | if ($prerelease || $release['prerelease'] === false) |
| 351 | 351 | { |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @throws Exception |
| 367 | 367 | * @return array with response |
| 368 | 368 | */ |
| 369 | -function github_api($_url, $data, $method='POST', $upload=null, $content_type=null) |
|
| 369 | +function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null) |
|
| 370 | 370 | { |
| 371 | 371 | global /*$config,*/ $verbose; |
| 372 | 372 | |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | curl_setopt($c, CURLOPT_TIMEOUT, 240); |
| 380 | 380 | curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); |
| 381 | 381 | |
| 382 | - switch($method) |
|
| 382 | + switch ($method) |
|
| 383 | 383 | { |
| 384 | 384 | case 'POST': |
| 385 | 385 | curl_setopt($c, CURLOPT_POST, true); |
@@ -387,13 +387,13 @@ discard block |
||
| 387 | 387 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 388 | 388 | break; |
| 389 | 389 | case 'GET': |
| 390 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 390 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
| 391 | 391 | break; |
| 392 | 392 | case 'FILE': |
| 393 | 393 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 394 | 394 | curl_setopt($c, CURLOPT_POST, true); |
| 395 | 395 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 396 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 396 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
| 397 | 397 | break; |
| 398 | 398 | default: |
| 399 | 399 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | curl_setopt($c, CURLOPT_URL, $url); |
| 402 | 402 | |
| 403 | 403 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
| 404 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 404 | + if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n"; |
|
| 405 | 405 | |
| 406 | 406 | if (($response = curl_exec($c)) === false) |
| 407 | 407 | { |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | curl_setopt($c, CURLOPT_HEADER, true); |
| 410 | 410 | curl_setopt($c, CURLOPT_RETURNTRANSFER, false); |
| 411 | 411 | curl_exec($c); |
| 412 | - throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
|
| 412 | + throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : '')); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
@@ -43,10 +43,13 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | chdir(__DIR__); // to enable relative pathes to work |
| 45 | 45 | |
| 46 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
|
| 46 | +if (php_sapi_name() !== 'cli') |
|
| 47 | +{ |
|
| 48 | + // security precaution: forbit calling setup-cli as web-page |
|
| 47 | 49 | { |
| 48 | 50 | die('<h1>install-cli.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 49 | 51 | } |
| 52 | +} |
|
| 50 | 53 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); |
| 51 | 54 | |
| 52 | 55 | // parse arguments |
@@ -91,7 +94,10 @@ discard block |
||
| 91 | 94 | } |
| 92 | 95 | } |
| 93 | 96 | |
| 94 | -if (!$run_git && count($argv) > 1) usage("Too many arguments!"); |
|
| 97 | +if (!$run_git && count($argv) > 1) |
|
| 98 | +{ |
|
| 99 | + usage("Too many arguments!"); |
|
| 100 | +} |
|
| 95 | 101 | |
| 96 | 102 | function usage($err=null) |
| 97 | 103 | { |
@@ -154,9 +160,15 @@ discard block |
||
| 154 | 160 | } |
| 155 | 161 | } |
| 156 | 162 | |
| 157 | -if ($verbose) echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 163 | +if ($verbose) |
|
| 164 | +{ |
|
| 165 | + echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 166 | +} |
|
| 158 | 167 | |
| 159 | -if (!extension_loaded('curl')) die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n"); |
|
| 168 | +if (!extension_loaded('curl')) |
|
| 169 | +{ |
|
| 170 | + die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n"); |
|
| 171 | +} |
|
| 160 | 172 | |
| 161 | 173 | // check if we are on a git clone |
| 162 | 174 | $output = array(); |
@@ -198,7 +210,10 @@ discard block |
||
| 198 | 210 | { |
| 199 | 211 | $channel = isset($matches[1]) ? 'release' : 'bugfix'; |
| 200 | 212 | } |
| 201 | -if ($verbose) echo "Currently using branch: $branch --> $channel channel\n"; |
|
| 213 | +if ($verbose) |
|
| 214 | +{ |
|
| 215 | + echo "Currently using branch: $branch --> $channel channel\n"; |
|
| 216 | +} |
|
| 202 | 217 | |
| 203 | 218 | if ($argv) |
| 204 | 219 | { |
@@ -290,7 +305,10 @@ discard block |
||
| 290 | 305 | { |
| 291 | 306 | global $verbose, $failed, $succieded; |
| 292 | 307 | |
| 293 | - if ($verbose) echo "$cmd\n"; |
|
| 308 | + if ($verbose) |
|
| 309 | + { |
|
| 310 | + echo "$cmd\n"; |
|
| 311 | + } |
|
| 294 | 312 | $ret = null; |
| 295 | 313 | system($cmd, $ret); |
| 296 | 314 | if ($ret == 0) |
@@ -330,7 +348,10 @@ discard block |
||
| 330 | 348 | error_log("\n>>> ".$cmd."\n"); |
| 331 | 349 | system($cmd, $ret); |
| 332 | 350 | // break if command is not successful |
| 333 | - if ($ret) return $ret; |
|
| 351 | + if ($ret) |
|
| 352 | + { |
|
| 353 | + return $ret; |
|
| 354 | + } |
|
| 334 | 355 | } |
| 335 | 356 | } |
| 336 | 357 | return $ret; |
@@ -383,25 +404,40 @@ discard block |
||
| 383 | 404 | { |
| 384 | 405 | case 'POST': |
| 385 | 406 | curl_setopt($c, CURLOPT_POST, true); |
| 386 | - if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 407 | + if (is_array($data)) |
|
| 408 | + { |
|
| 409 | + $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 410 | + } |
|
| 387 | 411 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 388 | 412 | break; |
| 389 | 413 | case 'GET': |
| 390 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 414 | + if(count($data)) |
|
| 415 | + { |
|
| 416 | + $url .= '?' . http_build_query($data); |
|
| 417 | + } |
|
| 391 | 418 | break; |
| 392 | 419 | case 'FILE': |
| 393 | 420 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 394 | 421 | curl_setopt($c, CURLOPT_POST, true); |
| 395 | 422 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 396 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 423 | + if(count($data)) |
|
| 424 | + { |
|
| 425 | + $url .= '?' . http_build_query($data); |
|
| 426 | + } |
|
| 397 | 427 | break; |
| 398 | 428 | default: |
| 399 | 429 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
| 400 | 430 | } |
| 401 | 431 | curl_setopt($c, CURLOPT_URL, $url); |
| 402 | 432 | |
| 403 | - if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 404 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 433 | + if (is_string($data)) |
|
| 434 | + { |
|
| 435 | + $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 436 | + } |
|
| 437 | + if ($verbose) |
|
| 438 | + { |
|
| 439 | + echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 440 | + } |
|
| 405 | 441 | |
| 406 | 442 | if (($response = curl_exec($c)) === false) |
| 407 | 443 | { |
@@ -412,7 +448,10 @@ discard block |
||
| 412 | 448 | throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
| 413 | 449 | } |
| 414 | 450 | |
| 415 | - if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 451 | + if ($verbose) |
|
| 452 | + { |
|
| 453 | + echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 454 | + } |
|
| 416 | 455 | |
| 417 | 456 | curl_close($c); |
| 418 | 457 | |