76 if (empty($a_ini_file_name))
78 $this->
error(
"no_file_given");
82 $this->INI_FILE_NAME = $a_ini_file_name;
94 if (!file_exists($this->INI_FILE_NAME))
96 $this->
error(
"file_does_not_exist");
102 if ($this->
parse() ==
false)
119 $this->GROUPS = @parse_ini_file($this->INI_FILE_NAME,
true);
122 if ($this->GROUPS ==
false)
127 $this->GROUPS = @parse_ini_file($this->INI_FILE_NAME,
true);
128 if ($this->GROUPS ==
false)
130 $this->
error(
"file_not_accessible");
135 $temp = array_keys($this->GROUPS);
136 $this->CURRENT_GROUP = $temp[count($temp)-1];
148 $fp = @fopen($this->INI_FILE_NAME,
"r");
151 $l = fgets($fp, 4096);
153 if ((substr(
$l, 0, 2) ==
"/*" && $starttag) ||
154 substr(
$l, 0, 5) ==
"*/ ?>")
159 if (substr(
$l, 0, 5) ==
"<?php")
161 $l =
"; <?php exit; ?>";
166 $l = str_replace(
"\n",
"",
$l);
167 $l = str_replace(
"\r",
"",
$l);
174 $fp = @fopen($this->INI_FILE_NAME,
"w");
178 foreach ($lines as
$l)
180 fwrite($fp, $l.
"\r\n");
194 if (ereg(
"\[([[:alnum:]]+)\]",$a_data,
$out))
196 $this->CURRENT_GROUP= trim(
$out[1]);
198 elseif (!empty($a_data))
200 $split_data = split(
"=", $a_data);
213 $this->GROUPS = $a_data;
224 $fp = @fopen($this->INI_FILE_NAME,
"w");
228 $this->
error(
"Cannot create file $this->INI_FILE_NAME");
233 $result = fwrite($fp,
"; <?php exit; ?>\r\n");
236 $group_cnt = count($groups);
238 for ($i=0; $i<$group_cnt; $i++)
240 $group_name = $groups[$i];
244 $res = sprintf(
"[%s]\r\n",$group_name);
248 $res = sprintf(
"\r\n[%s]\r\n",$group_name);
254 for (reset($group); $key=key($group);next($group))
256 $res = sprintf(
"%s = %s\r\n",$key,
"\"".$group[$key].
"\"");
275 $group_cnt = count($groups);
281 for ($i=0; $i<$group_cnt; $i++)
283 $group_name = $groups[$i];
287 $content = sprintf(
"[%s]\n",$group_name);
291 $content .= sprintf(
"\n[%s]\n",$group_name);
297 for (reset($group); $key=key($group);next($group))
299 $content .= sprintf(
"%s = %s\n",$key,$group[$key]);
313 return count($this->GROUPS);
325 for (reset($this->GROUPS);$key=key($this->GROUPS);next($this->GROUPS))
341 if (!isset($this->GROUPS[$a_group_name]))
359 $this->
error(
"Group '".$a_group_name.
"' does not exist");
363 return $this->GROUPS[$a_group_name];
376 $this->
error(
"Group '".$a_group_name.
"' exists");
380 $this->GROUPS[$a_group_name] = array();
394 $this->
error(
"Group '".$a_group_name.
"' does not exist");
398 unset($this->GROUPS[$a_group_name]);
411 return isset($this->GROUPS[$a_group][$a_var_name]);
424 if (!isset($this->GROUPS[$a_group][$a_var_name]))
426 $this->
error(
"'".$a_var_name.
"' does not exist in '".$a_group.
"'");
430 return trim($this->GROUPS[$a_group][$a_var_name]);
445 $this->
error(
"Group '".$a_group_name.
"' does not exist");
449 $this->GROUPS[$a_group_name][$a_var_name] = $a_var_value;
460 $this->ERROR = $a_errmsg;
setVariable($a_group_name, $a_var_name, $a_var_value)
sets a variable in a group public
write()
save ini-file-data to filesystem private
readVariable($a_group, $a_var_name)
reads a single variable from a group public
getError()
returns error public
parse()
load and parse an inifile private
removeGroup($a_group_name)
removes a group public
show()
returns the content of IniFile public
getGroupCount()
returns number of groups public
ilIniFile($a_ini_file_name)
Constructor public.
variableExists($a_group, $a_var_name)
returns if a variable exists or not public
error($a_errmsg)
set error message public
setContent($a_data)
DESCRIPTION MISSING public.
read()
read from ini file public
groupExists($a_group_name)
checks if a group exists public
fixIniFile()
Fix ini file (make it compatible for PHP 5.3)
readGroups()
returns an array with the names of all the groups public
addGroup($a_group_name)
adds a new group public
readGroup($a_group_name)
returns an associative array of the variables in one group public
parse_data($a_data)
parse data private