Source for file mvblog_inifilereader.php
Documentation is available at mvblog_inifilereader.php
* MvBlog -- An open source no-nosense blogtool
* Copyright (C) 2005-2007, Michiel van Baak
* Michiel van Baak <mvanbaak@users.sourceforge.net>
* See http://www.mvblog.org for more information on MvBlog.
* That page also provides Bugtrackers, Filereleases etc.
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
* @copyright 2005-2007 Ferry Boender
* Class to read an ini file
* @var string $filename The ini file to read
public function __construct($availSettings, $filename) {
$settings =
$this->parse($contents);
protected function read($filename) {
// Custom parser so we get file &line numbers
protected function parse($contents) {
// Find and replace dos line endings
// Find and replace mac line endings
$contents =
explode("\n", $contents);
for ($i =
0; $i <
count($contents); $i++
) {
if (preg_match('/^\[(.*?)\]*$/', $contents[$i], $match)) {
if (!preg_match("/^\s*#.*$/", $contents[$i]) &&
// Comment
preg_match('/^\s*(.*?)\s*=\s*(.*?)\s*$/', $contents[$i], $match)) {
$settings[$section][] =
array("key" =>
$key, "value" =>
$value, "line" =>
$i);
foreach ($settings as $section =>
$data) {
foreach($data as $setting) {
$value =
$setting["value"];
$line =
$setting["line"];
throw
new mvblog_IniFileReaderException(3, $value, $key, $type, $section, $file, $line);
Documentation generated on Fri, 28 Dec 2007 13:17:40 +0100 by phpDocumentor 1.4.1