@@ -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 | { |
@@ -263,17 +278,26 @@ discard block |
||
| 263 | 278 | |
| 264 | 279 | // update composer managed dependencies |
| 265 | 280 | $cmd = $composer.' install '.implode(' ', $composer_args); |
| 266 | -if ($verbose) echo "$cmd\n"; |
|
| 281 | +if ($verbose) |
|
| 282 | +{ |
|
| 283 | + echo "$cmd\n"; |
|
| 284 | +} |
|
| 267 | 285 | system($cmd); |
| 268 | 286 | |
| 269 | 287 | // update npm dependencies and run grunt to minify javascript and css |
| 270 | 288 | if ($npm && $grunt) |
| 271 | 289 | { |
| 272 | 290 | $cmd = $npm.' install'; |
| 273 | - if ($verbose) echo "$cmd\n"; |
|
| 291 | + if ($verbose) |
|
| 292 | + { |
|
| 293 | + echo "$cmd\n"; |
|
| 294 | + } |
|
| 274 | 295 | system($cmd); |
| 275 | 296 | |
| 276 | - if ($verbose) echo "$grunt\n"; |
|
| 297 | + if ($verbose) |
|
| 298 | + { |
|
| 299 | + echo "$grunt\n"; |
|
| 300 | + } |
|
| 277 | 301 | system($grunt); |
| 278 | 302 | } |
| 279 | 303 | |
@@ -303,7 +327,10 @@ discard block |
||
| 303 | 327 | error_log("\n>>> ".$cmd."\n"); |
| 304 | 328 | system($cmd, $ret); |
| 305 | 329 | // break if command is not successful |
| 306 | - if ($ret) return $ret; |
|
| 330 | + if ($ret) |
|
| 331 | + { |
|
| 332 | + return $ret; |
|
| 333 | + } |
|
| 307 | 334 | } |
| 308 | 335 | } |
| 309 | 336 | return $ret; |
@@ -355,25 +382,40 @@ discard block |
||
| 355 | 382 | { |
| 356 | 383 | case 'POST': |
| 357 | 384 | curl_setopt($c, CURLOPT_POST, true); |
| 358 | - if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 385 | + if (is_array($data)) |
|
| 386 | + { |
|
| 387 | + $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 388 | + } |
|
| 359 | 389 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 360 | 390 | break; |
| 361 | 391 | case 'GET': |
| 362 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 392 | + if(count($data)) |
|
| 393 | + { |
|
| 394 | + $url .= '?' . http_build_query($data); |
|
| 395 | + } |
|
| 363 | 396 | break; |
| 364 | 397 | case 'FILE': |
| 365 | 398 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 366 | 399 | curl_setopt($c, CURLOPT_POST, true); |
| 367 | 400 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 368 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 401 | + if(count($data)) |
|
| 402 | + { |
|
| 403 | + $url .= '?' . http_build_query($data); |
|
| 404 | + } |
|
| 369 | 405 | break; |
| 370 | 406 | default: |
| 371 | 407 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
| 372 | 408 | } |
| 373 | 409 | curl_setopt($c, CURLOPT_URL, $url); |
| 374 | 410 | |
| 375 | - if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 376 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 411 | + if (is_string($data)) |
|
| 412 | + { |
|
| 413 | + $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 414 | + } |
|
| 415 | + if ($verbose) |
|
| 416 | + { |
|
| 417 | + echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 418 | + } |
|
| 377 | 419 | |
| 378 | 420 | if (($response = curl_exec($c)) === false) |
| 379 | 421 | { |
@@ -384,7 +426,10 @@ discard block |
||
| 384 | 426 | throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
| 385 | 427 | } |
| 386 | 428 | |
| 387 | - if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 429 | + if ($verbose) |
|
| 430 | + { |
|
| 431 | + echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 432 | + } |
|
| 388 | 433 | |
| 389 | 434 | curl_close($c); |
| 390 | 435 | |