diff -Naur cacti-0.8.7e-old/auth_changepassword.php cacti-0.8.7e/auth_changepassword.php --- cacti-0.8.7e-old/auth_changepassword.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/auth_changepassword.php 2009-06-28 22:51:07.000000000 -0500 @@ -59,6 +59,8 @@ header("Location: index.php"); break; case '3': /* default graph page */ header("Location: graph_view.php"); break; + default: + api_plugin_hook_function('login_options_navigate', $user['login_opts']); } }else{ header("Location: graph_view.php"); diff -Naur cacti-0.8.7e-old/auth_login.php cacti-0.8.7e/auth_login.php --- cacti-0.8.7e-old/auth_login.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/auth_login.php 2009-06-28 22:51:07.000000000 -0500 @@ -212,6 +212,8 @@ header("Location: index.php"); break; case '3': /* default graph page */ header("Location: graph_view.php"); break; + default: + api_plugin_hook_function('login_options_navigate', $user['login_opts']); } exit; @@ -262,9 +264,17 @@
"> + - +
+
diff -Naur cacti-0.8.7e-old/data_sources.php cacti-0.8.7e/data_sources.php --- cacti-0.8.7e-old/data_sources.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/data_sources.php 2009-06-28 22:51:07.000000000 -0500 @@ -44,6 +44,8 @@ 7 => "Disable" ); +$ds_actions = api_plugin_hook_function('data_source_action_array', $ds_actions); + /* set default action */ if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; } @@ -402,7 +404,10 @@ api_reapply_suggested_data_source_title($selected_items[$i]); update_data_source_title_cache($selected_items[$i]); } + } else { + api_plugin_hook_function('data_source_action_execute', $_POST['drp_action']); } + header("Location: data_sources.php"); exit; } @@ -533,7 +538,12 @@

$ds_list

