function fromPHPArray($str) { //first, strip the "array(" and ")" $startIndex = strpos($str, '(') + 1; $endIndex = strrpos($str, ')'); $str = substr($str, $startIndex, $endIndex - $startIndex); //convert to raw array $array = explode(", ", $str); //strip elements $stripArray = array(); foreach ($array as $entry) { array_push($stripArray, stripFromPHP($entry)); } //convert to simple semicolon-delimited array return implode(";", $stripArray); }
$fin = fopen('../config.php', 'r'); $options = array(); //try to find the options from the current configuration file while ($line = fgets($fin)) { $index = strpos($line, ' = '); if ($index !== FALSE) { $key = substr($line, 9, $index - 11); $val_start = $index + 3; $val_end = strrpos($line, ";"); //before the line's ending semicolon $val = substr($line, $val_start, $val_end - $val_start); if (in_array($key, $option_list) && !in_array($key, $hide_options)) { if (in_array($key, $array_options)) { $options[$key] = fromPHPArray($val); } else { $options[$key] = stripFromPHP($val); } } } } //now let the user edit other options not in config $counter = 0; foreach ($option_list as $option_name) { if (!array_key_exists($option_name, $options)) { $options[$option_name] = FALSE; //value of false denotes hidden type, show as password box } } get_page_advanced("man_config", "root", array('optionsMap' => $options, 'tabs' => $option_tabs, 'tab_list' => $display_tabs)); } else { header('Location: index.php');