cacti function

9 篇文章 0 订阅
5 篇文章 0 订阅

1 include

1.1 global_arrays_php

后期的汉化工作可以从此入手

global先引入项目基础数组,在通过api_plugin_hook('config_arrays')引入pa以及plugin自定义的数组,具体调用过程是去plugin_hooks表中查询处所有hook=config_arrays的记录,然后调用他们的function字段的方法。
其中pa的例子如下:
调用了plugin_config_arrays方法,添加了$menu['Configuration']['plugins.php'] = 'Plugin Management';
以及api_plugin_load_realms();用户插件的认证范围
array_namechineseposition
$menu菜单
$messages
$cdef_operatorscdef操作符
$cdef_functionscdef数学函数
$input_typesdataInput类型
$reindex_typesdataQuery类型
$snmp_query_field_actionssnmp查询字段行为
$consolidation_functions合并方法
$data_source_typesdataSource类型
$graph_item_types绘制图片类型
$image_types图片格式
$snmp_versionssnmp版本
$snmp_auth_protocolssnmp认证协议
$snmp_priv_protocolssnmp权限协议
$banned_snmp_strings禁止snmp的提示字符串
$logfile_options日志文件选项
$availability_options可用选项
$ping_methodsping方法
$logfile_verbosity日志文件常用提示
$poller_options轮训选项
$poller_intervals轮训间隔
$device_threads设备线程
$cron_intervals定时任务间隔
$registered_cacti_names注册cacti名称
$graph_views图片视图
$graph_tree_views图片树形视图
$auth_methods认证方式
$auth_realms认证范围
$ldap_versionsldap版本
$ldap_encryptionldap加密方式
$ldap_modesldap模式
$snmp_implimentationssnmp连接方式
$rrdtool_versionsrrdtool版本
$cdef_item_typescdef选项类型
$graph_color_alpha图片颜色透明度
$tree_sort_types树形排序类型
$tree_item_types树形节点类型
$host_group_typeshost分组类型
$custom_data_source_types自定义dataSource类型
$log_tail_lines日志文件结尾行数
$item_rows行数选项
$graphs_per_page每页图片数
$page_refresh_interval页面刷新间隔
$user_auth_realms用户认证范围
$user_auth_realm_filenames用户认证范围文件名
$hash_type_codes散列类型代码
$hash_version_codes散列版本代码
$hash_type_names散列类型名称
$host_struchost结构
$graph_timespans图片时间元素
$graph_timeshifts图片时间切换
$graph_weekdays图片周日期
$graph_dateformats图片日期格式
$graph_datechar图片日期间隔符
$plugin_architecturepa版本

1.2 global_settings_php

与global_arrays类似,
global先引入项目settings基础数组,在通过api_plugin_hook('config_settings')引入pa以及plugin的settings数组,
namechineseposition
$tabssetting的tabsetting页面
$tabs_graphssetting的tag图片setting页面
$settings所有设置选项setting页面
$settings_graphs所有设置选项控件类型等setting页面

1.3 global_form_php

定义了一个VALID_HOST_FIELDS
有效的host字段
包括

(hostname|host_id|snmp_community|snmp_username|snmp_password|snmp_auth_protocol|snmp_priv_passphrase|snmp_priv_protocol|snmp_context|snmp_version|snmp_port|snmp_timeout)
通过定义所有的form数组好处是:可以统一一套array,真正绘制input的时候可以调用inject_form_variables()来防止input的所有属性的inject注入,过滤非法字符等,然后通过定义的draw_edit_form,来统一绘制form表单的所有input

最后调用了一个api_plugin_hook(‘config_form’);
此过程和grobal_array以及global_form相同,这里不再赘述;

namechineseposition
$fields_cdef_editfile: cdef.php, action: edit
$fields_color_editfile: color.php, action: edit
$fields_data_input_editfile: data_input.php, action: edit
$fields_data_input_field_edit_1file: data_input.php, action: field_edit (dropdown)
$fields_data_input_field_edit_2file: data_input.php, action: field_edit (textbox)
$fields_data_input_field_editfile: data_input.php, action: field_edit
$fields_data_template_template_editfile: data_templates.php, action: template_edit
$struct_data_sourcefile: (data_sources.php|data_templates.php), action: (ds/template)_edit
$struct_data_source_itemfile: (data_sources.php|data_templates.php), action: (ds/template)_edit
$fields_grprint_presets_editfile: grprint_presets.php, action: edit
$struct_graphfile: (graphs.php/graph_templates.php), action: (graph/template)_edit
$struct_graph_itemfile: (graphs.php/graph_templates.php), action: item_edit
$fields_graph_template_template_editfile: graph_templates.php, action: template_edit
$fields_graph_template_input_editfile: graph_templates.php, action: input_edit
$fields_host_editfile: host.php, action: edit
$fields_host_template_editfile: host_templates.php, action: edit
$fields_rra_editfile: rra.php, action: edit
$fields_data_query_editfile: data_queries.php, action: edit
$fields_data_query_item_editfile: data_queries.php, action: item_edit
$fields_tree_editfile: tree.php, action: edit
$fields_user_user_edit_hostfile: user_admin.php, action: user_edit (host)
$export_typesall
$fields_template_importall