\n - "; + "; + } else { + $save['drp_action'] = $_POST['drp_action']; + $save['ds_list'] = $ds_list; + $save['ds_array'] = (isset($ds_array)? $ds_array : array()); + api_plugin_hook_function('data_source_action_prepare', $save); } if (!isset($ds_array)) { @@ -675,6 +685,8 @@ input_validate_input_number(get_request_var("id")); /* ==================================================== */ + api_plugin_hook('data_source_edit_top'); + $use_data_template = true; $host_id = 0; @@ -967,8 +979,9 @@ form_save_button("data_sources.php"); - include_once("./include/bottom_footer.php"); + api_plugin_hook('data_source_edit_bottom'); + include_once("./include/bottom_footer.php"); } function get_poller_interval($seconds) { @@ -1300,6 +1313,7 @@ $i = 0; if (sizeof($data_sources) > 0) { foreach ($data_sources as $data_source) { + $data_source = api_plugin_hook_function('data_sources_table', $data_source); $data_template_name = ((empty($data_source["data_template_name"])) ? "None" : $data_source["data_template_name"]); $data_input_name = ((empty($data_source["data_input_name"])) ? "External" : $data_source["data_input_name"]); $poller_interval = ((isset($poller_intervals[$data_source["local_data_id"]])) ? $poller_intervals[$data_source["local_data_id"]] : 0); @@ -1328,4 +1342,3 @@ print "\n"; } ?> - diff -Naur cacti-0.8.7e-old/graph_image.php cacti-0.8.7e/graph_image.php --- cacti-0.8.7e-old/graph_image.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/graph_image.php 2009-06-28 22:51:07.000000000 -0500 @@ -44,6 +44,8 @@ /* flush the headers now */ ob_end_clean(); +api_plugin_hook_function('graph_image'); + session_write_close(); $graph_data_array = array(); diff -Naur cacti-0.8.7e-old/graph.php cacti-0.8.7e/graph.php --- cacti-0.8.7e-old/graph.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/graph.php 2009-06-28 22:03:15.000000000 -0500 @@ -98,6 +98,7 @@ Zoom Graph
CSV Export
Graph Source/Properties + 'view', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $rra['id'], 'view_type' => $_REQUEST['view_type'])); ?> @@ -212,6 +213,7 @@ Graph Source/Properties CSV Export
+ 'zoom', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $_GET['rra_id'], 'view_type' => $_REQUEST['view_type'])); ?> @@ -244,6 +246,7 @@ Zoom Graph
CSV Export
+ 'properties', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $_GET['rra_id'], 'view_type' => $_REQUEST['view_type'])); ?> diff -Naur cacti-0.8.7e-old/graphs_new.php cacti-0.8.7e/graphs_new.php --- cacti-0.8.7e-old/graphs_new.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/graphs_new.php 2009-06-28 22:51:07.000000000 -0500 @@ -479,7 +479,8 @@ *">Edit this Host
- *Create New Host + *Create New Host
+ diff -Naur cacti-0.8.7e-old/graphs.php cacti-0.8.7e/graphs.php --- cacti-0.8.7e-old/graphs.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/graphs.php 2009-06-28 22:51:07.000000000 -0500 @@ -45,6 +45,8 @@ 4 => "Convert to Graph Template" ); +$graph_actions = api_plugin_hook_function('graphs_action_array', $graph_actions); + /* set default action */ if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; } @@ -360,8 +362,10 @@ input_validate_input_number($selected_items[$i]); /* ==================================================== */ - api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]); + api_resize_graphs($selected_items[$i], $_POST['graph_width'], $_POST['graph_height']); } + } else { + api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']); } header("Location: graphs.php"); @@ -502,6 +506,11 @@ \n "; + } else { + $save['drp_action'] = $_POST['drp_action']; + $save['graph_list'] = $graph_list; + $save['graph_array'] = (isset($graph_array) ? $graph_array : array()); + api_plugin_hook_function('graphs_action_prepare', $save); } if (!isset($graph_array)) { diff -Naur cacti-0.8.7e-old/host.php cacti-0.8.7e/host.php --- cacti-0.8.7e-old/host.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/host.php 2009-06-28 22:51:07.000000000 -0500 @@ -44,6 +44,8 @@ 6 => "Change Availability Options" ); +$device_actions = api_plugin_hook_function('device_action_array', $device_actions); + /* set default action */ if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; } @@ -309,6 +311,8 @@ api_tree_item_save(0, $_POST["tree_id"], TREE_ITEM_TYPE_HOST, $_POST["tree_item_id"], "", 0, read_graph_config_option("default_rra_id"), $selected_items[$i], 1, 1, false); } + } else { + api_plugin_hook_function('device_action_execute', $_POST['drp_action']); } header("Location: host.php"); @@ -445,6 +449,11 @@ \n \n "; + } else { + $save['drp_action'] = $_POST['drp_action']; + $save['host_list'] = $host_list; + $save['host_array'] = (isset($host_array)? $host_array : array()); + api_plugin_hook_function('device_action_prepare', $save); } if (!isset($host_array)) { @@ -533,6 +542,8 @@ display_output_messages(); + api_plugin_hook('host_edit_top'); + if (!empty($_GET["id"])) { $host = db_fetch_row("select * from host where id=" . $_GET["id"]); $header_label = "[edit: " . $host["description"] . "]"; @@ -643,7 +654,8 @@ *">Create Graphs for this Host
*&ds_rows=30&filter=&template_id=-1&method_id=-1&page=1">Data Source List
- *&graph_rows=30&filter=&template_id=-1&page=1">Graph List + *&graph_rows=30&filter=&template_id=-1&page=1">Graph List
+ @@ -1104,6 +1116,8 @@ } form_save_button("host.php"); + + api_plugin_hook('host_edit_bottom'); } function host() { diff -Naur cacti-0.8.7e-old/include/auth.php cacti-0.8.7e/include/auth.php --- cacti-0.8.7e-old/include/auth.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/include/auth.php 2009-06-28 22:51:07.000000000 -0500 @@ -31,6 +31,9 @@ } if (read_config_option("auth_method") != 0) { + /* handle alternate authentication realms */ + api_plugin_hook_function('auth_alternate_realms'); + /* handle change password dialog */ if ((isset($_SESSION['sess_change_password'])) && (read_config_option("webbasic_enabled") != "on")) { header ("Location: auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php")); @@ -75,7 +78,7 @@ Cacti - + @@ -83,7 +86,7 @@ - + @@ -91,7 +94,7 @@ need access to this particular section, please contact the Cacti administrator. - +
Access Deniedimages/auth_deny.gif' border='0' alt='Access Denied'>
( Return | Login )( Return | index.php'>Login )
diff -Naur cacti-0.8.7e-old/include/bottom_footer.php cacti-0.8.7e/include/bottom_footer.php --- cacti-0.8.7e-old/include/bottom_footer.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/include/bottom_footer.php 2009-06-28 22:51:07.000000000 -0500 @@ -21,6 +21,10 @@ | http://www.cacti.net/ | +-------------------------------------------------------------------------+ */ + +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE); +if (($oper_mode == OPER_MODE_NATIVE) || ($oper_mode == OPER_MODE_IFRAME_NONAV)) { + ?>
@@ -31,6 +35,9 @@ array( "message" => 'Save Successful.', @@ -641,4 +643,10 @@ GDC_SLASH => "/" ); +$plugin_architecture = array( + 'version' => '2.5' + ); + +api_plugin_hook('config_arrays'); + ?> diff -Naur cacti-0.8.7e-old/include/global_constants.php cacti-0.8.7e/include/global_constants.php --- cacti-0.8.7e-old/include/global_constants.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/include/global_constants.php 2009-06-28 22:51:07.000000000 -0500 @@ -175,4 +175,8 @@ define("SNMP_CMDPHP", 1); define("SNMP_WEBUI", 2); +define('OPER_MODE_NATIVE', 0); +define('OPER_MODE_RESKIN', 1); +define('OPER_MODE_IFRAME_NONAV', 2); + ?> diff -Naur cacti-0.8.7e-old/include/global_form.php cacti-0.8.7e/include/global_form.php --- cacti-0.8.7e-old/include/global_form.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/include/global_form.php 2009-06-28 22:51:07.000000000 -0500 @@ -22,8 +22,9 @@ +-------------------------------------------------------------------------+ */ -if (!defined("VALID_HOST_FIELDS")) { - define("VALID_HOST_FIELDS", "(hostname|snmp_community|snmp_username|snmp_password|snmp_auth_protocol|snmp_priv_passphrase|snmp_priv_protocol|snmp_context|snmp_version|snmp_port|snmp_timeout)"); +if (!defined('VALID_HOST_FIELDS')) { + $string = api_plugin_hook_function('valid_host_fields', '(hostname|snmp_community|snmp_username|snmp_password|snmp_auth_protocol|snmp_priv_passphrase|snmp_priv_protocol|snmp_context|snmp_version|snmp_port|snmp_timeout)'); + define('VALID_HOST_FIELDS', $string); } /* file: cdef.php, action: edit */ @@ -1184,4 +1185,7 @@ "dropdown_sql" => "select id,name from snmp_query order by name" ) ); -?> + + +api_plugin_hook('config_form'); + diff -Naur cacti-0.8.7e-old/include/global.php cacti-0.8.7e/include/global.php --- cacti-0.8.7e-old/include/global.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/include/global.php 2009-06-28 22:51:07.000000000 -0500 @@ -41,6 +41,22 @@ /* Default session name - Session name must contain alpha characters */ $cacti_session_name = "Cacti"; +$plugins = array(); +//$plugins[] = 'thold'; + +/* Do not edit this line */ +$config = array(); + +/* + Edit this to point to the default URL of your Cacti install + ex: if your cacti install as at http://serverip/cacti/ this + would be set to /cacti/ +*/ + +$config['url_path'] = '/'; + +define('URL_PATH', $config['url_path']); + /* Include configuration */ include(dirname(__FILE__) . "/config.php"); @@ -76,7 +92,6 @@ "structure_rra_paths.php" ); -$config = array(); $colors = array(); /* this should be auto-detected, set it manually if needed */ @@ -180,18 +195,23 @@ /* display ALL errors */ error_reporting(E_ALL); +/* current cacti version */ +$config["cacti_version"] = "0.8.7c"; + /* include base modules */ include($config["library_path"] . "/adodb/adodb.inc.php"); include($config["library_path"] . "/database.php"); -include_once($config["library_path"] . "/functions.php"); -include_once($config["include_path"] . "/global_constants.php"); -include_once($config["include_path"] . "/global_arrays.php"); -include_once($config["include_path"] . "/global_settings.php"); /* connect to the database server */ db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port); /* include additional modules */ +include_once($config["library_path"] . "/functions.php"); +include_once($config["include_path"] . "/global_constants.php"); +include_once($config["library_path"] . "/plugins.php"); +include_once($config["include_path"] . "/plugins.php"); +include_once($config["include_path"] . "/global_arrays.php"); +include_once($config["include_path"] . "/global_settings.php"); include_once($config["include_path"] . "/global_form.php"); include_once($config["library_path"] . "/html.php"); include_once($config["library_path"] . "/html_form.php"); @@ -200,6 +220,8 @@ include_once($config["library_path"] . "/variables.php"); include_once($config["library_path"] . "/auth.php"); +api_plugin_hook("config_insert"); + /* current cacti version */ $config["cacti_version"] = "0.8.7e"; diff -Naur cacti-0.8.7e-old/include/global_settings.php cacti-0.8.7e/include/global_settings.php --- cacti-0.8.7e-old/include/global_settings.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/include/global_settings.php 2009-06-28 22:51:07.000000000 -0500 @@ -1185,4 +1185,6 @@ ) ); +api_plugin_hook('config_settings'); + ?> diff -Naur cacti-0.8.7e-old/include/plugins.php cacti-0.8.7e/include/plugins.php --- cacti-0.8.7e-old/include/plugins.php 1969-12-31 17:00:00.000000000 -0700 +++ cacti-0.8.7e/include/plugins.php 2009-06-28 22:51:07.000000000 -0500 @@ -0,0 +1,36 @@ + - Cacti + <?php echo $page_title; ?> \r\n"; }else{ - print "\r\n"; + $refresh = api_plugin_hook_function('top_graph_refresh', read_graph_config_option('page_refresh')); + print "\r\n"; } } ?> - - - - - - - - + + + + + + + + + - + +> + +> + + @@ -104,7 +120,7 @@ @@ -112,10 +128,10 @@ - - @@ -141,9 +157,10 @@ + - + + "; } @@ -762,18 +769,19 @@ @arg $actions_array - an array that contains a list of possible actions. this array should be compatible with the form_dropdown() function */ function draw_actions_dropdown($actions_array) { + global $config; ?>
- +
-  Console" alt="Graphs" align="absmiddle" border="0">  +  Console" alt="Graphs" align="absmiddle" border="0"> - Settings';}?>  .gif" border="0" title="Tree View" alt="Tree View" align="absmiddle">.gif" border="0" title="List View" alt="List View" align="absmiddle">.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"> 
+ Settings';}?>  .gif" border="0" title="Tree View" alt="Tree View" align="absmiddle">.gif" border="0" title="List View" alt="List View" align="absmiddle">.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"> 
@@ -92,7 +108,7 @@
-
+
- Logged in as (Logout)  + Logged in as (Logout
- " height="2" border="0">
+
+ " height="2" border="0">
+
diff -Naur cacti-0.8.7e-old/include/top_header.php cacti-0.8.7e/include/top_header.php --- cacti-0.8.7e-old/include/top_header.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/include/top_header.php 2009-06-28 22:51:07.000000000 -0500 @@ -22,37 +22,52 @@ +-------------------------------------------------------------------------+ */ -global $colors; +global $colors, $config; + +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE); +if ($oper_mode == OPER_MODE_RESKIN) { + return; +} + +$page_title = api_plugin_hook_function('page_title', 'Cacti'); + ?> - Cacti - - - + <?php echo $page_title; ?> + + + "; - }?> + } + api_plugin_hook('page_head'); ?> - + +> + +> + + @@ -64,7 +79,7 @@ @@ -72,10 +87,10 @@ - - + @@ -85,9 +100,12 @@
- + +  ConsoleGraphs
-  ConsoleGraphs -
-
+
- Logged in as (Logout)  + Logged in as (Logout
-
-
+ +
+
-
-

-
+
+

about.php'>

+
- + +
+ diff -Naur cacti-0.8.7e-old/index.php cacti-0.8.7e/index.php --- cacti-0.8.7e-old/index.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/index.php 2009-06-28 22:51:07.000000000 -0500 @@ -25,6 +25,8 @@ include("./include/auth.php"); include("./include/top_header.php"); +api_plugin_hook('console_before'); + ?> @@ -46,6 +48,8 @@ diff -Naur cacti-0.8.7e-old/lib/api_device.php cacti-0.8.7e/lib/api_device.php --- cacti-0.8.7e-old/lib/api_device.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/lib/api_device.php 2009-06-28 22:51:07.000000000 -0500 @@ -137,6 +137,8 @@ $save["ping_retries"] = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3); $save["max_oids"] = form_input_validate($max_oids, "max_oids", "^[0-9]+$", true, 3); + $save = api_plugin_hook_function('api_device_save', $save); + $host_id = 0; if (!is_error_message()) { diff -Naur cacti-0.8.7e-old/lib/auth.php cacti-0.8.7e/lib/auth.php --- cacti-0.8.7e-old/lib/auth.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/lib/auth.php 2009-06-28 22:51:07.000000000 -0500 @@ -122,6 +122,8 @@ } } + api_plugin_hook_function('copy_user', array('template_id' => $template_id, 'new_id' => $new_id)); + return true; } @@ -153,6 +155,7 @@ db_execute("delete from settings_graphs where user_id=" . $user_id); db_execute("delete from settings_tree where user_id=" . $user_id); + api_plugin_hook_function('user_remove', $user_id); } diff -Naur cacti-0.8.7e-old/lib/functions.php cacti-0.8.7e/lib/functions.php --- cacti-0.8.7e-old/lib/functions.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/lib/functions.php 2009-06-28 22:51:07.000000000 -0500 @@ -1639,6 +1639,7 @@ /* draw_navigation_text - determines the top header navigation text for the current page and displays it to the browser */ function draw_navigation_text() { + global $config; $nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : array()); $nav = array( @@ -1651,8 +1652,8 @@ "graph.php:zoom" => array("title" => "Zoom", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"), "graph.php:properties" => array("title" => "Properties", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"), "graph_settings.php:" => array("title" => "Settings", "mapping" => "graph_view.php:", "url" => "graph_settings.php", "level" => "1"), - "index.php:" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"), - "index.php:login" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"), + "index.php:" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"), + "index.php:login" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"), "graphs.php:" => array("title" => "Graph Management", "mapping" => "index.php:", "url" => "graphs.php", "level" => "1"), "graphs.php:graph_edit" => array("title" => "(Edit)", "mapping" => "index.php:,graphs.php:", "url" => "", "level" => "2"), "graphs.php:graph_diff" => array("title" => "Change Graph Template", "mapping" => "index.php:,graphs.php:,graphs.php:graph_edit", "url" => "", "level" => "3"), @@ -1730,6 +1731,8 @@ "templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"), ); + $nav = api_plugin_hook_function('draw_navigation_text', $nav); + $current_page = basename($_SERVER["PHP_SELF"]); input_validate_input_regex(get_request_var_request("action"), "^([a-zA-Z0-9_-]+)$"); diff -Naur cacti-0.8.7e-old/lib/html_form.php cacti-0.8.7e/lib/html_form.php --- cacti-0.8.7e-old/lib/html_form.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/lib/html_form.php 2009-06-28 22:51:07.000000000 -0500 @@ -655,11 +655,13 @@ on a confirmation form @arg $cancel_url - the url to go to when the user clicks 'cancel' @arg $action_url - the url to go to when the user clicks 'delete' */ -function form_confirm_buttons($action_url, $cancel_url) { ?> +function form_confirm_buttons($action_url, $cancel_url) { + global $config; + ?>
- Cancel - ">Delete + Cancel + ">Delete
- Cancel - + images/button_cancel2.gif' alt='Cancel' align='absmiddle' border='0'> + images/' alt='' align='absmiddle'>
diff -Naur cacti-0.8.7e-old/lib/html.php cacti-0.8.7e/lib/html.php --- cacti-0.8.7e-old/lib/html.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/lib/html.php 2009-06-28 22:38:23.000000000 -0500 @@ -86,6 +86,7 @@ @arg $extra_url_args - extra arguments to append to the url @arg $header - html to use as a header */ function html_graph_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") { + global $config; $i = 0; if (sizeof($graph_array) > 0) { if ($header != "") { @@ -142,14 +143,15 @@
-
;"><?php print $graph["title_cache"];?>
+ " . $graph["title_cache"] . "

" : "");?>
- Zoom Graph
- CSV Export
- Graph Source/Properties
- Page Top
+ graph.php?action=zoom&local_graph_id=&rra_id=0&'>images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'>
+ graph_xport.php?local_graph_id=&rra_id=0&'>images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'>
+ graph.php?action=properties&local_graph_id=&rra_id=0&'>images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'>
+ 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => 'view')); ?> + images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'>
@@ -175,6 +177,7 @@ @arg $extra_url_args - extra arguments to append to the url @arg $header - html to use as a header */ function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") { + global $config; $i = 0; $k = 0; $j = 0; $num_graphs = sizeof($graph_array); @@ -266,13 +269,14 @@ @@ -704,6 +708,8 @@ } while (list($item_sub_url, $item_sub_title) = each($item_title)) { + $item_sub_url = $config['url_path'] . $item_sub_url; + /* indent sub-items */ if ($i > 0) { $prepend_string = "--- "; @@ -713,7 +719,7 @@ /* do not put a line between each sub-item */ if (($i == 0) || ($draw_sub_items == false)) { - $background = "images/menu_line.gif"; + $background = $config['url_path'] . "images/menu_line.gif"; }else{ $background = ""; } @@ -742,17 +748,18 @@ }else{ if ((isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) { /* draw normal (non sub-item) menu item */ + $item_url = $config['url_path'] . $item_url; if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) { - print "\n"; + print "\n"; }else{ - print "\n"; + print "\n"; } } } } } - print "\n"; + print "\n"; print "
- <?php print $graph["title_cache"];?> + graph.php?action=view&rra_id=all&local_graph_id='>graph_image.php?local_graph_id=&rra_id=0&graph_height=&graph_width=&graph_nolegend=true' border='0' alt=''> " . $graph["title_cache"] . "

