diff --git a/lam/lib/profiles.inc b/lam/lib/profiles.inc index 138daa0d..164597ce 100644 --- a/lam/lib/profiles.inc +++ b/lam/lib/profiles.inc @@ -97,14 +97,13 @@ function loadUserProfile($profile) { // search keywords $parts = array(); $parts = split(": ", $line); - if (sizeof($parts) < 3) continue; // ignore malformed settings + if (sizeof($parts) != 2) continue; // ignore malformed settings else { - $module = array_shift($parts); - $option = array_shift($parts); - $values = $parts; + $option = $parts[0]; + $value = $parts[1]; // remove line ends - for ($i = 0; $i < sizeof($values); $i++) $values[$i] = chop($values[$i]); - $settings[$module][$option] = $values; + $value = chop($value); + $settings[$option] = explode("+::+", $value); } } fclose($file); @@ -135,14 +134,13 @@ function loadGroupProfile($profile) { // search keywords $parts = array(); $parts = split(": ", $line); - if (sizeof($parts) < 3) continue; // ignore malformed settings + if (sizeof($parts) != 2) continue; // ignore malformed settings else { - $module = array_shift($parts); - $option = array_shift($parts); - $values = $parts; + $option = $parts[0]; + $value = $parts[1]; // remove line ends - for ($i = 0; $i < sizeof($values); $i++) $values[$i] = chop($values[$i]); - $settings[$module][$option] = $values; + $value = chop($value); + $settings[$option] = explode("+::+", $value); } } fclose($file); @@ -173,14 +171,13 @@ function loadHostProfile($profile) { // search keywords $parts = array(); $parts = split(": ", $line); - if (sizeof($parts) < 3) continue; // ignore malformed settings + if (sizeof($parts) != 2) continue; // ignore malformed settings else { - $module = array_shift($parts); - $option = array_shift($parts); - $values = $parts; + $option = $parts[0]; + $value = $parts[1]; // remove line ends - for ($i = 0; $i < sizeof($values); $i++) $values[$i] = chop($values[$i]); - $settings[$module][$option] = $values; + $value = chop($value); + $settings[$option] = explode("+::+", $value); } } fclose($file); @@ -198,7 +195,7 @@ function loadHostProfile($profile) { // saves an hash array (attribute => value) to an user profile // file is created, if needed // $profile: name of the user profile (without .pru) -// $attributes: hash array(module => array(attribute => value)) +// $attributes: hash array(attribute => value) function saveUserProfile($attributes, $profile) { if (!$_SESSION['loggedIn'] == true) return false; // check profile name @@ -209,14 +206,11 @@ function saveUserProfile($attributes, $profile) { $path = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/users/" . $profile . ".pru"; $file = @fopen($path, "w"); if ($file) { - // write attributes - $modules = array_keys($attributes); - for ($m = 0; $m < sizeof($modules); $m++) { - $keys = array_keys($attributes[$modules[$m]]); - for ($i = 0; $i < sizeof($keys); $i++) { - $line = $modules[$m] . ": " . $keys[$i] . ": " . $attributes[$modules[$m]][$keys[$i]] . "\n"; - fputs($file, $line); - } + // write attributes + $keys = array_keys($attributes); + for ($i = 0; $i < sizeof($keys); $i++) { + $line = $keys[$i] . ": " . implode("+::+", $attributes[$keys[$i]]) . "\n"; + fputs($file, $line); } // close file fclose($file); @@ -231,7 +225,7 @@ function saveUserProfile($attributes, $profile) { // saves an hash array (attribute => value) to an group profile // file is created, if needed // $profile: name of the group profile (without .prg) -// $attributes: hash array(module => array(attribute => value)) +// $attributes: hash array(attribute => value) function saveGroupProfile($attributes, $profile) { if (!$_SESSION['loggedIn'] == true) return false; // check profile name @@ -243,13 +237,10 @@ function saveGroupProfile($attributes, $profile) { $file = @fopen($path, "w"); if ($file) { // write attributes - $modules = array_keys($attributes); - for ($m = 0; $m < sizeof($modules); $m++) { - $keys = array_keys($attributes[$modules[$m]]); - for ($i = 0; $i < sizeof($keys); $i++) { - $line = $modules[$m] . ": " . $keys[$i] . ": " . $attributes[$modules[$m]][$keys[$i]] . "\n"; - fputs($file, $line); - } + $keys = array_keys($attributes); + for ($i = 0; $i < sizeof($keys); $i++) { + $line = $keys[$i] . ": " . implode("+::+", $attributes[$keys[$i]]) . "\n"; + fputs($file, $line); } // close file fclose($file); @@ -264,7 +255,7 @@ function saveGroupProfile($attributes, $profile) { // saves an hash array (attribute => value) to an host profile // file is created, if needed // $profile: name of the host profile (without .prh) -// $attributes: hash array(module => array(attribute => value)) +// $attributes: hash array(attribute => value) function saveHostProfile($attributes, $profile) { if (!$_SESSION['loggedIn'] == true) return false; // check profile name @@ -276,13 +267,10 @@ function saveHostProfile($attributes, $profile) { $file = @fopen($path, "w"); if ($file) { // write attributes - $modules = array_keys($attributes); - for ($m = 0; $m < sizeof($modules); $m++) { - $keys = array_keys($attributes[$modules[$m]]); - for ($i = 0; $i < sizeof($keys); $i++) { - $line = $modules[$m] . ": " . $keys[$i] . ": " . $attributes[$modules[$m]][$keys[$i]] . "\n"; - fputs($file, $line); - } + $keys = array_keys($attributes); + for ($i = 0; $i < sizeof($keys); $i++) { + $line = $keys[$i] . ": " . implode("+::+", $attributes[$keys[$i]]) . "\n"; + fputs($file, $line); } // close file fclose($file);