]> git.pld-linux.org Git - packages/cacti.git/blame - cacti-plugin-0.8.7d-PA-v2.4.diff
- tested, rel 1 STBR
[packages/cacti.git] / cacti-plugin-0.8.7d-PA-v2.4.diff
CommitLineData
5cde2610
GS
1diff -urN cacti-0.8.7d.orig/auth_changepassword.php cacti-0.8.7d/auth_changepassword.php
2--- cacti-0.8.7d.orig/auth_changepassword.php 2009-02-12 03:55:50.000000000 +0100
3+++ cacti-0.8.7d/auth_changepassword.php 2009-02-17 08:57:36.000000000 +0100
4@@ -59,6 +59,8 @@
5 header("Location: index.php"); break;
6 case '3': /* default graph page */
7 header("Location: graph_view.php"); break;
8+ default:
9+ api_plugin_hook_function('login_options_navigate', $user['login_opts']);
10 }
11 }else{
12 header("Location: graph_view.php");
13diff -urN cacti-0.8.7d.orig/auth_login.php cacti-0.8.7d/auth_login.php
14--- cacti-0.8.7d.orig/auth_login.php 2009-02-12 03:55:50.000000000 +0100
15+++ cacti-0.8.7d/auth_login.php 2009-02-17 08:57:36.000000000 +0100
16@@ -212,6 +212,8 @@
17 header("Location: index.php"); break;
18 case '3': /* default graph page */
19 header("Location: graph_view.php"); break;
20+ default:
21+ api_plugin_hook_function('login_options_navigate', $user['login_opts']);
22 }
23 exit;
24
25@@ -262,9 +264,17 @@
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">
29+<?php
30+
31+api_plugin_hook("login_before");
32+
33+$cacti_logo = $config['url_path'] . 'images/auth_login.gif';
34+$cacti_logo = api_plugin_hook_function('cacti_image', $cacti_logo);
35+
36+?>
37 <table align="center">
38 <tr>
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>
41 </tr>
42 <?php
43
44@@ -317,6 +327,7 @@
45 <td><input type="submit" value="Login"></td>
46 </tr>
47 </table>
48+<?php api_plugin_hook('login_after'); ?>
49 </form>
50 </body>
51 </html>
52diff -urN cacti-0.8.7d.orig/data_sources.php cacti-0.8.7d/data_sources.php
53--- cacti-0.8.7d.orig/data_sources.php 2009-02-12 03:55:50.000000000 +0100
54+++ cacti-0.8.7d/data_sources.php 2009-02-17 08:57:36.000000000 +0100
55@@ -44,6 +44,8 @@
56 7 => "Disable"
57 );
58
59+$ds_actions = api_plugin_hook_function('data_source_action_array', $ds_actions);
60+
61 /* set default action */
62 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
63
64@@ -402,7 +404,10 @@
65 api_reapply_suggested_data_source_title($selected_items[$i]);
66 update_data_source_title_cache($selected_items[$i]);
67 }
68+ } else {
69+ api_plugin_hook_function('data_source_action_execute', $_POST['drp_action']);
70 }
71+
72 header("Location: data_sources.php");
73 exit;
74 }
75@@ -533,7 +538,12 @@
76 <p>$ds_list</p>
77 </td>
78 </tr>\n
79- ";
80+ ";
81+ } else {
82+ $save['drp_action'] = $_POST['drp_action'];
83+ $save['ds_list'] = $ds_list;
84+ $save['ds_array'] = (isset($ds_array)? $ds_array : array());
85+ api_plugin_hook_function('data_source_action_prepare', $save);
86 }
87
88 if (!isset($ds_array)) {
89@@ -675,6 +685,8 @@
90 input_validate_input_number(get_request_var("id"));
91 /* ==================================================== */
92
93+ api_plugin_hook('data_source_edit_top');
94+
95 $use_data_template = true;
96 $host_id = 0;
97
98@@ -967,8 +979,9 @@
99
100 form_save_button("data_sources.php");
101
102- include_once("./include/bottom_footer.php");
103+ api_plugin_hook('data_source_edit_bottom');
104
105+ include_once("./include/bottom_footer.php");
106 }
107
108 function get_poller_interval($seconds) {
109@@ -1300,6 +1313,7 @@
110 $i = 0;
111 if (sizeof($data_sources) > 0) {
112 foreach ($data_sources as $data_source) {
113+ $data_source = api_plugin_hook_function('data_sources_table', $data_source);
114 $data_template_name = ((empty($data_source["data_template_name"])) ? "<em>None</em>" : $data_source["data_template_name"]);
115 $data_input_name = ((empty($data_source["data_input_name"])) ? "<em>External</em>" : $data_source["data_input_name"]);
116 $poller_interval = ((isset($poller_intervals[$data_source["local_data_id"]])) ? $poller_intervals[$data_source["local_data_id"]] : 0);
117@@ -1328,4 +1342,3 @@
118 print "</form>\n";
119 }
120 ?>
121-
122diff -urN cacti-0.8.7d.orig/graph_image.php cacti-0.8.7d/graph_image.php
123--- cacti-0.8.7d.orig/graph_image.php 2009-02-12 03:55:50.000000000 +0100
124+++ cacti-0.8.7d/graph_image.php 2009-02-17 08:57:36.000000000 +0100
125@@ -44,6 +44,8 @@
126 /* flush the headers now */
127 ob_end_clean();
128
129+api_plugin_hook_function('graph_image');
130+
131 session_write_close();
132
133 $graph_data_array = array();
134diff -urN cacti-0.8.7d.orig/graph.php cacti-0.8.7d/graph.php
135--- cacti-0.8.7d.orig/graph.php 2009-02-12 03:55:50.000000000 +0100
136+++ cacti-0.8.7d/graph.php 2009-02-17 08:57:36.000000000 +0100
137@@ -98,6 +98,7 @@
138 <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>
139 <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>
140 <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>
141+ <?php api_plugin_hook('graph_buttons', array('hook' => 'view', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $rra['id'], 'view_type' => $_REQUEST['view_type'])); ?>
142 </td>
143 </tr>
144 <tr>
145@@ -212,6 +213,7 @@
146 <td valign='top' style='padding: 3px;' class='noprint'>
147 <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>
148 <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"];?>&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>
149++ <?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'])); ?>
150 </td>
151 </tr>
152 <tr>
153@@ -244,6 +246,7 @@
154 <td valign='top' style='padding: 3px;'>
155 <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>
156 <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>
157+ <?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'])); ?>
158 </td>
159 </tr>
160 <tr>
161diff -urN cacti-0.8.7d.orig/graphs_new.php cacti-0.8.7d/graphs_new.php
162--- cacti-0.8.7d.orig/graphs_new.php 2009-02-12 03:55:50.000000000 +0100
163+++ cacti-0.8.7d/graphs_new.php 2009-02-17 08:57:36.000000000 +0100
164@@ -479,7 +479,8 @@
165 </td>
166 <td nowrap style='white-space: nowrap;' class="textInfo" align="center" valign="top">
167 <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>
168- <span style="white-space: nowrap; color: #c16921;">*</span><a href="host.php?action=edit">Create New Host</a>
169+ <span style="white-space: nowrap; color: #c16921;">*</span><a href="host.php?action=edit">Create New Host</a><br>
170+ <?php api_plugin_hook('graphs_new_top_links'); ?>
171 </td>
172 </tr>
173 </table>
174diff -urN cacti-0.8.7d.orig/graphs.php cacti-0.8.7d/graphs.php
175--- cacti-0.8.7d.orig/graphs.php 2009-02-12 03:55:50.000000000 +0100
176+++ cacti-0.8.7d/graphs.php 2009-02-17 08:57:36.000000000 +0100
177@@ -45,6 +45,8 @@
178 4 => "Convert to Graph Template"
179 );
180
181+$graph_actions = api_plugin_hook_function('graphs_action_array', $graph_actions);
182+
183 /* set default action */
184 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
185
186@@ -360,8 +362,10 @@
187 input_validate_input_number($selected_items[$i]);
188 /* ==================================================== */
189
190- api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
191+ api_resize_graphs($selected_items[$i], $_POST['graph_width'], $_POST['graph_height']);
192 }
193+ } else {
194+ api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
195 }
196
197 header("Location: graphs.php");
198@@ -502,6 +506,11 @@
199 </td>
200 </tr>\n
201 ";
202+ } else {
203+ $save['drp_action'] = $_POST['drp_action'];
204+ $save['graph_list'] = $graph_list;
205+ $save['graph_array'] = (isset($graph_array) ? $graph_array : array());
206+ api_plugin_hook_function('graphs_action_prepare', $save);
207 }
208
209 if (!isset($graph_array)) {
210diff -urN cacti-0.8.7d.orig/host.php cacti-0.8.7d/host.php
211--- cacti-0.8.7d.orig/host.php 2009-02-12 03:55:50.000000000 +0100
212+++ cacti-0.8.7d/host.php 2009-02-17 08:57:36.000000000 +0100
213@@ -44,6 +44,8 @@
214 6 => "Change Availability Options"
215 );
216
217+$device_actions = api_plugin_hook_function('device_action_array', $device_actions);
218+
219 /* set default action */
220 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
221
222@@ -309,6 +311,8 @@
223
224 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);
225 }
226+ } else {
227+ api_plugin_hook_function('device_action_execute', $_POST['drp_action']);
228 }
229
230 header("Location: host.php");
231@@ -445,6 +449,11 @@
232 </tr>\n
233 <input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
234 ";
235+ } else {
236+ $save['drp_action'] = $_POST['drp_action'];
237+ $save['host_list'] = $host_list;
238+ $save['host_array'] = (isset($host_array)? $host_array : array());
239+ api_plugin_hook_function('device_action_prepare', $save);
240 }
241
242 if (!isset($host_array)) {
243@@ -533,6 +542,8 @@
244
245 display_output_messages();
246
247+ api_plugin_hook('host_edit_top');
248+
249 if (!empty($_GET["id"])) {
250 $host = db_fetch_row("select * from host where id=" . $_GET["id"]);
251 $header_label = "[edit: " . $host["description"] . "]";
252@@ -643,7 +654,8 @@
253 <td class="textInfo" valign="top">
254 <span style="color: #c16921;">*</span><a href="graphs_new.php?host_id=<?php print $host["id"];?>">Create Graphs for this Host</a><br>
255 <span style="color: #c16921;">*</span><a href="data_sources.php?host_id=<?php print $host["id"];?>&ds_rows=30&filter=&template_id=-1&method_id=-1&page=1">Data Source List</a><br>
256- <span style="color: #c16921;">*</span><a href="graphs.php?host_id=<?php print $host["id"];?>&graph_rows=30&filter=&template_id=-1&page=1">Graph List</a>
257+ <span style="color: #c16921;">*</span><a href="graphs.php?host_id=<?php print $host["id"];?>&graph_rows=30&filter=&template_id=-1&page=1">Graph List</a><br>
258+ <?php api_plugin_hook('device_edit_top_links'); ?>
259 </td>
260 </tr>
261 </table>
262@@ -1104,6 +1116,8 @@
263 }
264
265 form_save_button("host.php");
266+
267+ api_plugin_hook('host_edit_bottom');
268 }
269
270 function host() {
271diff -urN cacti-0.8.7d.orig/include/auth.php cacti-0.8.7d/include/auth.php
272--- cacti-0.8.7d.orig/include/auth.php 2009-02-12 03:55:50.000000000 +0100
273+++ cacti-0.8.7d/include/auth.php 2009-02-17 08:57:36.000000000 +0100
274@@ -31,6 +31,9 @@
275 }
276
277 if (read_config_option("auth_method") != 0) {
278+ /* handle alternate authentication realms */
279+ api_plugin_hook_function('auth_alternate_realms');
280+
281 /* handle change password dialog */
282 if ((isset($_SESSION['sess_change_password'])) && (read_config_option("webbasic_enabled") != "on")) {
283 header ("Location: auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php"));
284@@ -75,7 +78,7 @@
285 <html>
286 <head>
287 <title>Cacti</title>
288- <link href="include/main.css" rel="stylesheet">
289+ <link href="<?php echo $config['url_path']; ?>include/main.css" rel="stylesheet">
290 </style>
291 </head>
292
293@@ -83,7 +86,7 @@
294
295 <table width="450" align='center'>
296 <tr>
297- <td colspan='2'><img src='images/auth_deny.gif' border='0' alt='Access Denied'></td>
298+ <td colspan='2'><img src='<?php echo $config['url_path']; ?>images/auth_deny.gif' border='0' alt='Access Denied'></td>
299 </tr>
300 <tr height='10'><td></td></tr>
301 <tr>
302@@ -91,7 +94,7 @@
303 need access to this particular section, please contact the Cacti administrator.</td>
304 </tr>
305 <tr>
306- <td class='textArea' colspan='2' align='center'>( <a href='' onclick='javascript: history.back();'>Return</a> | <a href='index.php'>Login</a> )</td>
307+ <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>
308 </tr>
309 </table>
310
311diff -urN cacti-0.8.7d.orig/include/bottom_footer.php cacti-0.8.7d/include/bottom_footer.php
312--- cacti-0.8.7d.orig/include/bottom_footer.php 2009-02-12 03:55:50.000000000 +0100
313+++ cacti-0.8.7d/include/bottom_footer.php 2009-02-17 08:57:36.000000000 +0100
314@@ -21,6 +21,10 @@
315 | http://www.cacti.net/ |
316 +-------------------------------------------------------------------------+
317 */
318+
319+$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
320+if (($oper_mode == OPER_MODE_NATIVE) || ($oper_mode == OPER_MODE_IFRAME_NONAV)) {
321+
322 ?>
323 <br>
324 </td>
325@@ -31,6 +35,9 @@
326 </html>
327
328 <?php
329+
330+}
331+
332 /* we use this session var to store field values for when a save fails,
333 this way we can restore the field's previous values. we reset it here, because
334 they only need to be stored for a single page */
335diff -urN cacti-0.8.7d.orig/include/global_arrays.php cacti-0.8.7d/include/global_arrays.php
336--- cacti-0.8.7d.orig/include/global_arrays.php 2009-02-12 03:55:50.000000000 +0100
337+++ cacti-0.8.7d/include/global_arrays.php 2009-02-17 08:57:36.000000000 +0100
338@@ -22,6 +22,8 @@
339 +-------------------------------------------------------------------------+
340 */
341
342+global $menu;
343+
344 $messages = array(
345 1 => array(
346 "message" => 'Save Successful.',
347@@ -640,4 +642,10 @@
348 GDC_SLASH => "/"
349 );
350
351+$plugin_architecture = array(
352+ 'version' => '2.4'
353+ );
354+
355+api_plugin_hook('config_arrays');
356+
357 ?>
358diff -urN cacti-0.8.7d.orig/include/global_constants.php cacti-0.8.7d/include/global_constants.php
359--- cacti-0.8.7d.orig/include/global_constants.php 2009-02-12 03:55:50.000000000 +0100
360+++ cacti-0.8.7d/include/global_constants.php 2009-02-17 09:55:38.000000000 +0100
361@@ -175,4 +175,8 @@
362 define("SNMP_CMDPHP", 1);
363 define("SNMP_WEBUI", 2);
364
365+define('OPER_MODE_NATIVE', 0);
366+define('OPER_MODE_RESKIN', 1);
367+define('OPER_MODE_IFRAME_NONAV', 2);
368+
369 ?>
370diff -urN cacti-0.8.7d.orig/include/global_form.php cacti-0.8.7d/include/global_form.php
371--- cacti-0.8.7d.orig/include/global_form.php 2009-02-12 03:55:50.000000000 +0100
372+++ cacti-0.8.7d/include/global_form.php 2009-02-17 08:57:36.000000000 +0100
373@@ -22,8 +22,9 @@
374 +-------------------------------------------------------------------------+
375 */
376
377-if (!defined("VALID_HOST_FIELDS")) {
378- 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)");
379+if (!defined('VALID_HOST_FIELDS')) {
380+ $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)');
381+ define('VALID_HOST_FIELDS', $string);
382 }
383
384 /* file: cdef.php, action: edit */
385@@ -1184,4 +1185,7 @@
386 "dropdown_sql" => "select id,name from snmp_query order by name"
387 )
388 );
389-?>
390+
391+
392+api_plugin_hook('config_form');
393+
394diff -urN cacti-0.8.7d.orig/include/global.php cacti-0.8.7d/include/global.php
395--- cacti-0.8.7d.orig/include/global.php 2009-02-12 03:55:50.000000000 +0100
396+++ cacti-0.8.7d/include/global.php 2009-02-17 08:57:36.000000000 +0100
397@@ -41,6 +41,22 @@
398 /* Default session name - Session name must contain alpha characters */
399 $cacti_session_name = "Cacti";
400
401+$plugins = array();
402+//$plugins[] = 'thold';
403+
404+/* Do not edit this line */
405+$config = array();
406+
407+/*
408+ Edit this to point to the default URL of your Cacti install
409+ ex: if your cacti install as at http://serverip/cacti/ this
410+ would be set to /cacti/
411+*/
412+
413+$config['url_path'] = '/';
414+
415+define('URL_PATH', $config['url_path']);
416+
417 /* Include configuration */
418 include(dirname(__FILE__) . "/config.php");
419
420@@ -75,7 +91,6 @@
421 "structure_rra_paths.php"
422 );
423
424-$config = array();
425 $colors = array();
426
427 /* this should be auto-detected, set it manually if needed */
428@@ -179,18 +194,23 @@
429 /* display ALL errors */
430 error_reporting(E_ALL);
431
432+/* current cacti version */
433+$config["cacti_version"] = "0.8.7c";
434+
435 /* include base modules */
436 include($config["library_path"] . "/adodb/adodb.inc.php");
437 include($config["library_path"] . "/database.php");
438-include_once($config["library_path"] . "/functions.php");
439-include_once($config["include_path"] . "/global_constants.php");
440-include_once($config["include_path"] . "/global_arrays.php");
441-include_once($config["include_path"] . "/global_settings.php");
442
443 /* connect to the database server */
444 db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
445
446 /* include additional modules */
447+include_once($config["library_path"] . "/functions.php");
448+include_once($config["include_path"] . "/global_constants.php");
449+include_once($config["library_path"] . "/plugins.php");
450+include_once($config["include_path"] . "/plugins.php");
451+include_once($config["include_path"] . "/global_arrays.php");
452+include_once($config["include_path"] . "/global_settings.php");
453 include_once($config["include_path"] . "/global_form.php");
454 include_once($config["library_path"] . "/html.php");
455 include_once($config["library_path"] . "/html_form.php");
456@@ -199,6 +219,8 @@
457 include_once($config["library_path"] . "/variables.php");
458 include_once($config["library_path"] . "/auth.php");
459
460+api_plugin_hook("config_insert");
461+
462 /* current cacti version */
463 $config["cacti_version"] = "0.8.7d";
464
465diff -urN cacti-0.8.7d.orig/include/global_settings.php cacti-0.8.7d/include/global_settings.php
466--- cacti-0.8.7d.orig/include/global_settings.php 2009-02-12 03:55:50.000000000 +0100
467+++ cacti-0.8.7d/include/global_settings.php 2009-02-17 08:57:36.000000000 +0100
468@@ -1185,4 +1185,6 @@
469 )
470 );
471
472+api_plugin_hook('config_settings');
473+
474 ?>
475diff -urN cacti-0.8.7d.orig/include/plugins.php cacti-0.8.7d/include/plugins.php
476--- cacti-0.8.7d.orig/include/plugins.php 1970-01-01 01:00:00.000000000 +0100
477+++ cacti-0.8.7d/include/plugins.php 2009-02-17 08:57:36.000000000 +0100
478@@ -0,0 +1,36 @@
479+<?php
480+
481+/*
482+ * Copyright (c) 1999-2005 The SquirrelMail Project Team (http://squirrelmail.org)
483+ * Licensed under the GNU GPL. For full terms see the file COPYING.
484+ */
485+
486+global $plugin_hooks;
487+$plugin_hooks = array();
488+
489+function use_plugin ($name) {
490+ global $config;
491+ if (file_exists($config['base_path'] . "/plugins/$name/setup.php")) {
492+ include_once($config['base_path'] . "/plugins/$name/setup.php");
493+ $function = "plugin_init_$name";
494+ if (function_exists($function)) {
495+ $function();
496+ }
497+ }
498+}
499+
500+/**
501+ * This function executes a hook.
502+ * @param string $name Name of hook to fire
503+ * @return mixed $data
504+ */
505+
506+/* On startup, register all plugins configured for use. */
507+if (isset($plugins) && is_array($plugins)) {
508+ foreach ($plugins as $name) {
509+ use_plugin($name);
510+ }
511+}
512+
513+
514+
515diff -urN cacti-0.8.7d.orig/include/top_graph_header.php cacti-0.8.7d/include/top_graph_header.php
516--- cacti-0.8.7d.orig/include/top_graph_header.php 2009-02-12 03:55:50.000000000 +0100
517+++ cacti-0.8.7d/include/top_graph_header.php 2009-02-17 08:57:36.000000000 +0100
518@@ -25,6 +25,11 @@
519 $using_guest_account = false;
520 $show_console_tab = true;
521
522+$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
523+if ($oper_mode == OPER_MODE_RESKIN) {
524+ return;
525+}
526+
527 /* ================= input validation ================= */
528 input_validate_input_number(get_request_var_request("local_graph_id"));
529 /* ==================================================== */
530@@ -46,45 +51,55 @@
531 }
532
533 /* need to correct $_SESSION["sess_nav_level_cache"] in zoom view */
534-if ($_REQUEST["action"] == "zoom") {
535+if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "zoom") {
536 $_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all";
537 }
538
539+$page_title = api_plugin_hook_function('page_title', 'Cacti');
540+
541 ?>
542 <html>
543 <head>
544- <title>Cacti</title>
545+ <title><?php echo $page_title; ?></title>
546 <?php if (isset($_SESSION["custom"])) {
547 if ($_SESSION["custom"]) {
548 print "<meta http-equiv=refresh content='99999'>\r\n";
549 }else{
550- print "<meta http-equiv=refresh content='" . read_graph_config_option("page_refresh") . "'>\r\n";
551- }
552+ $refresh = api_plugin_hook_function('top_graph_refresh', read_graph_config_option('page_refresh'));
553+ print "<meta http-equiv=refresh content='" . $refresh . "'>\r\n"; }
554 }
555 ?>
556- <link href="include/main.css" rel="stylesheet">
557- <link href="images/favicon.ico" rel="shortcut icon"/>
558- <script type="text/javascript" src="include/layout.js"></script>
559- <script type="text/javascript" src="include/treeview/ua.js"></script>
560- <script type="text/javascript" src="include/treeview/ftiens4.js"></script>
561- <script type="text/javascript" src="include/jscalendar/calendar.js"></script>
562- <script type="text/javascript" src="include/jscalendar/lang/calendar-en.js"></script>
563- <script type="text/javascript" src="include/jscalendar/calendar-setup.js"></script>
564+ <link href="<?php echo $config['url_path']; ?>include/main.css" rel="stylesheet">
565+ <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
566+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
567+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ua.js"></script>
568+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ftiens4.js"></script>
569+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar.js"></script>
570+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/lang/calendar-en.js"></script>
571+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar-setup.js"></script>
572+ <?php api_plugin_hook('page_head'); ?>
573 </head>
574
575-<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
576+<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
577+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" <?php print api_plugin_hook_function("body_style", "");?>>
578 <a name='page_top'></a>
579+<?php }else{?>
580+<body leftmargin="15" topmargin="15" marginwidth="15" marginheight="15" <?php print api_plugin_hook_function("body_style", "");?>>
581+<?php }?>
582
583 <table width="100%" height="100%" cellspacing="0" cellpadding="0">
584+<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
585 <tr height="25" bgcolor="#a9a9a9" class="noprint">
586 <td colspan="2" valign="bottom" nowrap>
587 <table width="100%" cellspacing="0" cellpadding="0">
588- <tr style="background: transparent url('images/cacti_backdrop2.gif') no-repeat center right;">
589+ <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop2.gif') no-repeat center right;">
590 <td id="tabs" nowrap>
591- &nbsp;<?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>&nbsp;
592+ &nbsp;<?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
593+ api_plugin_hook('top_graph_header_tabs');
594+ ?>
595 </td>
596 <td id="gtabs" align="right" nowrap>
597- <?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>';}?>&nbsp;&nbsp;<?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 }?>&nbsp;<br>
598+ <?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>';}?>&nbsp;&nbsp;<?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 }?>&nbsp;<br>
599 </td>
600 </tr>
601 </table>
602@@ -92,7 +107,7 @@
603 </tr>
604 <tr height="2" colspan="2" bgcolor="#183c8f" class="noprint">
605 <td colspan="2">
606- <img src="images/transparent_line.gif" width="170" height="2" border="0"><br>
607+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="170" height="2" border="0"><br>
608 </td>
609 </tr>
610 <tr height="5" bgcolor="#e9e9e9" class="noprint">
611@@ -104,7 +119,7 @@
612 </td>
613 <td align="right">
614 <?php if ((isset($_SESSION["sess_user_id"])) && ($using_guest_account == false)) { ?>
615- 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>)&nbsp;
616+ 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>)&nbsp;
617 <?php } ?>
618 </td>
619 </tr>
620@@ -112,10 +127,10 @@
621 </td>
622 </tr>
623 <tr class="noprint">
624- <td bgcolor="#efefef" colspan="1" height="8" style="background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
625- <img src="images/transparent_line.gif" width="<?php print read_graph_config_option("default_dual_pane_width");?>" height="2" border="0"><br>
626+ <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;">
627+ <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>
628 </td>
629- <td bgcolor="#ffffff" colspan="1" height="8" style="background-image: url(images/shadow.gif); background-repeat: repeat-x;">
630+ <td bgcolor="#ffffff" colspan="1" height="8" style="background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;">
631
632 </td>
633 </tr>
634@@ -141,9 +156,10 @@
635 </td>
636 </tr>
637 <?php }?>
638+<?php } ?>
639
640 <tr>
641- <?php if ((read_graph_config_option("default_tree_view_mode") == "2") && (($_REQUEST["action"] == "tree") || ((isset($_REQUEST["view_type"]) ? $_REQUEST["view_type"] : "") == "tree"))) { ?>
642+ <?php if ((read_graph_config_option("default_tree_view_mode") == "2") && (isset($_REQUEST["action"]) && (($_REQUEST["action"] == "tree") || ((isset($_REQUEST["view_type"]) ? $_REQUEST["view_type"] : "") == "tree")))) { ?>
643 <td valign="top" style="padding: 5px; border-right: #aaaaaa 1px solid;" bgcolor='#efefef' width='<?php print read_graph_config_option("default_dual_pane_width");?>' class='noprint'>
644 <table border=0 cellpadding=0 cellspacing=0><tr><td><font size=-2><a style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank></a></font></td></tr></table>
645 <?php grow_dhtml_trees(); ?>
646diff -urN cacti-0.8.7d.orig/include/top_header.php cacti-0.8.7d/include/top_header.php
647--- cacti-0.8.7d.orig/include/top_header.php 2009-02-12 03:55:50.000000000 +0100
648+++ cacti-0.8.7d/include/top_header.php 2009-02-17 08:57:36.000000000 +0100
649@@ -22,37 +22,52 @@
650 +-------------------------------------------------------------------------+
651 */
652
653-global $colors;
654+global $colors, $config;
655+
656+$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
657+if ($oper_mode == OPER_MODE_RESKIN) {
658+ return;
659+}
660+
661+$page_title = api_plugin_hook_function('page_title', 'Cacti');
662+
663 ?>
664 <html>
665 <head>
666- <title>Cacti</title>
667- <link href="include/main.css" rel="stylesheet">
668- <link href="images/favicon.ico" rel="shortcut icon"/>
669- <script type="text/javascript" src="include/layout.js"></script>
670+ <title><?php echo $page_title; ?></title>
671+ <link href="<?php echo $config['url_path']; ?>include/main.css" rel="stylesheet">
672+ <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
673+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
674 <?php if (isset($refresh)) {
675 print "<meta http-equiv=refresh content=\"" . $refresh["seconds"] . "; url='" . $refresh["page"] . "'\">";
676- }?>
677+ }
678+ api_plugin_hook('page_head'); ?>
679 </style>
680 </head>
681
682-<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/left_border.gif">
683+<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
684+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" <?php print api_plugin_hook_function("body_style", "");?>>
685+<?php }else{?>
686+<body leftmargin="15" topmargin="15" marginwidth="15" marginheight="15" <?php print api_plugin_hook_function("body_style", "");?>>
687+<?php }?>
688
689 <table width="100%" cellspacing="0" cellpadding="0">
690+<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
691 <tr height="1" bgcolor="#a9a9a9">
692 <td valign="bottom" colspan="3" nowrap>
693 <table width="100%" cellspacing="0" cellpadding="0">
694- <tr style="background: transparent url('images/cacti_backdrop.gif') no-repeat center right;">
695+ <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop.gif') no-repeat center right;">
696 <td id="tabs" valign="bottom">
697- &nbsp;<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>
698- </td>
699+ &nbsp;<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
700+ api_plugin_hook('top_header_tabs');
701+ ?></td>
702 </tr>
703 </table>
704 </td>
705 </tr>
706 <tr height="2" bgcolor="#183c8f">
707 <td colspan="3">
708- <img src="images/transparent_line.gif" height="2" border="0"><br>
709+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" height="2" border="0"><br>
710 </td>
711 </tr>
712 <tr height="5" bgcolor="#e9e9e9">
713@@ -64,7 +79,7 @@
714 </td>
715 <td align="right">
716 <?php if (read_config_option("auth_method") != 0) { ?>
717- 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>)&nbsp;
718+ 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>)&nbsp;
719 <?php } ?>
720 </td>
721 </tr>
722@@ -72,10 +87,10 @@
723 </td>
724 </tr>
725 <tr>
726- <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;">
727- <img src="images/transparent_line.gif" width="135" height="2" border="0"><br>
728- </td>
729- <td colspan="2" height="8" style="background-image: url(images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
730+ <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;">
731+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="135" height="2" border="0"><br>
732+ </td>
733+ <td colspan="2" height="8" style="background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
734
735 </td>
736 </tr>
737@@ -85,9 +100,12 @@
738 <?php draw_menu();?>
739 </table>
740
741- <img src="images/transparent_line.gif" width="135" height="5" border="0"><br>
742- <p align="center"><a href='about.php'><img src="images/cacti_logo.gif" border="0"></a></p>
743- <img src="images/transparent_line.gif" width="135" height="5" border="0"><br>
744+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="135" height="5" border="0"><br>
745+ <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>
746+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="135" height="5" border="0"><br>
747 </td>
748 <td width="100%" colspan="2" valign="top" style="padding: 5px; border-right: #aaaaaa 1px solid;"><?php display_output_messages();?>
749-
750+<?php }else{ ?>
751+ <tr>
752+ <td width="100%" valign="top"><?php display_output_messages();?>
753+<?php } ?>
754diff -urN cacti-0.8.7d.orig/index.php cacti-0.8.7d/index.php
755--- cacti-0.8.7d.orig/index.php 2009-02-12 03:55:50.000000000 +0100
756+++ cacti-0.8.7d/index.php 2009-02-17 08:57:36.000000000 +0100
757@@ -25,6 +25,8 @@
758 include("./include/auth.php");
759 include("./include/top_header.php");
760
761+api_plugin_hook('console_before');
762+
763 ?>
764 <table width="100%" align="center">
765 <tr>
766@@ -46,6 +48,8 @@
767
768 <?php
769
770+api_plugin_hook('console_after');
771+
772 include("./include/bottom_footer.php");
773
774 ?>
775diff -urN cacti-0.8.7d.orig/lib/api_device.php cacti-0.8.7d/lib/api_device.php
776--- cacti-0.8.7d.orig/lib/api_device.php 2009-02-12 03:55:50.000000000 +0100
777+++ cacti-0.8.7d/lib/api_device.php 2009-02-17 08:57:36.000000000 +0100
778@@ -132,6 +132,8 @@
779 $save["ping_retries"] = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3);
780 $save["max_oids"] = form_input_validate($max_oids, "max_oids", "^[0-9]+$", true, 3);
781
782+ $save = api_plugin_hook_function('api_device_save', $save);
783+
784 $host_id = 0;
785
786 if (!is_error_message()) {
787diff -urN cacti-0.8.7d.orig/lib/auth.php cacti-0.8.7d/lib/auth.php
788--- cacti-0.8.7d.orig/lib/auth.php 2009-02-12 03:55:50.000000000 +0100
789+++ cacti-0.8.7d/lib/auth.php 2009-02-17 08:57:36.000000000 +0100
790@@ -122,6 +122,8 @@
791 }
792 }
793
794+ api_plugin_hook_function('copy_user', array('template_id' => $template_id, 'new_id' => $new_id));
795+
796 return true;
797
798 }
799@@ -153,6 +155,7 @@
800 db_execute("delete from settings_graphs where user_id=" . $user_id);
801 db_execute("delete from settings_tree where user_id=" . $user_id);
802
803+ api_plugin_hook_function('user_remove', $user_id);
804 }
805
806
807diff -urN cacti-0.8.7d.orig/lib/functions.php cacti-0.8.7d/lib/functions.php
808--- cacti-0.8.7d.orig/lib/functions.php 2009-02-12 03:55:50.000000000 +0100
809+++ cacti-0.8.7d/lib/functions.php 2009-02-17 08:57:36.000000000 +0100
810@@ -1640,6 +1640,7 @@
811 /* draw_navigation_text - determines the top header navigation text for the current page and displays it to
812 the browser */
813 function draw_navigation_text() {
814+ global $config;
815 $nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : array());
816
817 $nav = array(
818@@ -1652,8 +1653,8 @@
819 "graph.php:zoom" => array("title" => "Zoom", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
820 "graph.php:properties" => array("title" => "Properties", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
821 "graph_settings.php:" => array("title" => "Settings", "mapping" => "graph_view.php:", "url" => "graph_settings.php", "level" => "1"),
822- "index.php:" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
823- "index.php:login" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
824+ "index.php:" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
825+ "index.php:login" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
826 "graphs.php:" => array("title" => "Graph Management", "mapping" => "index.php:", "url" => "graphs.php", "level" => "1"),
827 "graphs.php:graph_edit" => array("title" => "(Edit)", "mapping" => "index.php:,graphs.php:", "url" => "", "level" => "2"),
828 "graphs.php:graph_diff" => array("title" => "Change Graph Template", "mapping" => "index.php:,graphs.php:,graphs.php:graph_edit", "url" => "", "level" => "3"),
829@@ -1731,6 +1732,8 @@
830 "templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"),
831 );
832
833+ $nav = api_plugin_hook_function('draw_navigation_text', $nav);
834+
835 $current_page = basename($_SERVER["PHP_SELF"]);
836
837 input_validate_input_regex(get_request_var_request("action"), "^([a-zA-Z0-9_-]+)$");
838diff -urN cacti-0.8.7d.orig/lib/html_form.php cacti-0.8.7d/lib/html_form.php
839--- cacti-0.8.7d.orig/lib/html_form.php 2009-02-12 03:55:50.000000000 +0100
840+++ cacti-0.8.7d/lib/html_form.php 2009-02-17 08:57:36.000000000 +0100
841@@ -661,11 +661,13 @@
842 on a confirmation form
843 @arg $cancel_url - the url to go to when the user clicks 'cancel'
844 @arg $action_url - the url to go to when the user clicks 'delete' */
845-function form_confirm_buttons($action_url, $cancel_url) { ?>
846+function form_confirm_buttons($action_url, $cancel_url) {
847+ global $config;
848+ ?>
849 <tr>
850 <td bgcolor="#E1E1E1">
851- <a href="<?php print $cancel_url;?>"><img src="images/button_cancel.gif" border="0" alt="Cancel" align="absmiddle"></a>
852- <a href="<?php print $action_url . "&confirm=yes";?>"><img src="images/button_delete.gif" border="0" alt="Delete" align="absmiddle"></a>
853+ <a href="<?php print $cancel_url;?>"><img src="<?php print $config['url_path'] ?>images/button_cancel.gif" border="0" alt="Cancel" align="absmiddle"></a>
854+ <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>
855 </td>
856 </tr>
857 <?php }
858@@ -676,6 +678,7 @@
859 @arg $force_type - if specified, will force the 'action' button to be either
860 'save' or 'create'. otherwise this field should be properly auto-detected */
861 function form_save_button($cancel_url, $force_type = "", $key_field = "id") {
862+ global $config;
863 if (empty($force_type)) {
864 if (empty($_GET[$key_field])) {
865 $img = "button_create.gif";
866@@ -696,8 +699,8 @@
867 <tr>
868 <td bgcolor="#f5f5f5" align="right">
869 <input type='hidden' name='action' value='save'>
870- <a href='<?php print $cancel_url;?>'><img src='images/button_cancel2.gif' alt='Cancel' align='absmiddle' border='0'></a>
871- <input type='image' src='images/<?php print $img;?>' alt='<?php print $alt;?>' align='absmiddle'>
872+ <a href='<?php print $cancel_url;?>'><img src='<?php echo $config['url_path']; ?>images/button_cancel2.gif' alt='Cancel' align='absmiddle' border='0'></a>
873+ <input type='image' src='<?php echo $config['url_path']; ?>images/<?php print $img;?>' alt='<?php print $alt;?>' align='absmiddle'>
874 </td>
875 </tr>
876 </table>
877diff -urN cacti-0.8.7d.orig/lib/html.php cacti-0.8.7d/lib/html.php
878--- cacti-0.8.7d.orig/lib/html.php 2009-02-12 03:55:50.000000000 +0100
879+++ cacti-0.8.7d/lib/html.php 2009-02-17 08:57:36.000000000 +0100
880@@ -86,6 +86,7 @@
881 @arg $extra_url_args - extra arguments to append to the url
882 @arg $header - html to use as a header */
883 function html_graph_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
884+ global $config;
885 $i = 0;
886 if (sizeof($graph_array) > 0) {
887 if ($header != "") {
888@@ -142,14 +143,15 @@
889 <table align='center' cellpadding='0'>
890 <tr>
891 <td align='center'>
892- <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>
893+ <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>
894 <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . $graph["title_cache"] . "</strong></p>" : "");?>
895 </td>
896 <td valign='top' style='align: left; padding: 3px;' class='noprint'>
897- <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>
898- <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>
899- <a href='graph.php?action=properties&local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br>
900- <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
901+ <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>
902+ <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>
903+ <a href='<?php print $config['url_path']; ?>graph.php?action=properties&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_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br>
904+ <?php api_plugin_hook('graph_buttons', array('hook' => 'graphs', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => '')); ?>
905+ <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>
906 </td>
907 </tr>
908 </table>
909@@ -175,6 +177,7 @@
910 @arg $extra_url_args - extra arguments to append to the url
911 @arg $header - html to use as a header */
912 function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
913+ global $config;
914 $i = 0; $k = 0; $j = 0;
915
916 $num_graphs = sizeof($graph_array);
917@@ -260,13 +263,14 @@
918 <table align='center' cellpadding='0'>
919 <tr>
920 <td align='center'>
921- <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>
922+ <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>
923 <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . $graph["title_cache"] . "</strong></p>" : "");?>
924 </td>
925 <td valign='top' style='align: left; padding: 3px;'>
926- <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>
927- <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>
928- <a href='graph.php?action=properties&local_graph_id=<?php print $graph["local_graph_id"];?>&rra_id=0&<?php print $extra_url_args;?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br>
929+ <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>
930+ <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>
931+ <a href='<?php print $config['url_path']; ?>graph.php?action=properties&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_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br>
932+ <?php api_plugin_hook('graph_buttons_thumbnails', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => '')); ?>
933 <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
934 </td>
935 </tr>
936@@ -698,6 +702,8 @@
937 }
938
939 while (list($item_sub_url, $item_sub_title) = each($item_title)) {
940+ $item_sub_url = $config['url_path'] . $item_sub_url;
941+
942 /* indent sub-items */
943 if ($i > 0) {
944 $prepend_string = "---&nbsp;";
945@@ -707,7 +713,7 @@
946
947 /* do not put a line between each sub-item */
948 if (($i == 0) || ($draw_sub_items == false)) {
949- $background = "images/menu_line.gif";
950+ $background = $config['url_path'] . "images/menu_line.gif";
951 }else{
952 $background = "";
953 }
954@@ -736,17 +742,18 @@
955 }else{
956 if ((isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) {
957 /* draw normal (non sub-item) menu item */
958+ $item_url = $config['url_path'] . $item_url;
959 if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) {
960- print "<tr><td class='textMenuItemSelected' background='images/menu_line.gif'><strong><a href='$item_url'>$item_title</a></strong></td></tr>\n";
961+ 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";
962 }else{
963- print "<tr><td class='textMenuItem' background='images/menu_line.gif'><a href='$item_url'>$item_title</a></td></tr>\n";
964+ print "<tr><td class='textMenuItem' background='" . $config['url_path'] . "images/menu_line.gif'><a href='$item_url'>$item_title</a></td></tr>\n";
965 }
966 }
967 }
968 }
969 }
970
971- print "<tr><td class='textMenuItem' background='images/menu_line.gif'></td></tr>\n";
972+ print "<tr><td class='textMenuItem' background='" . $config['url_path'] . "images/menu_line.gif'></td></tr>\n";
973
974 print "</table></td></tr>";
975 }
976@@ -756,18 +763,19 @@
977 @arg $actions_array - an array that contains a list of possible actions. this array should
978 be compatible with the form_dropdown() function */
979 function draw_actions_dropdown($actions_array) {
980+ global $config;
981 ?>
982 <table align='center' width='100%'>
983 <tr>
984 <td width='1' valign='top'>
985- <img src='images/arrow.gif' alt='' align='absmiddle'>&nbsp;
986+ <img src='<?php echo $config['url_path']; ?>images/arrow.gif' alt='' align='absmiddle'>&nbsp;
987 </td>
988 <td align='right'>
989 Choose an action:
990 <?php form_dropdown("drp_action",$actions_array,"","","1","","");?>
991 </td>
992 <td width='1' align='right'>
993- <input type='image' src='images/button_go.gif' alt='Go'>
994+ <input type='image' src='<?php echo $config['url_path']; ?>images/button_go.gif' alt='Go'>
995 </td>
996 </tr>
997 </table>
998diff -urN cacti-0.8.7d.orig/lib/plugins.php cacti-0.8.7d/lib/plugins.php
999--- cacti-0.8.7d.orig/lib/plugins.php 1970-01-01 01:00:00.000000000 +0100
1000+++ cacti-0.8.7d/lib/plugins.php 2009-02-17 08:57:36.000000000 +0100
1001@@ -0,0 +1,380 @@
1002+<?php
1003+
1004+
1005+
1006+function do_hook ($name) {
1007+ $data = func_get_args();
1008+ $data = api_plugin_hook ($name, $data);
1009+ return $data;
1010+}
1011+
1012+function do_hook_function($name,$parm=NULL) {
1013+ return api_plugin_hook_function ($name, $parm);
1014+}
1015+
1016+function api_user_realm_auth ($filename = '') {
1017+ return api_plugin_user_realm_auth ($filename);
1018+}
1019+
1020+/**
1021+ * This function executes a hook.
1022+ * @param string $name Name of hook to fire
1023+ * @return mixed $data
1024+ */
1025+function api_plugin_hook ($name) {
1026+ global $config, $plugin_hooks;
1027+ $data = func_get_args();
1028+ $ret = '';
1029+ $p = array();
1030+
1031+ $result = db_fetch_assoc("SELECT name, file, function FROM plugin_hooks WHERE status = 1 AND hook = '$name'", false);
1032+ if (count($result)) {
1033+ foreach ($result as $hdata) {
1034+ $p[] = $hdata['name'];
1035+ if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
1036+ include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
1037+ }
1038+ $function = $hdata['function'];
1039+ if (function_exists($function)) {
1040+ $function($data);
1041+ }
1042+ }
1043+ }
1044+
1045+ if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
1046+ foreach ($plugin_hooks[$name] as $pname => $function) {
1047+ if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
1048+ $function($data);
1049+ }
1050+ }
1051+ }
1052+
1053+ /* Variable-length argument lists have a slight problem when */
1054+ /* passing values by reference. Pity. This is a workaround. */
1055+ return $data;
1056+}
1057+
1058+function api_plugin_hook_function ($name, $parm=NULL) {
1059+ global $config, $plugin_hooks;
1060+ $ret = $parm;
1061+ $p = array();
1062+ $result = db_fetch_assoc("SELECT name, file, function FROM plugin_hooks WHERE status = 1 AND hook = '$name'", false);
1063+
1064+ if (count($result)) {
1065+ foreach ($result as $hdata) {
1066+ $p[] = $hdata['name'];
1067+ if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
1068+ include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
1069+ }
1070+ $function = $hdata['function'];
1071+ if (function_exists($function)) {
1072+ $ret = $function($ret);
1073+ }
1074+ }
1075+ }
1076+
1077+ if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
1078+ foreach ($plugin_hooks[$name] as $pname => $function) {
1079+ if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
1080+ $ret = $function($ret);
1081+ }
1082+ }
1083+ }
1084+
1085+ /* Variable-length argument lists have a slight problem when */
1086+ /* passing values by reference. Pity. This is a workaround. */
1087+ return $ret;
1088+}
1089+
1090+function api_plugin_db_table_create ($plugin, $table, $data) {
1091+ global $config, $database_default;
1092+ include_once($config["library_path"] . "/database.php");
1093+
1094+ $result = db_fetch_assoc("show tables from `" . $database_default . "`") or die (mysql_error());
1095+ $tables = array();
1096+ foreach($result as $index => $arr) {
1097+ foreach ($arr as $t) {
1098+ $tables[] = $t;
1099+ }
1100+ }
1101+ if (!in_array($table, $tables)) {
1102+ $c = 0;
1103+ $sql = 'CREATE TABLE `' . $table . "` (\n";
1104+ foreach ($data['columns'] as $column) {
1105+ if (isset($column['name'])) {
1106+ if ($c > 0)
1107+ $sql .= ",\n";
1108+ $sql .= '`' . $column['name'] . '`';
1109+ if (isset($column['type']))
1110+ $sql .= ' ' . $column['type'];
1111+ if (isset($column['unsigned']))
1112+ $sql .= ' unsigned';
1113+ if (isset($column['NULL']) && $column['NULL'] == false)
1114+ $sql .= ' NOT NULL';
1115+ if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
1116+ $sql .= ' default NULL';
1117+ if (isset($column['default']))
1118+ $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
1119+ if (isset($column['auto_increment']))
1120+ $sql .= ' auto_increment';
1121+ $c++;
1122+ }
1123+ }
1124+
1125+ if (isset($data['primary'])) {
1126+ $sql .= ",\n PRIMARY KEY (`" . $data['primary'] . '`)';
1127+ }
1128+
1129+ foreach ($data['keys'] as $key) {
1130+ if (isset($key['name'])) {
1131+ $sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)';
1132+ }
1133+ }
1134+ $sql .= ') TYPE = ' . $data['type'];
1135+
1136+ if (isset($data['comment'])) {
1137+ $sql .= " COMMENT = '" . $data['comment'] . "'";
1138+ }
1139+ if (db_execute($sql)) {
1140+ db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1141+ }
1142+ } else {
1143+ db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1144+ }
1145+}
1146+
1147+function api_plugin_db_changes_remove ($plugin) {
1148+ // Example: api_plugin_db_changes_remove ('thold');
1149+
1150+ $tables = db_fetch_assoc("SELECT `table` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='create'", false);
1151+ if (count($tables)) {
1152+ foreach ($tables as $table) {
1153+ db_execute("DROP TABLE `" . $table['table'] . "`;");
1154+ }
1155+ db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false);
1156+ }
1157+ $columns = db_fetch_assoc("SELECT `table`, `column` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='addcolumn'", false);
1158+ if (count($columns)) {
1159+ foreach ($columns as $column) {
1160+ db_execute('ALTER TABLE `' . $column['table'] . '` DROP `' . $column['column'] . '`');
1161+ }
1162+ db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false);
1163+ }
1164+}
1165+
1166+function api_plugin_db_add_column ($plugin, $table, $column) {
1167+ // Example: api_plugin_db_add_column ('thold', 'plugin_config', array('name' => 'test' . rand(1, 200), 'type' => 'varchar (255)', 'NULL' => false));
1168+
1169+ global $config, $database_default;
1170+ include_once($config['library_path'] . '/database.php');
1171+
1172+ $result = db_fetch_assoc('show columns from `' . $table . '`') or die (mysql_error());
1173+ $columns = array();
1174+ foreach($result as $index => $arr) {
1175+ foreach ($arr as $t) {
1176+ $columns[] = $t;
1177+ }
1178+ }
1179+ if (isset($column['name']) && !in_array($column['name'], $columns)) {
1180+ $sql = 'ALTER TABLE `' . $table . '` ADD `' . $column['name'] . '`';
1181+ if (isset($column['type']))
1182+ $sql .= ' ' . $column['type'];
1183+ if (isset($column['unsigned']))
1184+ $sql .= ' unsigned';
1185+ if (isset($column['NULL']) && $column['NULL'] == false)
1186+ $sql .= ' NOT NULL';
1187+ if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
1188+ $sql .= ' default NULL';
1189+ if (isset($column['default']))
1190+ $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
1191+ if (isset($column['auto_increment']))
1192+ $sql .= ' auto_increment';
1193+ if (isset($column['after']))
1194+ $sql .= ' AFTER ' . $column['after'];
1195+
1196+ if (db_execute($sql)) {
1197+ db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')");
1198+ }
1199+ }
1200+}
1201+
1202+function api_plugin_install ($plugin) {
1203+ global $config;
1204+ include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1205+
1206+ $exists = db_fetch_assoc("SELECT id FROM plugin_config WHERE directory = '$plugin'", false);
1207+ if (!count($exists)) {
1208+ db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1209+ }
1210+
1211+ $name = $author = $webpage = $version = '';
1212+ $function = 'plugin_' . $plugin . '_version';
1213+ if (function_exists($function)){
1214+ $info = $function();
1215+ $name = $info['longname'];
1216+ $webpage = $info['homepage'];
1217+ $author = $info['author'];
1218+ $version = $info['version'];
1219+ }
1220+
1221+ db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')");
1222+
1223+ $function = 'plugin_' . $plugin . '_install';
1224+ if (function_exists($function)){
1225+ $function();
1226+ $ready = api_plugin_check_config ($plugin);
1227+ if ($ready) {
1228+ // Set the plugin as "disabled" so it can go live
1229+ db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1230+ } else {
1231+ // Set the plugin as "needs configuration"
1232+ db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'");
1233+ }
1234+ }
1235+}
1236+
1237+function api_plugin_uninstall ($plugin) {
1238+ global $config;
1239+ include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1240+ // Run the Plugin's Uninstall Function first
1241+ $function = 'plugin_' . $plugin . '_uninstall';
1242+ if (function_exists($function)) {
1243+ $function();
1244+ }
1245+ api_plugin_remove_hooks ($plugin);
1246+ api_plugin_remove_realms ($plugin);
1247+ db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1248+ api_plugin_db_changes_remove ($plugin);
1249+}
1250+
1251+function api_plugin_check_config ($plugin) {
1252+ global $config;
1253+ include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1254+ $function = 'plugin_' . $plugin . '_check_config';
1255+ if (function_exists($function)) {
1256+ return $function();
1257+ }
1258+ return TRUE;
1259+}
1260+
1261+function api_plugin_enable ($plugin) {
1262+ $ready = api_plugin_check_config ($plugin);
1263+ if ($ready) {
1264+ api_plugin_enable_hooks ($plugin);
1265+ db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'");
1266+ }
1267+}
1268+
1269+function api_plugin_is_enabled ($plugin) {
1270+ $status = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = '$plugin'", false);
1271+ if ($status == '1')
1272+ return true;
1273+ return false;
1274+}
1275+
1276+function api_plugin_disable ($plugin) {
1277+ api_plugin_disable_hooks ($plugin);
1278+ db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1279+}
1280+
1281+function api_plugin_register_hook ($plugin, $hook, $function, $file) {
1282+ $exists = db_fetch_assoc("SELECT id FROM plugin_hooks WHERE name = '$plugin' AND hook = '$hook'", false);
1283+ if (!count($exists)) {
1284+ $settings = array('config_settings', 'config_arrays', 'config_form');
1285+ if (!in_array($hook, $settings)) {
1286+ db_execute("INSERT INTO plugin_hooks (name, hook, function, file) VALUES ('$plugin', '$hook', '$function', '$file')");
1287+ } else {
1288+ db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)");
1289+ }
1290+ }
1291+}
1292+
1293+function api_plugin_remove_hooks ($plugin) {
1294+ db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'");
1295+}
1296+
1297+function api_plugin_enable_hooks ($plugin) {
1298+ db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'");
1299+}
1300+
1301+function api_plugin_disable_hooks ($plugin) {
1302+ db_execute("UPDATE plugin_hooks SET status = 0 WHERE name = '$plugin' AND hook != 'config_settings' AND hook != 'config_arrays' AND hook != 'config_form'");
1303+}
1304+
1305+function api_plugin_register_realm ($plugin, $file, $display, $admin = false) {
1306+ $exists = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1307+ if (!count($exists)) {
1308+ db_execute("INSERT INTO plugin_realms (plugin, file, display) VALUES ('$plugin', '$file', '$display')");
1309+ if ($admin) {
1310+ $realm_id = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1311+ $realm_id = $realm_id[0]['id'] + 100;
1312+ $user_id = db_fetch_assoc("SELECT id FROM user_auth WHERE username = 'admin'", false);
1313+ if (count($user_id)) {
1314+ $user_id = $user_id[0]['id'];
1315+ $exists = db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id = $user_id and realm_id = $realm_id", false);
1316+ if (!count($exists)) {
1317+ db_execute("INSERT INTO user_auth_realm (user_id, realm_id) VALUES ($user_id, $realm_id)");
1318+ }
1319+ }
1320+ }
1321+ }
1322+}
1323+
1324+function api_plugin_remove_realms ($plugin) {
1325+ $realms = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin'", false);
1326+ foreach ($realms as $realm) {
1327+ $id = $realm['id'] + 100;
1328+ db_execute("DELETE FROM user_auth_realm WHERE realm_id = '$id'");
1329+ }
1330+ db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'");
1331+}
1332+
1333+function api_plugin_load_realms () {
1334+ global $user_auth_realms, $user_auth_realm_filenames;
1335+ $plugin_realms = db_fetch_assoc("SELECT * FROM plugin_realms ORDER BY plugin, display", false);
1336+ if (count($plugin_realms)) {
1337+ foreach ($plugin_realms as $plugin_realm) {
1338+ $plugin_files = explode(',', $plugin_realm['file']);
1339+ foreach($plugin_files as $plugin_file) {
1340+ $user_auth_realm_filenames[$plugin_file] = $plugin_realm['id'] + 100;
1341+ }
1342+ $user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display'];
1343+ }
1344+ }
1345+}
1346+
1347+function api_plugin_user_realm_auth ($filename = '') {
1348+ global $user_realms, $user_auth_realms, $user_auth_realm_filenames;
1349+ /* list all realms that this user has access to */
1350+ if (!isset($user_realms)) {
1351+ if (read_config_option('global_auth') == 'on' || read_config_option('auth_method') != 0) {
1352+ $user_realms = db_fetch_assoc("select realm_id from user_auth_realm where user_id=" . $_SESSION["sess_user_id"], false);
1353+ $user_realms = array_rekey($user_realms, "realm_id", "realm_id");
1354+ }else{
1355+ $user_realms = $user_auth_realms;
1356+ }
1357+ }
1358+ if ($filename != '') {
1359+ if (isset($user_realms[$user_auth_realm_filenames{basename($filename)}]))
1360+ return TRUE;
1361+ }
1362+ return FALSE;
1363+}
1364+
1365+function plugin_config_arrays () {
1366+ global $menu;
1367+ $menu['Configuration']['plugins.php'] = 'Plugin Management';
1368+ api_plugin_load_realms ();
1369+}
1370+
1371+function plugin_draw_navigation_text ($nav) {
1372+ $nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1");
1373+ return $nav;
1374+}
1375+
1376+
1377+
1378+
1379+
1380+
1381+
1382diff -urN cacti-0.8.7d.orig/lib/poller.php cacti-0.8.7d/lib/poller.php
1383--- cacti-0.8.7d.orig/lib/poller.php 2009-02-12 03:55:50.000000000 +0100
1384+++ cacti-0.8.7d/lib/poller.php 2009-02-17 08:57:36.000000000 +0100
1385@@ -324,8 +324,11 @@
1386 }
1387 }
1388 }
1389+ api_plugin_hook_function('poller_output', $rrd_update_array);
1390
1391- $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1392+ if (api_plugin_hook_function('poller_on_demand', $results)) {
1393+ $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1394+ }
1395 }
1396
1397 return $rrds_processed;
1398diff -urN cacti-0.8.7d.orig/lib/rrd.php cacti-0.8.7d/lib/rrd.php
1399--- cacti-0.8.7d.orig/lib/rrd.php 2009-02-12 03:55:50.000000000 +0100
1400+++ cacti-0.8.7d/lib/rrd.php 2009-02-17 08:57:36.000000000 +0100
1401@@ -557,6 +557,10 @@
1402 }
1403 }
1404
1405+ $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));
1406+ if (isset($data['return']) && $data['return'] != false)
1407+ return $data['return'];
1408+
1409 /* find the step and how often this graph is updated with new data */
1410 $ds_step = db_fetch_cell("select
1411 data_template_data.rrd_step
1412@@ -1388,6 +1392,13 @@
1413 }
1414 }
1415
1416+ $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));
1417+ if (!empty($graph_array)) {
1418+ $graph_defs = $graph_array['graph_defs'];
1419+ $txt_graph_items = $graph_array['txt_graph_items'];
1420+ $graph_opts = $graph_array['graph_opts'];
1421+ }
1422+
1423 /* either print out the source or pass the source onto rrdtool to get us a nice PNG */
1424 if (isset($graph_data_array["print_source"])) {
1425 print "<PRE>" . read_config_option("path_rrdtool") . " graph $graph_opts$graph_defs$txt_graph_items</PRE>";
1426@@ -1396,13 +1407,19 @@
1427 rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrd_struc);
1428 return 0;
1429 }else{
1430+ $graph_data_array = api_plugin_hook_function('prep_graph_array', $graph_data_array);
1431+
1432 if (isset($graph_data_array["output_flag"])) {
1433 $output_flag = $graph_data_array["output_flag"];
1434 }else{
1435 $output_flag = RRDTOOL_OUTPUT_GRAPH_DATA;
1436 }
1437
1438- return rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrd_struc);
1439+ $output = rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrd_struc);
1440+
1441+ api_plugin_hook_function('rrdtool_function_graph_set_file', array('output' => $output, 'local_graph_id' => $local_graph_id, 'rra_id' => $rra_id));
1442+
1443+ return $output;
1444 }
1445 }
1446 }
1447diff -urN cacti-0.8.7d.orig/lib/variables.php cacti-0.8.7d/lib/variables.php
1448--- cacti-0.8.7d.orig/lib/variables.php 2009-02-12 03:55:50.000000000 +0100
1449+++ cacti-0.8.7d/lib/variables.php 2009-02-17 08:57:36.000000000 +0100
1450@@ -183,6 +183,9 @@
1451 $string = str_replace($l_escape_string . "host_max_oids" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["max_oids"], $string);
1452 $string = str_replace($l_escape_string . "host_id" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["id"], $string);
1453
1454+ $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));
1455+ $string = $temp['string'];
1456+
1457 return $string;
1458 }
1459
1460diff -urN cacti-0.8.7d.orig/plugins/index.php cacti-0.8.7d/plugins/index.php
1461--- cacti-0.8.7d.orig/plugins/index.php 1970-01-01 01:00:00.000000000 +0100
1462+++ cacti-0.8.7d/plugins/index.php 2009-02-17 08:57:36.000000000 +0100
1463@@ -0,0 +1,5 @@
1464+<?php
1465+
1466+header("Location:../index.php");
1467+
1468+?>
1469diff -urN cacti-0.8.7d.orig/plugins.php cacti-0.8.7d/plugins.php
1470--- cacti-0.8.7d.orig/plugins.php 1970-01-01 01:00:00.000000000 +0100
1471+++ cacti-0.8.7d/plugins.php 2009-02-17 08:57:36.000000000 +0100
1472@@ -0,0 +1,435 @@
1473+<?php
1474+
1475+
1476+include("./include/auth.php");
1477+
1478+
1479+$pluginslist = retrieve_plugin_list ();
1480+
1481+/* tab information */
1482+$ptabs = array(
1483+ "current" => "Installed",
1484+// "uninstalled" => "Uninstalled",
1485+// "download" => "Download",
1486+// "updates" => "Updates",
1487+);
1488+
1489+
1490+$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');
1491+
1492+
1493+/* set the default settings category */
1494+if (!isset($_GET["tab"])) {
1495+ /* there is no selected tab; select the first one */
1496+ $current_tab = array_keys($ptabs);
1497+ $current_tab = $current_tab[0];
1498+}else{
1499+ $current_tab = $_GET["tab"];
1500+}
1501+
1502+
1503+// Check to see if we are installing, etc...
1504+$modes = array('install', 'uninstall', 'disable', 'enable', 'check');
1505+
1506+if (isset($_GET['mode']) && in_array($_GET['mode'], $modes) && isset($_GET['id'])) {
1507+
1508+ input_validate_input_regex(get_request_var("id"), "^([a-zA-Z0-9]+)$");
1509+
1510+ $mode = $_GET['mode'];
1511+ $id = sanitize_search_string($_GET['id']);
1512+
1513+ switch ($mode) {
1514+ case 'install':
1515+ api_plugin_install($id);
1516+ $pluginslist = retrieve_plugin_list ();
1517+ break;
1518+ case 'uninstall':
1519+ if (!in_array($id, $pluginslist))
1520+ break;
1521+ api_plugin_uninstall($id);
1522+ $pluginslist = retrieve_plugin_list ();
1523+ break;
1524+ case 'disable':
1525+ if (!in_array($id, $pluginslist))
1526+ break;
1527+ api_plugin_disable ($id);
1528+ break;
1529+ case 'enable':
1530+ if (!in_array($id, $pluginslist))
1531+ break;
1532+ api_plugin_enable ($id);
1533+ break;
1534+ case 'check':
1535+ if (!in_array($id, $pluginslist))
1536+ break;
1537+ break;
1538+ }
1539+}
1540+
1541+function retrieve_plugin_list () {
1542+ $pluginslist = array();
1543+ $temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name');
1544+ foreach ($temp as $t) {
1545+ $pluginslist[] = $t['directory'];
1546+ }
1547+ return $pluginslist;
1548+}
1549+
1550+
1551+ include("./include/top_header.php");
1552+
1553+ /* draw the categories tabs on the top of the page */
1554+/*
1555+ print "<table class='tabs' width='98%' cellspacing='0' cellpadding='3' align='center'><tr>\n";
1556+
1557+ if (sizeof($ptabs) > 0) {
1558+ foreach (array_keys($ptabs) as $tab_short_name) {
1559+ print "<td " . (($tab_short_name == $current_tab) ? "bgcolor='silver'" : "bgcolor='#DFDFDF'") . " nowrap='nowrap' width='" . (strlen($ptabs[$tab_short_name]) * 9) . "' align='center' class='tab'>
1560+ <span class='textHeader'><a href='plugins.php?tab=$tab_short_name'>$ptabs[$tab_short_name]</a></span>
1561+ </td>\n
1562+ <td width='1'></td>\n";
1563+ }
1564+ }
1565+
1566+ print "<td></td>\n</tr></table>\n";
1567+*/
1568+ html_start_box("<strong> Plugin Management</strong>", "98%", $colors["header"], "3", "center", "");
1569+
1570+ print "<tr><td><table width='100%'>";
1571+
1572+ //update_info_table();
1573+
1574+ switch ($current_tab) {
1575+ case 'current':
1576+ update_show_current();
1577+ break;
1578+ case 'uninstalled':
1579+ update_show_uninstalled ();
1580+ break;
1581+ default:
1582+ print '<br><br><br>';
1583+ }
1584+
1585+/*
1586+ $last_check = read_config_option("plugin_update_last_check");
1587+ if ($last_check < 1)
1588+ $last_check = 0;
1589+
1590+ print "<center>Last Scanned : " . ($last_check > 0 ? date("F j, Y g:i:s a", $last_check) : "Never") . "</center>";
1591+*/
1592+ print "</table></td></tr>";
1593+
1594+ html_end_box();
1595+
1596+ include("./include/bottom_footer.php");
1597+
1598+function update_show_updates () {
1599+ global $pluginslist, $colors, $config, $plugin_architecture;
1600+
1601+ $cinfo = array();
1602+ sort($pluginslist);
1603+
1604+ $cinfo = update_get_plugin_info ();
1605+
1606+ $x = 0;
1607+
1608+ $info = update_get_cached_plugin_info();
1609+
1610+ $cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ;
1611+ if (isset($cinfo['cacti_plugin_arch']['version']))
1612+ $archnew = update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']);
1613+ else
1614+ $archnew = 0;
1615+
1616+ if ($cactinew) {
1617+ $x++;
1618+ print "<tr><td width='25%' valign=top><table width='100%'>";
1619+ html_header(array("Cacti"), 2);
1620+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1621+ print "<td width='25%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr>";
1622+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1623+ print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti']['changes']) . "</td></tr></table>";
1624+ }
1625+ if (isset($plugin_architecture['version']) && $archnew) {
1626+ $x++;
1627+ print "<table width='100%'>";
1628+ html_header(array("Plugin Architecture"), 2);
1629+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1630+ print "<td width='25%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td>";
1631+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1632+ print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti_plugin_arch']['changes']) . "</td></tr></table>";
1633+ }
1634+ print "<table width='100%' cellspacing=0 cellpadding=3>";
1635+
1636+ foreach ($pluginslist as $plugin) {
1637+ if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) {
1638+ $x++;
1639+ print "<table width='100%'>";
1640+ html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2);
1641+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1642+ print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1643+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1644+ print "<td><strong>Version:</strong></td><td>" . $info[$plugin]['version'] . "</td>";
1645+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1646+ 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>";
1647+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1648+ 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>";
1649+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1650+ print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info[$plugin]['changes']) . "</td>";
1651+
1652+ print "</tr></table>";
1653+ }
1654+ }
1655+ if ($x == 0)
1656+ print "<br><center><b>There are currently no Updates!</b></center><br>";
1657+ print "</table>";
1658+ html_end_box(TRUE);
1659+}
1660+
1661+function update_check_if_newer() {
1662+ return false;
1663+}
1664+
1665+function update_show_current () {
1666+ global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names;
1667+
1668+
1669+
1670+ $cinfo = array();
1671+ $cinfo = update_get_plugin_info ();
1672+
1673+ sort($pluginslist);
1674+
1675+ $path = $config['base_path'] . '/plugins/';
1676+ $dh = opendir($path);
1677+ while (($file = readdir($dh)) !== false) {
1678+ if (is_dir("$path/$file")) {
1679+ if (file_exists("$path/$file/setup.php") && !in_array($file, $pluginslist)) {
1680+ include_once("$path/$file/setup.php");
1681+ if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) {
1682+ $function = $file . '_version';
1683+ $cinfo[$file] = $function();
1684+ $cinfo[$file]['status'] = -2;
1685+ if (in_array($file, $plugins)) {
1686+ $cinfo[$file]['status'] = -1;
1687+ }
1688+ $pluginslist[] = $file;
1689+ } else if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
1690+ $function = $file . '_version';
1691+ $cinfo[$file] = $function();
1692+ $cinfo[$file]['status'] = 0;
1693+ $pluginslist[] = $file;
1694+ }
1695+ }
1696+ }
1697+ }
1698+ closedir($dh);
1699+
1700+ print "<table width='100%' cellspacing=0 cellpadding=3>";
1701+ print "<tr><td width='50%'><table width='100%'>";
1702+ html_header(array("Cacti"), 2);
1703+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1704+ print "<td width='50%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr></table>";
1705+ print "</td><td>";
1706+ if (isset($plugin_architecture['version'])) {
1707+ print "<table width='100%'>";
1708+ html_header(array("Plugin Architecture"), 2);
1709+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1710+ print "<td width='50%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td></tr></table>";
1711+ }
1712+ print "</td></tr></table>";
1713+
1714+ print "<table width='100%' cellspacing=0 cellpadding=3>";
1715+ $x = 0;
1716+
1717+ foreach ($pluginslist as $plugin) {
1718+ if (isset($cinfo[$plugin])) {
1719+
1720+ if ($x == 0) {
1721+ print "<tr><td width='50%' valign=top>";
1722+ } else {
1723+ print "</td><td valign=top>";
1724+ }
1725+ if (!isset($info[$plugin]['version']))
1726+ $info[$plugin]['version'] = '';
1727+
1728+ print "<table width='100%'>";
1729+ html_header(array((isset($cinfo[$plugin]['name']) ? $cinfo[$plugin]['name'] : $plugin)), 2);
1730+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1731+ print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1732+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1733+ 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>";
1734+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1735+ 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>";
1736+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1737+ 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>";
1738+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1739+ print "<td><strong>Status:</strong></td><td>" . $status_names[$cinfo[$plugin]['status']] . "</td>";
1740+
1741+ if ($cinfo[$plugin]['status'] > -1) {
1742+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1743+
1744+ $links = array('install' => 'Install', 'uninstall' => 'Uninstall', 'enable' => 'Enable', 'disable' => 'Disable', 'check' => 'Check');
1745+
1746+ switch ($cinfo[$plugin]['status']) {
1747+ case 0: //Not Installed
1748+ $links['install'] = "<a href='plugins.php?mode=install&id=$plugin'><b>Install</b></a>";
1749+ break;
1750+ case 1: // Currently Active
1751+ $links['uninstall'] = "<a href='plugins.php?mode=uninstall&id=$plugin'><b>Uninstall</b></a>";
1752+ $links['disable'] = "<a href='plugins.php?mode=disable&id=$plugin'><b>Disable</b></a>";
1753+ break;
1754+ case 2: // Needs Configuring
1755+ $links['check'] = "<a href='plugins.php?mode=check&id=$plugin'><b>Check</b></a>";
1756+ break;
1757+ case 3: // Needs Upgrade
1758+ $links['check'] = "<a href='plugins.php?mode=check&id=$plugin'><b>Check</b></a>";
1759+ break;
1760+ case 4: // Installed but not active
1761+ $links['uninstall'] = "<a href='plugins.php?mode=uninstall&id=$plugin'><b>Uninstall</b></a>";
1762+ $links['enable'] = "<a href='plugins.php?mode=enable&id=$plugin'><b>Enable</b></a>";
1763+ break;
1764+ }
1765+
1766+ print "<td></td><td>";
1767+ $c = 1;
1768+ foreach ($links as $temp => $link) {
1769+ print $link;
1770+ if ($c < count($links))
1771+ print ' | ';
1772+ $c++;
1773+ }
1774+ print "</td>";
1775+ print "</tr>";
1776+ }
1777+
1778+ print "</table>";
1779+ if ($x == 1) {
1780+ print "</td></tr>";
1781+ }
1782+ $x++;
1783+ if ($x > 1) $x = 0;
1784+ }
1785+ }
1786+ if ($x == 1)
1787+ print "</td><td></td></tr>";
1788+ print "</table>";
1789+ html_end_box(TRUE);
1790+}
1791+
1792+
1793+function update_show_uninstalled () {
1794+ global $pluginslist, $colors, $plugin_architecture, $config, $status_names;
1795+
1796+ $cinfo = array();
1797+ sort($pluginslist);
1798+
1799+ print "<table width='100%' cellspacing=0 cellpadding=3>";
1800+ $x = 0;
1801+
1802+ $newplugins = array();
1803+ $cinfo = array ();
1804+
1805+ $path = $config['base_path'] . '/plugins/';
1806+ $dh = opendir($path);
1807+ while (($file = readdir($dh)) !== false) {
1808+ if (is_dir("$path/$file")) {
1809+ if (file_exists("$path/$file/setup.php") && !in_array($file, $pluginslist)) {
1810+ include_once("$path/$file/setup.php");
1811+ if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
1812+ $function = 'plugin_' . $file . '_version';
1813+ $cinfo[$file] = $function();
1814+ $cinfo[$file]['status'] = 0;
1815+ $newplugins[] = $file;
1816+ }
1817+ }
1818+ }
1819+ }
1820+ closedir($dh);
1821+
1822+ if (count($newplugins)) {
1823+ foreach ($newplugins as $plugin) {
1824+ if (isset($cinfo[$plugin])) {
1825+
1826+ if ($x == 0) {
1827+ print "<tr><td width='50%'>";
1828+ } else {
1829+ print "</td><td>";
1830+ }
1831+ if (!isset($info[$plugin]['version']))
1832+ $info[$plugin]['version'] = '';
1833+
1834+ print "<table width='100%'>";
1835+ html_header(array((isset($cinfo[$plugin]['name']) ? $cinfo[$plugin]['name'] : $plugin)), 2);
1836+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1837+ print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1838+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1839+ 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>";
1840+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1841+ 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>";
1842+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1843+ 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>";
1844+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1845+ print "<td><strong>Status:</strong></td><td>" . $status_names[$cinfo[$plugin]['status']] . "</td>";
1846+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1847+
1848+ $links = array('install' => 'Install', 'uninstall' => 'Uninstall', 'enable' => 'Enable', 'disable' => 'Disable', 'check' => 'Check');
1849+
1850+ switch ($cinfo[$plugin]['status']) {
1851+ case 0: //Not Installed
1852+ $links['install'] = "<a href='plugins.php?mode=install&id=$plugin&tab=uninstalled'><b>Install</b></a>";
1853+ break;
1854+ case 1: // Currently Active
1855+ $links['uninstall'] = "<a href='plugins.php?mode=uninstall&id=$plugin&tab=uninstalled'><b>Uninstall</b></a>";
1856+ $links['disable'] = "<a href='plugins.php?mode=disable&id=$plugin&tab=uninstalled'><b>Disable</b></a>";
1857+ break;
1858+ case 2: // Needs Configuring
1859+ $links['check'] = "<a href='plugins.php?mode=check&id=$plugin&tab=uninstalled'><b>Check</b></a>";
1860+ break;
1861+ case 3: // Needs Upgrade
1862+ $links['check'] = "<a href='plugins.php?mode=check&id=$plugin&tab=uninstalled'><b>Check</b></a>";
1863+ break;
1864+ case 4: // Installed but not active
1865+ $links['enable'] = "<a href='plugins.php?mode=enable&id=$plugin&tab=uninstalled'><b>Enable</b></a>";
1866+ break;
1867+ }
1868+
1869+ print "<td></td><td>";
1870+ $c = 1;
1871+ foreach ($links as $temp => $link) {
1872+ print $link;
1873+ if ($c < count($links))
1874+ print ' | ';
1875+ $c++;
1876+ }
1877+
1878+ print "</td>";
1879+ print "</tr></table>";
1880+ if ($x == 1) {
1881+ print "</td></tr>";
1882+ }
1883+ $x++;
1884+ if ($x > 1) $x = 0;
1885+ }
1886+ }
1887+ } else {
1888+ print "<center>There are no Uninstalled Plugins</center>";
1889+ }
1890+ if ($x == 1)
1891+ print "</td><td></td></tr>";
1892+ print "</table>";
1893+ html_end_box(TRUE);
1894+}
1895+
1896+function update_get_plugin_info () {
1897+ $cinfo = array();
1898+ $info = db_fetch_assoc("SELECT * from plugin_config");
1899+ if (is_array($info)) {
1900+ foreach($info as $inf) {
1901+ $cinfo[$inf['directory']] = $inf;
1902+ $cinfo[$inf['directory']]['changes']='';
1903+ }
1904+ }
1905+ return $cinfo;
1906+}
1907+
1908diff -urN cacti-0.8.7d.orig/poller.php cacti-0.8.7d/poller.php
1909--- cacti-0.8.7d.orig/poller.php 2009-02-12 03:55:50.000000000 +0100
1910+++ cacti-0.8.7d/poller.php 2009-02-17 08:57:36.000000000 +0100
1911@@ -73,6 +73,8 @@
1912 }
1913 }
1914
1915+api_plugin_hook('poller_top');
1916+
1917 /* record the start time */
1918 list($micro,$seconds) = split(" ", microtime());
1919 $poller_start = $seconds + $micro;
1920@@ -261,6 +263,8 @@
1921 $total_procs = $concurrent_processes;
1922 }
1923
1924+ $extra_args = api_plugin_hook_function ('poller_command_args', $extra_args);
1925+
1926 /* Populate each execution file with appropriate information */
1927 foreach ($polling_hosts as $item) {
1928 if ($host_count == 1) {
1929@@ -403,9 +407,11 @@
1930
1931 /* sleep the appripriate amount of time */
1932 if ($poller_runs_completed < $poller_runs) {
1933+ api_plugin_hook('poller_bottom');
1934 db_close();
1935 usleep($sleep_time * 1000000);
1936 db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
1937+ api_plugin_hook('poller_top');
1938 }
1939 }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM) {
1940 cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER");
1941@@ -452,4 +458,6 @@
1942 echo " --debug|-d Output debug information. Similar to cacti's DEBUG logging level.\n\n";
1943 }
1944
1945+api_plugin_hook('poller_bottom');
1946+
1947 ?>
1948diff -urN cacti-0.8.7d.orig/user_admin.php cacti-0.8.7d/user_admin.php
1949--- cacti-0.8.7d.orig/user_admin.php 2009-02-12 03:55:50.000000000 +0100
1950+++ cacti-0.8.7d/user_admin.php 2009-02-17 08:57:36.000000000 +0100
1951@@ -72,9 +72,11 @@
1952 break;
1953
1954 default:
1955- include_once("include/top_header.php");
1956- user();
1957- include_once("include/bottom_footer.php");
1958+ if (!api_plugin_hook_function('user_admin_action', get_request_var_request("action"))) {
1959+ include_once("include/top_header.php");
1960+ user();
1961+ include_once("include/bottom_footer.php");
1962+ }
1963 break;
1964 }
1965
1966@@ -418,6 +420,7 @@
1967 $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);
1968 $save["realm"] = get_request_var_post("realm", 0);
1969 $save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3);
1970+ $save = api_plugin_hook_function('user_admin_setup_sql_save', $save);
1971
1972 if (!is_error_message()) {
1973 $user_id = sql_save($save, "user_auth");
1974@@ -460,6 +463,8 @@
1975 policy_hosts = " . get_request_var_post("policy_hosts") . ",
1976 policy_graph_templates = " . get_request_var_post("policy_graph_templates") . "
1977 WHERE id = " . get_request_var_post("id"));
1978+ } else {
1979+ api_plugin_hook('user_admin_user_save');
1980 }
1981 }
1982 }
1983@@ -910,6 +915,8 @@
1984 $header_label = "[new]";
1985 }
1986
1987+ api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0));
1988+
1989 html_start_box("<strong>User Management</strong> $header_label", "100%", $colors["header"], "3", "center", "");
1990
1991 draw_edit_form(array(
1992@@ -936,6 +943,7 @@
1993 <td <?php print ((get_request_var("action") == "graph_settings_edit") ? "bgcolor='silver'" : "bgcolor='#DFDFDF'");?> nowrap='nowrap' width='130' align='center' class='tab'>
1994 <span class='textHeader'><a href='user_admin.php?action=graph_settings_edit&id=<?php print $_GET["id"];?>'>Graph Settings</a></span>
1995 </td>
1996+ <?php api_plugin_hook('user_admin_tab');?>
1997 <td></td>
1998 </tr>
1999 </table>
2000@@ -949,7 +957,9 @@
2001 }elseif (get_request_var("action") == "graph_perms_edit") {
2002 graph_perms_edit();
2003 }else{
2004- user_realms_edit();
2005+ if (api_plugin_hook_function('user_admin_run_action', get_request_var_request("action"))) {
2006+ user_realms_edit();
2007+ }
2008 }
2009
2010 form_save_button("user_admin.php");
2011diff -urN cacti-0.8.7d.orig/utilities.php cacti-0.8.7d/utilities.php
2012--- cacti-0.8.7d.orig/utilities.php 2009-02-12 03:55:50.000000000 +0100
2013+++ cacti-0.8.7d/utilities.php 2009-02-17 08:57:36.000000000 +0100
2014@@ -129,11 +129,14 @@
2015 include_once("./include/bottom_footer.php");
2016 break;
2017 default:
2018- include_once("./include/top_header.php");
2019
2020- utilities();
2021+ if (!api_plugin_hook_function('utilities_action', $_REQUEST['action'])) {
2022+ include_once('./include/top_header.php');
2023
2024- include_once("./include/bottom_footer.php");
2025+ utilities();
2026+
2027+ include_once('./include/bottom_footer.php');
2028+ }
2029 break;
2030 }
2031
2032@@ -1642,6 +1645,8 @@
2033
2034 <?php
2035
2036+ api_plugin_hook('utilities_list');
2037+
2038 html_end_box();
2039 }
2040
This page took 0.273857 seconds and 4 git commands to generate.