|
1 | 1 | <?php
|
| 2 | +error_reporting(E_ALL); |
| 3 | +ini_set('display_errors', 'on'); |
2 | 4 | if (!@$argv) {
|
3 | 5 | fwrite(STDERR, "CLI ONLY");
|
4 | 6 | exit(1);
|
5 | 7 | }
|
| 8 | +$XATAFACE_CONFIG_PATHS = array(); |
6 | 9 |
|
7 |
| -$files = array('conf.ini', 'conf.ini.php', 'conf.db.ini', 'conf.db.ini.php'); |
| 10 | +$cliConfPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'cli-conf.ini'; |
| 11 | + |
| 12 | +if (is_readable($cliConfPath)) { |
| 13 | + $cliConf = parse_ini_file($cliConfPath, true); |
| 14 | + if (isset($cliConf['XATAFACE_CONFIG_PATHS'])) { |
| 15 | + $paths = explode(":", $cliConf['XATAFACE_CONFIG_PATHS']); |
| 16 | + foreach ($paths as $path) { |
| 17 | + if (!trim($path)) { |
| 18 | + continue; |
| 19 | + } |
| 20 | + $XATAFACE_CONFIG_PATHS[] = dirname($cliConfPath).DIRECTORY_SEPARATOR.$path; |
| 21 | + } |
| 22 | + } |
| 23 | +} |
| 24 | +$XATAFACE_CONFIG_PATHS[] = dirname(__FILE__). DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'app'; |
| 25 | +$files = array('conf.ini.php', 'conf.ini'); |
8 | 26 | $conf = array();
|
9 | 27 | foreach ($files as $file) {
|
10 |
| - $file_path = dirname(__FILE__) |
11 |
| - . DIRECTORY_SEPARATOR . '..' |
12 |
| - . DIRECTORY_SEPARATOR . 'app' |
13 |
| - . DIRECTORY_SEPARATOR . $file; |
14 |
| - if (file_exists($file_path)) { |
15 |
| - $conf = array_merge_recursive($conf, parse_ini_file($file_path, true)); |
16 |
| - } |
| 28 | + foreach ($XATAFACE_CONFIG_PATHS as $path) { |
| 29 | + $file_path = $path . DIRECTORY_SEPARATOR . $file; |
| 30 | + if (file_exists($file_path)) { |
| 31 | + $tmp = parse_ini_file($file_path, true); |
| 32 | + if ( @$tmp['__include__'] ){ |
| 33 | + $includes = array_map('trim',explode(',', $tmp['__include__'])); |
| 34 | + foreach ($includes as $i){ |
| 35 | + if (!trim($i)) { |
| 36 | + continue; |
| 37 | + } |
| 38 | + $p = dirname($file_path) . DIRECTORY_SEPARATOR . $i; |
| 39 | + if ( is_readable($p) ){ |
| 40 | + $tmp = array_merge($tmp, parse_ini_file($p, true)); |
| 41 | + } else if ( is_readable($p.'.php') ){ |
| 42 | + $tmp = array_merge($tmp, parse_ini_file($p.'.php', true)); |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | + $conf = array_merge_recursive($tmp, $conf); |
| 47 | + } |
| 48 | + } |
| 49 | + |
17 | 50 | }
|
18 | 51 | if (count($argv) < 2) {
|
19 | 52 | print_r($conf);
|
|
30 | 63 | echo dirname(dirname(realpath(__FILE__)));
|
31 | 64 | exit;
|
32 | 65 | case 'XFServerPort':
|
33 |
| - echo '9090'; |
| 66 | + if (@$conf['XFServerPort']) { |
| 67 | + echo $conf['XFServerPort']; |
| 68 | + } else { |
| 69 | + echo '9090'; |
| 70 | + } |
| 71 | + |
34 | 72 | exit;
|
35 | 73 | case 'XFShortVersionString':
|
36 | 74 | $version_path = dirname(__FILE__)
|
|
0 commit comments