1 diff -Naur 0.8.7-old/auth_changepassword.php 0.8.7/auth_changepassword.php
2 --- 0.8.7-old/auth_changepassword.php 2008-02-12 08:39:56.000000000 -0600
3 +++ 0.8.7/auth_changepassword.php 2008-02-12 09:25:57.000000000 -0600
5 header("Location: index.php"); break;
6 case '3': /* default graph page */
7 header("Location: graph_view.php"); break;
9 + api_plugin_hook_function('login_options_navigate', $user['login_opts']);
12 header("Location: graph_view.php");
13 diff -Naur 0.8.7-old/auth_login.php 0.8.7/auth_login.php
14 --- 0.8.7-old/auth_login.php 2008-02-12 08:39:56.000000000 -0600
15 +++ 0.8.7/auth_login.php 2008-02-12 09:25:57.000000000 -0600
17 header("Location: index.php"); break;
18 case '3': /* default graph page */
19 header("Location: graph_view.php"); break;
21 + api_plugin_hook_function('login_options_navigate', $user['login_opts']);
26 <body bgcolor="#FFFFFF" onload="document.login.login_username.focus()">
27 <form name="login" method="post" action="<?php print basename($_SERVER["PHP_SELF"]);?>">
28 <input type="hidden" name="action" value="login">
31 +api_plugin_hook("login_before");
33 +$cacti_logo = $config['url_path'] . 'images/auth_login.gif';
34 +$cacti_logo = api_plugin_hook_function('cacti_image', $cacti_logo);
37 <table align="center">
39 - <td colspan="2"><img src="images/auth_login.gif" border="0" alt=""></td>
40 + <td colspan="2"><center><?php if ($cacti_logo != '') { ?><img src="<?php echo $cacti_logo; ?>" border="0" alt=""><?php } ?></center></td>
45 <td><input type="submit" value="Login"></td>
48 +<?php api_plugin_hook('login_after'); ?>
52 diff -Naur 0.8.7-old/data_sources.php 0.8.7/data_sources.php
53 --- 0.8.7-old/data_sources.php 2008-02-12 08:39:56.000000000 -0600
54 +++ 0.8.7/data_sources.php 2008-02-12 09:25:57.000000000 -0600
57 if (sizeof($data_sources) > 0) {
58 foreach ($data_sources as $data_source) {
59 + $data_source = api_plugin_hook_function('data_sources_table', $data_source);
60 $data_template_name = ((empty($data_source["data_template_name"])) ? "<em>None</em>" : $data_source["data_template_name"]);
61 $data_input_name = ((empty($data_source["data_input_name"])) ? "<em>External</em>" : $data_source["data_input_name"]);
62 $poller_interval = ((isset($poller_intervals[$data_source["local_data_id"]])) ? $poller_intervals[$data_source["local_data_id"]] : 0);
63 diff -Naur 0.8.7-old/graph_image.php 0.8.7/graph_image.php
64 --- 0.8.7-old/graph_image.php 2008-02-12 08:39:56.000000000 -0600
65 +++ 0.8.7/graph_image.php 2008-02-12 09:25:57.000000000 -0600
67 /* flush the headers now */
70 +api_plugin_hook_function('graph_image');
72 session_write_close();
74 $graph_data_array = array();
75 diff -Naur 0.8.7-old/graph.php 0.8.7/graph.php
76 --- 0.8.7-old/graph.php 2008-02-12 08:39:56.000000000 -0600
77 +++ 0.8.7/graph.php 2008-02-12 09:25:57.000000000 -0600
79 <a href='graph.php?action=zoom&local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $rra["id"];?>&view_type=<?php print $_REQUEST["view_type"];?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
80 <a href='graph_xport.php?local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $rra["id"];?>&view_type=<?php print $_REQUEST["view_type"];?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
81 <a href='graph.php?action=properties&local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $rra["id"];?>&view_type=<?php print $_REQUEST["view_type"];?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a>
82 + <?php api_plugin_hook('graph_buttons', array('hook' => 'view', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $rra['id'], 'view_type' => $_REQUEST['view_type'])); ?>
87 <td valign='top' style='padding: 3px;' class='noprint'>
88 <a href='graph.php?action=properties&local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $_GET["rra_id"];?>&view_type=<?php print $_REQUEST["view_type"];?>&graph_start=<?php print $graph_start;?>&graph_end=<?php print $graph_end;?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a>
89 <a href='graph_xport.php?local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $rra["id"];?>&view_type=<?php print $_REQUEST["view_type"];?>&graph_start=<?php print $graph_start;?>&graph_end=<?php print $graph_end;?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
90 + <?php api_plugin_hook('graph_buttons', array('hook' => 'zoom', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $_GET['rra_id'], 'view_type' => $_REQUEST['view_type'])); ?>
95 <td valign='top' style='padding: 3px;'>
96 <a href='graph.php?action=zoom&local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $_GET["rra_id"];?>&view_type=<?php print $_REQUEST["view_type"];?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
97 <a href='graph_xport.php?local_graph_id=<?php print $_GET["local_graph_id"];?>&rra_id=<?php print $_GET["rra_id"];?>&view_type=<?php print $_REQUEST["view_type"];?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
98 + <?php api_plugin_hook('graph_buttons', array('hook' => 'properties', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $_GET['rra_id'], 'view_type' => $_REQUEST['view_type'])); ?>
102 diff -Naur 0.8.7-old/graphs_new.php 0.8.7/graphs_new.php
103 --- 0.8.7-old/graphs_new.php 2008-02-12 08:39:56.000000000 -0600
104 +++ 0.8.7/graphs_new.php 2008-02-12 09:25:57.000000000 -0600
107 <td nowrap style='white-space: nowrap;' class="textInfo" align="center" valign="top">
108 <span style="white-space: nowrap; color: #c16921;">*</span><a href="host.php?action=edit&id=<?php print $_REQUEST["host_id"];?>">Edit this Host</a><br>
109 - <span style="white-space: nowrap; color: #c16921;">*</span><a href="host.php?action=edit">Create New Host</a>
110 + <span style="white-space: nowrap; color: #c16921;">*</span><a href="host.php?action=edit">Create New Host</a><br>
111 + <?php api_plugin_hook('graphs_new_top_links'); ?>
115 diff -Naur 0.8.7-old/graphs.php 0.8.7/graphs.php
116 --- 0.8.7-old/graphs.php 2008-02-12 08:39:56.000000000 -0600
117 +++ 0.8.7/graphs.php 2008-02-12 09:25:57.000000000 -0600
119 4 => "Convert to Graph Template"
122 +$graph_actions = api_plugin_hook_function('graphs_action_array', $graph_actions);
124 /* set default action */
125 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
128 input_validate_input_number($selected_items[$i]);
129 /* ==================================================== */
131 - api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
132 + api_resize_graphs($selected_items[$i], $_POST['graph_width'], $_POST['graph_height']);
135 + api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
138 header("Location: graphs.php");
144 + $save['drp_action'] = $_POST['drp_action'];
145 + $save['graph_list'] = $graph_list;
146 + $save['graph_array'] = $graph_array;
147 + api_plugin_hook_function('graphs_action_prepare', $save);
150 if (!isset($graph_array)) {
151 diff -Naur 0.8.7-old/host.php 0.8.7/host.php
152 --- 0.8.7-old/host.php 2008-02-12 08:39:56.000000000 -0600
153 +++ 0.8.7/host.php 2008-02-12 09:25:57.000000000 -0600
155 6 => "Change Availability Options"
158 +$device_actions = api_plugin_hook_function('device_action_array', $device_actions);
160 /* set default action */
161 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
165 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);
168 + api_plugin_hook_function('device_action_execute', $_POST['drp_action']);
171 header("Location: host.php");
174 <input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
177 + $save['drp_action'] = $_POST['drp_action'];
178 + $save['host_list'] = $host_list;
179 + $save['host_array'] = (isset($host_array)? $host_array : array());
180 + api_plugin_hook_function('device_action_prepare', $save);
183 if (!isset($host_array)) {
184 diff -Naur 0.8.7-old/include/auth.php 0.8.7/include/auth.php
185 --- 0.8.7-old/include/auth.php 2008-02-12 08:39:56.000000000 -0600
186 +++ 0.8.7/include/auth.php 2008-02-12 09:33:30.000000000 -0600
190 if (read_config_option("auth_method") != 0) {
191 + /* handle alternate authentication realms */
192 + do_hook_function('auth_alternate_realms');
194 /* handle change password dialog */
195 if ((isset($_SESSION['sess_change_password'])) && (read_config_option("webbasic_enabled") != "on")) {
196 header ("Location: auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php"));
201 - <link href="include/main.css" rel="stylesheet">
202 + <link href="<?php echo $config['url_path']; ?>include/main.css" rel="stylesheet">
208 <table width="450" align='center'>
210 - <td colspan='2'><img src='images/auth_deny.gif' border='0' alt='Access Denied'></td>
211 + <td colspan='2'><img src='<?php echo $config['url_path']; ?>images/auth_deny.gif' border='0' alt='Access Denied'></td>
213 <tr height='10'><td></td></tr>
216 need access to this particular section, please contact the Cacti administrator.</td>
219 - <td class='textArea' colspan='2' align='center'>( <a href='' onclick='javascript: history.back();'>Return</a> | <a href='index.php'>Login</a> )</td>
220 + <td class='textArea' colspan='2' align='center'>( <a href='' onclick='javascript: history.back();'>Return</a> | <a href='<?php echo $config['url_path']; ?>index.php'>Login</a> )</td>
224 diff -Naur 0.8.7-old/include/global_arrays.php 0.8.7/include/global_arrays.php
225 --- 0.8.7-old/include/global_arrays.php 2008-02-12 08:39:56.000000000 -0600
226 +++ 0.8.7/include/global_arrays.php 2008-02-12 09:25:57.000000000 -0600
228 +-------------------------------------------------------------------------+
235 "message" => 'Save Successful.',
240 +$plugin_architecture = array(
244 +api_plugin_hook('config_arrays');
247 diff -Naur 0.8.7-old/include/global_form.php 0.8.7/include/global_form.php
248 --- 0.8.7-old/include/global_form.php 2008-02-12 08:39:56.000000000 -0600
249 +++ 0.8.7/include/global_form.php 2008-02-12 09:25:57.000000000 -0600
251 +-------------------------------------------------------------------------+
254 -if (!defined("VALID_HOST_FIELDS")) {
255 - 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)");
256 +if (!defined('VALID_HOST_FIELDS')) {
257 + $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)');
258 + define('VALID_HOST_FIELDS', $string);
261 /* file: cdef.php, action: edit */
262 @@ -1154,4 +1155,6 @@
266 +api_plugin_hook('config_form');
269 diff -Naur 0.8.7-old/include/global.php 0.8.7/include/global.php
270 --- 0.8.7-old/include/global.php 2008-02-12 08:39:56.000000000 -0600
271 +++ 0.8.7/include/global.php 2008-02-12 09:25:57.000000000 -0600
273 /* Default session name - Session name must contain alpha characters */
274 $cacti_session_name = "Cacti";
277 +//$plugins[] = 'thold';
279 +/* Do not edit this line */
282 /* Include configuration */
283 include(dirname(__FILE__) . "/config.php");
286 "rebuild_poller_cache.php"
292 /* this should be auto-detected, set it manually if needed */
293 @@ -179,18 +184,24 @@
294 /* display ALL errors */
295 error_reporting(E_ALL);
297 +/* current cacti version */
298 +$config["cacti_version"] = "0.8.7b";
300 /* include base modules */
301 include($config["library_path"] . "/adodb/adodb.inc.php");
302 include($config["library_path"] . "/database.php");
303 -include_once($config["library_path"] . "/functions.php");
304 -include_once($config["include_path"] . "/global_constants.php");
305 -include_once($config["include_path"] . "/global_arrays.php");
306 -include_once($config["include_path"] . "/global_settings.php");
308 /* connect to the database server */
309 db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
311 /* include additional modules */
313 +include_once($config["library_path"] . "/functions.php");
314 +include_once($config["include_path"] . "/global_constants.php");
315 +include_once($config["library_path"] . "/plugins.php");
316 +include_once($config["include_path"] . "/plugins.php");
317 +include_once($config["include_path"] . "/global_arrays.php");
318 +include_once($config["include_path"] . "/global_settings.php");
319 include_once($config["include_path"] . "/global_form.php");
320 include_once($config["library_path"] . "/html.php");
321 include_once($config["library_path"] . "/html_form.php");
323 include_once($config["library_path"] . "/html_validate.php");
324 include_once($config["library_path"] . "/variables.php");
325 include_once($config["library_path"] . "/auth.php");
326 +include_once($config["library_path"] . "/auth.php");
328 -/* current cacti version */
329 -$config["cacti_version"] = "0.8.7b";
333 \ No newline at end of file
334 diff -Naur 0.8.7-old/include/global_settings.php 0.8.7/include/global_settings.php
335 --- 0.8.7-old/include/global_settings.php 2008-02-12 08:39:56.000000000 -0600
336 +++ 0.8.7/include/global_settings.php 2008-02-12 09:25:57.000000000 -0600
337 @@ -1083,4 +1083,6 @@
341 +api_plugin_hook('config_settings');
344 diff -Naur 0.8.7-old/include/plugins.php 0.8.7/include/plugins.php
345 --- 0.8.7-old/include/plugins.php 1969-12-31 17:00:00.000000000 -0700
346 +++ 0.8.7/include/plugins.php 2008-02-12 09:25:57.000000000 -0600
351 + * Copyright (c) 1999-2005 The SquirrelMail Project Team (http://squirrelmail.org)
352 + * Licensed under the GNU GPL. For full terms see the file COPYING.
355 +global $plugin_hooks;
356 +$plugin_hooks = array();
358 +function use_plugin ($name) {
360 + if (file_exists($config['base_path'] . "/plugins/$name/setup.php")) {
361 + include_once($config['base_path'] . "/plugins/$name/setup.php");
362 + $function = "plugin_init_$name";
363 + if (function_exists($function)) {
370 + * This function executes a hook.
371 + * @param string $name Name of hook to fire
372 + * @return mixed $data
375 +/* On startup, register all plugins configured for use. */
376 +if (isset($plugins) && is_array($plugins)) {
377 + foreach ($plugins as $name) {
382 +if (isset($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['REMOTE_ADDR'])) {
383 + $config['url_path'] = substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT']), strlen(__FILE__) - strlen($_SERVER['DOCUMENT_ROOT']) - strlen('include/plugins.php'));
384 + db_execute("REPLACE INTO settings (name, value) VALUES ('url_path', '" . $config['url_path'] . "')");
386 + $config['url_path'] = db_fetch_cell("SELECT value FROM settings WHERE name = 'url_path'");
389 +define('URL_PATH', $config['url_path']);
395 diff -Naur 0.8.7-old/include/top_graph_header.php 0.8.7/include/top_graph_header.php
396 --- 0.8.7-old/include/top_graph_header.php 2008-02-12 08:39:56.000000000 -0600
397 +++ 0.8.7/include/top_graph_header.php 2008-02-12 09:25:57.000000000 -0600
399 $using_guest_account = false;
400 $show_console_tab = true;
402 +$newtop = api_plugin_hook_function('top_graph_header', false);
403 +if ($newtop == true) {
407 /* ================= input validation ================= */
408 input_validate_input_number(get_request_var_request("local_graph_id"));
409 /* ==================================================== */
414 +$page_title = api_plugin_hook_function('page_title', 'Cacti');
419 - <title>Cacti</title>
420 + <title><?php echo $page_title; ?></title>
421 <?php if (isset($_SESSION["custom"])) {
422 if ($_SESSION["custom"]) {
423 print "<meta http-equiv=refresh content='99999'>\r\n";
425 - print "<meta http-equiv=refresh content='" . read_graph_config_option("page_refresh") . "'>\r\n";
426 + $refresh = api_plugin_hook_function('top_graph_refresh', read_graph_config_option('page_refresh'));
427 + print "<meta http-equiv=refresh content='" . $refresh . "'>\r\n";
431 - <link href="include/main.css" rel="stylesheet">
432 - <link href="images/favicon.ico" rel="shortcut icon"/>
433 - <script type="text/javascript" src="include/layout.js"></script>
434 - <script type="text/javascript" src="include/treeview/ua.js"></script>
435 - <script type="text/javascript" src="include/treeview/ftiens4.js"></script>
436 - <script type="text/javascript" src="include/jscalendar/calendar.js"></script>
437 - <script type="text/javascript" src="include/jscalendar/lang/calendar-en.js"></script>
438 - <script type="text/javascript" src="include/jscalendar/calendar-setup.js"></script>
439 + <link href="<?php echo $config['url_path']; ?>include/main.css" rel="stylesheet">
440 + <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
441 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
442 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ua.js"></script>
443 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ftiens4.js"></script>
444 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar.js"></script>
445 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/lang/calendar-en.js"></script>
446 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar-setup.js"></script>
447 + <?php api_plugin_hook('page_head'); ?>
450 <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
451 @@ -123,13 +132,15 @@
452 <table width="100%" cellspacing="0" cellpadding="0">
455 - <?php if ($show_console_tab == true) {?><a href="index.php"><img src="images/tab_console.gif" alt="Console" align="absmiddle" border="0"></a><?php }?><a href="graph_view.php"><img src="images/tab_graphs<?php if ((substr(basename($_SERVER["PHP_SELF"]),0,5) == "graph") || (basename($_SERVER["PHP_SELF"]) == "graph_settings.php")) { print "_down"; } print ".gif";?>" alt="Graphs" align="absmiddle" border="0"></a>
456 + <?php if ($show_console_tab == true) {?><a href="<?php echo $config['url_path']; ?>index.php"><img src="<?php echo $config['url_path']; ?>images/tab_console.gif" alt="Console" align="absmiddle" border="0"></a><?php }?><a href="<?php echo $config['url_path']; ?>graph_view.php"><img src="<?php echo $config['url_path']; ?>images/tab_graphs<?php if ((substr(basename($_SERVER["PHP_SELF"]),0,5) == "graph") || (basename($_SERVER["PHP_SELF"]) == "graph_settings.php")) { print "_down"; } print ".gif";?>" alt="Graphs" align="absmiddle" border="0"></a><?php
457 + api_plugin_hook('top_graph_header_tabs');
461 - <img src="images/cacti_backdrop2.gif" align="absmiddle">
462 + <img src="<?php echo $config['url_path']; ?>images/cacti_backdrop2.gif" align="absmiddle">
464 <td align="right" nowrap>
465 - <?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["graph_settings"] == "on")) { print '<a href="graph_settings.php"><img src="images/tab_settings'; if (basename($_SERVER["PHP_SELF"]) == "graph_settings.php") { print "_down"; } print '.gif" border="0" alt="Settings" align="absmiddle"></a>';}?> <?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_tree"] == "on")) {?><a href="graph_view.php?action=tree"><img src="images/tab_mode_tree<?php if ($_REQUEST["action"] == "tree") { print "_down"; }?>.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_list"] == "on")) {?><a href="graph_view.php?action=list"><img src="images/tab_mode_list<?php if ($_REQUEST["action"] == "list") { print "_down"; }?>.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_preview"] == "on")) {?><a href="graph_view.php?action=preview"><img src="images/tab_mode_preview<?php if ($_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?> <br>
466 + <?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["graph_settings"] == "on")) { print '<a href="' . $config['url_path'] . 'graph_settings.php"><img src="' . $config['url_path'] . 'images/tab_settings'; if (basename($_SERVER["PHP_SELF"]) == "graph_settings.php") { print "_down"; } print '.gif" border="0" alt="Settings" align="absmiddle"></a>';}?> <?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_tree"] == "on")) {?><a href="<?php echo $config['url_path']; ?>graph_view.php?action=tree"><img src="<?php echo $config['url_path']; ?>images/tab_mode_tree<?php if ($_REQUEST["action"] == "tree") { print "_down"; }?>.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_list"] == "on")) {?><a href="<?php echo $config['url_path']; ?>graph_view.php?action=list"><img src="<?php echo $config['url_path']; ?>images/tab_mode_list<?php if ($_REQUEST["action"] == "list") { print "_down"; }?>.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_preview"] == "on")) {?><a href="<?php echo $config['url_path']; ?>graph_view.php?action=preview"><img src="<?php echo $config['url_path']; ?>images/tab_mode_preview<?php if ($_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?> <br>
472 <tr height="2" colspan="2" bgcolor="#183c8f" class="noprint">
474 - <img src="images/transparent_line.gif" width="170" height="2" border="0"><br>
475 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="170" height="2" border="0"><br>
478 <tr height="5" bgcolor="#e9e9e9" class="noprint">
482 <?php if ((isset($_SESSION["sess_user_id"])) && ($using_guest_account == false)) { ?>
483 - Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="logout.php">Logout</a>)
484 + Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="<?php echo $config['url_path']; ?>logout.php">Logout</a>)
488 @@ -157,10 +168,10 @@
492 - <td bgcolor="#efefef" colspan="1" height="8" style="background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
493 - <img src="images/transparent_line.gif" width="<?php print read_graph_config_option("default_dual_pane_width");?>" height="2" border="0"><br>
494 + <td bgcolor="#efefef" colspan="1" height="8" style="background-image: url(<?php echo $config['url_path']; ?>images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
495 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="<?php print read_graph_config_option("default_dual_pane_width");?>" height="2" border="0"><br>
497 - <td bgcolor="#ffffff" colspan="1" height="8" style="background-image: url(images/shadow.gif); background-repeat: repeat-x;">
498 + <td bgcolor="#ffffff" colspan="1" height="8" style="background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;">
502 diff -Naur 0.8.7-old/include/top_header.php 0.8.7/include/top_header.php
503 --- 0.8.7-old/include/top_header.php 2008-02-12 08:39:56.000000000 -0600
504 +++ 0.8.7/include/top_header.php 2008-02-12 09:25:57.000000000 -0600
506 +-------------------------------------------------------------------------+
510 +global $colors, $config;
512 +$newtop = api_plugin_hook_function('top_header', false);
513 +if ($newtop == true) {
517 +$page_title = api_plugin_hook_function('page_title', 'Cacti');
522 - <title>Cacti</title>
523 - <link href="include/main.css" rel="stylesheet">
524 - <link href="images/favicon.ico" rel="shortcut icon"/>
525 - <script type="text/javascript" src="include/layout.js"></script>
526 + <title><?php echo $page_title; ?></title>
527 + <link href="<?php echo $config['url_path']; ?>include/main.css" rel="stylesheet">
528 + <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
529 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
530 <?php if (isset($refresh)) {
531 print "<meta http-equiv=refresh content=\"" . $refresh["seconds"] . "; url='" . $refresh["page"] . "'\">";
534 + api_plugin_hook('page_head'); ?>
538 -<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/left_border.gif">
539 +<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="<?php echo $config['url_path']; ?>images/left_border.gif">
541 <table width="100%" cellspacing="0" cellpadding="0">
542 <tr height="37" bgcolor="#a9a9a9">
544 <table width="100%" cellspacing="0" cellpadding="0">
547 - <a href="index.php"><img src="images/tab_console_down.gif" alt="Console" align="absmiddle" border="0"></a><a href="graph_view.php"><img src="images/tab_graphs.gif" alt="Graphs" align="absmiddle" border="0"></a>
549 + <a href="<?php echo $config['url_path']; ?>index.php"><img src="<?php echo $config['url_path']; ?>images/tab_console_down.gif" alt="Console" align="absmiddle" border="0"></a><a href="<?php echo $config['url_path']; ?>graph_view.php"><img src="<?php echo $config['url_path']; ?>images/tab_graphs.gif" alt="Graphs" align="absmiddle" border="0"></a><?php
550 + api_plugin_hook('top_header_tabs');
553 - <img src="images/cacti_backdrop.gif" align="absmiddle">
554 + <img src="<?php echo $config['url_path']; ?>images/cacti_backdrop.gif" align="absmiddle">
560 <tr height="2" bgcolor="#183c8f">
562 - <img src="images/transparent_line.gif" height="2" border="0"><br>
563 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" height="2" border="0"><br>
566 <tr height="5" bgcolor="#e9e9e9">
570 <?php if (read_config_option("auth_method") != 0) { ?>
571 - Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="logout.php">Logout</a>)
572 + Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="<?php echo $config['url_path']; ?>logout.php">Logout</a>)
580 - <td bgcolor="#f5f5f5" colspan="1" height="8" width="135" style="background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
581 - <img src="images/transparent_line.gif" width="135" height="2" border="0"><br>
583 - <td colspan="2" height="8" style="background-image: url(images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
584 + <td bgcolor="#f5f5f5" colspan="1" height="8" width="135" style="background-image: url(<?php echo $config['url_path']; ?>images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
585 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="135" height="2" border="0"><br>
587 + <td colspan="2" height="8" style="background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
595 - <img src="images/transparent_line.gif" width="135" height="5" border="0"><br>
596 - <p align="center"><a href='about.php'><img src="images/cacti_logo.gif" border="0"></a></p>
597 - <img src="images/transparent_line.gif" width="135" height="5" border="0"><br>
598 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="135" height="5" border="0"><br>
599 + <p align="center"><a href='<?php echo $config['url_path']; ?>about.php'><img src="<?php echo $config['url_path']; ?>images/cacti_logo.gif" border="0"></a></p>
600 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="135" height="5" border="0"><br>
602 <td width="100%" colspan="2" valign="top" style="padding: 5px; border-right: #aaaaaa 1px solid;"><?php display_output_messages();?>
604 diff -Naur 0.8.7-old/index.php 0.8.7/index.php
605 --- 0.8.7-old/index.php 2008-02-12 08:39:56.000000000 -0600
606 +++ 0.8.7/index.php 2008-02-12 09:25:57.000000000 -0600
608 include("./include/auth.php");
609 include("./include/top_header.php");
611 +api_plugin_hook('console_before');
614 <table width="100%" align="center">
620 +api_plugin_hook('console_after');
622 include("./include/bottom_footer.php");
625 diff -Naur 0.8.7-old/lib/api_device.php 0.8.7/lib/api_device.php
626 --- 0.8.7-old/lib/api_device.php 2008-02-12 08:39:56.000000000 -0600
627 +++ 0.8.7/lib/api_device.php 2008-02-12 09:25:57.000000000 -0600
629 $save["ping_retries"] = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3);
630 $save["max_oids"] = form_input_validate($max_oids, "max_oids", "^[0-9]+$", true, 3);
632 + $save = api_plugin_hook_function('api_device_save', $save);
636 if (!is_error_message()) {
637 diff -Naur 0.8.7-old/lib/functions.php 0.8.7/lib/functions.php
638 --- 0.8.7-old/lib/functions.php 2008-02-12 08:39:56.000000000 -0600
639 +++ 0.8.7/lib/functions.php 2008-02-12 09:25:57.000000000 -0600
640 @@ -1532,6 +1532,7 @@
641 /* draw_navigation_text - determines the top header navigation text for the current page and displays it to
643 function draw_navigation_text() {
645 $nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : array());
648 @@ -1544,7 +1545,7 @@
649 "graph.php:zoom" => array("title" => "Zoom", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
650 "graph.php:properties" => array("title" => "Properties", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
651 "graph_settings.php:" => array("title" => "Settings", "mapping" => "graph_view.php:", "url" => "graph_settings.php", "level" => "1"),
652 - "index.php:" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
653 + "index.php:" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
654 "graphs.php:" => array("title" => "Graph Management", "mapping" => "index.php:", "url" => "graphs.php", "level" => "1"),
655 "graphs.php:graph_edit" => array("title" => "(Edit)", "mapping" => "index.php:,graphs.php:", "url" => "", "level" => "2"),
656 "graphs.php:graph_diff" => array("title" => "Change Graph Template", "mapping" => "index.php:,graphs.php:,graphs.php:graph_edit", "url" => "", "level" => "3"),
657 @@ -1621,6 +1622,8 @@
658 "templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"),
661 + $nav = api_plugin_hook_function('draw_navigation_text', $nav);
663 $current_page = basename($_SERVER["PHP_SELF"]);
665 input_validate_input_regex(get_request_var_request("action"), "^([a-zA-Z0-9_-]+)$");
666 diff -Naur 0.8.7-old/lib/html_form.php 0.8.7/lib/html_form.php
667 --- 0.8.7-old/lib/html_form.php 2008-02-12 08:39:56.000000000 -0600
668 +++ 0.8.7/lib/html_form.php 2008-02-12 09:28:24.000000000 -0600
669 @@ -657,11 +657,13 @@
670 on a confirmation form
671 @arg $cancel_url - the url to go to when the user clicks 'cancel'
672 @arg $action_url - the url to go to when the user clicks 'delete' */
673 -function form_confirm_buttons($action_url, $cancel_url) { ?>
674 +function form_confirm_buttons($action_url, $cancel_url) {
678 <td bgcolor="#E1E1E1">
679 - <a href="<?php print $cancel_url;?>"><img src="images/button_cancel.gif" border="0" alt="Cancel" align="absmiddle"></a>
680 - <a href="<?php print $action_url . "&confirm=yes";?>"><img src="images/button_delete.gif" border="0" alt="Delete" align="absmiddle"></a>
681 + <a href="<?php print $cancel_url;?>"><img src="<?php print $config['url_path'] ?>images/button_cancel.gif" border="0" alt="Cancel" align="absmiddle"></a>
682 + <a href="<?php print $action_url . "&confirm=yes";?>"><img src="<?php print $config['url_path'] ?>images/button_delete.gif" border="0" alt="Delete" align="absmiddle"></a>
687 @arg $force_type - if specified, will force the 'action' button to be either
688 'save' or 'create'. otherwise this field should be properly auto-detected */
689 function form_save_button($cancel_url, $force_type = "", $key_field = "id") {
691 if (empty($force_type)) {
692 if (empty($_GET[$key_field])) {
693 $img = "button_create.gif";
696 <td bgcolor="#f5f5f5" align="right">
697 <input type='hidden' name='action' value='save'>
698 - <a href='<?php print $cancel_url;?>'><img src='images/button_cancel2.gif' alt='Cancel' align='absmiddle' border='0'></a>
699 - <input type='image' src='images/<?php print $img;?>' alt='<?php print $alt;?>' align='absmiddle'>
700 + <a href='<?php print $cancel_url;?>'><img src='<?php echo $config['url_path']; ?>images/button_cancel2.gif' alt='Cancel' align='absmiddle' border='0'></a>
701 + <input type='image' src='<?php echo $config['url_path']; ?>images/<?php print $img;?>' alt='<?php print $alt;?>' align='absmiddle'>
705 diff -Naur 0.8.7-old/lib/html.php 0.8.7/lib/html.php
706 --- 0.8.7-old/lib/html.php 2008-02-12 08:39:56.000000000 -0600
707 +++ 0.8.7/lib/html.php 2008-02-12 09:25:57.000000000 -0600
709 @arg $extra_url_args - extra arguments to append to the url
710 @arg $header - html to use as a header */
711 function html_graph_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
714 if (sizeof($graph_array) > 0) {
717 <table width='1' cellpadding='0'>
720 - <a href='graph.php?action=view&local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=all'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='graph_image.php?local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0<?php print (($extra_url_args == "") ? "" : "&$extra_url_args");?>' border='0' alt='<?php print $graph["title_cache"];?>'></a>
721 + <a href='<?php print $config['url_path']; ?>graph.php?action=view&local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=all'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print $config['url_path']; ?>graph_image.php?local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0<?php print (($extra_url_args == "") ? "" : "&$extra_url_args");?>' border='0' alt='<?php print $graph["title_cache"];?>'></a>
723 <td valign='top' style='padding: 3px;' class='noprint'>
724 - <a href='graph.php?action=zoom&local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
725 - <a href='graph_xport.php?local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
726 - <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
727 + <a href='<?php print $config['url_path']; ?>graph.php?action=zoom&local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='<?php print $config['url_path']; ?>images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
728 + <a href='<?php print $config['url_path']; ?>graph_xport.php?local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='<?php print $config['url_path']; ?>images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
729 + <a href='#page_top'><img src='<?php print $config['url_path']; ?>images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
730 + <?php api_plugin_hook('graph_buttons', array('hook' => 'graphs', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => '')); ?>
735 @arg $extra_url_args - extra arguments to append to the url
736 @arg $header - html to use as a header */
737 function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
740 if (sizeof($graph_array) > 0) {
742 @@ -144,12 +147,12 @@
743 <table width='1' cellpadding='0'>
746 - <a href='graph.php?action=view&rra_id=all&local_graph_id=<?php print $graph["local_graph_id"];?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='graph_image.php?local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&graph_height=<?php print read_graph_config_option("default_height");?>&graph_width=<?php print read_graph_config_option("default_width");?>&graph_nolegend=true<?php print (($extra_url_args == "") ? "" : "&$extra_url_args");?>' border='0' alt='<?php print $graph["title_cache"];?>'></a>
747 + <a href='<?php print $config['url_path']; ?>graph.php?action=view&rra_id=all&local_graph_id=<?php print $graph["local_graph_id"];?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print $config['url_path']; ?>graph_image.php?local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&graph_height=<?php print read_graph_config_option("default_height");?>&graph_width=<?php print read_graph_config_option("default_width");?>&graph_nolegend=true<?php print (($extra_url_args == "") ? "" : "&$extra_url_args");?>' border='0' alt='<?php print $graph["title_cache"];?>'></a>
749 <td valign='top' style='padding: 3px;'>
750 - <a href='graph.php?action=zoom&local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
751 - <a href='graph_xport.php?local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
752 - <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
753 + <a href='<?php print $config['url_path']; ?>graph.php?action=zoom&local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='<?php print $config['url_path']; ?>images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
754 + <a href='<?php print $config['url_path']; ?>graph_xport.php?local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='<?php print $config['url_path']; ?>images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
755 + <a href='#page_top'><img src='<?php print $config['url_path']; ?>images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
762 while (list($item_sub_url, $item_sub_title) = each($item_title)) {
763 + $item_sub_url = $config['url_path'] . $item_sub_url;
765 /* indent sub-items */
767 $prepend_string = "--- ";
770 /* do not put a line between each sub-item */
771 if (($i == 0) || ($draw_sub_items == false)) {
772 - $background = "images/menu_line.gif";
773 + $background = $config['url_path'] . "images/menu_line.gif";
777 @@ -570,17 +575,18 @@
779 if ((isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) {
780 /* draw normal (non sub-item) menu item */
781 + $item_url = $config['url_path'] . $item_url;
782 if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) {
783 - print "<tr><td class='textMenuItemSelected' background='images/menu_line.gif'><strong><a href='$item_url'>$item_title</a></strong></td></tr>\n";
784 + print "<tr><td class='textMenuItemSelected' background='" . $config['url_path'] . "images/menu_line.gif'><strong><a href='$item_url'>$item_title</a></strong></td></tr>\n";
786 - print "<tr><td class='textMenuItem' background='images/menu_line.gif'><a href='$item_url'>$item_title</a></td></tr>\n";
787 + print "<tr><td class='textMenuItem' background='" . $config['url_path'] . "images/menu_line.gif'><a href='$item_url'>$item_title</a></td></tr>\n";
794 - print "<tr><td class='textMenuItem' background='images/menu_line.gif'></td></tr>\n";
795 + print "<tr><td class='textMenuItem' background='" . $config['url_path'] . "images/menu_line.gif'></td></tr>\n";
797 print "</table></td></tr>";
799 @@ -590,18 +596,19 @@
800 @arg $actions_array - an array that contains a list of possible actions. this array should
801 be compatible with the form_dropdown() function */
802 function draw_actions_dropdown($actions_array) {
805 <table align='center' width='100%'>
807 <td width='1' valign='top'>
808 - <img src='images/arrow.gif' alt='' align='absmiddle'>
809 + <img src='<?php echo $config['url_path']; ?>images/arrow.gif' alt='' align='absmiddle'>
813 <?php form_dropdown("drp_action",$actions_array,"","","1","","");?>
815 <td width='1' align='right'>
816 - <input type='image' src='images/button_go.gif' alt='Go'>
817 + <input type='image' src='<?php echo $config['url_path']; ?>images/button_go.gif' alt='Go'>
821 diff -Naur 0.8.7-old/lib/html_tree.php 0.8.7/lib/html_tree.php
822 --- 0.8.7-old/lib/html_tree.php 2008-02-12 08:39:56.000000000 -0600
823 +++ 0.8.7/lib/html_tree.php 2008-02-12 09:25:57.000000000 -0600
825 if (read_graph_config_option("thumbnail_section_tree_1") == "on") {
826 if (read_graph_config_option("timespan_sel") == "on") {
827 print "<td><a href='graph.php?local_graph_id=$local_graph_id&rra_id=all'><img align='middle' alt='$graph_title' class='graphimage' id='graph_$local_graph_id'
828 - src='graph_image.php?local_graph_id=$local_graph_id&rra_id=0&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end() . '&graph_height=' .
829 + src='graph_image.php?action=view&local_graph_id=$local_graph_id&rra_id=0&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end() . '&graph_height=' .
830 read_graph_config_option("default_height") . '&graph_width=' . read_graph_config_option("default_width") . "&graph_nolegend=true' border='0'></a></td>\n";
832 /* if we are at the end of a row, start a new one */
836 print "<td><a href='graph.php?local_graph_id=$local_graph_id&rra_id=all'><img align='middle' alt='$graph_title' class='graphimage' id='graph_$local_graph_id'
837 - src='graph_image.php?local_graph_id=$local_graph_id&rra_id=$rra_id&graph_start=" . -(db_fetch_cell("select timespan from rra where id=$rra_id")) . '&graph_height=' .
838 + src='graph_image.php?action=view&local_graph_id=$local_graph_id&rra_id=$rra_id&graph_start=" . -(db_fetch_cell("select timespan from rra where id=$rra_id")) . '&graph_height=' .
839 read_graph_config_option("default_height") . '&graph_width=' . read_graph_config_option("default_width") . "&graph_nolegend=true' border='0'></a></td>\n";
841 /* if we are at the end of a row, start a new one */
842 @@ -909,10 +909,10 @@
845 if (read_graph_config_option("timespan_sel") == "on") {
846 - print "<td><a href='graph.php?local_graph_id=$local_graph_id&rra_id=all'><img class='graphimage' id='graph_$local_graph_id' src='graph_image.php?local_graph_id=$local_graph_id&rra_id=0&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end() . "' border='0' alt='$graph_title'></a></td>";
847 + print "<td><a href='graph.php?local_graph_id=$local_graph_id&rra_id=all'><img class='graphimage' id='graph_$local_graph_id' src='graph_image.php?action=view&local_graph_id=$local_graph_id&rra_id=0&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end() . "' border='0' alt='$graph_title'></a></td>";
850 - print "<td><a href='graph.php?local_graph_id=$local_graph_id&rra_id=all'><img class='graphimage' id='graph_$local_graph_id' src='graph_image.php?local_graph_id=$local_graph_id&rra_id=$rra_id' border='0' alt='$graph_title'></a></td>";
851 + print "<td><a href='graph.php?local_graph_id=$local_graph_id&rra_id=all'><img class='graphimage' id='graph_$local_graph_id' src='graph_image.php?action=view&local_graph_id=$local_graph_id&rra_id=$rra_id' border='0' alt='$graph_title'></a></td>";
855 diff -Naur 0.8.7-old/lib/plugins.php 0.8.7/lib/plugins.php
856 --- 0.8.7-old/lib/plugins.php 1969-12-31 17:00:00.000000000 -0700
857 +++ 0.8.7/lib/plugins.php 2008-02-12 09:36:16.000000000 -0600
863 +function do_hook ($name) {
864 + $data = func_get_args();
865 + $data = api_plugin_hook ($name, $data);
869 +function do_hook_function($name,$parm=NULL) {
870 + return api_plugin_hook_function ($name, $parm);
873 +function api_user_realm_auth ($filename = '') {
874 + return api_plugin_user_realm_auth ($filename);
878 + * This function executes a hook.
879 + * @param string $name Name of hook to fire
880 + * @return mixed $data
882 +function api_plugin_hook ($name) {
883 + global $config, $plugin_hooks;
884 + $data = func_get_args();
888 + $result = db_fetch_assoc("SELECT name, file, function FROM plugin_hooks WHERE status = 1 AND hook = '$name'", false);
889 + if (count($result)) {
890 + foreach ($result as $hdata) {
891 + $p[] = $hdata['name'];
892 + if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
893 + include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
895 + $function = $hdata['function'];
896 + if (function_exists($function)) {
902 + if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
903 + foreach ($plugin_hooks[$name] as $pname => $function) {
904 + if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
910 + /* Variable-length argument lists have a slight problem when */
911 + /* passing values by reference. Pity. This is a workaround. */
915 +function api_plugin_hook_function ($name, $parm=NULL) {
916 + global $config, $plugin_hooks;
919 + $result = db_fetch_assoc("SELECT name, file, function FROM plugin_hooks WHERE status = 1 AND hook = '$name'", false);
921 + if (count($result)) {
922 + foreach ($result as $hdata) {
923 + $p[] = $hdata['name'];
924 + if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
925 + include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
927 + $function = $hdata['function'];
928 + if (function_exists($function)) {
929 + $ret = $function($ret);
934 + if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
935 + foreach ($plugin_hooks[$name] as $pname => $function) {
936 + if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
937 + $ret = $function($ret);
942 + /* Variable-length argument lists have a slight problem when */
943 + /* passing values by reference. Pity. This is a workaround. */
947 +function api_plugin_db_table_create ($plugin, $table, $data) {
948 + global $config, $database_default;
949 + include_once($config["library_path"] . "/database.php");
951 + $result = db_fetch_assoc("show tables from `" . $database_default . "`") or die (mysql_error());
953 + foreach($result as $index => $arr) {
954 + foreach ($arr as $t) {
958 + if (!in_array($table, $tables)) {
960 + $sql = 'CREATE TABLE `' . $table . "` (\n";
961 + foreach ($data['columns'] as $column) {
962 + if (isset($column['name'])) {
965 + $sql .= '`' . $column['name'] . '`';
966 + if (isset($column['type']))
967 + $sql .= ' ' . $column['type'];
968 + if (isset($column['unsigned']))
969 + $sql .= ' unsigned';
970 + if (isset($column['NULL']) && $column['NULL'] == false)
971 + $sql .= ' NOT NULL';
972 + if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
973 + $sql .= ' default NULL';
974 + if (isset($column['default']))
975 + $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
976 + if (isset($column['auto_increment']))
977 + $sql .= ' auto_increment';
982 + if (isset($data['primary'])) {
983 + $sql .= ",\n PRIMARY KEY (`" . $data['primary'] . '`)';
986 + foreach ($data['keys'] as $key) {
987 + if (isset($key['name'])) {
988 + $sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)';
991 + $sql .= ') TYPE = ' . $data['type'];
993 + if (isset($data['comment'])) {
994 + $sql .= " COMMENT = '" . $data['comment'] . "'";
996 + if (db_execute($sql)) {
997 + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1000 + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1004 +function api_plugin_db_changes_remove ($plugin) {
1005 + // Example: api_plugin_db_changes_remove ('thold');
1007 + $tables = db_fetch_assoc("SELECT `table` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='create'", false);
1008 + if (count($tables)) {
1009 + foreach ($tables as $table) {
1010 + db_execute("DROP TABLE `" . $table['table'] . "`;");
1012 + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false);
1014 + $columns = db_fetch_assoc("SELECT `table`, `column` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='addcolumn'", false);
1015 + if (count($columns)) {
1016 + foreach ($columns as $column) {
1017 + db_execute('ALTER TABLE `' . $column['table'] . '` DROP `' . $column['column'] . '`');
1019 + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false);
1023 +function api_plugin_db_add_column ($plugin, $table, $column) {
1024 + // Example: api_plugin_db_add_column ('thold', 'plugin_config', array('name' => 'test' . rand(1, 200), 'type' => 'varchar (255)', 'NULL' => false));
1026 + global $config, $database_default;
1027 + include_once($config['library_path'] . '/database.php');
1029 + $result = db_fetch_assoc('show columns from `' . $table . '`') or die (mysql_error());
1030 + $columns = array();
1031 + foreach($result as $index => $arr) {
1032 + foreach ($arr as $t) {
1036 + if (isset($column['name']) && !in_array($column['name'], $columns)) {
1037 + $sql = 'ALTER TABLE `' . $table . '` ADD `' . $column['name'] . '`';
1038 + if (isset($column['type']))
1039 + $sql .= ' ' . $column['type'];
1040 + if (isset($column['unsigned']))
1041 + $sql .= ' unsigned';
1042 + if (isset($column['NULL']) && $column['NULL'] == false)
1043 + $sql .= ' NOT NULL';
1044 + if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
1045 + $sql .= ' default NULL';
1046 + if (isset($column['default']))
1047 + $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
1048 + if (isset($column['auto_increment']))
1049 + $sql .= ' auto_increment';
1050 + if (isset($column['after']))
1051 + $sql .= ' AFTER ' . $column['after'];
1053 + if (db_execute($sql)) {
1054 + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')");
1059 +function api_plugin_install ($plugin) {
1061 + include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1063 + $exists = db_fetch_assoc("SELECT id FROM plugin_config WHERE directory = '$plugin'", false);
1064 + if (!count($exists)) {
1065 + db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1068 + $name = $author = $webpage = $version = '';
1069 + $function = 'plugin_' . $plugin . '_version';
1070 + if (function_exists($function)){
1071 + $info = $function();
1072 + $name = $info['longname'];
1073 + $webpage = $info['homepage'];
1074 + $author = $info['author'];
1075 + $version = $info['version'];
1078 + db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')");
1080 + $function = 'plugin_' . $plugin . '_install';
1081 + if (function_exists($function)){
1083 + $ready = api_plugin_check_config ($plugin);
1085 + // Set the plugin as "disabled" so it can go live
1086 + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1088 + // Set the plugin as "needs configuration"
1089 + db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'");
1094 +function api_plugin_uninstall ($plugin) {
1096 + include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1097 + // Run the Plugin's Uninstall Function first
1098 + $function = 'plugin_' . $plugin . '_uninstall';
1099 + if (function_exists($function)) {
1102 + api_plugin_remove_hooks ($plugin);
1103 + api_plugin_remove_realms ($plugin);
1104 + db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1105 + api_plugin_db_changes_remove ($plugin);
1108 +function api_plugin_check_config ($plugin) {
1110 + include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1111 + $function = 'plugin_' . $plugin . '_check_config';
1112 + if (function_exists($function)) {
1113 + return $function();
1118 +function api_plugin_enable ($plugin) {
1119 + $ready = api_plugin_check_config ($plugin);
1121 + api_plugin_enable_hooks ($plugin);
1122 + db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'");
1126 +function api_plugin_is_enabled ($plugin) {
1127 + $status = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = '$plugin'", false);
1128 + if ($status == '1')
1133 +function api_plugin_disable ($plugin) {
1134 + api_plugin_disable_hooks ($plugin);
1135 + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1138 +function api_plugin_register_hook ($plugin, $hook, $function, $file) {
1139 + $exists = db_fetch_assoc("SELECT id FROM plugin_hooks WHERE name = '$plugin' AND hook = '$hook'", false);
1140 + if (!count($exists)) {
1141 + $settings = array('config_settings', 'config_arrays', 'config_form');
1142 + if (!in_array($hook, $settings)) {
1143 + db_execute("INSERT INTO plugin_hooks (name, hook, function, file) VALUES ('$plugin', '$hook', '$function', '$file')");
1145 + db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)");
1150 +function api_plugin_remove_hooks ($plugin) {
1151 + db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'");
1154 +function api_plugin_enable_hooks ($plugin) {
1155 + db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'");
1158 +function api_plugin_disable_hooks ($plugin) {
1159 + db_execute("UPDATE plugin_hooks SET status = 0 WHERE name = '$plugin' AND hook != 'config_settings' AND hook != 'config_arrays' AND hook != 'config_form'");
1162 +function api_plugin_register_realm ($plugin, $file, $display, $admin = false) {
1163 + $exists = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1164 + if (!count($exists)) {
1165 + db_execute("INSERT INTO plugin_realms (plugin, file, display) VALUES ('$plugin', '$file', '$display')");
1167 + $realm_id = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1168 + $realm_id = $realm_id[0]['id'] + 100;
1169 + $user_id = db_fetch_assoc("SELECT id FROM user_auth WHERE username = 'admin'", false);
1170 + if (count($user_id)) {
1171 + $user_id = $user_id[0]['id'];
1172 + $exists = db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id = $user_id and realm_id = $realm_id", false);
1173 + if (!count($exists)) {
1174 + db_execute("INSERT INTO user_auth_realm (user_id, realm_id) VALUES ($user_id, $realm_id)");
1181 +function api_plugin_remove_realms ($plugin) {
1182 + $realms = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin'", false);
1183 + foreach ($realms as $realm) {
1184 + $id = $realm['id'] + 100;
1185 + db_execute("DELETE FROM user_auth_realm WHERE realm_id = '$id'");
1187 + db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'");
1190 +function api_plugin_load_realms () {
1191 + global $user_auth_realms, $user_auth_realm_filenames;
1192 + $plugin_realms = db_fetch_assoc("SELECT * FROM plugin_realms", false);
1193 + if (count($plugin_realms)) {
1194 + foreach ($plugin_realms as $plugin_realm) {
1195 + $plugin_files = explode(',', $plugin_realm['file']);
1196 + foreach($plugin_files as $plugin_file) {
1197 + $user_auth_realm_filenames[$plugin_file] = $plugin_realm['id'] + 100;
1199 + $user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display'];
1204 +function api_plugin_user_realm_auth ($filename = '') {
1205 + global $user_realms, $user_auth_realms, $user_auth_realm_filenames;
1206 + /* list all realms that this user has access to */
1207 + if (!isset($user_realms)) {
1208 + if (read_config_option('global_auth') == 'on' || read_config_option('auth_method') == 1) {
1209 + $user_realms = db_fetch_assoc("select realm_id from user_auth_realm where user_id=" . $_SESSION["sess_user_id"], false);
1210 + $user_realms = array_rekey($user_realms, "realm_id", "realm_id");
1212 + $user_realms = $user_auth_realms;
1215 + if ($filename != '') {
1216 + if (isset($user_realms[$user_auth_realm_filenames{basename($filename)}]))
1222 +function plugin_config_arrays () {
1224 + $menu['Configuration']['plugins.php'] = 'Plugin Management';
1225 + api_plugin_load_realms ();
1228 +function plugin_draw_navigation_text ($nav) {
1229 + $nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1");
1239 diff -Naur 0.8.7-old/lib/poller.php 0.8.7/lib/poller.php
1240 --- 0.8.7-old/lib/poller.php 2008-02-12 08:39:56.000000000 -0600
1241 +++ 0.8.7/lib/poller.php 2008-02-12 09:25:57.000000000 -0600
1242 @@ -320,8 +320,11 @@
1246 + api_plugin_hook_function('poller_output', $rrd_update_array);
1248 - $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1249 + if (api_plugin_hook_function('poller_on_demand', $results)) {
1250 + $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1254 return $rrds_processed;
1255 diff -Naur 0.8.7-old/lib/rrd.php 0.8.7/lib/rrd.php
1256 --- 0.8.7-old/lib/rrd.php 2008-02-12 08:39:56.000000000 -0600
1257 +++ 0.8.7/lib/rrd.php 2008-02-12 09:25:57.000000000 -0600
1258 @@ -484,6 +484,10 @@
1262 + $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));
1263 + if (isset($data['return']) && $data['return'] != false)
1264 + return $data['return'];
1266 /* find the step and how often this graph is updated with new data */
1267 $ds_step = db_fetch_cell("select
1268 data_template_data.rrd_step
1269 @@ -1186,6 +1190,13 @@
1273 + $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));
1274 + if (!empty($graph_array)) {
1275 + $graph_defs = $graph_array['graph_defs'];
1276 + $txt_graph_items = $graph_array['txt_graph_items'];
1277 + $graph_opts = $graph_array['graph_opts'];
1280 /* either print out the source or pass the source onto rrdtool to get us a nice PNG */
1281 if (isset($graph_data_array["print_source"])) {
1282 print "<PRE>" . read_config_option("path_rrdtool") . " graph $graph_opts$graph_defs$txt_graph_items</PRE>";
1283 @@ -1194,13 +1205,19 @@
1284 rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrd_struc);
1287 + $graph_data_array = api_plugin_hook_function('prep_graph_array', $graph_data_array);
1289 if (isset($graph_data_array["output_flag"])) {
1290 $output_flag = $graph_data_array["output_flag"];
1292 $output_flag = RRDTOOL_OUTPUT_GRAPH_DATA;
1295 - return rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrd_struc);
1296 + $output = rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrd_struc);
1298 + api_plugin_hook_function('rrdtool_function_graph_set_file', array('output' => $output, 'local_graph_id' => $local_graph_id, 'rra_id' => $rra_id));
1304 diff -Naur 0.8.7-old/lib/variables.php 0.8.7/lib/variables.php
1305 --- 0.8.7-old/lib/variables.php 2008-02-12 08:39:56.000000000 -0600
1306 +++ 0.8.7/lib/variables.php 2008-02-12 09:25:57.000000000 -0600
1308 $string = str_replace($l_escape_string . "host_snmp_timeout" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["snmp_timeout"], $string);
1309 $string = str_replace($l_escape_string . "host_id" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["id"], $string);
1311 + $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));
1312 + $string = $temp['string'];
1317 diff -Naur 0.8.7-old/plugins/index.php 0.8.7/plugins/index.php
1318 --- 0.8.7-old/plugins/index.php 1969-12-31 17:00:00.000000000 -0700
1319 +++ 0.8.7/plugins/index.php 2008-02-12 09:25:57.000000000 -0600
1323 +header("Location:../index.php");
1326 diff -Naur 0.8.7-old/plugins.php 0.8.7/plugins.php
1327 --- 0.8.7-old/plugins.php 1969-12-31 17:00:00.000000000 -0700
1328 +++ 0.8.7/plugins.php 2008-02-12 09:25:57.000000000 -0600
1333 +include("./include/auth.php");
1336 +$plugins = retrieve_plugin_list ();
1338 +/* tab information */
1340 + "current" => "Installed",
1341 + "uninstalled" => "Uninstalled",
1342 + "download" => "Download",
1343 + "updates" => "Updates",
1347 +$status_names = array('Not Installed', 'Active', 'Awaiting Configuration', 'Awaiting Upgrade', 'Installed');
1350 +/* set the default settings category */
1351 +if (!isset($_GET["tab"])) {
1352 + /* there is no selected tab; select the first one */
1353 + $current_tab = array_keys($ptabs);
1354 + $current_tab = $current_tab[0];
1356 + $current_tab = $_GET["tab"];
1360 +// Check to see if we are installing, etc...
1361 +$modes = array('install', 'uninstall', 'disable', 'enable', 'check');
1363 +if (isset($_GET['mode']) && in_array($_GET['mode'], $modes) && isset($_GET['id'])) {
1365 + input_validate_input_regex(get_request_var("id"), "^([a-zA-Z0-9]+)$");
1367 + $mode = $_GET['mode'];
1368 + $id = sanitize_search_string($_GET['id']);
1372 + api_plugin_install($id);
1373 + $plugins = retrieve_plugin_list ();
1376 + if (!in_array($id, $plugins))
1378 + api_plugin_uninstall($id);
1379 + $plugins = retrieve_plugin_list ();
1382 + if (!in_array($id, $plugins))
1384 + api_plugin_disable ($id);
1387 + if (!in_array($id, $plugins))
1389 + api_plugin_enable ($id);
1392 + if (!in_array($id, $plugins))
1398 +function retrieve_plugin_list () {
1399 + $plugins = array();
1400 + $temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name');
1401 + foreach ($temp as $t) {
1402 + $plugins[] = $t['directory'];
1408 + include("./include/top_header.php");
1410 + /* draw the categories tabs on the top of the page */
1411 + print "<table class='tabs' width='98%' cellspacing='0' cellpadding='3' align='center'><tr>\n";
1413 + if (sizeof($ptabs) > 0) {
1414 + foreach (array_keys($ptabs) as $tab_short_name) {
1415 + print "<td " . (($tab_short_name == $current_tab) ? "bgcolor='silver'" : "bgcolor='#DFDFDF'") . " nowrap='nowrap' width='" . (strlen($ptabs[$tab_short_name]) * 9) . "' align='center' class='tab'>
1416 + <span class='textHeader'><a href='plugins.php?tab=$tab_short_name'>$ptabs[$tab_short_name]</a></span>
1418 + <td width='1'></td>\n";
1422 + print "<td></td>\n</tr></table>\n";
1424 + html_start_box("<strong>Plugins (" . $ptabs[$current_tab] . ")</strong>", "98%", $colors["header"], "3", "center", "");
1426 + print "<tr><td><table width='100%'>";
1428 + //update_info_table();
1430 + switch ($current_tab) {
1432 + update_show_current();
1434 + case 'uninstalled':
1435 + update_show_uninstalled ();
1438 + print '<br><br><br>';
1441 + $last_check = read_config_option("plugin_update_last_check");
1442 + if ($last_check < 1)
1445 + print "<center>Last Scanned : " . ($last_check > 0 ? date("F j, Y g:i:s a", $last_check) : "Never") . "</center>";
1447 + print "</table></td></tr>";
1451 + include("./include/bottom_footer.php");
1453 +function update_show_updates () {
1454 + global $plugins, $colors, $config, $plugin_architecture;
1459 + $cinfo = update_get_plugin_info ();
1463 + $info = update_get_cached_plugin_info();
1465 + $cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ;
1466 + if (isset($cinfo['cacti_plugin_arch']['version']))
1467 + $archnew = update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']);
1473 + print "<tr><td width='25%' valign=top><table width='100%'>";
1474 + html_header(array("Cacti"), 2);
1475 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1476 + print "<td width='25%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr>";
1477 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1478 + print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti']['changes']) . "</td></tr></table>";
1480 + if (isset($plugin_architecture['version']) && $archnew) {
1482 + print "<table width='100%'>";
1483 + html_header(array("Plugin Architecture"), 2);
1484 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1485 + print "<td width='25%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td>";
1486 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1487 + print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti_plugin_arch']['changes']) . "</td></tr></table>";
1489 + print "<table width='100%' cellspacing=0 cellpadding=3>";
1491 + foreach ($plugins as $plugin) {
1492 + if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) {
1494 + print "<table width='100%'>";
1495 + html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2);
1496 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1497 + print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1498 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1499 + print "<td><strong>Version:</strong></td><td>" . $info[$plugin]['version'] . "</td>";
1500 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1501 + print "<td><strong>Author:</strong></td><td>" . (isset($cinfo[$plugin]['author']) && $cinfo[$plugin]['author'] != '' ? (isset($cinfo[$plugin]['email']) && $cinfo[$plugin]['email'] != '' ? "<a href='mailto:" . $cinfo[$plugin]['email'] . "'>" . $cinfo[$plugin]['author'] . "</a>" : $cinfo[$plugin]['author']) : "") . "</td>";
1502 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1503 + print "<td><strong>Home Page:</strong></td><td>" . (isset($cinfo[$plugin]['webpage']) && $cinfo[$plugin]['webpage'] != '' ? "<a href='" . $cinfo[$plugin]['webpage'] . "'>" . $cinfo[$plugin]['webpage'] . "</a>" : "") . "</td>";
1504 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1505 + print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info[$plugin]['changes']) . "</td>";
1507 + print "</tr></table>";
1511 + print "<br><center><b>There are currently no Updates!</b></center><br>";
1513 + html_end_box(TRUE);
1516 +function update_check_if_newer() {
1520 +function update_show_current () {
1521 + global $plugins, $colors, $plugin_architecture, $config, $status_names;
1525 + $cinfo = update_get_plugin_info ();
1527 + print "<table width='100%' cellspacing=0 cellpadding=3>";
1528 + print "<tr><td width='50%'><table width='100%'>";
1529 + html_header(array("Cacti"), 2);
1530 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1531 + print "<td width='50%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr></table>";
1532 + print "</td><td>";
1533 + if (isset($plugin_architecture['version'])) {
1534 + print "<table width='100%'>";
1535 + html_header(array("Plugin Architecture"), 2);
1536 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1537 + print "<td width='50%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td></tr></table>";
1539 + print "</td></tr></table>";
1541 + print "<table width='100%' cellspacing=0 cellpadding=3>";
1544 + foreach ($plugins as $plugin) {
1545 + if (isset($cinfo[$plugin])) {
1548 + print "<tr><td width='50%'>";
1550 + print "</td><td>";
1552 + if (!isset($info[$plugin]['version']))
1553 + $info[$plugin]['version'] = '';
1555 + print "<table width='100%'>";
1556 + html_header(array((isset($cinfo[$plugin]['name']) ? $cinfo[$plugin]['name'] : $plugin)), 2);
1557 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1558 + print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1559 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1560 + print "<td><strong>Version:</strong></td><td>" . (isset($cinfo[$plugin]['version']) ? $cinfo[$plugin]['version'] : "") . (update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version']) ? ' - <font color=red><b>(Update Available!)</strong></font>' : '') . "</td>";
1561 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1562 + print "<td><strong>Author:</strong></td><td>" . (isset($cinfo[$plugin]['author']) && $cinfo[$plugin]['author'] != '' ? (isset($cinfo[$plugin]['email']) && $cinfo[$plugin]['email'] != '' ? "<a href='mailto:" . $cinfo[$plugin]['email'] . "'>" . $cinfo[$plugin]['author'] . "</a>" : $cinfo[$plugin]['author']) : "") . "</td>";
1563 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1564 + print "<td><strong>Home Page:</strong></td><td>" . (isset($cinfo[$plugin]['webpage']) && $cinfo[$plugin]['webpage'] != '' ? "<a href='" . $cinfo[$plugin]['webpage'] . "'>" . $cinfo[$plugin]['webpage'] . "</a>" : "") . "</td>";
1565 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1566 + print "<td><strong>Status:</strong></td><td>" . $status_names[$cinfo[$plugin]['status']] . "</td>";
1567 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1569 + $links = array('install' => 'Install', 'uninstall' => 'Uninstall', 'enable' => 'Enable', 'disable' => 'Disable', 'check' => 'Check');
1571 + switch ($cinfo[$plugin]['status']) {
1572 + case 0: //Not Installed
1573 + $links['install'] = "<a href='plugins.php?mode=install&id=$plugin'><b>Install</b></a>";
1575 + case 1: // Currently Active
1576 + $links['uninstall'] = "<a href='plugins.php?mode=uninstall&id=$plugin'><b>Uninstall</b></a>";
1577 + $links['disable'] = "<a href='plugins.php?mode=disable&id=$plugin'><b>Disable</b></a>";
1579 + case 2: // Needs Configuring
1580 + $links['check'] = "<a href='plugins.php?mode=check&id=$plugin'><b>Check</b></a>";
1582 + case 3: // Needs Upgrade
1583 + $links['check'] = "<a href='plugins.php?mode=check&id=$plugin'><b>Check</b></a>";
1585 + case 4: // Installed but not active
1586 + $links['uninstall'] = "<a href='plugins.php?mode=uninstall&id=$plugin'><b>Uninstall</b></a>";
1587 + $links['enable'] = "<a href='plugins.php?mode=enable&id=$plugin'><b>Enable</b></a>";
1591 + print "<td></td><td>";
1593 + foreach ($links as $temp => $link) {
1595 + if ($c < count($links))
1601 + print "</tr></table>";
1603 + print "</td></tr>";
1606 + if ($x > 1) $x = 0;
1610 + print "</td><td></td></tr>";
1612 + html_end_box(TRUE);
1616 +function update_show_uninstalled () {
1617 + global $plugins, $colors, $plugin_architecture, $config, $status_names;
1622 + print "<table width='100%' cellspacing=0 cellpadding=3>";
1625 + $newplugins = array();
1626 + $cinfo = array ();
1628 + $path = $config['base_path'] . '/plugins/';
1629 + $dh = opendir($path);
1630 + while (($file = readdir($dh)) !== false) {
1631 + if (is_dir("$path/$file")) {
1632 + if (file_exists("$path/$file/setup.php") && !in_array($file, $plugins)) {
1633 + include_once("$path/$file/setup.php");
1634 + if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
1635 + $function = 'plugin_' . $file . '_version';
1636 + $cinfo[$file] = $function();
1637 + $cinfo[$file]['status'] = 0;
1638 + $newplugins[] = $file;
1645 + if (count($newplugins)) {
1646 + foreach ($newplugins as $plugin) {
1647 + if (isset($cinfo[$plugin])) {
1650 + print "<tr><td width='50%'>";
1652 + print "</td><td>";
1654 + if (!isset($info[$plugin]['version']))
1655 + $info[$plugin]['version'] = '';
1657 + print "<table width='100%'>";
1658 + html_header(array((isset($cinfo[$plugin]['name']) ? $cinfo[$plugin]['name'] : $plugin)), 2);
1659 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1660 + print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1661 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1662 + print "<td><strong>Version:</strong></td><td>" . (isset($cinfo[$plugin]['version']) ? $cinfo[$plugin]['version'] : "") . (update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version']) ? ' - <font color=red><b>(Update Available!)</strong></font>' : '') . "</td>";
1663 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1664 + print "<td><strong>Author:</strong></td><td>" . (isset($cinfo[$plugin]['author']) && $cinfo[$plugin]['author'] != '' ? (isset($cinfo[$plugin]['email']) && $cinfo[$plugin]['email'] != '' ? "<a href='mailto:" . $cinfo[$plugin]['email'] . "'>" . $cinfo[$plugin]['author'] . "</a>" : $cinfo[$plugin]['author']) : "") . "</td>";
1665 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1666 + print "<td><strong>Home Page:</strong></td><td>" . (isset($cinfo[$plugin]['homepage']) && $cinfo[$plugin]['homepage'] != '' ? "<a href='" . $cinfo[$plugin]['homepage'] . "'>" . $cinfo[$plugin]['homepage'] . "</a>" : "") . "</td>";
1667 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1668 + print "<td><strong>Status:</strong></td><td>" . $status_names[$cinfo[$plugin]['status']] . "</td>";
1669 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1671 + $links = array('install' => 'Install', 'uninstall' => 'Uninstall', 'enable' => 'Enable', 'disable' => 'Disable', 'check' => 'Check');
1673 + switch ($cinfo[$plugin]['status']) {
1674 + case 0: //Not Installed
1675 + $links['install'] = "<a href='plugins.php?mode=install&id=$plugin&tab=uninstalled'><b>Install</b></a>";
1677 + case 1: // Currently Active
1678 + $links['uninstall'] = "<a href='plugins.php?mode=uninstall&id=$plugin&tab=uninstalled'><b>Uninstall</b></a>";
1679 + $links['disable'] = "<a href='plugins.php?mode=disable&id=$plugin&tab=uninstalled'><b>Disable</b></a>";
1681 + case 2: // Needs Configuring
1682 + $links['check'] = "<a href='plugins.php?mode=check&id=$plugin&tab=uninstalled'><b>Check</b></a>";
1684 + case 3: // Needs Upgrade
1685 + $links['check'] = "<a href='plugins.php?mode=check&id=$plugin&tab=uninstalled'><b>Check</b></a>";
1687 + case 4: // Installed but not active
1688 + $links['enable'] = "<a href='plugins.php?mode=enable&id=$plugin&tab=uninstalled'><b>Enable</b></a>";
1692 + print "<td></td><td>";
1694 + foreach ($links as $temp => $link) {
1696 + if ($c < count($links))
1702 + print "</tr></table>";
1704 + print "</td></tr>";
1707 + if ($x > 1) $x = 0;
1711 + print "<center>There are no Uninstalled Plugins</center>";
1714 + print "</td><td></td></tr>";
1716 + html_end_box(TRUE);
1719 +function update_get_plugin_info () {
1721 + $info = db_fetch_assoc("SELECT * from plugin_config");
1722 + if (is_array($info)) {
1723 + foreach($info as $inf) {
1724 + $cinfo[$inf['directory']] = $inf;
1725 + $cinfo[$inf['directory']]['changes']='';
1732 \ No newline at end of file
1733 diff -Naur 0.8.7-old/poller.php 0.8.7/poller.php
1734 --- 0.8.7-old/poller.php 2008-02-12 08:39:56.000000000 -0600
1735 +++ 0.8.7/poller.php 2008-02-12 09:25:57.000000000 -0600
1740 +api_plugin_hook('poller_top');
1742 /* record the start time */
1743 list($micro,$seconds) = split(" ", microtime());
1744 $poller_start = $seconds + $micro;
1746 $method = "cmd.php";
1749 + $extra_args = api_plugin_hook_function ('poller_command_args', $extra_args);
1751 /* Populate each execution file with appropriate information */
1752 foreach ($polling_hosts as $item) {
1753 if ($host_count == 1) {
1754 @@ -402,9 +406,11 @@
1756 /* sleep the appripriate amount of time */
1757 if ($poller_runs_completed < $poller_runs) {
1758 + api_plugin_hook('poller_bottom');
1760 usleep($sleep_time * 1000000);
1761 db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
1762 + api_plugin_hook('poller_top');
1764 }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM) {
1765 cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER");
1767 echo " --debug|-d Output debug information. Similar to cacti's DEBUG logging level.\n\n";
1770 +api_plugin_hook('poller_bottom');
1773 diff -Naur 0.8.7-old/user_admin.php 0.8.7/user_admin.php
1774 --- 0.8.7-old/user_admin.php 2008-02-12 08:39:56.000000000 -0600
1775 +++ 0.8.7/user_admin.php 2008-02-12 09:25:57.000000000 -0600
1780 - include_once("include/top_header.php");
1782 - include_once("include/bottom_footer.php");
1783 + if (!api_plugin_hook_function('user_admin_action', get_request_var_request("action"))) {
1784 + include_once("include/top_header.php");
1786 + include_once("include/bottom_footer.php");
1792 $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);
1793 $save["realm"] = get_request_var_post("realm", 0);
1794 $save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3);
1795 + $save = api_plugin_hook_function('user_admin_setup_sql_save', $save);
1797 if (!is_error_message()) {
1798 $user_id = sql_save($save, "user_auth");
1800 policy_hosts = " . get_request_var_post("policy_hosts") . ",
1801 policy_graph_templates = " . get_request_var_post("policy_graph_templates") . "
1802 WHERE id = " . get_request_var_post("id"));
1804 + api_plugin_hook('user_admin_user_save');
1809 $header_label = "[new]";
1812 + api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0));
1814 html_start_box("<strong>User Management</strong> $header_label", "100%", $colors["header"], "3", "center", "");
1816 draw_edit_form(array(
1818 <td <?php print ((get_request_var("action") == "graph_settings_edit") ? "bgcolor='silver'" : "bgcolor='#DFDFDF'");?> nowrap='nowrap' width='130' align='center' class='tab'>
1819 <span class='textHeader'><a href='user_admin.php?action=graph_settings_edit&id=<?php print $_GET["id"];?>'>Graph Settings</a></span>
1821 + <?php api_plugin_hook('user_admin_tab');?>
1826 }elseif (get_request_var("action") == "graph_perms_edit") {
1829 - user_realms_edit();
1830 + if (api_plugin_hook_function('user_admin_run_action', get_request_var_request("action"))) {
1831 + user_realms_edit();
1835 form_save_button("user_admin.php");
1836 diff -Naur 0.8.7-old/utilities.php 0.8.7/utilities.php
1837 --- 0.8.7-old/utilities.php 2008-02-12 08:39:56.000000000 -0600
1838 +++ 0.8.7/utilities.php 2008-02-12 09:25:57.000000000 -0600
1839 @@ -129,11 +129,14 @@
1840 include_once("./include/bottom_footer.php");
1843 - include_once("./include/top_header.php");
1846 + if (!api_plugin_hook_function('utilities_action', $_REQUEST['action'])) {
1847 + include_once('./include/top_header.php');
1849 - include_once("./include/bottom_footer.php");
1852 + include_once('./include/bottom_footer.php');
1857 @@ -1335,6 +1338,8 @@
1861 + api_plugin_hook('utilities_list');