3 This plugin parses the "ewiki.ini" file and sets ewiki variables
4 and constants accordingly, then loads plugins. Such a configuration
5 file could be prepared using the SetupWizard.
7 Note: PHPs parse_ini_file() is insufficient for our .ini file,
8 because it lacks recognizing repeated entry names.
13 error_reporting(error_reporting() & 0xFFFE);
14 if ($ini = ewiki_parse_ini_file("ewiki.ini")) {
17 if ($v = $ini["db"]["init"][0]) {
18 foreach (split('&&|;', $v) as $v) {
19 $i = strtok(preg_replace("/[\"\s\']/", "", $v), "(");
20 $v = explode(",", strtok(")"));
22 call_user_func_array($i, $v); // auto function_exists() check
28 foreach ($ini["config"] as $i=>$v) {
31 $i = preg_replace("/[\s\"\'\$\]]/", "", $i);
32 $i = explode("[", $i);
33 switch (count($i) + (strlen($i[count($i)-1]) ? 0 : 10)) {
34 case 1: $GLOBALS[$i[0]] = $v; break;
35 case 2: $GLOBALS[$i[0]][$i[1]] = $v; break;
36 case 12: $GLOBALS[$i[0]][] = $v; break;
37 case 3: $GLOBALS[$i[0]][$i[1]][$i[2]] = $v; break;
38 case 13: $GLOBALS[$i[0]][$i[1]][] = $v; break;
39 case 4: $GLOBALS[$i[0]][$i[1]][$i[2]][$i[3]] = $v; break;
40 case 14: $GLOBALS[$i[0]][$i[1]][$i[2]][] = $v;
49 foreach ($ini["plugins"]["load"] as $v) {
52 $i = $v = $ini = NULL;
56 include_once("ewiki.php");
60 #-- load and decipher .ini files
61 function ewiki_parse_ini_file($fn) {
62 return ewiki_parse_ini_str(@implode("",file($fn)));
64 function ewiki_parse_ini_str($s)
68 foreach (explode("\n", $s) as $line) {
70 if ($line[0] == "[") {
71 $sect = trim(strtok(substr($line, 1), "]"));
73 elseif (($line[0] == ";") || ($line[0] == "#")) {
75 elseif (strpos($line, "=")) {
76 $opt = trim(strtolower(strtok($line, "=")));
77 $val = trim(strtok("\r\n"));
78 $r[$sect][$opt][] = $val;