3 * PHPwikiBot Configuration File Parser
6 * @name Configuration Parser
7 * @license http://www.gnu.org/licenses/gpl.html GPLv3+
10 /** Include the required files */
11 require dirname(__FILE__
).'/spyc.php';
12 require_once dirname(__FILE__
).'/stddef.inc';
13 /** Load config.yml */
14 $cfg = spyc_load_file('config.yml');
16 /** Find out some config problems */
17 if (!isset ($cfg['useragent']) ||
!is_string($cfg['useragent'])) echo '\'useragent\' MUST be a string!!!'.PHP_EOL
;
18 if (!isset ($cfg['key']) ||
!is_string($cfg['key'])) echo '\'key\' MUST be a string!!!'.PHP_EOL
;
19 if (!isset ($cfg['logfile']) ||
!is_string($cfg['logfile'])) echo '\'logfile\' MUST be a string!!!'.PHP_EOL
;
20 if (!isset ($cfg['output_log']) ||
!is_bool($cfg['output_log'])) echo '\'output_log\' MUST be yes or no!!!'.PHP_EOL
;
21 if (!isset ($cfg['log2stderr']) ||
!is_bool($cfg['log2stderr'])) echo '\'log2stderr\' MUST be yes or no!!!'.PHP_EOL
;
23 /** Set the variables */
24 /** User-Agent of the bot */
25 $useragent = $cfg['useragent'];
26 /** Password encryption key */
28 /** Log level handling */
29 switch ($cfg['log_level']) {
31 $log_level = LG_DEBUG
;
37 $log_level = LG_NOTICE
;
43 $log_level = LG_ERROR
;
46 $log_level = LG_FATAL
;
50 Error level MUST be one of the following:
61 $logfile = $cfg['logfile'];
62 /** Whether to output the log */
63 $output_log = $cfg['output_log'];
64 /** Log to STDERR??? */
65 define('LOG_TO_STDERR', $cfg['log2stderr']);
66 /** Wiki Configuration */
68 /** User Configuration */
69 $users = $cfg['users'];