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 $fp = @fopen($this->INI_FILE_NAME,
"w");
198 $this->
error(
"Cannot create file $this->INI_FILE_NAME");
203 $result = fwrite($fp,
"; <?php exit; ?>\r\n");
206 $group_cnt = count($groups);
208 for ($i=0; $i<$group_cnt; $i++)
210 $group_name = $groups[$i];
214 $res = sprintf(
"[%s]\r\n",$group_name);
218 $res = sprintf(
"\r\n[%s]\r\n",$group_name);
224 for (reset($group); $key=key($group);next($group))
226 $res = sprintf(
"%s = %s\r\n",$key,
"\"".$group[$key].
"\"");
245 $group_cnt = count($groups);
251 for ($i=0; $i<$group_cnt; $i++)
253 $group_name = $groups[$i];
257 $content = sprintf(
"[%s]\n",$group_name);
261 $content .= sprintf(
"\n[%s]\n",$group_name);
267 for (reset($group); $key=key($group);next($group))
269 $content .= sprintf(
"%s = %s\n",$key,$group[$key]);
283 return count($this->GROUPS);
295 for (reset($this->GROUPS);$key=key($this->GROUPS);next($this->GROUPS))
311 if (!isset($this->GROUPS[$a_group_name]))
329 $this->
error(
"Group '".$a_group_name.
"' does not exist");
333 return $this->GROUPS[$a_group_name];
346 $this->
error(
"Group '".$a_group_name.
"' exists");
350 $this->GROUPS[$a_group_name] =
array();
364 $this->
error(
"Group '".$a_group_name.
"' does not exist");
368 unset($this->GROUPS[$a_group_name]);
381 return isset($this->GROUPS[$a_group][$a_var_name]);
394 if (!isset($this->GROUPS[$a_group][$a_var_name]))
396 $this->
error(
"'".$a_var_name.
"' does not exist in '".$a_group.
"'");
400 return trim($this->GROUPS[$a_group][$a_var_name]);
415 $this->
error(
"Group '".$a_group_name.
"' does not exist");
419 $this->GROUPS[$a_group_name][$a_var_name] = $a_var_value;
430 $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
__construct($a_ini_file_name)
Constructor 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
variableExists($a_group, $a_var_name)
returns if a variable exists or not public
error($a_errmsg)
set error message public
read()
read from ini file public
Create styles array
The data for the language used.
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