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];
196 $res = sprintf(
"[%s]\r\n", $group_name);
198 $res = sprintf(
"\r\n[%s]\r\n", $group_name);
204 for (reset($group);
$key=key($group);next($group)) {
205 $res = sprintf(
"%s = %s\r\n",
$key,
"\"" . $group[
$key] .
"\"");
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)) {
243 $content .= sprintf(
"%s = %s\n",
$key, $group[
$key]);
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;
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
foreach($_POST as $key=> $value) $res
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