@@ -39,10 +39,13 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | chdir(__DIR__); // to enable relative pathes to work |
| 41 | 41 | |
| 42 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
|
| 42 | +if (php_sapi_name() !== 'cli') |
|
| 43 | +{ |
|
| 44 | + // security precaution: forbit calling setup-cli as web-page |
|
| 43 | 45 | { |
| 44 | 46 | die('<h1>install-cli.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 45 | 47 | } |
| 48 | +} |
|
| 46 | 49 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); |
| 47 | 50 | |
| 48 | 51 | // parse arguments |
@@ -83,7 +86,10 @@ discard block |
||
| 83 | 86 | } |
| 84 | 87 | } |
| 85 | 88 | |
| 86 | -if (!$run_git && count($argv) > 1) usage("Too many arguments!"); |
|
| 89 | +if (!$run_git && count($argv) > 1) |
|
| 90 | +{ |
|
| 91 | + usage("Too many arguments!"); |
|
| 92 | +} |
|
| 87 | 93 | |
| 88 | 94 | function usage($err=null) |
| 89 | 95 | { |
@@ -144,9 +150,15 @@ discard block |
||
| 144 | 150 | } |
| 145 | 151 | } |
| 146 | 152 | |
| 147 | -if ($verbose) echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 153 | +if ($verbose) |
|
| 154 | +{ |
|
| 155 | + echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 156 | +} |
|
| 148 | 157 | |
| 149 | -if (!extension_loaded('curl')) die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n"); |
|
| 158 | +if (!extension_loaded('curl')) |
|
| 159 | +{ |
|
| 160 | + die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n"); |
|
| 161 | +} |
|
| 150 | 162 | |
| 151 | 163 | // check if we are on a git clone |
| 152 | 164 | $output = array(); |
@@ -188,7 +200,10 @@ discard block |
||
| 188 | 200 | { |
| 189 | 201 | $channel = isset($matches[1]) ? 'release' : 'bugfix'; |
| 190 | 202 | } |
| 191 | -if ($verbose) echo "Currently using branch: $branch --> $channel channel\n"; |
|
| 203 | +if ($verbose) |
|
| 204 | +{ |
|
| 205 | + echo "Currently using branch: $branch --> $channel channel\n"; |
|
| 206 | +} |
|
| 192 | 207 | |
| 193 | 208 | if ($argv) |
| 194 | 209 | { |
@@ -239,24 +254,36 @@ discard block |
||
| 239 | 254 | $cmd .= "; $git pull --rebase"; |
| 240 | 255 | } |
| 241 | 256 | $cmd .= "; test -z \"$($git stash list)\" || $git stash pop"; |
| 242 | - if ($verbose) echo "$cmd\n"; |
|
| 257 | + if ($verbose) |
|
| 258 | + { |
|
| 259 | + echo "$cmd\n"; |
|
| 260 | + } |
|
| 243 | 261 | system($cmd); |
| 244 | 262 | } |
| 245 | 263 | } |
| 246 | 264 | |
| 247 | 265 | // update composer managed dependencies |
| 248 | 266 | $cmd = $composer.' install'; |
| 249 | -if ($verbose) echo "$cmd\n"; |
|
| 267 | +if ($verbose) |
|
| 268 | +{ |
|
| 269 | + echo "$cmd\n"; |
|
| 270 | +} |
|
| 250 | 271 | system($cmd); |
| 251 | 272 | |
| 252 | 273 | // update npm dependencies and run grunt to minify javascript and css |
| 253 | 274 | if ($npm && $grunt) |
| 254 | 275 | { |
| 255 | 276 | $cmd = $npm.' install'; |
| 256 | - if ($verbose) echo "$cmd\n"; |
|
| 277 | + if ($verbose) |
|
| 278 | + { |
|
| 279 | + echo "$cmd\n"; |
|
| 280 | + } |
|
| 257 | 281 | system($cmd); |
| 258 | 282 | |
| 259 | - if ($verbose) echo "$grunt\n"; |
|
| 283 | + if ($verbose) |
|
| 284 | + { |
|
| 285 | + echo "$grunt\n"; |
|
| 286 | + } |
|
| 260 | 287 | system($grunt); |
| 261 | 288 | } |
| 262 | 289 | |
@@ -284,7 +311,10 @@ discard block |
||
| 284 | 311 | error_log("\n>>> ".$cmd."\n"); |
| 285 | 312 | system($cmd, $ret); |
| 286 | 313 | // break if command is not successful |
| 287 | - if ($ret) return $ret; |
|
| 314 | + if ($ret) |
|
| 315 | + { |
|
| 316 | + return $ret; |
|
| 317 | + } |
|
| 288 | 318 | } |
| 289 | 319 | } |
| 290 | 320 | return $ret; |
@@ -336,25 +366,40 @@ discard block |
||
| 336 | 366 | { |
| 337 | 367 | case 'POST': |
| 338 | 368 | curl_setopt($c, CURLOPT_POST, true); |
| 339 | - if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 369 | + if (is_array($data)) |
|
| 370 | + { |
|
| 371 | + $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 372 | + } |
|
| 340 | 373 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 341 | 374 | break; |
| 342 | 375 | case 'GET': |
| 343 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 376 | + if(count($data)) |
|
| 377 | + { |
|
| 378 | + $url .= '?' . http_build_query($data); |
|
| 379 | + } |
|
| 344 | 380 | break; |
| 345 | 381 | case 'FILE': |
| 346 | 382 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 347 | 383 | curl_setopt($c, CURLOPT_POST, true); |
| 348 | 384 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 349 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 385 | + if(count($data)) |
|
| 386 | + { |
|
| 387 | + $url .= '?' . http_build_query($data); |
|
| 388 | + } |
|
| 350 | 389 | break; |
| 351 | 390 | default: |
| 352 | 391 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
| 353 | 392 | } |
| 354 | 393 | curl_setopt($c, CURLOPT_URL, $url); |
| 355 | 394 | |
| 356 | - if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 357 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 395 | + if (is_string($data)) |
|
| 396 | + { |
|
| 397 | + $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 398 | + } |
|
| 399 | + if ($verbose) |
|
| 400 | + { |
|
| 401 | + echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 402 | + } |
|
| 358 | 403 | |
| 359 | 404 | if (($response = curl_exec($c)) === false) |
| 360 | 405 | { |
@@ -365,7 +410,10 @@ discard block |
||
| 365 | 410 | throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
| 366 | 411 | } |
| 367 | 412 | |
| 368 | - if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 413 | + if ($verbose) |
|
| 414 | + { |
|
| 415 | + echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 416 | + } |
|
| 369 | 417 | |
| 370 | 418 | curl_close($c); |
| 371 | 419 | |