jablonka.czprosek.czf

websvn

Subversion Repositories:
[/] [include/] [accessfile.php] - Blame information for rev 3

 

Line No. Rev Author Line
11simandl<?php
2// WebSVN - Subversion repository viewing via the web using PHP
3// Copyright (C) 2004-2006 Tim Armes
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18//
19// --
20//
21// accessfile.php
22//
23// Read a .ini style file
24 
25class IniFile {
26 var $sections;
27 
28 // {{{ __construct
29 
30 function IniFile() {
31 $this->sections = array();
32 }
33 
34 // }}}
35 
36 // {{{ readIniFile
37 
38 function readIniFile($name) {
393simandl // does not use parse_ini_file function since php 5.3 does not support comment lines starting with #
401simandl $contents = file($name);
41 $cursection = '';
423simandl $curkey = '';
431simandl $first = true;
44 
453simandl foreach ($contents as $line) {
46 $line = rtrim($line);
47 $str = ltrim($line);
481simandl if (empty($str)) {
49 continue;
50 }
51 
523simandl // @todo remove ' in the next major release to be in line with the svn book
531simandl if ($str{0} == '#' or $str{0} == "'") {
54 continue;
55 }
56 
573simandl if ($str != $line && !empty($cursection) && !empty($curkey)) {
58 // line starts with whitespace
59 $this->sections[$cursection][$curkey] .= strtolower($str);
60 } else if ($str{0} == '[') {
611simandl $cursection = strtolower(substr($str, 1, strlen($str) - 2));
623simandl if (!($str{strlen($str) - 2} == '/' || $str == '[aliases]' || $str == '[groups]')) {
631simandl $cursection .= '/';
64 }
65 $first = true;
66 } else if (!empty($cursection)) {
673simandl if ($first) {
68 if (($cursection != 'aliases' && $cursection != 'groups') || !isset($this->sections[$cursection])) {
69 $this->sections[$cursection] = array();
70 }
711simandl }
723simandl list($key, $val) = explode('=', $str, 2);
73 $key = strtolower(trim($key));
74 $curkey = $key;
75 $this->sections[$cursection][$key] = strtolower(trim($val));
761simandl $first = false;
77 }
78 }
79 }
80 
81 // }}}
82 
83 // {{{ getSections
84 
85 function &getSections() {
86 return $this->sections;
87 }
88 
89 // }}}
90 
91 // {{{ getValues
92 
93 function getValues($section) {
94 return @$this->sections[strtolower($section)];
95 }
96 
97 // }}}
98 
99 // {{{ getValue
100 
101 function getValue($section, $key) {
102 return @$this->sections[strtolower($section)][strtolower($key)];
103 }
104 
105 // }}}
106}

Powered by WebSVN 2.2.1