{= # # # # # get_db_data.cfv # # # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; include "templates.util.encoding"; include "templates.util.bytes"; include "templates.config_pages.database.get_db_data_util"; string profile_name = internal.profile_name; string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); string page_token = v.fp.page_token; # # Check RBAC permissions # if ((is_root_admin or get_config_feature_permission(session_id, profile_name, "database", "view")) and get_is_valid_page_token(session_id, "database", page_token)) then ( bool is_windows = (_PLATFORM eq "Windows"); string dir_divider = (if is_windows then "\\" else "/"); string db_path = "profiles." . profile_name . ".database"; node db_options = db_path . ".options"; node db_options_server = db_options{"server"}; node db_tuning = db_path . ".tuning"; # # Handle automatically_update_when_older_than # # We modify the value and add a unit, so the initial seconds value may be shown in seconds, minutes, hours or days. # KHP 26/April/2010 - Disabled automatically_update_db in GUI but option is still valid in profile. #* int auto_update_db_seconds = @db_options{"automatically_update_when_older_than"}; int auto_update_db_value; string auto_update_db_unit; bool auto_update_db_active = false; bool validMinutes = false; bool validHours = false; bool validDays = false; if (auto_update_db_seconds > 0) then ( if (auto_update_db_seconds >= 60) then ( if ((auto_update_db_seconds % 60) == 0) then (validMinutes = true;); if (auto_update_db_seconds >= 3600) then ( if ((auto_update_db_seconds % 3600) == 0) then (validHours = true;); if (auto_update_db_seconds >= (3600 * 24) and (auto_update_db_seconds % (3600 * 24) == 0)) then ( validDays = true; ); ); ); auto_update_db_active = true; ); if (validDays) then ( auto_update_db_value = auto_update_db_seconds / (3600 * 24); auto_update_db_unit = 'days'; ) else if (validHours) then ( auto_update_db_value = auto_update_db_seconds / 3600; auto_update_db_unit = 'hours'; ) else if (validMinutes) then ( auto_update_db_value = auto_update_db_seconds / 60; auto_update_db_unit = 'minutes'; ) else ( # use seconds auto_update_db_value = auto_update_db_seconds; auto_update_db_unit = 'seconds'; ); *# # # # # Get profiles_dat # # # string profiles_dat = get_db_profiles_dat(profile_name); # # # # General dat # # # #* string general_dat = "{"; general_dat .= add_json("id", "i0", "string"); general_dat .= add_json("type", "database:general", "string"); general_dat .= add_json("label", lang_admin.database.general, "string"); # Create the auto_update_when_older_than dat which has special properties string auto_update_when_older_than_dat = "{"; auto_update_when_older_than_dat .= add_json("value", auto_update_db_value, "int"); auto_update_when_older_than_dat .= add_json("type", "time", "string"); auto_update_when_older_than_dat .= add_json("timeUnit", auto_update_db_unit, "string"); auto_update_when_older_than_dat .= add_json("isActive", auto_update_db_active, "bool"); auto_update_when_older_than_dat = close_json(auto_update_when_older_than_dat); string option_items_dat = "{"; option_items_dat .= add_json("automatically_update_when_older_than", auto_update_when_older_than_dat, "obj"); # option_items_dat .= get_db_option_dat("options", "prompt_before_erasing_database"); option_items_dat = close_json(option_items_dat); general_dat .= add_json("dat", option_items_dat, "obj"); general_dat = close_json(general_dat); *# # debug_message("\n#### general_dat:\n" . general_dat . "\n\n"); # # # # Server dat # # # string server_dat = "{"; server_dat .= add_json("id", "i1", "string"); server_dat .= add_json("type", "database:server", "string"); server_dat .= add_json("label", lang_admin.database.server, "string"); string server_items_dat = get_db_options_server_dat(db_options_server); server_dat .= add_json("dat", server_items_dat, "obj"); server_dat = close_json(server_dat); # # # # # Tuning 1 dat (general tuning) # # # # string tuning_1_dat = "{"; tuning_1_dat .= add_json("id", "i2", "string"); tuning_1_dat .= add_json("type", "database:tuning1", "string"); tuning_1_dat .= add_json("label", lang_admin.database.general_tuning, "string"); string tuning_1_items_dat = "{"; # tuning_1_items_dat .= get_db_option_dat("tuning", "update_xrefs_on_update"); KHP 20/Dec/2011 - deprecated # tuning_1_items_dat .= get_db_option_dat("tuning", "build_xref_tables_in_threads"); KHP 20/Dec/2011 - deprecated tuning_1_items_dat .= get_db_option_dat("tuning", "keep_itemnums_in_memory"); # tuning_1_items_dat .= get_db_option_dat("tuning", "build_all_indices_simultaneously"); KHP 12/Aug/2009 - disabled because option is currently not used # tuning_1_items_dat .= get_db_option_dat("tuning", "build_indices_during_log_processing"); KHP 16/Feb/2009 - disabled because option is currently not used # tuning_1_items_dat .= get_db_option_dat("tuning", "build_all_xref_tables_simultaneously"); KHP 12/Aug/2009 - disabled because option is currently not used # tuning_1_items_dat .= get_db_option_dat("tuning", "build_xref_tables_and_indices_simultaneously"); KHP 12/Aug/2009 - disabled because option is currently not used # tuning_1_items_dat .= get_db_option_dat("tuning", "build_xref_tables_during_log_processing"); KHP 16/Feb/2009 - disabled because option is currently not used # tuning_1_items_dat .= get_db_option_dat("tuning", "build_indices_in_threads"); KHP 12/Aug/2009 - disabled because option is currently not used # tuning_1_items_dat .= get_db_option_dat("tuning", "build_indices_in_memory"); KHP 16/Feb/2009 - disabled because option is currently not used tuning_1_items_dat .= get_db_tuning_split_queries_dat(db_tuning); tuning_1_items_dat = close_json(tuning_1_items_dat); tuning_1_dat .= add_json("dat", tuning_1_items_dat, "obj"); tuning_1_dat = close_json(tuning_1_dat); # # # # # Tuning 2 dat (sizes tuning) # # # # string tuning_2_dat = "{"; tuning_2_dat .= add_json("id", "i3", "string"); tuning_2_dat .= add_json("type", "database:tuning2", "string"); tuning_2_dat .= add_json("label", lang_admin.database.sizes_tuning, "string"); # Note, we need a new array in the object because most options require # a value and byteUnit property! string tuning_2_items_dat = "{"; tuning_2_items_dat .= get_db_option_dat("tuning", "list_cache_size"); tuning_2_items_dat .= get_db_option_dat("tuning", "maximum_xref_segment_merge_size"); # tuning_2_items_dat .= get_db_option_dat("tuning", "hash_table_starting_size"); KHP 21/July/2010 - disabled # tuning_2_items_dat .= get_db_option_dat("tuning", "hash_table_expansion_factor"); KHP 21/July/2010 - disabled # tuning_2_items_dat .= get_db_option_dat("tuning", "hash_table_surplus_factor"); KHP 21/July/2010 - disabled # tuning_2_items_dat .= get_db_option_dat("tuning", "maximum_main_table_segment_size"); KHP 08/Dec/2010 - disabled tuning_2_items_dat .= get_db_option_dat("tuning", "maximum_paging_caching_buffer_full_load"); tuning_2_items_dat = close_json(tuning_2_items_dat); tuning_2_dat .= add_json("dat", tuning_2_items_dat, "obj"); tuning_2_dat = close_json(tuning_2_dat); # # Response # string items_dat = "["; # items_dat .= general_dat . ","; items_dat .= server_dat . ","; items_dat .= tuning_1_dat . ","; items_dat .= tuning_2_dat . "]"; string dat = "{"; dat .= add_json("isWindows", is_windows, "string"); dat .= add_json("dirDivider", dir_divider, "string"); dat .= add_json("haveMYSQL", internal.HAVE_MYSQL, "bool"); dat .= add_json("haveODBC", internal.HAVE_ODBC, "bool"); dat .= add_json("profilesDb", profiles_dat, "obj"); dat .= add_json("itemsDb", items_dat, "obj"); dat = close_json(dat); debug_message("#### dat:\n" . dat . "\n"); 'database.getDatabaseDataResponse(' . dat . ')'; ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); =}