" : "");?>
- Zoom Graph
- CSV Export
- Graph Source/Properties
+ graph.php?action=zoom&local_graph_id=&rra_id=0&'>images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'>
+ graph_xport.php?local_graph_id=&rra_id=0&'>images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'>
+ graph.php?action=properties&local_graph_id=&rra_id=0&'>images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'>
+ 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => '')); ?> Page Top
$item_title
$item_title
$item_title
$item_title
-   + images/arrow.gif' alt='' align='absmiddle'>  Choose an action: - + images/button_go.gif' alt='Go'>
diff -Naur cacti-0.8.7e-old/lib/plugins.php cacti-0.8.7e/lib/plugins.php --- cacti-0.8.7e-old/lib/plugins.php 1969-12-31 17:00:00.000000000 -0700 +++ cacti-0.8.7e/lib/plugins.php 2009-06-28 22:51:07.000000000 -0500 @@ -0,0 +1,380 @@ + $function) { + if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) { + $function($data); + } + } + } + + /* Variable-length argument lists have a slight problem when */ + /* passing values by reference. Pity. This is a workaround. */ + return $data; +} + +function api_plugin_hook_function ($name, $parm=NULL) { + global $config, $plugin_hooks; + $ret = $parm; + $p = array(); + $result = db_fetch_assoc("SELECT name, file, function FROM plugin_hooks WHERE status = 1 AND hook = '$name'", false); + + if (count($result)) { + foreach ($result as $hdata) { + $p[] = $hdata['name']; + if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) { + include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']); + } + $function = $hdata['function']; + if (function_exists($function)) { + $ret = $function($ret); + } + } + } + + if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) { + foreach ($plugin_hooks[$name] as $pname => $function) { + if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) { + $ret = $function($ret); + } + } + } + + /* Variable-length argument lists have a slight problem when */ + /* passing values by reference. Pity. This is a workaround. */ + return $ret; +} + +function api_plugin_db_table_create ($plugin, $table, $data) { + global $config, $database_default; + include_once($config["library_path"] . "/database.php"); + + $result = db_fetch_assoc("show tables from `" . $database_default . "`") or die (mysql_error()); + $tables = array(); + foreach($result as $index => $arr) { + foreach ($arr as $t) { + $tables[] = $t; + } + } + if (!in_array($table, $tables)) { + $c = 0; + $sql = 'CREATE TABLE `' . $table . "` (\n"; + foreach ($data['columns'] as $column) { + if (isset($column['name'])) { + if ($c > 0) + $sql .= ",\n"; + $sql .= '`' . $column['name'] . '`'; + if (isset($column['type'])) + $sql .= ' ' . $column['type']; + if (isset($column['unsigned'])) + $sql .= ' unsigned'; + if (isset($column['NULL']) && $column['NULL'] == false) + $sql .= ' NOT NULL'; + if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default'])) + $sql .= ' default NULL'; + if (isset($column['default'])) + $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'"); + if (isset($column['auto_increment'])) + $sql .= ' auto_increment'; + $c++; + } + } + + if (isset($data['primary'])) { + $sql .= ",\n PRIMARY KEY (`" . $data['primary'] . '`)'; + } + + foreach ($data['keys'] as $key) { + if (isset($key['name'])) { + $sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)'; + } + } + $sql .= ') TYPE = ' . $data['type']; + + if (isset($data['comment'])) { + $sql .= " COMMENT = '" . $data['comment'] . "'"; + } + if (db_execute($sql)) { + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')"); + } + } else { + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')"); + } +} + +function api_plugin_db_changes_remove ($plugin) { + // Example: api_plugin_db_changes_remove ('thold'); + + $tables = db_fetch_assoc("SELECT `table` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='create'", false); + if (count($tables)) { + foreach ($tables as $table) { + db_execute("DROP TABLE `" . $table['table'] . "`;"); + } + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false); + } + $columns = db_fetch_assoc("SELECT `table`, `column` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='addcolumn'", false); + if (count($columns)) { + foreach ($columns as $column) { + db_execute('ALTER TABLE `' . $column['table'] . '` DROP `' . $column['column'] . '`'); + } + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false); + } +} + +function api_plugin_db_add_column ($plugin, $table, $column) { + // Example: api_plugin_db_add_column ('thold', 'plugin_config', array('name' => 'test' . rand(1, 200), 'type' => 'varchar (255)', 'NULL' => false)); + + global $config, $database_default; + include_once($config['library_path'] . '/database.php'); + + $result = db_fetch_assoc('show columns from `' . $table . '`') or die (mysql_error()); + $columns = array(); + foreach($result as $index => $arr) { + foreach ($arr as $t) { + $columns[] = $t; + } + } + if (isset($column['name']) && !in_array($column['name'], $columns)) { + $sql = 'ALTER TABLE `' . $table . '` ADD `' . $column['name'] . '`'; + if (isset($column['type'])) + $sql .= ' ' . $column['type']; + if (isset($column['unsigned'])) + $sql .= ' unsigned'; + if (isset($column['NULL']) && $column['NULL'] == false) + $sql .= ' NOT NULL'; + if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default'])) + $sql .= ' default NULL'; + if (isset($column['default'])) + $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'"); + if (isset($column['auto_increment'])) + $sql .= ' auto_increment'; + if (isset($column['after'])) + $sql .= ' AFTER ' . $column['after']; + + if (db_execute($sql)) { + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')"); + } + } +} + +function api_plugin_install ($plugin) { + global $config; + include_once($config['base_path'] . "/plugins/$plugin/setup.php"); + + $exists = db_fetch_assoc("SELECT id FROM plugin_config WHERE directory = '$plugin'", false); + if (!count($exists)) { + db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'"); + } + + $name = $author = $webpage = $version = ''; + $function = 'plugin_' . $plugin . '_version'; + if (function_exists($function)){ + $info = $function(); + $name = $info['longname']; + $webpage = $info['homepage']; + $author = $info['author']; + $version = $info['version']; + } + + db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')"); + + $function = 'plugin_' . $plugin . '_install'; + if (function_exists($function)){ + $function(); + $ready = api_plugin_check_config ($plugin); + if ($ready) { + // Set the plugin as "disabled" so it can go live + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'"); + } else { + // Set the plugin as "needs configuration" + db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'"); + } + } +} + +function api_plugin_uninstall ($plugin) { + global $config; + include_once($config['base_path'] . "/plugins/$plugin/setup.php"); + // Run the Plugin's Uninstall Function first + $function = 'plugin_' . $plugin . '_uninstall'; + if (function_exists($function)) { + $function(); + } + api_plugin_remove_hooks ($plugin); + api_plugin_remove_realms ($plugin); + db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'"); + api_plugin_db_changes_remove ($plugin); +} + +function api_plugin_check_config ($plugin) { + global $config; + include_once($config['base_path'] . "/plugins/$plugin/setup.php"); + $function = 'plugin_' . $plugin . '_check_config'; + if (function_exists($function)) { + return $function(); + } + return TRUE; +} + +function api_plugin_enable ($plugin) { + $ready = api_plugin_check_config ($plugin); + if ($ready) { + api_plugin_enable_hooks ($plugin); + db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'"); + } +} + +function api_plugin_is_enabled ($plugin) { + $status = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = '$plugin'", false); + if ($status == '1') + return true; + return false; +} + +function api_plugin_disable ($plugin) { + api_plugin_disable_hooks ($plugin); + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'"); +} + +function api_plugin_register_hook ($plugin, $hook, $function, $file) { + $exists = db_fetch_assoc("SELECT id FROM plugin_hooks WHERE name = '$plugin' AND hook = '$hook'", false); + if (!count($exists)) { + $settings = array('config_settings', 'config_arrays', 'config_form'); + if (!in_array($hook, $settings)) { + db_execute("INSERT INTO plugin_hooks (name, hook, function, file) VALUES ('$plugin', '$hook', '$function', '$file')"); + } else { + db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)"); + } + } +} + +function api_plugin_remove_hooks ($plugin) { + db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'"); +} + +function api_plugin_enable_hooks ($plugin) { + db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'"); +} + +function api_plugin_disable_hooks ($plugin) { + db_execute("UPDATE plugin_hooks SET status = 0 WHERE name = '$plugin' AND hook != 'config_settings' AND hook != 'config_arrays' AND hook != 'config_form'"); +} + +function api_plugin_register_realm ($plugin, $file, $display, $admin = false) { + $exists = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false); + if (!count($exists)) { + db_execute("INSERT INTO plugin_realms (plugin, file, display) VALUES ('$plugin', '$file', '$display')"); + if ($admin) { + $realm_id = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false); + $realm_id = $realm_id[0]['id'] + 100; + $user_id = db_fetch_assoc("SELECT id FROM user_auth WHERE username = 'admin'", false); + if (count($user_id)) { + $user_id = $user_id[0]['id']; + $exists = db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id = $user_id and realm_id = $realm_id", false); + if (!count($exists)) { + db_execute("INSERT INTO user_auth_realm (user_id, realm_id) VALUES ($user_id, $realm_id)"); + } + } + } + } +} + +function api_plugin_remove_realms ($plugin) { + $realms = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin'", false); + foreach ($realms as $realm) { + $id = $realm['id'] + 100; + db_execute("DELETE FROM user_auth_realm WHERE realm_id = '$id'"); + } + db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'"); +} + +function api_plugin_load_realms () { + global $user_auth_realms, $user_auth_realm_filenames; + $plugin_realms = db_fetch_assoc("SELECT * FROM plugin_realms ORDER BY plugin, display", false); + if (count($plugin_realms)) { + foreach ($plugin_realms as $plugin_realm) { + $plugin_files = explode(',', $plugin_realm['file']); + foreach($plugin_files as $plugin_file) { + $user_auth_realm_filenames[$plugin_file] = $plugin_realm['id'] + 100; + } + $user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display']; + } + } +} + +function api_plugin_user_realm_auth ($filename = '') { + global $user_realms, $user_auth_realms, $user_auth_realm_filenames; + /* list all realms that this user has access to */ + if (!isset($user_realms)) { + if (read_config_option('global_auth') == 'on' || read_config_option('auth_method') != 0) { + $user_realms = db_fetch_assoc("select realm_id from user_auth_realm where user_id=" . $_SESSION["sess_user_id"], false); + $user_realms = array_rekey($user_realms, "realm_id", "realm_id"); + }else{ + $user_realms = $user_auth_realms; + } + } + if ($filename != '') { + if (isset($user_realms[$user_auth_realm_filenames{basename($filename)}])) + return TRUE; + } + return FALSE; +} + +function plugin_config_arrays () { + global $menu; + $menu['Configuration']['plugins.php'] = 'Plugin Management'; + api_plugin_load_realms (); +} + +function plugin_draw_navigation_text ($nav) { + $nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1"); + return $nav; +} + + + + + + + diff -Naur cacti-0.8.7e-old/lib/poller.php cacti-0.8.7e/lib/poller.php --- cacti-0.8.7e-old/lib/poller.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/lib/poller.php 2009-06-28 22:51:07.000000000 -0500 @@ -326,8 +326,11 @@ } } } + api_plugin_hook_function('poller_output', $rrd_update_array); - $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe); + if (api_plugin_hook_function('poller_on_demand', $results)) { + $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe); + } } return $rrds_processed; diff -Naur cacti-0.8.7e-old/lib/rrd.php cacti-0.8.7e/lib/rrd.php --- cacti-0.8.7e-old/lib/rrd.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/lib/rrd.php 2009-06-28 22:51:07.000000000 -0500 @@ -557,6 +557,10 @@ } } + $data = api_plugin_hook_function('rrdtool_function_graph_cache_check', array('local_graph_id' => $local_graph_id,'rra_id' => $rra_id,'rrd_struc' => $rrd_struc,'graph_data_array' => $graph_data_array, 'return' => false)); + if (isset($data['return']) && $data['return'] != false) + return $data['return']; + /* find the step and how often this graph is updated with new data */ $ds_step = db_fetch_cell("select data_template_data.rrd_step @@ -1388,6 +1392,13 @@ } } + $graph_array = api_plugin_hook_function('rrd_graph_graph_options', array('graph_opts' => $graph_opts, 'graph_defs' => $graph_defs, 'txt_graph_items' => $txt_graph_items, 'graph_id' => $local_graph_id, 'start' => $graph_start, 'end' => $graph_end)); + if (!empty($graph_array)) { + $graph_defs = $graph_array['graph_defs']; + $txt_graph_items = $graph_array['txt_graph_items']; + $graph_opts = $graph_array['graph_opts']; + } + /* either print out the source or pass the source onto rrdtool to get us a nice PNG */ if (isset($graph_data_array["print_source"])) { print "
" . read_config_option("path_rrdtool") . " graph $graph_opts$graph_defs$txt_graph_items
"; @@ -1396,13 +1407,19 @@ rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrd_struc); return 0; }else{ + $graph_data_array = api_plugin_hook_function('prep_graph_array', $graph_data_array); + if (isset($graph_data_array["output_flag"])) { $output_flag = $graph_data_array["output_flag"]; }else{ $output_flag = RRDTOOL_OUTPUT_GRAPH_DATA; } - return rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrd_struc); + $output = rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrd_struc); + + api_plugin_hook_function('rrdtool_function_graph_set_file', array('output' => $output, 'local_graph_id' => $local_graph_id, 'rra_id' => $rra_id)); + + return $output; } } } diff -Naur cacti-0.8.7e-old/lib/variables.php cacti-0.8.7e/lib/variables.php --- cacti-0.8.7e-old/lib/variables.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/lib/variables.php 2009-06-28 22:51:07.000000000 -0500 @@ -183,6 +183,9 @@ $string = str_replace($l_escape_string . "host_max_oids" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["max_oids"], $string); $string = str_replace($l_escape_string . "host_id" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["id"], $string); + $temp = api_plugin_hook_function('substitute_host_data', array('string' => $string, 'l_escape_string' => $l_escape_string, 'r_escape_string' => $r_escape_string, 'host_id' => $host_id)); + $string = $temp['string']; + return $string; } diff -Naur cacti-0.8.7e-old/plugins/index.php cacti-0.8.7e/plugins/index.php --- cacti-0.8.7e-old/plugins/index.php 1969-12-31 17:00:00.000000000 -0700 +++ cacti-0.8.7e/plugins/index.php 2009-06-28 22:51:07.000000000 -0500 @@ -0,0 +1,5 @@ + diff -Naur cacti-0.8.7e-old/plugins.php cacti-0.8.7e/plugins.php --- cacti-0.8.7e-old/plugins.php 1969-12-31 17:00:00.000000000 -0700 +++ cacti-0.8.7e/plugins.php 2009-06-28 22:43:46.000000000 -0500 @@ -0,0 +1,436 @@ + "Installed", +// "uninstalled" => "Uninstalled", +// "download" => "Download", +// "updates" => "Updates", +); + + +$status_names = array(-2 => 'Old Plugin Architecture', -1 => 'Old Plugin Architecture - Running', 0 => 'Not Installed', 1 => 'Active', 2 => 'Awaiting Configuration', 3 => 'Awaiting Upgrade', 4 => 'Installed'); + + +/* set the default settings category */ +if (!isset($_GET["tab"])) { + /* there is no selected tab; select the first one */ + $current_tab = array_keys($ptabs); + $current_tab = $current_tab[0]; +}else{ + $current_tab = $_GET["tab"]; +} + + +// Check to see if we are installing, etc... +$modes = array('install', 'uninstall', 'disable', 'enable', 'check'); + +if (isset($_GET['mode']) && in_array($_GET['mode'], $modes) && isset($_GET['id'])) { + + input_validate_input_regex(get_request_var("id"), "^([a-zA-Z0-9]+)$"); + + $mode = $_GET['mode']; + $id = sanitize_search_string($_GET['id']); + + switch ($mode) { + case 'install': + api_plugin_install($id); + $pluginslist = retrieve_plugin_list (); + break; + case 'uninstall': + if (!in_array($id, $pluginslist)) + break; + api_plugin_uninstall($id); + $pluginslist = retrieve_plugin_list (); + break; + case 'disable': + if (!in_array($id, $pluginslist)) + break; + api_plugin_disable ($id); + break; + case 'enable': + if (!in_array($id, $pluginslist)) + break; + api_plugin_enable ($id); + break; + case 'check': + if (!in_array($id, $pluginslist)) + break; + break; + } +} + +function retrieve_plugin_list () { + $pluginslist = array(); + $temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name'); + foreach ($temp as $t) { + $pluginslist[] = $t['directory']; + } + return $pluginslist; +} + + + include("./include/top_header.php"); + + /* draw the categories tabs on the top of the page */ +/* + print "\n"; + + if (sizeof($ptabs) > 0) { + foreach (array_keys($ptabs) as $tab_short_name) { + print "\n + \n"; + } + } + + print "\n
+ $ptabs[$tab_short_name] +
\n"; +*/ + html_start_box(" Plugin Management", "98%", $colors["header"], "3", "center", ""); + + print ""; + + //update_info_table(); + + switch ($current_tab) { + case 'current': + update_show_current(); + break; + case 'uninstalled': + update_show_uninstalled (); + break; + default: + print '


'; + } + +/* + $last_check = read_config_option("plugin_update_last_check"); + if ($last_check < 1) + $last_check = 0; + + print "
Last Scanned : " . ($last_check > 0 ? date("F j, Y g:i:s a", $last_check) : "Never") . "
"; +*/ + print "
"; + + html_end_box(); + + include("./include/bottom_footer.php"); + +function update_show_updates () { + global $pluginslist, $colors, $config, $plugin_architecture; + + $cinfo = array(); + sort($pluginslist); + + $cinfo = update_get_plugin_info (); + + $x = 0; + + $info = update_get_cached_plugin_info(); + + $cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ; + if (isset($cinfo['cacti_plugin_arch']['version'])) + $archnew = update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']); + else + $archnew = 0; + + if ($cactinew) { + $x++; + print ""; + html_header(array("Cacti"), 2); + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print "
Version:" . $config["cacti_version"] . "
Changes:" . str_replace("\n", '
', $info['cacti']['changes']) . "
"; + } + if (isset($plugin_architecture['version']) && $archnew) { + $x++; + print ""; + html_header(array("Plugin Architecture"), 2); + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print "
Version:" . $plugin_architecture['version'] . "Changes:" . str_replace("\n", '
', $info['cacti_plugin_arch']['changes']) . "
"; + } + print ""; + + foreach ($pluginslist as $plugin) { + if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) { + $x++; + print "
"; + html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2); + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + + print "
Directory:$pluginVersion:" . $info[$plugin]['version'] . "Author:" . (isset($cinfo[$plugin]['author']) && $cinfo[$plugin]['author'] != '' ? (isset($cinfo[$plugin]['email']) && $cinfo[$plugin]['email'] != '' ? "" . $cinfo[$plugin]['author'] . "" : $cinfo[$plugin]['author']) : "") . "Home Page:" . (isset($cinfo[$plugin]['webpage']) && $cinfo[$plugin]['webpage'] != '' ? "" . $cinfo[$plugin]['webpage'] . "" : "") . "Changes:" . str_replace("\n", '
', $info[$plugin]['changes']) . "
"; + } + } + if ($x == 0) + print "
There are currently no Updates!

"; + print ""; + html_end_box(TRUE); +} + +function update_check_if_newer() { + return false; +} + +function update_show_current () { + global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names; + + + + $cinfo = array(); + $cinfo = update_get_plugin_info (); + + sort($pluginslist); + + $path = $config['base_path'] . '/plugins/'; + $dh = opendir($path); + while (($file = readdir($dh)) !== false) { + if (is_dir("$path/$file")) { + if (file_exists("$path/$file/setup.php") && !in_array($file, $pluginslist)) { + include_once("$path/$file/setup.php"); + if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) { + $function = $file . '_version'; + $cinfo[$file] = $function(); + $cinfo[$file]['status'] = -2; + if (in_array($file, $plugins)) { + $cinfo[$file]['status'] = -1; + } + $pluginslist[] = $file; + } else if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) { + $function = $file . '_version'; + $cinfo[$file] = $function(); + $cinfo[$file]['status'] = 0; + $pluginslist[] = $file; + } + } + } + } + closedir($dh); + + print ""; + print "
"; + html_header(array("Cacti"), 2); + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print "
Version:" . $config["cacti_version"] . "
"; + print "
"; + if (isset($plugin_architecture['version'])) { + print ""; + html_header(array("Plugin Architecture"), 2); + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print "
Version:" . $plugin_architecture['version'] . "
"; + } + print "
"; + + print ""; + $x = 0; + + sort($pluginslist); + foreach ($pluginslist as $plugin) { + if (isset($cinfo[$plugin])) { + + if ($x == 0) { + print ""; + } + $x++; + if ($x > 1) $x = 0; + } + } + if ($x == 1) + print ""; + print "
"; + } else { + print ""; + } + if (!isset($info[$plugin]['version'])) + $info[$plugin]['version'] = ''; + + print ""; + html_header(array((isset($cinfo[$plugin]['name']) ? $cinfo[$plugin]['name'] : $plugin)), 2); + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + + if ($cinfo[$plugin]['status'] > -1) { + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + + $links = array('install' => 'Install', 'uninstall' => 'Uninstall', 'enable' => 'Enable', 'disable' => 'Disable', 'check' => 'Check'); + + switch ($cinfo[$plugin]['status']) { + case 0: //Not Installed + $links['install'] = "Install"; + break; + case 1: // Currently Active + $links['uninstall'] = "Uninstall"; + $links['disable'] = "Disable"; + break; + case 2: // Needs Configuring + $links['check'] = "Check"; + break; + case 3: // Needs Upgrade + $links['check'] = "Check"; + break; + case 4: // Installed but not active + $links['uninstall'] = "Uninstall"; + $links['enable'] = "Enable"; + break; + } + + print ""; + print ""; + } + + print "
Directory:$pluginVersion:" . (isset($cinfo[$plugin]['version']) ? $cinfo[$plugin]['version'] : "") . (update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version']) ? ' - (Update Available!)' : '') . "Author:" . (isset($cinfo[$plugin]['author']) && $cinfo[$plugin]['author'] != '' ? (isset($cinfo[$plugin]['email']) && $cinfo[$plugin]['email'] != '' ? "" . $cinfo[$plugin]['author'] . "" : $cinfo[$plugin]['author']) : "") . "Home Page:" . (isset($cinfo[$plugin]['webpage']) && $cinfo[$plugin]['webpage'] != '' ? "" . $cinfo[$plugin]['webpage'] . "" : "") . "Status:" . $status_names[$cinfo[$plugin]['status']] . ""; + $c = 1; + foreach ($links as $temp => $link) { + print $link; + if ($c < count($links)) + print ' | '; + $c++; + } + print "
"; + if ($x == 1) { + print "
"; + html_end_box(TRUE); +} + + +function update_show_uninstalled () { + global $pluginslist, $colors, $plugin_architecture, $config, $status_names; + + $cinfo = array(); + sort($pluginslist); + + print ""; + $x = 0; + + $newplugins = array(); + $cinfo = array (); + + $path = $config['base_path'] . '/plugins/'; + $dh = opendir($path); + while (($file = readdir($dh)) !== false) { + if (is_dir("$path/$file")) { + if (file_exists("$path/$file/setup.php") && !in_array($file, $pluginslist)) { + include_once("$path/$file/setup.php"); + if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) { + $function = 'plugin_' . $file . '_version'; + $cinfo[$file] = $function(); + $cinfo[$file]['status'] = 0; + $newplugins[] = $file; + } + } + } + } + closedir($dh); + + if (count($newplugins)) { + foreach ($newplugins as $plugin) { + if (isset($cinfo[$plugin])) { + + if ($x == 0) { + print ""; + } + $x++; + if ($x > 1) $x = 0; + } + } + } else { + print "
There are no Uninstalled Plugins
"; + } + if ($x == 1) + print ""; + print "
"; + } else { + print ""; + } + if (!isset($info[$plugin]['version'])) + $info[$plugin]['version'] = ''; + + print ""; + html_header(array((isset($cinfo[$plugin]['name']) ? $cinfo[$plugin]['name'] : $plugin)), 2); + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + print ""; + form_alternate_row_color($colors["alternate"],$colors["light"], 0); + + $links = array('install' => 'Install', 'uninstall' => 'Uninstall', 'enable' => 'Enable', 'disable' => 'Disable', 'check' => 'Check'); + + switch ($cinfo[$plugin]['status']) { + case 0: //Not Installed + $links['install'] = "Install"; + break; + case 1: // Currently Active + $links['uninstall'] = "Uninstall"; + $links['disable'] = "Disable"; + break; + case 2: // Needs Configuring + $links['check'] = "Check"; + break; + case 3: // Needs Upgrade + $links['check'] = "Check"; + break; + case 4: // Installed but not active + $links['enable'] = "Enable"; + break; + } + + print ""; + print "
Directory:$pluginVersion:" . (isset($cinfo[$plugin]['version']) ? $cinfo[$plugin]['version'] : "") . (update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version']) ? ' - (Update Available!)' : '') . "Author:" . (isset($cinfo[$plugin]['author']) && $cinfo[$plugin]['author'] != '' ? (isset($cinfo[$plugin]['email']) && $cinfo[$plugin]['email'] != '' ? "" . $cinfo[$plugin]['author'] . "" : $cinfo[$plugin]['author']) : "") . "Home Page:" . (isset($cinfo[$plugin]['homepage']) && $cinfo[$plugin]['homepage'] != '' ? "" . $cinfo[$plugin]['homepage'] . "" : "") . "Status:" . $status_names[$cinfo[$plugin]['status']] . ""; + $c = 1; + foreach ($links as $temp => $link) { + print $link; + if ($c < count($links)) + print ' | '; + $c++; + } + + print "
"; + if ($x == 1) { + print "
"; + html_end_box(TRUE); +} + +function update_get_plugin_info () { + $cinfo = array(); + $info = db_fetch_assoc("SELECT * from plugin_config"); + if (is_array($info)) { + foreach($info as $inf) { + $cinfo[$inf['directory']] = $inf; + $cinfo[$inf['directory']]['changes']=''; + } + } + return $cinfo; +} + diff -Naur cacti-0.8.7e-old/poller.php cacti-0.8.7e/poller.php --- cacti-0.8.7e-old/poller.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/poller.php 2009-06-28 22:51:07.000000000 -0500 @@ -73,6 +73,8 @@ } } +api_plugin_hook('poller_top'); + /* record the start time */ list($micro,$seconds) = split(" ", microtime()); $poller_start = $seconds + $micro; @@ -261,6 +263,8 @@ $total_procs = $concurrent_processes; } + $extra_args = api_plugin_hook_function ('poller_command_args', $extra_args); + /* Populate each execution file with appropriate information */ foreach ($polling_hosts as $item) { if ($host_count == 1) { @@ -403,9 +407,11 @@ /* sleep the appripriate amount of time */ if ($poller_runs_completed < $poller_runs) { + api_plugin_hook('poller_bottom'); db_close(); usleep($sleep_time * 1000000); db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port); + api_plugin_hook('poller_top'); } }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM) { cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER"); @@ -452,4 +458,6 @@ echo " --debug|-d Output debug information. Similar to cacti's DEBUG logging level.\n\n"; } +api_plugin_hook('poller_bottom'); + ?> diff -Naur cacti-0.8.7e-old/user_admin.php cacti-0.8.7e/user_admin.php --- cacti-0.8.7e-old/user_admin.php 2009-06-28 11:07:28.000000000 -0500 +++ cacti-0.8.7e/user_admin.php 2009-06-28 22:51:07.000000000 -0500 @@ -72,9 +72,11 @@ break; default: - include_once("include/top_header.php"); - user(); - include_once("include/bottom_footer.php"); + if (!api_plugin_hook_function('user_admin_action', get_request_var_request("action"))) { + include_once("include/top_header.php"); + user(); + include_once("include/bottom_footer.php"); + } break; } @@ -418,6 +420,7 @@ $save["policy_graph_templates"] = form_input_validate(get_request_var_post("policy_graph_templates", get_request_var_post("_policy_graph_templates")), "policy_graph_templates", "", true, 3); $save["realm"] = get_request_var_post("realm", 0); $save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3); + $save = api_plugin_hook_function('user_admin_setup_sql_save', $save); if (!is_error_message()) { $user_id = sql_save($save, "user_auth"); @@ -460,6 +463,8 @@ policy_hosts = " . get_request_var_post("policy_hosts") . ", policy_graph_templates = " . get_request_var_post("policy_graph_templates") . " WHERE id = " . get_request_var_post("id")); + } else { + api_plugin_hook('user_admin_user_save'); } } } @@ -910,6 +915,8 @@ $header_label = "[new]"; } + api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0)); + html_start_box("User Management $header_label", "100%", $colors["header"], "3", "center", ""); draw_edit_form(array( @@ -936,6 +943,7 @@ nowrap='nowrap' width='130' align='center' class='tab'> Graph Settings + @@ -949,7 +957,9 @@ }elseif (get_request_var("action") == "graph_perms_edit") { graph_perms_edit(); }else{ - user_realms_edit(); + if (api_plugin_hook_function('user_admin_run_action', get_request_var_request("action"))) { + user_realms_edit(); + } } form_save_button("user_admin.php"); diff -Naur cacti-0.8.7e-old/utilities.php cacti-0.8.7e/utilities.php --- cacti-0.8.7e-old/utilities.php 2009-06-28 11:07:26.000000000 -0500 +++ cacti-0.8.7e/utilities.php 2009-06-28 22:51:07.000000000 -0500 @@ -129,11 +129,14 @@ include_once("./include/bottom_footer.php"); break; default: - include_once("./include/top_header.php"); - utilities(); + if (!api_plugin_hook_function('utilities_action', $_REQUEST['action'])) { + include_once('./include/top_header.php'); - include_once("./include/bottom_footer.php"); + utilities(); + + include_once('./include/bottom_footer.php'); + } break; } @@ -1642,6 +1645,8 @@