73 if (empty($a_ini_file_name))
75 $this->
error(
"no_file_given");
79 $this->INI_FILE_NAME = $a_ini_file_name;
91 if (!file_exists($this->INI_FILE_NAME))
93 $this->
error(
"file_does_not_exist");
99 if ($this->
parse() ==
false)
116 $this->GROUPS = @parse_ini_file($this->INI_FILE_NAME,
true);
119 if ($this->GROUPS ==
false)
124 $this->GROUPS = @parse_ini_file($this->INI_FILE_NAME,
true);
125 if ($this->GROUPS ==
false)
127 $this->
error(
"file_not_accessible");
132 $temp = array_keys($this->GROUPS);
133 $this->CURRENT_GROUP = $temp[count($temp)-1];
145 $fp = @fopen($this->INI_FILE_NAME,
"r");
148 $l = fgets($fp, 4096);
150 if ((substr($l, 0, 2) ==
"/*" && $starttag) ||
151 substr($l, 0, 5) ==
"*/ ?>")
156 if (substr($l, 0, 5) ==
"<?php")
158 $l =
"; <?php exit; ?>";
163 $l = str_replace(
"\n",
"", $l);
164 $l = str_replace(
"\r",
"", $l);
171 $fp = @fopen($this->INI_FILE_NAME,
"w");
175 foreach ($lines as $l)
177 fwrite($fp, $l.
"\r\n");
191 if (ereg(
"\[([[:alnum:]]+)\]",$a_data,
$out))
193 $this->CURRENT_GROUP= trim(
$out[1]);
195 elseif (!empty($a_data))
197 $split_data = split(
"=", $a_data);
210 $this->GROUPS = $a_data;
221 $fp = @fopen($this->INI_FILE_NAME,
"w");
225 $this->
error(
"Cannot create file $this->INI_FILE_NAME");
230 $result = fwrite($fp,
"; <?php exit; ?>\r\n");
233 $group_cnt = count($groups);
235 for ($i=0; $i<$group_cnt; $i++)
237 $group_name = $groups[$i];
241 $res = sprintf(
"[%s]\r\n",$group_name);
245 $res = sprintf(
"\r\n[%s]\r\n",$group_name);
251 for (reset($group); $key=key($group);next($group))
253 $res = sprintf(
"%s = %s\r\n",$key,
"\"".$group[$key].
"\"");
272 $group_cnt = count($groups);
278 for ($i=0; $i<$group_cnt; $i++)
280 $group_name = $groups[$i];
284 $content = sprintf(
"[%s]\n",$group_name);
288 $content .= sprintf(
"\n[%s]\n",$group_name);
294 for (reset($group); $key=key($group);next($group))
296 $content .= sprintf(
"%s = %s\n",$key,$group[$key]);
310 return count($this->GROUPS);
322 for (reset($this->GROUPS);$key=key($this->GROUPS);next($this->GROUPS))
338 if (!isset($this->GROUPS[$a_group_name]))
356 $this->
error(
"Group '".$a_group_name.
"' does not exist");
360 return $this->GROUPS[$a_group_name];
373 $this->
error(
"Group '".$a_group_name.
"' exists");
377 $this->GROUPS[$a_group_name] = array();
391 $this->
error(
"Group '".$a_group_name.
"' does not exist");
395 unset($this->GROUPS[$a_group_name]);
408 return isset($this->GROUPS[$a_group][$a_var_name]);
421 if (!isset($this->GROUPS[$a_group][$a_var_name]))
423 $this->
error(
"'".$a_var_name.
"' does not exist in '".$a_group.
"'");
427 return trim($this->GROUPS[$a_group][$a_var_name]);
442 $this->
error(
"Group '".$a_group_name.
"' does not exist");
446 $this->GROUPS[$a_group_name][$a_var_name] = $a_var_value;
457 $this->ERROR = $a_errmsg;