|
49 | 49 |
|
50 | 50 | //If there's no appropriate autoloader, add one
|
51 | 51 | if (!class_exists('PEAR2\Net\RouterOS\Communicator', true)) {
|
52 |
| - include_once 'PEAR2/Autoload.php'; |
53 |
| - chdir(__DIR__); |
54 |
| - Autoload::initialize(realpath('../src')); |
55 |
| - Autoload::initialize(realpath('../../Net_Transmitter.git/src')); |
56 |
| - Autoload::initialize(realpath('../../Console_Color.git/src')); |
| 52 | + $autoloader = stream_resolve_include_path('../vendor/autoload.php'); |
| 53 | + if (false !== $autoloader) { |
| 54 | + include_once $autoloader; |
| 55 | + } else { |
| 56 | + $autoloader = stream_resolve_include_path('PEAR2/Autoload.php'); |
| 57 | + if (false !== $autoloader) { |
| 58 | + include_once $autoloader; |
| 59 | + Autoload::initialize(realpath('../src')); |
| 60 | + Autoload::initialize(realpath('../../Net_Transmitter.git/src')); |
| 61 | + Autoload::initialize(realpath('../../Cache_SHM.git/src')); |
| 62 | + } else { |
| 63 | + fwrite( |
| 64 | + STDERR, |
| 65 | + <<<HEREDOC |
| 66 | +No recognized autoloader is available. |
| 67 | +Please install this package with Pyrus, PEAR or Composer. |
| 68 | +Alternatively, install PEAR2_Autoload, and/or add it to your include_path. |
| 69 | +HEREDOC |
| 70 | + ); |
| 71 | + exit(10); |
| 72 | + } |
| 73 | + } |
| 74 | + unset($autoloader); |
57 | 75 | }
|
58 | 76 |
|
59 | 77 | // Locate the data dir, in preference as:
|
|
72 | 90 | STDERR,
|
73 | 91 | 'Unable to find data dir.'
|
74 | 92 | );
|
75 |
| - exit(10); |
| 93 | + exit(11); |
76 | 94 | }
|
77 | 95 | $consoleDefFile = realpath($dataDir . '/roscon.xml');
|
78 | 96 | if (false === $consoleDefFile) {
|
|
84 | 102 | {$dataDir}
|
85 | 103 | HEREDOC
|
86 | 104 | );
|
87 |
| - exit(11); |
| 105 | + exit(12); |
88 | 106 | }
|
89 | 107 |
|
90 | 108 | $cmdParser = CommandLine::fromXmlFile($consoleDefFile);
|
|
95 | 113 | STDERR,
|
96 | 114 | 'Error when parsing command line: ' . $e->getMessage() . "\n"
|
97 | 115 | );
|
98 |
| - $cmdParser->displayUsage(12); |
| 116 | + $cmdParser->displayUsage(13); |
99 | 117 | }
|
100 | 118 |
|
101 | 119 | $c_colors = array(
|
|
126 | 144 | Color\Backgrounds::YELLOW
|
127 | 145 | );
|
128 | 146 | $c_colors[''] = new Color();
|
| 147 | + |
| 148 | + foreach ($c_colors as $mode => $color) { |
| 149 | + $c_colors[$mode] = ((string)$color) . "\033[K"; |
| 150 | + } |
129 | 151 | }
|
130 | 152 |
|
131 | 153 | $cmd->options['size'] = $cmd->options['size'] ?: 80;
|
|
188 | 210 | <<<HEREDOC
|
189 | 211 | Login refused. Possible reasons:
|
190 | 212 | 1. No such username.
|
191 |
| -3. The user does not have the "api" privilege. Check the username's group, and |
192 |
| - it's permissions at "/user groups". |
193 |
| -2. Mistyped password. If the password contains non-ASCII characters, be careful |
194 |
| - of your locale settings - either they must match those of the terminal you |
195 |
| - set your password on, or you must type the equivalent code points in your |
196 |
| - locale, which may display as different characters. |
| 213 | + Make sure you have spelled it correctly. |
| 214 | +2. The user does not have the "api" privilege. |
| 215 | + Check the permissions of the user's group at "/user group". |
| 216 | +3. The user is not allowed to access the router from your web server's IP. |
| 217 | + Make sure your web server's IP address is within the subnets the user is |
| 218 | + allowed to log in from. You can check them at the "address" property |
| 219 | + of the user in the "/user" menu. |
| 220 | +4. Mistyped password. |
| 221 | + If the password contains non-ASCII characters, be careful of your locale. |
| 222 | + It must match that of the terminal you set your password on, or you must |
| 223 | + type the equivalent code points in your current locale, which may display as |
| 224 | + different characters. |
197 | 225 |
|
198 | 226 | HEREDOC
|
199 | 227 | );
|
|
0 commit comments