attributes are no longer seperated by modules,
attributes are returned as arrays
This commit is contained in:
parent
0902c105ef
commit
b8f5597679
|
@ -97,14 +97,13 @@ function loadUserProfile($profile) {
|
||||||
// search keywords
|
// search keywords
|
||||||
$parts = array();
|
$parts = array();
|
||||||
$parts = split(": ", $line);
|
$parts = split(": ", $line);
|
||||||
if (sizeof($parts) < 3) continue; // ignore malformed settings
|
if (sizeof($parts) != 2) continue; // ignore malformed settings
|
||||||
else {
|
else {
|
||||||
$module = array_shift($parts);
|
$option = $parts[0];
|
||||||
$option = array_shift($parts);
|
$value = $parts[1];
|
||||||
$values = $parts;
|
|
||||||
// remove line ends
|
// remove line ends
|
||||||
for ($i = 0; $i < sizeof($values); $i++) $values[$i] = chop($values[$i]);
|
$value = chop($value);
|
||||||
$settings[$module][$option] = $values;
|
$settings[$option] = explode("+::+", $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
@ -135,14 +134,13 @@ function loadGroupProfile($profile) {
|
||||||
// search keywords
|
// search keywords
|
||||||
$parts = array();
|
$parts = array();
|
||||||
$parts = split(": ", $line);
|
$parts = split(": ", $line);
|
||||||
if (sizeof($parts) < 3) continue; // ignore malformed settings
|
if (sizeof($parts) != 2) continue; // ignore malformed settings
|
||||||
else {
|
else {
|
||||||
$module = array_shift($parts);
|
$option = $parts[0];
|
||||||
$option = array_shift($parts);
|
$value = $parts[1];
|
||||||
$values = $parts;
|
|
||||||
// remove line ends
|
// remove line ends
|
||||||
for ($i = 0; $i < sizeof($values); $i++) $values[$i] = chop($values[$i]);
|
$value = chop($value);
|
||||||
$settings[$module][$option] = $values;
|
$settings[$option] = explode("+::+", $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
@ -173,14 +171,13 @@ function loadHostProfile($profile) {
|
||||||
// search keywords
|
// search keywords
|
||||||
$parts = array();
|
$parts = array();
|
||||||
$parts = split(": ", $line);
|
$parts = split(": ", $line);
|
||||||
if (sizeof($parts) < 3) continue; // ignore malformed settings
|
if (sizeof($parts) != 2) continue; // ignore malformed settings
|
||||||
else {
|
else {
|
||||||
$module = array_shift($parts);
|
$option = $parts[0];
|
||||||
$option = array_shift($parts);
|
$value = $parts[1];
|
||||||
$values = $parts;
|
|
||||||
// remove line ends
|
// remove line ends
|
||||||
for ($i = 0; $i < sizeof($values); $i++) $values[$i] = chop($values[$i]);
|
$value = chop($value);
|
||||||
$settings[$module][$option] = $values;
|
$settings[$option] = explode("+::+", $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
@ -198,7 +195,7 @@ function loadHostProfile($profile) {
|
||||||
// saves an hash array (attribute => value) to an user profile
|
// saves an hash array (attribute => value) to an user profile
|
||||||
// file is created, if needed
|
// file is created, if needed
|
||||||
// $profile: name of the user profile (without .pru)
|
// $profile: name of the user profile (without .pru)
|
||||||
// $attributes: hash array(module => array(attribute => value))
|
// $attributes: hash array(attribute => value)
|
||||||
function saveUserProfile($attributes, $profile) {
|
function saveUserProfile($attributes, $profile) {
|
||||||
if (!$_SESSION['loggedIn'] == true) return false;
|
if (!$_SESSION['loggedIn'] == true) return false;
|
||||||
// check profile name
|
// check profile name
|
||||||
|
@ -209,14 +206,11 @@ function saveUserProfile($attributes, $profile) {
|
||||||
$path = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/users/" . $profile . ".pru";
|
$path = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/users/" . $profile . ".pru";
|
||||||
$file = @fopen($path, "w");
|
$file = @fopen($path, "w");
|
||||||
if ($file) {
|
if ($file) {
|
||||||
// write attributes
|
// write attributes
|
||||||
$modules = array_keys($attributes);
|
$keys = array_keys($attributes);
|
||||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
for ($i = 0; $i < sizeof($keys); $i++) {
|
||||||
$keys = array_keys($attributes[$modules[$m]]);
|
$line = $keys[$i] . ": " . implode("+::+", $attributes[$keys[$i]]) . "\n";
|
||||||
for ($i = 0; $i < sizeof($keys); $i++) {
|
fputs($file, $line);
|
||||||
$line = $modules[$m] . ": " . $keys[$i] . ": " . $attributes[$modules[$m]][$keys[$i]] . "\n";
|
|
||||||
fputs($file, $line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// close file
|
// close file
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
@ -231,7 +225,7 @@ function saveUserProfile($attributes, $profile) {
|
||||||
// saves an hash array (attribute => value) to an group profile
|
// saves an hash array (attribute => value) to an group profile
|
||||||
// file is created, if needed
|
// file is created, if needed
|
||||||
// $profile: name of the group profile (without .prg)
|
// $profile: name of the group profile (without .prg)
|
||||||
// $attributes: hash array(module => array(attribute => value))
|
// $attributes: hash array(attribute => value)
|
||||||
function saveGroupProfile($attributes, $profile) {
|
function saveGroupProfile($attributes, $profile) {
|
||||||
if (!$_SESSION['loggedIn'] == true) return false;
|
if (!$_SESSION['loggedIn'] == true) return false;
|
||||||
// check profile name
|
// check profile name
|
||||||
|
@ -243,13 +237,10 @@ function saveGroupProfile($attributes, $profile) {
|
||||||
$file = @fopen($path, "w");
|
$file = @fopen($path, "w");
|
||||||
if ($file) {
|
if ($file) {
|
||||||
// write attributes
|
// write attributes
|
||||||
$modules = array_keys($attributes);
|
$keys = array_keys($attributes);
|
||||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
for ($i = 0; $i < sizeof($keys); $i++) {
|
||||||
$keys = array_keys($attributes[$modules[$m]]);
|
$line = $keys[$i] . ": " . implode("+::+", $attributes[$keys[$i]]) . "\n";
|
||||||
for ($i = 0; $i < sizeof($keys); $i++) {
|
fputs($file, $line);
|
||||||
$line = $modules[$m] . ": " . $keys[$i] . ": " . $attributes[$modules[$m]][$keys[$i]] . "\n";
|
|
||||||
fputs($file, $line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// close file
|
// close file
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
@ -264,7 +255,7 @@ function saveGroupProfile($attributes, $profile) {
|
||||||
// saves an hash array (attribute => value) to an host profile
|
// saves an hash array (attribute => value) to an host profile
|
||||||
// file is created, if needed
|
// file is created, if needed
|
||||||
// $profile: name of the host profile (without .prh)
|
// $profile: name of the host profile (without .prh)
|
||||||
// $attributes: hash array(module => array(attribute => value))
|
// $attributes: hash array(attribute => value)
|
||||||
function saveHostProfile($attributes, $profile) {
|
function saveHostProfile($attributes, $profile) {
|
||||||
if (!$_SESSION['loggedIn'] == true) return false;
|
if (!$_SESSION['loggedIn'] == true) return false;
|
||||||
// check profile name
|
// check profile name
|
||||||
|
@ -276,13 +267,10 @@ function saveHostProfile($attributes, $profile) {
|
||||||
$file = @fopen($path, "w");
|
$file = @fopen($path, "w");
|
||||||
if ($file) {
|
if ($file) {
|
||||||
// write attributes
|
// write attributes
|
||||||
$modules = array_keys($attributes);
|
$keys = array_keys($attributes);
|
||||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
for ($i = 0; $i < sizeof($keys); $i++) {
|
||||||
$keys = array_keys($attributes[$modules[$m]]);
|
$line = $keys[$i] . ": " . implode("+::+", $attributes[$keys[$i]]) . "\n";
|
||||||
for ($i = 0; $i < sizeof($keys); $i++) {
|
fputs($file, $line);
|
||||||
$line = $modules[$m] . ": " . $keys[$i] . ": " . $attributes[$modules[$m]][$keys[$i]] . "\n";
|
|
||||||
fputs($file, $line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// close file
|
// close file
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
|
Loading…
Reference in New Issue