@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | -chdir(__DIR__); // to enable relative pathes to work |
|
| 38 | +chdir(__DIR__); // to enable relative pathes to work |
|
| 39 | 39 | |
| 40 | 40 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
| 41 | 41 | { |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | $argv = $_SERVER['argv']; |
| 50 | 50 | $cmd = array_shift($argv); |
| 51 | 51 | |
| 52 | -foreach($argv as $n => $arg) |
|
| 52 | +foreach ($argv as $n => $arg) |
|
| 53 | 53 | { |
| 54 | 54 | if ($arg[0] === '-') |
| 55 | 55 | { |
| 56 | - switch($arg) |
|
| 56 | + switch ($arg) |
|
| 57 | 57 | { |
| 58 | 58 | case '-v': |
| 59 | 59 | case '--verbose': |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | if (count($argv) > 1) usage("Too many arguments!"); |
| 80 | 80 | |
| 81 | -function usage($err=null) |
|
| 81 | +function usage($err = null) |
|
| 82 | 82 | { |
| 83 | 83 | global $cmd; |
| 84 | 84 | |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | 101 | // check if the necessary binaries are installed |
| 102 | -foreach($bins as $name => $binaries) |
|
| 102 | +foreach ($bins as $name => $binaries) |
|
| 103 | 103 | { |
| 104 | - foreach((array)$binaries as $bin) |
|
| 104 | + foreach ((array)$binaries as $bin) |
|
| 105 | 105 | { |
| 106 | 106 | if (file_exists($bin) && is_executable($bin)) |
| 107 | 107 | { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $bins[$name] = $$name = false; |
| 121 | 121 | error_log("Could not find $name command!"); |
| 122 | - if (!in_array($name, ['npm','grunt'])) |
|
| 122 | + if (!in_array($name, ['npm', 'grunt'])) |
|
| 123 | 123 | { |
| 124 | 124 | exit(1); |
| 125 | 125 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | -if ($verbose) echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 134 | +if ($verbose) echo "Using following binaries: ".json_encode($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 135 | 135 | |
| 136 | 136 | if (!extension_loaded('curl')) die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n"); |
| 137 | 137 | |
@@ -140,14 +140,14 @@ discard block |
||
| 140 | 140 | if (!$git || !file_exists(__DIR__.'/.git') || !is_dir(__DIR__.'/.git') || |
| 141 | 141 | !exec($git.' branch --no-color', $output, $ret) || $ret) |
| 142 | 142 | { |
| 143 | - foreach($output as $line) |
|
| 143 | + foreach ($output as $line) |
|
| 144 | 144 | { |
| 145 | 145 | error_log($line); |
| 146 | 146 | } |
| 147 | 147 | error_log("Could not identify git branch (you need to use git clone or composer create-project --prefer-source --keep-vcs egroupware/egroupware)!"); |
| 148 | 148 | exit(1); |
| 149 | 149 | } |
| 150 | -foreach($output as $line) |
|
| 150 | +foreach ($output as $line) |
|
| 151 | 151 | { |
| 152 | 152 | if ($line[0] == '*') |
| 153 | 153 | { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | echo "Updating to: $target\n"; |
| 195 | 195 | |
| 196 | 196 | // Update EGroupware itself and further apps installed via git |
| 197 | -foreach(scandir(__DIR__) as $dir) |
|
| 197 | +foreach (scandir(__DIR__) as $dir) |
|
| 198 | 198 | { |
| 199 | 199 | if ($dir !== '..' && file_exists(__DIR__.'/'.$dir.'/.git') && |
| 200 | 200 | // these apps / dirs are managed by composer, no need to run manual updates |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | * @param boolean $return_name =true true: just return name, false: full release object |
| 245 | 245 | * @return array|string|null null if no release found |
| 246 | 246 | */ |
| 247 | -function get_latest_release($prerelease=false, $return_name=true) |
|
| 247 | +function get_latest_release($prerelease = false, $return_name = true) |
|
| 248 | 248 | { |
| 249 | - foreach(github_api('/repos/egroupware/egroupware/releases', [], 'GET') as $release) |
|
| 249 | + foreach (github_api('/repos/egroupware/egroupware/releases', [], 'GET') as $release) |
|
| 250 | 250 | { |
| 251 | 251 | if ($prerelease || $release['prerelease'] === false) |
| 252 | 252 | { |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @throws Exception |
| 267 | 267 | * @return array with response |
| 268 | 268 | */ |
| 269 | -function github_api($_url, $data, $method='POST', $upload=null, $content_type=null) |
|
| 269 | +function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null) |
|
| 270 | 270 | { |
| 271 | 271 | global /*$config,*/ $verbose; |
| 272 | 272 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | curl_setopt($c, CURLOPT_TIMEOUT, 240); |
| 280 | 280 | curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); |
| 281 | 281 | |
| 282 | - switch($method) |
|
| 282 | + switch ($method) |
|
| 283 | 283 | { |
| 284 | 284 | case 'POST': |
| 285 | 285 | curl_setopt($c, CURLOPT_POST, true); |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 288 | 288 | break; |
| 289 | 289 | case 'GET': |
| 290 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 290 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
| 291 | 291 | break; |
| 292 | 292 | case 'FILE': |
| 293 | 293 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 294 | 294 | curl_setopt($c, CURLOPT_POST, true); |
| 295 | 295 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 296 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 296 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
| 297 | 297 | break; |
| 298 | 298 | default: |
| 299 | 299 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | curl_setopt($c, CURLOPT_URL, $url); |
| 302 | 302 | |
| 303 | 303 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
| 304 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 304 | + if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n"; |
|
| 305 | 305 | |
| 306 | 306 | if (($response = curl_exec($c)) === false) |
| 307 | 307 | { |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | curl_setopt($c, CURLOPT_HEADER, true); |
| 310 | 310 | curl_setopt($c, CURLOPT_RETURNTRANSFER, false); |
| 311 | 311 | curl_exec($c); |
| 312 | - throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
|
| 312 | + throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : '')); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
@@ -37,10 +37,13 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | chdir(__DIR__); // to enable relative pathes to work |
| 39 | 39 | |
| 40 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
|
| 40 | +if (php_sapi_name() !== 'cli') |
|
| 41 | +{ |
|
| 42 | + // security precaution: forbit calling setup-cli as web-page |
|
| 41 | 43 | { |
| 42 | 44 | die('<h1>install-cli.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 43 | 45 | } |
| 46 | +} |
|
| 44 | 47 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); |
| 45 | 48 | |
| 46 | 49 | // parse arguments |
@@ -76,7 +79,10 @@ discard block |
||
| 76 | 79 | } |
| 77 | 80 | } |
| 78 | 81 | |
| 79 | -if (count($argv) > 1) usage("Too many arguments!"); |
|
| 82 | +if (count($argv) > 1) |
|
| 83 | +{ |
|
| 84 | + usage("Too many arguments!"); |
|
| 85 | +} |
|
| 80 | 86 | |
| 81 | 87 | function usage($err=null) |
| 82 | 88 | { |
@@ -131,9 +137,15 @@ discard block |
||
| 131 | 137 | } |
| 132 | 138 | } |
| 133 | 139 | |
| 134 | -if ($verbose) echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 140 | +if ($verbose) |
|
| 141 | +{ |
|
| 142 | + echo "Using following binaries: ".json_encode ($bins, JSON_UNESCAPED_SLASHES)."\n"; |
|
| 143 | +} |
|
| 135 | 144 | |
| 136 | -if (!extension_loaded('curl')) die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n"); |
|
| 145 | +if (!extension_loaded('curl')) |
|
| 146 | +{ |
|
| 147 | + die("Required PHP extesion 'curl' missing! You need to install php-curl package.\n\n"); |
|
| 148 | +} |
|
| 137 | 149 | |
| 138 | 150 | // check if we are on a git clone |
| 139 | 151 | $output = array(); |
@@ -165,7 +177,10 @@ discard block |
||
| 165 | 177 | { |
| 166 | 178 | $channel = isset($matches[1]) ? 'release' : 'bugfix'; |
| 167 | 179 | } |
| 168 | -if ($verbose) echo "Currently using branch: $branch --> $channel channel\n"; |
|
| 180 | +if ($verbose) |
|
| 181 | +{ |
|
| 182 | + echo "Currently using branch: $branch --> $channel channel\n"; |
|
| 183 | +} |
|
| 169 | 184 | |
| 170 | 185 | if ($argv) |
| 171 | 186 | { |
@@ -216,24 +231,36 @@ discard block |
||
| 216 | 231 | $cmd .= "; $git pull --rebase"; |
| 217 | 232 | } |
| 218 | 233 | $cmd .= "; test -z $($git stash list) || echo $git stash pop"; |
| 219 | - if ($verbose) echo "$cmd\n"; |
|
| 234 | + if ($verbose) |
|
| 235 | + { |
|
| 236 | + echo "$cmd\n"; |
|
| 237 | + } |
|
| 220 | 238 | system($cmd); |
| 221 | 239 | } |
| 222 | 240 | } |
| 223 | 241 | |
| 224 | 242 | // update composer managed dependencies |
| 225 | 243 | $cmd = $composer.' install'; |
| 226 | -if ($verbose) echo "$cmd\n"; |
|
| 244 | +if ($verbose) |
|
| 245 | +{ |
|
| 246 | + echo "$cmd\n"; |
|
| 247 | +} |
|
| 227 | 248 | system($cmd); |
| 228 | 249 | |
| 229 | 250 | // update npm dependencies and run grunt to minify javascript and css |
| 230 | 251 | if ($npm && $grunt) |
| 231 | 252 | { |
| 232 | 253 | $cmd = $npm.' install'; |
| 233 | - if ($verbose) echo "$cmd\n"; |
|
| 254 | + if ($verbose) |
|
| 255 | + { |
|
| 256 | + echo "$cmd\n"; |
|
| 257 | + } |
|
| 234 | 258 | system($cmd); |
| 235 | 259 | |
| 236 | - if ($verbose) echo "$grunt\n"; |
|
| 260 | + if ($verbose) |
|
| 261 | + { |
|
| 262 | + echo "$grunt\n"; |
|
| 263 | + } |
|
| 237 | 264 | system($grunt); |
| 238 | 265 | } |
| 239 | 266 | |
@@ -283,25 +310,40 @@ discard block |
||
| 283 | 310 | { |
| 284 | 311 | case 'POST': |
| 285 | 312 | curl_setopt($c, CURLOPT_POST, true); |
| 286 | - if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 313 | + if (is_array($data)) |
|
| 314 | + { |
|
| 315 | + $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 316 | + } |
|
| 287 | 317 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 288 | 318 | break; |
| 289 | 319 | case 'GET': |
| 290 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 320 | + if(count($data)) |
|
| 321 | + { |
|
| 322 | + $url .= '?' . http_build_query($data); |
|
| 323 | + } |
|
| 291 | 324 | break; |
| 292 | 325 | case 'FILE': |
| 293 | 326 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 294 | 327 | curl_setopt($c, CURLOPT_POST, true); |
| 295 | 328 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 296 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 329 | + if(count($data)) |
|
| 330 | + { |
|
| 331 | + $url .= '?' . http_build_query($data); |
|
| 332 | + } |
|
| 297 | 333 | break; |
| 298 | 334 | default: |
| 299 | 335 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
| 300 | 336 | } |
| 301 | 337 | curl_setopt($c, CURLOPT_URL, $url); |
| 302 | 338 | |
| 303 | - if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 304 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 339 | + if (is_string($data)) |
|
| 340 | + { |
|
| 341 | + $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 342 | + } |
|
| 343 | + if ($verbose) |
|
| 344 | + { |
|
| 345 | + echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 346 | + } |
|
| 305 | 347 | |
| 306 | 348 | if (($response = curl_exec($c)) === false) |
| 307 | 349 | { |
@@ -312,7 +354,10 @@ discard block |
||
| 312 | 354 | throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
| 313 | 355 | } |
| 314 | 356 | |
| 315 | - if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 357 | + if ($verbose) |
|
| 358 | + { |
|
| 359 | + echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 360 | + } |
|
| 316 | 361 | |
| 317 | 362 | curl_close($c); |
| 318 | 363 | |
@@ -301,7 +301,7 @@ |
||
| 301 | 301 | curl_setopt($c, CURLOPT_URL, $url); |
| 302 | 302 | |
| 303 | 303 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
| 304 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 304 | + if ($verbose) echo "sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 305 | 305 | |
| 306 | 306 | if (($response = curl_exec($c)) === false) |
| 307 | 307 | { |