sections = array(); } // }}} // {{{ readIniFile function readIniFile($name) { // does not use parse_ini_file function since php 5.3 does not support comment lines starting with # $contents = file($name); $cursection = ''; $curkey = ''; foreach ($contents as $line) { $line = rtrim($line); $str = ltrim($line); if (empty($str)) { continue; } // @todo remove ' in the next major release to be in line with the svn book if ($str{0} == '#' || $str{0} == "'") { continue; } if ($str != $line && !empty($cursection) && !empty($curkey)) { // line starts with whitespace $this->sections[$cursection][$curkey] .= strtolower($str); } else if ($str{0} == '[' && $str{strlen($str) - 1} == ']') { $cursection = strtolower(substr($str, 1, strlen($str) - 2)); } else if (!empty($cursection)) { if (!isset($this->sections[$cursection])) { $this->sections[$cursection] = array(); } list($key, $val) = explode('=', $str, 2); $key = strtolower(trim($key)); $curkey = $key; if ($cursection == 'groups' && isset($this->sections[$cursection][$key])) { $this->sections[$cursection][$key] .= ',' . strtolower(trim($val)); } else { $this->sections[$cursection][$key] = strtolower(trim($val)); } } } } // }}} // {{{ getSections function &getSections() { return $this->sections; } // }}} // {{{ getValues function getValues($section) { return @$this->sections[strtolower($section)]; } // }}} // {{{ getValue function getValue($section, $key) { return @$this->sections[strtolower($section)][strtolower($key)]; } // }}} }