2 lib

2.1 html_php

包含了所有组装控件的方法,即function

nameparamfunction
html_start_box$title,
$width, $background_color, $cell_padding, $align, $add_text
draws the start of an HTML box with an optional title
html_end_box$trailing_br = truedraws the end of an HTML box
html_graph_start_box$cellpadding = 3, $leading_br = truedraws the start of an HTML graph view box
html_graph_end_box/draws the end of an HTML graph view box
html_graph_area&$graph_array, $no_graphs_message = “”,
$extra_url_args = “”, $header = “”
draws an area the contains full sized graphs
html_graph_thumbnail_area&$graph_array, $no_graphs_message = “”,
$extra_url_args = “”, $header = “”
draws an area the contains thumbnail sized graphs
html_nav_bar$background_color, $colspan, $current_page, $rows_per_page, $total_rows, $nav_urldraws a navigation bar which includes previous/next links as well as currentpage information
html_header_sort$header_items, $sort_column, $sort_direction, $last_item_colspan = 1draws a header row suitable for display inside of a box element. When a user selects a column header, the collback function “filename” will be called to handle the sort the column and display the altered results.
html_header_sort_checkbox$header_items, $sort_column, $sort_direction, $include_form = true,
$form_action = “”
draws a header row with a ‘select all’ checkbox in the last cell suitable for display inside of a box element. When a user selects a column header, the collback function “filename” will be called to handle the sort the column and display the altered results.
html_header$header_items, $last_item_colspan = 1draws a header row suitable for display inside of a box element
html_header_checkbox$header_items, $include_form = true,
$form_action = “”
draws a header row with a ‘select all’ checkbox in the last cell suitable for display inside of a box element
html_create_list$form_data, $column_display, $column_id, $form_previous_valuedraws the items for an html dropdown given an array of data
html_split_string$string,
$length = 70,
$forgiveness = 10
takes a string and breaks it into a number of
separated segments
draw_graph_items_list$item_list,
$filename,
$url_data, $disable_controls
draws a nicely formatted list of graph items for display on an edit form
draw_menu/draw_menu - draws the cacti menu for display in the console
draw_actions_dropdown$actions_arraydraws a table the allows the user to select an action to perform on one or more data elements
DrawMatrixHeaderItem$matrix_name, $matrix_text_color, $column_span = 1Deprecated functions
form_area//

2.2 html_form_php

包含了所有组装包含form控件的方法,即function

nameparamfunction
draw_edit_form$arraydraws an html edit form
draw_edit_control$field_name, &$field_arraydraws a single control to be used on an html edit form
form_file$form_name,
$form_size = 30
draws a standard html file input element
form_filepath_box$form_name,
$form_previous_value,
$form_default_value,
$form_max_length,
$form_size = 30,
$type = “text”,
$current_id = 0
draws a standard html textbox and provides status of a files existence
form_dirpath_box$form_name,
$form_previous_value,
$form_default_value,
$form_max_length,
$form_size = 30,
$type = “text”,
$current_id = 0
draws a standard html textbox and provides status of a directories existence
form_text_box$form_name,
$form_previous_value,
$form_default_value,
$form_max_length,
$form_size = 30,
$type = “text”,
$current_id = 0
draws a standard html textbox
form_hidden_box$form_name,
$form_previous_value,
$form_default_value
draws a standard html hidden element
form_dropdown$form_name,
$form_data,
$column_display,
$column_id,
$form_previous_value,
$form_none_entry,
$form_default_value,
$class = “”,
$on_change = “”
draws a standard html dropdown box
form_checkbox$form_name,
$form_previous_value,
$form_caption,
$form_default_value,
$current_id = 0,
$class = “”,
$on_change = “”
draws a standard html checkbox
form_radio_button$form_name,
$form_previous_value,
$form_current_value,
$form_caption,
$form_default_value,
$class = “”,
$on_change = “”
draws a standard html radio button
form_text_area$form_name,
$form_previous_value,
$form_rows,
$form_columns,
$form_default_value,
$class = “”,
$on_change = “”
draws a standard html text area box
form_multi_dropdown$form_name,
$array_display,
$sql_previous_values,
$column_id,
$class = “”,
$on_change = “”
draws a standard html multiple select dropdown
form_color_dropdown$form_name,
$form_previous_value,
$form_none_entry,
$form_default_value,
$class = “”,
$on_change = “”
draws a dropdown containing a list of colors that uses a bit of css magic to make the dropdown item background color represent each color in the list
form_font_box$form_name,
$form_previous_value,
$form_default_value,
$form_max_length,
$form_size = 30,
$type = “text”,
$current_id = 0
draws a standard html textbox and provides status of a fonts existence
form_confirm$title_text,
$body_text,
$cancel_url,
$action_url
draws a table presenting the user with some choice and allowing them to either proceed (delete) or cancel
form_confirm_buttons$action_url,
$cancel_url
draws a cancel and delete button suitable for display on a confirmation form
form_save_button$cancel_url,
$force_type = “”,
$key_field = “id”
draws a (save/create) and cancel button at the bottom of an html edit form

