76 if (empty($a_ini_file_name)) {
77 $this->
error(
"no_file_given");
81 $this->INI_FILE_NAME = $a_ini_file_name;
93 if (!file_exists($this->INI_FILE_NAME)) {
94 $this->
error(
"file_does_not_exist");
98 if ($this->
parse() ==
false) {
114 $this->GROUPS = @parse_ini_file($this->INI_FILE_NAME,
true);
117 if ($this->GROUPS ==
false) {
121 $this->GROUPS = @parse_ini_file($this->INI_FILE_NAME,
true);
122 if ($this->GROUPS ==
false) {
123 $this->
error(
"file_not_accessible");
128 $temp = array_keys($this->GROUPS);
129 $this->CURRENT_GROUP = $temp[count($temp)-1];
140 $fp = @fopen($this->INI_FILE_NAME,
"r");
142 $l = fgets($fp, 4096);
144 if ((substr(
$l, 0, 2) ==
"/*" && $starttag) ||
145 substr(
$l, 0, 5) ==
"*/ ?>") {
149 if (substr(
$l, 0, 5) ==
"<?php") {
150 $l =
"; <?php exit; ?>";
154 $l = str_replace(
"\n",
"",
$l);
155 $l = str_replace(
"\r",
"",
$l);
162 $fp = @fopen($this->INI_FILE_NAME,
"w");
165 foreach ($lines as
$l) {
166 fwrite($fp,
$l .
"\r\n");
179 $fp = @fopen($this->INI_FILE_NAME,
"w");
182 $this->
error(
"Cannot create file $this->INI_FILE_NAME");
187 $result = fwrite($fp,
"; <?php exit; ?>\r\n");
190 $group_cnt = count($groups);
192 for (
$i=0;
$i<$group_cnt;
$i++) {
193 $group_name = $groups[
$i];
204 for (reset($group);
$key=key($group);next($group)) {
224 $group_cnt = count($groups);
230 for (
$i=0;
$i<$group_cnt;
$i++) {
231 $group_name = $groups[
$i];
234 $content =
sprintf(
"[%s]\n", $group_name);
236 $content .=
sprintf(
"\n[%s]\n", $group_name);
242 for (reset($group);
$key=key($group);next($group)) {
257 return count($this->GROUPS);
269 for (reset($this->GROUPS);
$key=key($this->GROUPS);next($this->GROUPS)) {
284 if (!isset($this->GROUPS[$a_group_name])) {
300 $this->
error(
"Group '" . $a_group_name .
"' does not exist");
304 return $this->GROUPS[$a_group_name];
316 $this->
error(
"Group '" . $a_group_name .
"' exists");
320 $this->GROUPS[$a_group_name] = array();
333 $this->
error(
"Group '" . $a_group_name .
"' does not exist");
337 unset($this->GROUPS[$a_group_name]);
350 return isset($this->GROUPS[$a_group][$a_var_name]);
363 if (!isset($this->GROUPS[$a_group][$a_var_name])) {
364 $this->
error(
"'" . $a_var_name .
"' does not exist in '" . $a_group .
"'");
368 return trim($this->GROUPS[$a_group][$a_var_name]);
379 public function setVariable($a_group_name, $a_var_name, $a_var_value)
382 $this->
error(
"Group '" . $a_group_name .
"' does not exist");
386 $this->GROUPS[$a_group_name][$a_var_name] = $a_var_value;
397 $this->ERROR = $a_errmsg;
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
getError()
returns error @access public
show()
returns the content of IniFile @access public
readGroups()
returns an array with the names of all the groups @access public
variableExists($a_group, $a_var_name)
returns if a variable exists or not @access public
getGroupCount()
returns number of groups @access public
removeGroup($a_group_name)
removes a group @access public
readGroup($a_group_name)
returns an associative array of the variables in one group @access public
addGroup($a_group_name)
adds a new group @access public
readVariable($a_group, $a_var_name)
reads a single variable from a group @access public
setVariable($a_group_name, $a_var_name, $a_var_value)
sets a variable in a group @access public
groupExists($a_group_name)
checks if a group exists @access public
error($a_errmsg)
set error message @access public
fixIniFile()
Fix ini file (make it compatible for PHP 5.3)
write()
save ini-file-data to filesystem @access private
parse()
load and parse an inifile @access private
__construct($a_ini_file_name)
Constructor @access public.
read()
read from ini file @access public
foreach($_POST as $key=> $value) $res