/** $group and $id should normally both be specified, but if $group is only specified, then an array of all items in the group will be returned. */ function get_opendb_config_var($group, $id = NULL, $keyid = NULL) { if (is_opendb_configured()) { global $CONFIG_VARS; if ($group != NULL) { // override config value. if ($group == 'db_server' || $group == 'session_handler' || is_array($CONFIG_VARS[$group])) { // cached vars if ($id !== NULL && $keyid !== NULL) { return $CONFIG_VARS[$group][$id][$keyid]; } else { if ($id !== NULL) { return $CONFIG_VARS[$group][$id]; } else { return $CONFIG_VARS[$group]; } } // will return an array of all config items in group } else { $group_r = get_opendb_db_config_var($group); if (is_array($group_r)) { $CONFIG_VARS[$group] = $group_r; } if ($id !== NULL && $keyid !== NULL) { return $CONFIG_VARS[$group][$id][$keyid]; } else { if ($id !== NULL) { return $CONFIG_VARS[$group][$id]; } else { return $CONFIG_VARS[$group]; } } } } else { //if($group!=NULL) return NULL; } } else { return NULL; } }
/** Will return Group Block, including any subblocks */ function get_group_block($config_group_r) { global $PHP_SELF; global $ADMIN_TYPE; $buffer .= "<form name=\"config\" action=\"{$PHP_SELF}\" method=\"POST\">" . "<input type=\"hidden\" name=\"type\" value=\"" . $ADMIN_TYPE . "\">" . "<input type=\"hidden\" name=\"op\" value=\"save\">" . "<input type=\"hidden\" name=\"group_id\" value=\"" . $config_group_r['id'] . "\">"; $buffer .= "<ul class=\"saveButtons\">\n\t\t\t\t<li><input type=\"submit\" class=\"submit\" value=\"Refresh\" onclick=\"this.form['op'].value='';\"></li>\n\t\t\t\t<li><input type=\"submit\" class=\"submit\" value=\"Save\"></li>\n\t\t\t</ul>\n"; $buffer .= "<h3>" . $config_group_r['name'] . "</h3>\n"; if (strlen($config_group_r['description']) > 0) { $buffer .= $config_group_r['description']; } $buffer .= "<table>"; $results = fetch_s_config_group_item_rs($config_group_r['id']); if ($results) { while ($config_group_item_r = db_fetch_assoc($results)) { if (strpos($config_group_item_r['type'], 'array') !== FALSE) { $values_r = get_opendb_db_config_var($config_group_item_r['group_id'], $config_group_item_r['id']); } else { $values_r = get_opendb_db_config_var($config_group_item_r['group_id'], $config_group_item_r['id'], $config_group_item_r['keyid']); } $buffer .= "<tr>" . "\n<td class=\"prompt\">" . $config_group_item_r['prompt'] . " <a href=\"#\" onmouseover=\"show_tooltip('" . addslashes(str_replace('"', '"', $config_group_item_r['description'])) . "','" . addslashes($config_group_item_r['prompt']) . "');\" onmouseout=\"return hide_tooltip();\">(?)</a>:</td>" . "<td class=\"data\">" . get_group_block_input_field($config_group_item_r, $values_r) . "</td></tr>"; } db_free_result($results); } $buffer .= "</table>"; // now do any subgroups $results = fetch_s_config_subgroup_rs($config_group_r['id']); if ($results) { while ($config_subgroup_r = db_fetch_assoc($results)) { $buffer .= "<h3>" . $config_subgroup_r['name'] . "</h3>"; if (strlen($config_subgroup_r['description']) > 0) { $buffer .= $config_subgroup_r['description']; } $buffer .= "<table>"; $results2 = fetch_s_config_group_item_rs($config_subgroup_r['id']); if ($results2) { while ($config_group_item_r = db_fetch_assoc($results2)) { if (strpos($config_group_item_r['type'], 'array') !== FALSE) { $values_r = get_opendb_db_config_var($config_group_item_r['group_id'], $config_group_item_r['id']); } else { $values_r = get_opendb_db_config_var($config_group_item_r['group_id'], $config_group_item_r['id'], $config_group_item_r['keyid']); } $buffer .= "<tr>" . "\n<td class=\"prompt\">" . $config_group_item_r['prompt'] . "<a href=\"#\" onmouseover=\"show_tooltip('" . addslashes(str_replace('"', '"', $config_group_item_r['description'])) . "','" . addslashes($config_group_item_r['prompt']) . "');\" onmouseout=\"return hide_tooltip();\">(?)</a>:</td>" . "<td class=\"data\">" . get_group_block_input_field($config_group_item_r, $values_r) . "</td></tr>"; } db_free_result($results2); } $buffer .= "</table>"; } db_free_result($results); } $buffer .= "</form>"; return $buffer; }