2.3 html_utility_php

nameparamfunction
inject_form_variables&$form_array,
$arg1=array(),
$arg2=array(),
$arg3=array(),
$arg4=array()
replaces all variables contained in $form_array with their actual values
form_alternate_row_color$row_color1,
$row_color2,
$row_value,
$row_id = “”
starts an HTML row with an alternating color scheme
form_selectable_cell$contents,
$id,
$width=”“,
$style=”“
format’s a table row such that it can be highlighted using cacti’s js actions
form_checkbox_cell$title,
$id
format’s a tables checkbox form element so that the cacti js actions work on it
form_end_row/ends a table row that is started with form_alternate_row
html_boolean$html_booleanreturns the boolean equivalent of an HTML checkbox value
html_boolean_friendly$html_booleanreturns the natural language equivalent of an HTML checkbox value
get_checkbox_style/finds the proper CSS padding to apply based on the current client browser in use
get_request_var$name,
$default = “”
returns the current value of a PHP $_GET variable, optionallyreturning a default value if the request variable does not exist
get_request_var_post$name,
$default = “”
returns the current value of a PHP $_POST variable, optionally returning a default value if the request variable does not exist
get_request_var_request$name,
$default = “”
returns the current value of a PHP $_POST variable, optionally returning a default value if the request variable does not exist
load_current_session_value$request_var_name,
$session_var_name,
$default_value
finds the correct value of a variable that is being cached as a session variable on an HTML form
get_colored_device_status$disabled,
$status
given a device’s status, return the colored text in HTML format suitable for display
get_current_graph_start/determine the correct graph start time selected using the timespan selector
get_current_graph_end/determine the correct graph end time selected using the timespan selector
get_page_list$current_page,
$pages_per_screen,
$rows_per_page,
$total_rows, $url,
$page_var = “page”
generates the html necessary to present the user with a list of pages limited in length and number of rows per page

2.4 html_validate_php

html表单验证类

nameparamfunction
input_validate_input_equals$value,
$c_value
验证两个input的值是否相等,使用的是!=,是strict比较
input_validate_input_number$value验证是否是数字
input_validate_input_regex$value,
$regex
验证value是否匹配传入的正则
die_html_input_error/输出Validation error

2.5 variables_php

variables.php浅析:
正如它内部的function name一样,它的功能就是更新的data_source_title_cache以及graph_title_cachedata_source_title_cache就是data_template_data表中的name_cache字段,至于更新的原因则是与name字段解析同步。(具体参考表中对该字段的注释)
同理graph_title_cache就是graph_template_graph表中的title和title_cache字段。
nameparamfunction
update
_data_source_title_cache
_from_template
$data_template_idupdates the title cache for all data sources that match a given data template
update
_data_source_title_cache
_from_query
$snmp_query_id,
$snmp_index
updates the title cache for all data sources that match a given data query/index combination
update
_data_source_title_cache
_from_host
$host_idupdates the title cache for all data sources that match a given host
update
_data_source_title_cache
$local_data_idupdates the title cache for a single data source
update
_graph_title_cache
_from_template
$graph_template_idupdates the title cache for all graphs that match a given graph template
update
_graph_title_cache
_from_query
$snmp_query_id,
$snmp_index
updates the title cache for all graphs that match a given data query/index combination
update_graph_title_cache
_from_host
$host_idupdates the title cache for all graphs that match a given host
update
_graph_title_cache
$local_graph_idupdates the title cache for a single graph
null_out_substitutions$stringtakes a string and cleans out any host variables that do not have values
expand_title$host_id,
$snmp_query_id,
$snmp_index,
$title
takes a string and substitutes all data query variables contained in it or cleans them out if no data query is in use
substitute
_script_query_path
$pathtakes a string and substitutes all path variables contained in it
substitute
_host_data
$string,
$l_escape_string,
$r_escape_string,
$host_id
takes a string and substitutes all host variables contained in it
substitute
_snmp_query_data
$string,
$host_id,
$snmp_query_id,
$snmp_index,
$max_chars = 0
takes a string and substitutes all data query variables contained in it
substitute
_data_input_data
$string,
$graph,
$local_data_id,
$max_chars = 0
takes a string and substitutes all data input variables contained in it

2.6 auth.php

nameparamfunction
user_copy$template_user,
$new_user,
$template_realm = 0,
$new_realm = 0,
$overwrite = false,
$data_override = array()
copies user account
user_remove$user_idremove a user account
user_disable$user_iddisable a user account
user_enable$user_idenable a user account
get_graph_permissions_sql$policy_graphs,
$policy_hosts,
$policy_graph_templates
creates SQL that reprents the current graph, host and graph template policies
is_graph_allowed$local_graph_iddetermines whether the current user is allowed to view a certain graph
is_tree_allowed$tree_iddetermines whether the current user is allowed to view a certain graph tree
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值