]> git.pld-linux.org Git - packages/cacti.git/blame - cacti-PA.patch
- added sql_injection_template_export.patch. Resolves: CVE-2010-1431
[packages/cacti.git] / cacti-PA.patch
CommitLineData
c9a520e2
ER
1diff -Naur cacti-0.8.7e-old/auth_changepassword.php cacti-0.8.7e/auth_changepassword.php
2--- cacti-0.8.7e-old/auth_changepassword.php 2009-06-28 11:07:11.000000000 -0500
3+++ cacti-0.8.7e/auth_changepassword.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/auth_login.php cacti-0.8.7e/auth_login.php
14--- cacti-0.8.7e-old/auth_login.php 2009-06-28 11:07:11.000000000 -0500
15+++ cacti-0.8.7e/auth_login.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/data_sources.php cacti-0.8.7e/data_sources.php
53--- cacti-0.8.7e-old/data_sources.php 2009-06-28 11:07:11.000000000 -0500
54+++ cacti-0.8.7e/data_sources.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/graph_image.php cacti-0.8.7e/graph_image.php
123--- cacti-0.8.7e-old/graph_image.php 2009-06-28 11:07:11.000000000 -0500
124+++ cacti-0.8.7e/graph_image.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/graph.php cacti-0.8.7e/graph.php
135--- cacti-0.8.7e-old/graph.php 2009-11-21 23:31:26.000000000 -0600
136+++ cacti-0.8.7e/graph.php 2009-11-21 23:06:16.000000000 -0600
137@@ -100,6 +100,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@@ -214,6 +215,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@@ -246,6 +248,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 -Naur cacti-0.8.7e-old/graphs_new.php cacti-0.8.7e/graphs_new.php
162--- cacti-0.8.7e-old/graphs_new.php 2009-06-28 11:07:11.000000000 -0500
163+++ cacti-0.8.7e/graphs_new.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/graphs.php cacti-0.8.7e/graphs.php
175--- cacti-0.8.7e-old/graphs.php 2009-06-28 11:07:11.000000000 -0500
176+++ cacti-0.8.7e/graphs.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/host.php cacti-0.8.7e/host.php
211--- cacti-0.8.7e-old/host.php 2009-06-28 11:07:11.000000000 -0500
212+++ cacti-0.8.7e/host.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/include/auth.php cacti-0.8.7e/include/auth.php
272--- cacti-0.8.7e-old/include/auth.php 2009-06-28 11:07:11.000000000 -0500
273+++ cacti-0.8.7e/include/auth.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/include/bottom_footer.php cacti-0.8.7e/include/bottom_footer.php
312--- cacti-0.8.7e-old/include/bottom_footer.php 2009-06-28 11:07:11.000000000 -0500
313+++ cacti-0.8.7e/include/bottom_footer.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/include/global_arrays.php cacti-0.8.7e/include/global_arrays.php
336--- cacti-0.8.7e-old/include/global_arrays.php 2009-11-21 23:31:26.000000000 -0600
337+++ cacti-0.8.7e/include/global_arrays.php 2009-11-21 23:06:16.000000000 -0600
338@@ -22,6 +22,8 @@
339 +-------------------------------------------------------------------------+
340 */
341
342+global $menu;
343+
344 $messages = array(
345 1 => array(
346 "message" => 'Save Successful.',
347@@ -645,4 +647,10 @@
348 GDC_SLASH => "/"
349 );
350
351+$plugin_architecture = array(
352+ 'version' => '2.6'
353+ );
354+
355+api_plugin_hook('config_arrays');
356+
357 ?>
358diff -Naur cacti-0.8.7e-old/include/global_constants.php cacti-0.8.7e/include/global_constants.php
359--- cacti-0.8.7e-old/include/global_constants.php 2009-06-28 11:07:11.000000000 -0500
360+++ cacti-0.8.7e/include/global_constants.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/include/global_form.php cacti-0.8.7e/include/global_form.php
371--- cacti-0.8.7e-old/include/global_form.php 2009-06-28 11:07:11.000000000 -0500
372+++ cacti-0.8.7e/include/global_form.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/include/global.php cacti-0.8.7e/include/global.php
395--- cacti-0.8.7e-old/include/global.php 2009-06-28 11:07:11.000000000 -0500
396+++ cacti-0.8.7e/include/global.php 2009-11-21 23:06:16.000000000 -0600
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@@ -76,7 +92,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@@ -180,18 +195,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@@ -200,6 +220,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.7e";
464
465diff -Naur cacti-0.8.7e-old/include/global_settings.php cacti-0.8.7e/include/global_settings.php
466--- cacti-0.8.7e-old/include/global_settings.php 2009-06-28 11:07:11.000000000 -0500
467+++ cacti-0.8.7e/include/global_settings.php 2009-11-21 23:06:16.000000000 -0600
468@@ -1185,4 +1185,6 @@
469 )
470 );
471
472+api_plugin_hook('config_settings');
473+
474 ?>
475diff -Naur cacti-0.8.7e-old/include/plugins.php cacti-0.8.7e/include/plugins.php
476--- cacti-0.8.7e-old/include/plugins.php 1969-12-31 17:00:00.000000000 -0700
477+++ cacti-0.8.7e/include/plugins.php 2009-11-21 23:06:16.000000000 -0600
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 -Naur cacti-0.8.7e-old/include/top_graph_header.php cacti-0.8.7e/include/top_graph_header.php
516--- cacti-0.8.7e-old/include/top_graph_header.php 2009-11-21 23:31:26.000000000 -0600
517+++ cacti-0.8.7e/include/top_graph_header.php 2009-11-21 23:20:04.000000000 -0600
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@@ -50,41 +55,52 @@
531 $_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all";
532 }
533
534+$page_title = api_plugin_hook_function('page_title', 'Cacti');
535+
536 ?>
537 <html>
538 <head>
539- <title>Cacti</title>
540+ <title><?php echo $page_title; ?></title>
541 <?php if (isset($_SESSION["custom"])) {
542 if ($_SESSION["custom"]) {
543 print "<meta http-equiv=refresh content='99999'>\r\n";
544 }else{
545- print "<meta http-equiv=refresh content='" . htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES) . "'>\r\n";
546+ $refresh = api_plugin_hook_function('top_graph_refresh', read_graph_config_option('page_refresh'));
547+ print "<meta http-equiv=refresh content='" . $refresh . "'>\r\n";
548 }
549 }
550 ?>
551- <link href="include/main.css" rel="stylesheet">
552- <link href="images/favicon.ico" rel="shortcut icon"/>
553- <script type="text/javascript" src="include/layout.js"></script>
554- <script type="text/javascript" src="include/treeview/ua.js"></script>
555- <script type="text/javascript" src="include/treeview/ftiens4.js"></script>
556- <script type="text/javascript" src="include/jscalendar/calendar.js"></script>
557- <script type="text/javascript" src="include/jscalendar/lang/calendar-en.js"></script>
558- <script type="text/javascript" src="include/jscalendar/calendar-setup.js"></script>
559+ <link href="<?php echo $config['url_path']; ?>include/main.css" rel="stylesheet">
560+ <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
561+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
562+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ua.js"></script>
563+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ftiens4.js"></script>
564+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar.js"></script>
565+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/lang/calendar-en.js"></script>
566+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar-setup.js"></script>
567+ <?php api_plugin_hook('page_head'); ?>
568 </head>
569
570-<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
571+<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
572+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" <?php print api_plugin_hook_function("body_style", "");?>>
573 <a name='page_top'></a>
574+<?php }else{?>
575+<body leftmargin="15" topmargin="15" marginwidth="15" marginheight="15" <?php print api_plugin_hook_function("body_style", "");?>>
576+<?php }?>
577
578 <table width="100%" height="100%" cellspacing="0" cellpadding="0">
579+<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
580 <tr height="25" bgcolor="#a9a9a9" class="noprint">
581 <td colspan="2" valign="bottom" nowrap>
582 <table width="100%" cellspacing="0" cellpadding="0">
583- <tr style="background: transparent url('images/cacti_backdrop2.gif') no-repeat center right;">
584+ <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop2.gif') no-repeat center right;">
585 <td id="tabs" nowrap>
586- &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;
587+ &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
588+ api_plugin_hook('top_graph_header_tabs');
589+ ?>
590 </td>
591 <td id="gtabs" align="right" nowrap>
592- <?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 (isset($_REQUEST["action"]) && $_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 (isset($_REQUEST["action"]) && $_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 (isset($_REQUEST["action"]) && $_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?>&nbsp;<br>
593+ <?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 (isset($_REQUEST["action"]) && $_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 (isset($_REQUEST["action"]) && $_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 (isset($_REQUEST["action"]) && $_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?>&nbsp;<br>
594 </td>
595 </tr>
596 </table>
597@@ -92,7 +108,7 @@
598 </tr>
599 <tr height="2" colspan="2" bgcolor="#183c8f" class="noprint">
600 <td colspan="2">
601- <img src="images/transparent_line.gif" width="170" height="2" border="0"><br>
602+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="170" height="2" border="0"><br>
603 </td>
604 </tr>
605 <tr height="5" bgcolor="#e9e9e9" class="noprint">
606@@ -104,7 +120,7 @@
607 </td>
608 <td align="right">
609 <?php if ((isset($_SESSION["sess_user_id"])) && ($using_guest_account == false)) { ?>
610- 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;
611+ 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;
612 <?php } ?>
613 </td>
614 </tr>
615@@ -112,10 +128,10 @@
616 </td>
617 </tr>
618 <tr class="noprint">
619- <td bgcolor="#efefef" colspan="1" height="8" style="background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
620- <img src="images/transparent_line.gif" width="<?php print htmlspecialchars(read_graph_config_option("default_dual_pane_width"));?>" height="2" border="0"><br>
621+ <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;">
622+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="<?php print htmlspecialchars(read_graph_config_option("default_dual_pane_width"));?>" height="2" border="0"><br>
623 </td>
624- <td bgcolor="#ffffff" colspan="1" height="8" style="background-image: url(images/shadow.gif); background-repeat: repeat-x;">
625+ <td bgcolor="#ffffff" colspan="1" height="8" style="background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;">
626
627 </td>
628 </tr>
629@@ -140,10 +156,10 @@
630 ?>
631 </td>
632 </tr>
633- <?php }?>
634-
635+ <?php }
636+ } ?>
637 <tr>
638- <?php if ((read_graph_config_option("default_tree_view_mode") == "2") && (($_REQUEST["action"] == "tree") || ((isset($_REQUEST["view_type"]) ? $_REQUEST["view_type"] : "") == "tree"))) { ?>
639+ <?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"))) { ?>
640 <td valign="top" style="padding: 5px; border-right: #aaaaaa 1px solid;" bgcolor='#efefef' width='<?php print htmlspecialchars(read_graph_config_option("default_dual_pane_width"));?>' class='noprint'>
641 <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>
642 <?php grow_dhtml_trees(); ?>
643diff -Naur cacti-0.8.7e-old/include/top_header.php cacti-0.8.7e/include/top_header.php
644--- cacti-0.8.7e-old/include/top_header.php 2009-06-28 11:07:11.000000000 -0500
645+++ cacti-0.8.7e/include/top_header.php 2009-11-21 23:06:16.000000000 -0600
646@@ -22,37 +22,52 @@
647 +-------------------------------------------------------------------------+
648 */
649
650-global $colors;
651+global $colors, $config;
652+
653+$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
654+if ($oper_mode == OPER_MODE_RESKIN) {
655+ return;
656+}
657+
658+$page_title = api_plugin_hook_function('page_title', 'Cacti');
659+
660 ?>
661 <html>
662 <head>
663- <title>Cacti</title>
664- <link href="include/main.css" rel="stylesheet">
665- <link href="images/favicon.ico" rel="shortcut icon"/>
666- <script type="text/javascript" src="include/layout.js"></script>
667+ <title><?php echo $page_title; ?></title>
668+ <link href="<?php echo $config['url_path']; ?>include/main.css" rel="stylesheet">
669+ <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
670+ <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
671 <?php if (isset($refresh)) {
672 print "<meta http-equiv=refresh content=\"" . $refresh["seconds"] . "; url='" . $refresh["page"] . "'\">";
673- }?>
674+ }
675+ api_plugin_hook('page_head'); ?>
676 </style>
677 </head>
678
679-<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/left_border.gif">
680+<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
681+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" <?php print api_plugin_hook_function("body_style", "");?>>
682+<?php }else{?>
683+<body leftmargin="15" topmargin="15" marginwidth="15" marginheight="15" <?php print api_plugin_hook_function("body_style", "");?>>
684+<?php }?>
685
686 <table width="100%" cellspacing="0" cellpadding="0">
687+<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
688 <tr height="1" bgcolor="#a9a9a9">
689 <td valign="bottom" colspan="3" nowrap>
690 <table width="100%" cellspacing="0" cellpadding="0">
691- <tr style="background: transparent url('images/cacti_backdrop.gif') no-repeat center right;">
692+ <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop.gif') no-repeat center right;">
693 <td id="tabs" valign="bottom">
694- &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>
695- </td>
696+ &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
697+ api_plugin_hook('top_header_tabs');
698+ ?></td>
699 </tr>
700 </table>
701 </td>
702 </tr>
703 <tr height="2" bgcolor="#183c8f">
704 <td colspan="3">
705- <img src="images/transparent_line.gif" height="2" border="0"><br>
706+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" height="2" border="0"><br>
707 </td>
708 </tr>
709 <tr height="5" bgcolor="#e9e9e9">
710@@ -64,7 +79,7 @@
711 </td>
712 <td align="right">
713 <?php if (read_config_option("auth_method") != 0) { ?>
714- 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;
715+ 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;
716 <?php } ?>
717 </td>
718 </tr>
719@@ -72,10 +87,10 @@
720 </td>
721 </tr>
722 <tr>
723- <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;">
724- <img src="images/transparent_line.gif" width="135" height="2" border="0"><br>
725- </td>
726- <td colspan="2" height="8" style="background-image: url(images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
727+ <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;">
728+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="135" height="2" border="0"><br>
729+ </td>
730+ <td colspan="2" height="8" style="background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
731
732 </td>
733 </tr>
734@@ -85,9 +100,12 @@
735 <?php draw_menu();?>
736 </table>
737
738- <img src="images/transparent_line.gif" width="135" height="5" border="0"><br>
739- <p align="center"><a href='about.php'><img src="images/cacti_logo.gif" border="0"></a></p>
740- <img src="images/transparent_line.gif" width="135" height="5" border="0"><br>
741+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="135" height="5" border="0"><br>
742+ <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>
743+ <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="135" height="5" border="0"><br>
744 </td>
745 <td width="100%" colspan="2" valign="top" style="padding: 5px; border-right: #aaaaaa 1px solid;"><?php display_output_messages();?>
746-
747+<?php }else{ ?>
748+ <tr>
749+ <td width="100%" valign="top"><?php display_output_messages();?>
750+<?php } ?>
751diff -Naur cacti-0.8.7e-old/index.php cacti-0.8.7e/index.php
752--- cacti-0.8.7e-old/index.php 2009-06-28 11:07:11.000000000 -0500
753+++ cacti-0.8.7e/index.php 2009-11-21 23:06:16.000000000 -0600
754@@ -25,6 +25,8 @@
755 include("./include/auth.php");
756 include("./include/top_header.php");
757
758+api_plugin_hook('console_before');
759+
760 ?>
761 <table width="100%" align="center">
762 <tr>
763@@ -46,6 +48,8 @@
764
765 <?php
766
767+api_plugin_hook('console_after');
768+
769 include("./include/bottom_footer.php");
770
771 ?>
772diff -Naur cacti-0.8.7e-old/lib/api_device.php cacti-0.8.7e/lib/api_device.php
773--- cacti-0.8.7e-old/lib/api_device.php 2009-06-28 11:07:11.000000000 -0500
774+++ cacti-0.8.7e/lib/api_device.php 2009-11-21 23:06:16.000000000 -0600
775@@ -137,6 +137,8 @@
776 $save["ping_retries"] = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3);
777 $save["max_oids"] = form_input_validate($max_oids, "max_oids", "^[0-9]+$", true, 3);
778
779+ $save = api_plugin_hook_function('api_device_save', $save);
780+
781 $host_id = 0;
782
783 if (!is_error_message()) {
784diff -Naur cacti-0.8.7e-old/lib/auth.php cacti-0.8.7e/lib/auth.php
785--- cacti-0.8.7e-old/lib/auth.php 2009-06-28 11:07:11.000000000 -0500
786+++ cacti-0.8.7e/lib/auth.php 2009-11-21 23:06:16.000000000 -0600
787@@ -122,6 +122,8 @@
788 }
789 }
790
791+ api_plugin_hook_function('copy_user', array('template_id' => $template_id, 'new_id' => $new_id));
792+
793 return true;
794
795 }
796@@ -153,6 +155,7 @@
797 db_execute("delete from settings_graphs where user_id=" . $user_id);
798 db_execute("delete from settings_tree where user_id=" . $user_id);
799
800+ api_plugin_hook_function('user_remove', $user_id);
801 }
802
803
804diff -Naur cacti-0.8.7e-old/lib/functions.php cacti-0.8.7e/lib/functions.php
805--- cacti-0.8.7e-old/lib/functions.php 2009-06-28 11:07:11.000000000 -0500
806+++ cacti-0.8.7e/lib/functions.php 2009-11-21 23:06:16.000000000 -0600
807@@ -1639,6 +1639,7 @@
808 /* draw_navigation_text - determines the top header navigation text for the current page and displays it to
809 the browser */
810 function draw_navigation_text() {
811+ global $config;
812 $nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : array());
813
814 $nav = array(
815@@ -1651,8 +1652,8 @@
816 "graph.php:zoom" => array("title" => "Zoom", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
817 "graph.php:properties" => array("title" => "Properties", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
818 "graph_settings.php:" => array("title" => "Settings", "mapping" => "graph_view.php:", "url" => "graph_settings.php", "level" => "1"),
819- "index.php:" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
820- "index.php:login" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
821+ "index.php:" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
822+ "index.php:login" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
823 "graphs.php:" => array("title" => "Graph Management", "mapping" => "index.php:", "url" => "graphs.php", "level" => "1"),
824 "graphs.php:graph_edit" => array("title" => "(Edit)", "mapping" => "index.php:,graphs.php:", "url" => "", "level" => "2"),
825 "graphs.php:graph_diff" => array("title" => "Change Graph Template", "mapping" => "index.php:,graphs.php:,graphs.php:graph_edit", "url" => "", "level" => "3"),
826@@ -1730,6 +1731,8 @@
827 "templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"),
828 );
829
830+ $nav = api_plugin_hook_function('draw_navigation_text', $nav);
831+
832 $current_page = basename($_SERVER["PHP_SELF"]);
833
834 input_validate_input_regex(get_request_var_request("action"), "^([a-zA-Z0-9_-]+)$");
835diff -Naur cacti-0.8.7e-old/lib/html_form.php cacti-0.8.7e/lib/html_form.php
836--- cacti-0.8.7e-old/lib/html_form.php 2009-11-21 23:31:26.000000000 -0600
837+++ cacti-0.8.7e/lib/html_form.php 2009-11-21 23:06:16.000000000 -0600
838@@ -722,11 +722,13 @@
839 on a confirmation form
840 @arg $cancel_url - the url to go to when the user clicks 'cancel'
841 @arg $action_url - the url to go to when the user clicks 'delete' */
842-function form_confirm_buttons($action_url, $cancel_url) { ?>
843+function form_confirm_buttons($action_url, $cancel_url) {
844+ global $config;
845+ ?>
846 <tr>
847 <td bgcolor="#E1E1E1">
848- <a href="<?php print $cancel_url;?>"><img src="images/button_cancel.gif" border="0" alt="Cancel" align="absmiddle"></a>
849- <a href="<?php print $action_url . "&confirm=yes";?>"><img src="images/button_delete.gif" border="0" alt="Delete" align="absmiddle"></a>
850+ <a href="<?php print $cancel_url;?>"><img src="<?php print $config['url_path'] ?>images/button_cancel.gif" border="0" alt="Cancel" align="absmiddle"></a>
851+ <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>
852 </td>
853 </tr>
854 <?php }
855@@ -737,6 +739,7 @@
856 @arg $force_type - if specified, will force the 'action' button to be either
857 'save' or 'create'. otherwise this field should be properly auto-detected */
858 function form_save_button($cancel_url, $force_type = "", $key_field = "id") {
859+ global $config;
860 if (empty($force_type)) {
861 if (empty($_GET[$key_field])) {
862 $img = "button_create.gif";
863@@ -757,8 +760,8 @@
864 <tr>
865 <td bgcolor="#f5f5f5" align="right">
866 <input type='hidden' name='action' value='save'>
867- <a href='<?php print $cancel_url;?>'><img src='images/button_cancel2.gif' alt='Cancel' align='absmiddle' border='0'></a>
868- <input type='image' src='images/<?php print $img;?>' alt='<?php print $alt;?>' align='absmiddle'>
869+ <a href='<?php print $cancel_url;?>'><img src='<?php echo $config['url_path']; ?>images/button_cancel2.gif' alt='Cancel' align='absmiddle' border='0'></a>
870+ <input type='image' src='<?php echo $config['url_path']; ?>images/<?php print $img;?>' alt='<?php print $alt;?>' align='absmiddle'>
871 </td>
872 </tr>
873 </table>
874diff -Naur cacti-0.8.7e-old/lib/html.php cacti-0.8.7e/lib/html.php
875--- cacti-0.8.7e-old/lib/html.php 2009-06-28 11:07:11.000000000 -0500
876+++ cacti-0.8.7e/lib/html.php 2009-11-21 23:06:16.000000000 -0600
877@@ -86,6 +86,7 @@
878 @arg $extra_url_args - extra arguments to append to the url
879 @arg $header - html to use as a header */
880 function html_graph_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
881+ global $config;
882 $i = 0;
883 if (sizeof($graph_array) > 0) {
884 if ($header != "") {
885@@ -142,14 +143,15 @@
886 <table align='center' cellpadding='0'>
887 <tr>
888 <td align='center'>
889- <div style="min-height: <?php echo (1.6 * read_config_option("export_default_height")) . "px"?>;"><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></div>
890+ <div style="min-height: <?php echo (1.6 * read_config_option("export_default_height")) . "px"?>;"><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></div>
891 <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . $graph["title_cache"] . "</strong></p>" : "");?>
892 </td>
893 <td valign='top' style='align: left; padding: 3px;' class='noprint'>
894- <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>
895- <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>
896- <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>
897- <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
898+ <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>
899+ <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>
900+ <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>
901+ <?php api_plugin_hook('graph_buttons', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => 'view')); ?>
902+ <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>
903 </td>
904 </tr>
905 </table>
906@@ -175,6 +177,7 @@
907 @arg $extra_url_args - extra arguments to append to the url
908 @arg $header - html to use as a header */
909 function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
910+ global $config;
911 $i = 0; $k = 0; $j = 0;
912
913 $num_graphs = sizeof($graph_array);
914@@ -266,13 +269,14 @@
915 <table align='center' cellpadding='0'>
916 <tr>
917 <td align='center'>
918- <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>
919+ <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>
920 <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . $graph["title_cache"] . "</strong></p>" : "");?>
921 </td>
922 <td valign='top' style='align: left; padding: 3px;'>
923- <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>
924- <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>
925- <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>
926+ <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>
927+ <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>
928+ <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>
929+ <?php api_plugin_hook('graph_buttons_thumbnails', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => '')); ?>
930 <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
931 </td>
932 </tr>
933@@ -704,6 +708,8 @@
934 }
935
936 while (list($item_sub_url, $item_sub_title) = each($item_title)) {
937+ $item_sub_url = $config['url_path'] . $item_sub_url;
938+
939 /* indent sub-items */
940 if ($i > 0) {
941 $prepend_string = "---&nbsp;";
942@@ -713,7 +719,7 @@
943
944 /* do not put a line between each sub-item */
945 if (($i == 0) || ($draw_sub_items == false)) {
946- $background = "images/menu_line.gif";
947+ $background = $config['url_path'] . "images/menu_line.gif";
948 }else{
949 $background = "";
950 }
951@@ -742,17 +748,18 @@
952 }else{
953 if ((isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) {
954 /* draw normal (non sub-item) menu item */
955+ $item_url = $config['url_path'] . $item_url;
956 if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) {
957- print "<tr><td class='textMenuItemSelected' background='images/menu_line.gif'><strong><a href='$item_url'>$item_title</a></strong></td></tr>\n";
958+ 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";
959 }else{
960- print "<tr><td class='textMenuItem' background='images/menu_line.gif'><a href='$item_url'>$item_title</a></td></tr>\n";
961+ print "<tr><td class='textMenuItem' background='" . $config['url_path'] . "images/menu_line.gif'><a href='$item_url'>$item_title</a></td></tr>\n";
962 }
963 }
964 }
965 }
966 }
967
968- print "<tr><td class='textMenuItem' background='images/menu_line.gif'></td></tr>\n";
969+ print "<tr><td class='textMenuItem' background='" . $config['url_path'] . "images/menu_line.gif'></td></tr>\n";
970
971 print "</table></td></tr>";
972 }
973@@ -762,18 +769,19 @@
974 @arg $actions_array - an array that contains a list of possible actions. this array should
975 be compatible with the form_dropdown() function */
976 function draw_actions_dropdown($actions_array) {
977+ global $config;
978 ?>
979 <table align='center' width='100%'>
980 <tr>
981 <td width='1' valign='top'>
982- <img src='images/arrow.gif' alt='' align='absmiddle'>&nbsp;
983+ <img src='<?php echo $config['url_path']; ?>images/arrow.gif' alt='' align='absmiddle'>&nbsp;
984 </td>
985 <td align='right'>
986 Choose an action:
987 <?php form_dropdown("drp_action",$actions_array,"","","1","","");?>
988 </td>
989 <td width='1' align='right'>
990- <input type='image' src='images/button_go.gif' alt='Go'>
991+ <input type='image' src='<?php echo $config['url_path']; ?>images/button_go.gif' alt='Go'>
992 </td>
993 </tr>
994 </table>
995diff -Naur cacti-0.8.7e-old/lib/plugins.php cacti-0.8.7e/lib/plugins.php
996--- cacti-0.8.7e-old/lib/plugins.php 1969-12-31 17:00:00.000000000 -0700
997+++ cacti-0.8.7e/lib/plugins.php 2009-11-21 23:06:16.000000000 -0600
998@@ -0,0 +1,380 @@
999+<?php
1000+
1001+
1002+
1003+function do_hook ($name) {
1004+ $data = func_get_args();
1005+ $data = api_plugin_hook ($name, $data);
1006+ return $data;
1007+}
1008+
1009+function do_hook_function($name,$parm=NULL) {
1010+ return api_plugin_hook_function ($name, $parm);
1011+}
1012+
1013+function api_user_realm_auth ($filename = '') {
1014+ return api_plugin_user_realm_auth ($filename);
1015+}
1016+
1017+/**
1018+ * This function executes a hook.
1019+ * @param string $name Name of hook to fire
1020+ * @return mixed $data
1021+ */
1022+function api_plugin_hook ($name) {
1023+ global $config, $plugin_hooks;
1024+ $data = func_get_args();
1025+ $ret = '';
1026+ $p = array();
1027+
1028+ $result = db_fetch_assoc("SELECT name, file, function FROM plugin_hooks WHERE status = 1 AND hook = '$name'", false);
1029+ if (count($result)) {
1030+ foreach ($result as $hdata) {
1031+ $p[] = $hdata['name'];
1032+ if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
1033+ include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
1034+ }
1035+ $function = $hdata['function'];
1036+ if (function_exists($function)) {
1037+ $function($data);
1038+ }
1039+ }
1040+ }
1041+
1042+ if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
1043+ foreach ($plugin_hooks[$name] as $pname => $function) {
1044+ if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
1045+ $function($data);
1046+ }
1047+ }
1048+ }
1049+
1050+ /* Variable-length argument lists have a slight problem when */
1051+ /* passing values by reference. Pity. This is a workaround. */
1052+ return $data;
1053+}
1054+
1055+function api_plugin_hook_function ($name, $parm=NULL) {
1056+ global $config, $plugin_hooks;
1057+ $ret = $parm;
1058+ $p = array();
1059+ $result = db_fetch_assoc("SELECT name, file, function FROM plugin_hooks WHERE status = 1 AND hook = '$name'", false);
1060+
1061+ if (count($result)) {
1062+ foreach ($result as $hdata) {
1063+ $p[] = $hdata['name'];
1064+ if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
1065+ include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
1066+ }
1067+ $function = $hdata['function'];
1068+ if (function_exists($function)) {
1069+ $ret = $function($ret);
1070+ }
1071+ }
1072+ }
1073+
1074+ if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
1075+ foreach ($plugin_hooks[$name] as $pname => $function) {
1076+ if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
1077+ $ret = $function($ret);
1078+ }
1079+ }
1080+ }
1081+
1082+ /* Variable-length argument lists have a slight problem when */
1083+ /* passing values by reference. Pity. This is a workaround. */
1084+ return $ret;
1085+}
1086+
1087+function api_plugin_db_table_create ($plugin, $table, $data) {
1088+ global $config, $database_default;
1089+ include_once($config["library_path"] . "/database.php");
1090+
1091+ $result = db_fetch_assoc("show tables from `" . $database_default . "`") or die (mysql_error());
1092+ $tables = array();
1093+ foreach($result as $index => $arr) {
1094+ foreach ($arr as $t) {
1095+ $tables[] = $t;
1096+ }
1097+ }
1098+ if (!in_array($table, $tables)) {
1099+ $c = 0;
1100+ $sql = 'CREATE TABLE `' . $table . "` (\n";
1101+ foreach ($data['columns'] as $column) {
1102+ if (isset($column['name'])) {
1103+ if ($c > 0)
1104+ $sql .= ",\n";
1105+ $sql .= '`' . $column['name'] . '`';
1106+ if (isset($column['type']))
1107+ $sql .= ' ' . $column['type'];
1108+ if (isset($column['unsigned']))
1109+ $sql .= ' unsigned';
1110+ if (isset($column['NULL']) && $column['NULL'] == false)
1111+ $sql .= ' NOT NULL';
1112+ if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
1113+ $sql .= ' default NULL';
1114+ if (isset($column['default']))
1115+ $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
1116+ if (isset($column['auto_increment']))
1117+ $sql .= ' auto_increment';
1118+ $c++;
1119+ }
1120+ }
1121+
1122+ if (isset($data['primary'])) {
1123+ $sql .= ",\n PRIMARY KEY (`" . $data['primary'] . '`)';
1124+ }
1125+
1126+ foreach ($data['keys'] as $key) {
1127+ if (isset($key['name'])) {
1128+ $sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)';
1129+ }
1130+ }
1131+ $sql .= ') TYPE = ' . $data['type'];
1132+
1133+ if (isset($data['comment'])) {
1134+ $sql .= " COMMENT = '" . $data['comment'] . "'";
1135+ }
1136+ if (db_execute($sql)) {
1137+ db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1138+ }
1139+ } else {
1140+ db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1141+ }
1142+}
1143+
1144+function api_plugin_db_changes_remove ($plugin) {
1145+ // Example: api_plugin_db_changes_remove ('thold');
1146+
1147+ $tables = db_fetch_assoc("SELECT `table` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='create'", false);
1148+ if (count($tables)) {
1149+ foreach ($tables as $table) {
1150+ db_execute("DROP TABLE `" . $table['table'] . "`;");
1151+ }
1152+ db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false);
1153+ }
1154+ $columns = db_fetch_assoc("SELECT `table`, `column` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='addcolumn'", false);
1155+ if (count($columns)) {
1156+ foreach ($columns as $column) {
1157+ db_execute('ALTER TABLE `' . $column['table'] . '` DROP `' . $column['column'] . '`');
1158+ }
1159+ db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false);
1160+ }
1161+}
1162+
1163+function api_plugin_db_add_column ($plugin, $table, $column) {
1164+ // Example: api_plugin_db_add_column ('thold', 'plugin_config', array('name' => 'test' . rand(1, 200), 'type' => 'varchar (255)', 'NULL' => false));
1165+
1166+ global $config, $database_default;
1167+ include_once($config['library_path'] . '/database.php');
1168+
1169+ $result = db_fetch_assoc('show columns from `' . $table . '`') or die (mysql_error());
1170+ $columns = array();
1171+ foreach($result as $index => $arr) {
1172+ foreach ($arr as $t) {
1173+ $columns[] = $t;
1174+ }
1175+ }
1176+ if (isset($column['name']) && !in_array($column['name'], $columns)) {
1177+ $sql = 'ALTER TABLE `' . $table . '` ADD `' . $column['name'] . '`';
1178+ if (isset($column['type']))
1179+ $sql .= ' ' . $column['type'];
1180+ if (isset($column['unsigned']))
1181+ $sql .= ' unsigned';
1182+ if (isset($column['NULL']) && $column['NULL'] == false)
1183+ $sql .= ' NOT NULL';
1184+ if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
1185+ $sql .= ' default NULL';
1186+ if (isset($column['default']))
1187+ $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
1188+ if (isset($column['auto_increment']))
1189+ $sql .= ' auto_increment';
1190+ if (isset($column['after']))
1191+ $sql .= ' AFTER ' . $column['after'];
1192+
1193+ if (db_execute($sql)) {
1194+ db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')");
1195+ }
1196+ }
1197+}
1198+
1199+function api_plugin_install ($plugin) {
1200+ global $config;
1201+ include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1202+
1203+ $exists = db_fetch_assoc("SELECT id FROM plugin_config WHERE directory = '$plugin'", false);
1204+ if (!count($exists)) {
1205+ db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1206+ }
1207+
1208+ $name = $author = $webpage = $version = '';
1209+ $function = 'plugin_' . $plugin . '_version';
1210+ if (function_exists($function)){
1211+ $info = $function();
1212+ $name = $info['longname'];
1213+ $webpage = $info['homepage'];
1214+ $author = $info['author'];
1215+ $version = $info['version'];
1216+ }
1217+
1218+ db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')");
1219+
1220+ $function = 'plugin_' . $plugin . '_install';
1221+ if (function_exists($function)){
1222+ $function();
1223+ $ready = api_plugin_check_config ($plugin);
1224+ if ($ready) {
1225+ // Set the plugin as "disabled" so it can go live
1226+ db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1227+ } else {
1228+ // Set the plugin as "needs configuration"
1229+ db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'");
1230+ }
1231+ }
1232+}
1233+
1234+function api_plugin_uninstall ($plugin) {
1235+ global $config;
1236+ include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1237+ // Run the Plugin's Uninstall Function first
1238+ $function = 'plugin_' . $plugin . '_uninstall';
1239+ if (function_exists($function)) {
1240+ $function();
1241+ }
1242+ api_plugin_remove_hooks ($plugin);
1243+ api_plugin_remove_realms ($plugin);
1244+ db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1245+ api_plugin_db_changes_remove ($plugin);
1246+}
1247+
1248+function api_plugin_check_config ($plugin) {
1249+ global $config;
1250+ include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1251+ $function = 'plugin_' . $plugin . '_check_config';
1252+ if (function_exists($function)) {
1253+ return $function();
1254+ }
1255+ return TRUE;
1256+}
1257+
1258+function api_plugin_enable ($plugin) {
1259+ $ready = api_plugin_check_config ($plugin);
1260+ if ($ready) {
1261+ api_plugin_enable_hooks ($plugin);
1262+ db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'");
1263+ }
1264+}
1265+
1266+function api_plugin_is_enabled ($plugin) {
1267+ $status = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = '$plugin'", false);
1268+ if ($status == '1')
1269+ return true;
1270+ return false;
1271+}
1272+
1273+function api_plugin_disable ($plugin) {
1274+ api_plugin_disable_hooks ($plugin);
1275+ db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1276+}
1277+
1278+function api_plugin_register_hook ($plugin, $hook, $function, $file) {
1279+ $exists = db_fetch_assoc("SELECT id FROM plugin_hooks WHERE name = '$plugin' AND hook = '$hook'", false);
1280+ if (!count($exists)) {
1281+ $settings = array('config_settings', 'config_arrays', 'config_form');
1282+ if (!in_array($hook, $settings)) {
1283+ db_execute("INSERT INTO plugin_hooks (name, hook, function, file) VALUES ('$plugin', '$hook', '$function', '$file')");
1284+ } else {
1285+ db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)");
1286+ }
1287+ }
1288+}
1289+
1290+function api_plugin_remove_hooks ($plugin) {
1291+ db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'");
1292+}
1293+
1294+function api_plugin_enable_hooks ($plugin) {
1295+ db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'");
1296+}
1297+
1298+function api_plugin_disable_hooks ($plugin) {
1299+ db_execute("UPDATE plugin_hooks SET status = 0 WHERE name = '$plugin' AND hook != 'config_settings' AND hook != 'config_arrays' AND hook != 'config_form'");
1300+}
1301+
1302+function api_plugin_register_realm ($plugin, $file, $display, $admin = false) {
1303+ $exists = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1304+ if (!count($exists)) {
1305+ db_execute("INSERT INTO plugin_realms (plugin, file, display) VALUES ('$plugin', '$file', '$display')");
1306+ if ($admin) {
1307+ $realm_id = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1308+ $realm_id = $realm_id[0]['id'] + 100;
1309+ $user_id = db_fetch_assoc("SELECT id FROM user_auth WHERE username = 'admin'", false);
1310+ if (count($user_id)) {
1311+ $user_id = $user_id[0]['id'];
1312+ $exists = db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id = $user_id and realm_id = $realm_id", false);
1313+ if (!count($exists)) {
1314+ db_execute("INSERT INTO user_auth_realm (user_id, realm_id) VALUES ($user_id, $realm_id)");
1315+ }
1316+ }
1317+ }
1318+ }
1319+}
1320+
1321+function api_plugin_remove_realms ($plugin) {
1322+ $realms = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin'", false);
1323+ foreach ($realms as $realm) {
1324+ $id = $realm['id'] + 100;
1325+ db_execute("DELETE FROM user_auth_realm WHERE realm_id = '$id'");
1326+ }
1327+ db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'");
1328+}
1329+
1330+function api_plugin_load_realms () {
1331+ global $user_auth_realms, $user_auth_realm_filenames;
1332+ $plugin_realms = db_fetch_assoc("SELECT * FROM plugin_realms ORDER BY plugin, display", false);
1333+ if (count($plugin_realms)) {
1334+ foreach ($plugin_realms as $plugin_realm) {
1335+ $plugin_files = explode(',', $plugin_realm['file']);
1336+ foreach($plugin_files as $plugin_file) {
1337+ $user_auth_realm_filenames[$plugin_file] = $plugin_realm['id'] + 100;
1338+ }
1339+ $user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display'];
1340+ }
1341+ }
1342+}
1343+
1344+function api_plugin_user_realm_auth ($filename = '') {
1345+ global $user_realms, $user_auth_realms, $user_auth_realm_filenames;
1346+ /* list all realms that this user has access to */
1347+ if (!isset($user_realms)) {
1348+ if (read_config_option('global_auth') == 'on' || read_config_option('auth_method') != 0) {
1349+ $user_realms = db_fetch_assoc("select realm_id from user_auth_realm where user_id=" . $_SESSION["sess_user_id"], false);
1350+ $user_realms = array_rekey($user_realms, "realm_id", "realm_id");
1351+ }else{
1352+ $user_realms = $user_auth_realms;
1353+ }
1354+ }
1355+ if ($filename != '') {
1356+ if (isset($user_realms[$user_auth_realm_filenames{basename($filename)}]))
1357+ return TRUE;
1358+ }
1359+ return FALSE;
1360+}
1361+
1362+function plugin_config_arrays () {
1363+ global $menu;
1364+ $menu['Configuration']['plugins.php'] = 'Plugin Management';
1365+ api_plugin_load_realms ();
1366+}
1367+
1368+function plugin_draw_navigation_text ($nav) {
1369+ $nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1");
1370+ return $nav;
1371+}
1372+
1373+
1374+
1375+
1376+
1377+
1378+
1379diff -Naur cacti-0.8.7e-old/lib/poller.php cacti-0.8.7e/lib/poller.php
1380--- cacti-0.8.7e-old/lib/poller.php 2009-06-28 11:07:11.000000000 -0500
1381+++ cacti-0.8.7e/lib/poller.php 2009-11-21 23:06:16.000000000 -0600
1382@@ -326,8 +326,11 @@
1383 }
1384 }
1385 }
1386+ api_plugin_hook_function('poller_output', $rrd_update_array);
1387
1388- $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1389+ if (api_plugin_hook_function('poller_on_demand', $results)) {
1390+ $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1391+ }
1392 }
1393
1394 return $rrds_processed;
1395diff -Naur cacti-0.8.7e-old/lib/rrd.php cacti-0.8.7e/lib/rrd.php
1396--- cacti-0.8.7e-old/lib/rrd.php 2009-06-28 11:07:11.000000000 -0500
1397+++ cacti-0.8.7e/lib/rrd.php 2009-11-21 23:06:16.000000000 -0600
1398@@ -557,6 +557,10 @@
1399 }
1400 }
1401
1402+ $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));
1403+ if (isset($data['return']) && $data['return'] != false)
1404+ return $data['return'];
1405+
1406 /* find the step and how often this graph is updated with new data */
1407 $ds_step = db_fetch_cell("select
1408 data_template_data.rrd_step
1409@@ -1388,6 +1392,13 @@
1410 }
1411 }
1412
1413+ $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));
1414+ if (!empty($graph_array)) {
1415+ $graph_defs = $graph_array['graph_defs'];
1416+ $txt_graph_items = $graph_array['txt_graph_items'];
1417+ $graph_opts = $graph_array['graph_opts'];
1418+ }
1419+
1420 /* either print out the source or pass the source onto rrdtool to get us a nice PNG */
1421 if (isset($graph_data_array["print_source"])) {
1422 print "<PRE>" . read_config_option("path_rrdtool") . " graph $graph_opts$graph_defs$txt_graph_items</PRE>";
1423@@ -1396,13 +1407,19 @@
1424 rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrd_struc);
1425 return 0;
1426 }else{
1427+ $graph_data_array = api_plugin_hook_function('prep_graph_array', $graph_data_array);
1428+
1429 if (isset($graph_data_array["output_flag"])) {
1430 $output_flag = $graph_data_array["output_flag"];
1431 }else{
1432 $output_flag = RRDTOOL_OUTPUT_GRAPH_DATA;
1433 }
1434
1435- return rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrd_struc);
1436+ $output = rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrd_struc);
1437+
1438+ api_plugin_hook_function('rrdtool_function_graph_set_file', array('output' => $output, 'local_graph_id' => $local_graph_id, 'rra_id' => $rra_id));
1439+
1440+ return $output;
1441 }
1442 }
1443 }
1444diff -Naur cacti-0.8.7e-old/lib/variables.php cacti-0.8.7e/lib/variables.php
1445--- cacti-0.8.7e-old/lib/variables.php 2009-06-28 11:07:11.000000000 -0500
1446+++ cacti-0.8.7e/lib/variables.php 2009-11-21 23:06:16.000000000 -0600
1447@@ -183,6 +183,9 @@
1448 $string = str_replace($l_escape_string . "host_max_oids" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["max_oids"], $string);
1449 $string = str_replace($l_escape_string . "host_id" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["id"], $string);
1450
1451+ $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));
1452+ $string = $temp['string'];
1453+
1454 return $string;
1455 }
1456
1457diff -Naur cacti-0.8.7e-old/plugins/index.php cacti-0.8.7e/plugins/index.php
1458--- cacti-0.8.7e-old/plugins/index.php 1969-12-31 17:00:00.000000000 -0700
1459+++ cacti-0.8.7e/plugins/index.php 2009-11-21 23:06:16.000000000 -0600
1460@@ -0,0 +1,5 @@
1461+<?php
1462+
1463+header("Location:../index.php");
1464+
1465+?>
1466diff -Naur cacti-0.8.7e-old/plugins.php cacti-0.8.7e/plugins.php
1467--- cacti-0.8.7e-old/plugins.php 1969-12-31 17:00:00.000000000 -0700
1468+++ cacti-0.8.7e/plugins.php 2009-11-21 23:06:16.000000000 -0600
1469@@ -0,0 +1,436 @@
1470+<?php
1471+
1472+
1473+include("./include/auth.php");
1474+
1475+
1476+$pluginslist = retrieve_plugin_list ();
1477+
1478+/* tab information */
1479+$ptabs = array(
1480+ "current" => "Installed",
1481+// "uninstalled" => "Uninstalled",
1482+// "download" => "Download",
1483+// "updates" => "Updates",
1484+);
1485+
1486+
1487+$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');
1488+
1489+
1490+/* set the default settings category */
1491+if (!isset($_GET["tab"])) {
1492+ /* there is no selected tab; select the first one */
1493+ $current_tab = array_keys($ptabs);
1494+ $current_tab = $current_tab[0];
1495+}else{
1496+ $current_tab = $_GET["tab"];
1497+}
1498+
1499+
1500+// Check to see if we are installing, etc...
1501+$modes = array('install', 'uninstall', 'disable', 'enable', 'check');
1502+
1503+if (isset($_GET['mode']) && in_array($_GET['mode'], $modes) && isset($_GET['id'])) {
1504+
1505+ input_validate_input_regex(get_request_var("id"), "^([a-zA-Z0-9]+)$");
1506+
1507+ $mode = $_GET['mode'];
1508+ $id = sanitize_search_string($_GET['id']);
1509+
1510+ switch ($mode) {
1511+ case 'install':
1512+ api_plugin_install($id);
1513+ $pluginslist = retrieve_plugin_list ();
1514+ break;
1515+ case 'uninstall':
1516+ if (!in_array($id, $pluginslist))
1517+ break;
1518+ api_plugin_uninstall($id);
1519+ $pluginslist = retrieve_plugin_list ();
1520+ break;
1521+ case 'disable':
1522+ if (!in_array($id, $pluginslist))
1523+ break;
1524+ api_plugin_disable ($id);
1525+ break;
1526+ case 'enable':
1527+ if (!in_array($id, $pluginslist))
1528+ break;
1529+ api_plugin_enable ($id);
1530+ break;
1531+ case 'check':
1532+ if (!in_array($id, $pluginslist))
1533+ break;
1534+ break;
1535+ }
1536+}
1537+
1538+function retrieve_plugin_list () {
1539+ $pluginslist = array();
1540+ $temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name');
1541+ foreach ($temp as $t) {
1542+ $pluginslist[] = $t['directory'];
1543+ }
1544+ return $pluginslist;
1545+}
1546+
1547+
1548+ include("./include/top_header.php");
1549+
1550+ /* draw the categories tabs on the top of the page */
1551+/*
1552+ print "<table class='tabs' width='98%' cellspacing='0' cellpadding='3' align='center'><tr>\n";
1553+
1554+ if (sizeof($ptabs) > 0) {
1555+ foreach (array_keys($ptabs) as $tab_short_name) {
1556+ print "<td " . (($tab_short_name == $current_tab) ? "bgcolor='silver'" : "bgcolor='#DFDFDF'") . " nowrap='nowrap' width='" . (strlen($ptabs[$tab_short_name]) * 9) . "' align='center' class='tab'>
1557+ <span class='textHeader'><a href='plugins.php?tab=$tab_short_name'>$ptabs[$tab_short_name]</a></span>
1558+ </td>\n
1559+ <td width='1'></td>\n";
1560+ }
1561+ }
1562+
1563+ print "<td></td>\n</tr></table>\n";
1564+*/
1565+ html_start_box("<strong> Plugin Management</strong>", "98%", $colors["header"], "3", "center", "");
1566+
1567+ print "<tr><td><table width='100%'>";
1568+
1569+ //update_info_table();
1570+
1571+ switch ($current_tab) {
1572+ case 'current':
1573+ update_show_current();
1574+ break;
1575+ case 'uninstalled':
1576+ update_show_uninstalled ();
1577+ break;
1578+ default:
1579+ print '<br><br><br>';
1580+ }
1581+
1582+/*
1583+ $last_check = read_config_option("plugin_update_last_check");
1584+ if ($last_check < 1)
1585+ $last_check = 0;
1586+
1587+ print "<center>Last Scanned : " . ($last_check > 0 ? date("F j, Y g:i:s a", $last_check) : "Never") . "</center>";
1588+*/
1589+ print "</table></td></tr>";
1590+
1591+ html_end_box();
1592+
1593+ include("./include/bottom_footer.php");
1594+
1595+function update_show_updates () {
1596+ global $pluginslist, $colors, $config, $plugin_architecture;
1597+
1598+ $cinfo = array();
1599+ sort($pluginslist);
1600+
1601+ $cinfo = update_get_plugin_info ();
1602+
1603+ $x = 0;
1604+
1605+ $info = update_get_cached_plugin_info();
1606+
1607+ $cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ;
1608+ if (isset($cinfo['cacti_plugin_arch']['version']))
1609+ $archnew = update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']);
1610+ else
1611+ $archnew = 0;
1612+
1613+ if ($cactinew) {
1614+ $x++;
1615+ print "<tr><td width='25%' valign=top><table width='100%'>";
1616+ html_header(array("Cacti"), 2);
1617+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1618+ print "<td width='25%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr>";
1619+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1620+ print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti']['changes']) . "</td></tr></table>";
1621+ }
1622+ if (isset($plugin_architecture['version']) && $archnew) {
1623+ $x++;
1624+ print "<table width='100%'>";
1625+ html_header(array("Plugin Architecture"), 2);
1626+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1627+ print "<td width='25%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td>";
1628+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1629+ print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti_plugin_arch']['changes']) . "</td></tr></table>";
1630+ }
1631+ print "<table width='100%' cellspacing=0 cellpadding=3>";
1632+
1633+ foreach ($pluginslist as $plugin) {
1634+ if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) {
1635+ $x++;
1636+ print "<table width='100%'>";
1637+ html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2);
1638+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1639+ print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1640+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1641+ print "<td><strong>Version:</strong></td><td>" . $info[$plugin]['version'] . "</td>";
1642+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1643+ 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>";
1644+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1645+ 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>";
1646+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1647+ print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info[$plugin]['changes']) . "</td>";
1648+
1649+ print "</tr></table>";
1650+ }
1651+ }
1652+ if ($x == 0)
1653+ print "<br><center><b>There are currently no Updates!</b></center><br>";
1654+ print "</table>";
1655+ html_end_box(TRUE);
1656+}
1657+
1658+function update_check_if_newer() {
1659+ return false;
1660+}
1661+
1662+function update_show_current () {
1663+ global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names;
1664+
1665+
1666+
1667+ $cinfo = array();
1668+ $cinfo = update_get_plugin_info ();
1669+
1670+ sort($pluginslist);
1671+
1672+ $path = $config['base_path'] . '/plugins/';
1673+ $dh = opendir($path);
1674+ while (($file = readdir($dh)) !== false) {
1675+ if (is_dir("$path/$file")) {
1676+ if (file_exists("$path/$file/setup.php") && !in_array($file, $pluginslist)) {
1677+ include_once("$path/$file/setup.php");
1678+ if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) {
1679+ $function = $file . '_version';
1680+ $cinfo[$file] = $function();
1681+ $cinfo[$file]['status'] = -2;
1682+ if (in_array($file, $plugins)) {
1683+ $cinfo[$file]['status'] = -1;
1684+ }
1685+ $pluginslist[] = $file;
1686+ } else if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
1687+ $function = $file . '_version';
1688+ $cinfo[$file] = $function();
1689+ $cinfo[$file]['status'] = 0;
1690+ $pluginslist[] = $file;
1691+ }
1692+ }
1693+ }
1694+ }
1695+ closedir($dh);
1696+
1697+ print "<table width='100%' cellspacing=0 cellpadding=3>";
1698+ print "<tr><td width='50%'><table width='100%'>";
1699+ html_header(array("Cacti"), 2);
1700+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1701+ print "<td width='50%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr></table>";
1702+ print "</td><td>";
1703+ if (isset($plugin_architecture['version'])) {
1704+ print "<table width='100%'>";
1705+ html_header(array("Plugin Architecture"), 2);
1706+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1707+ print "<td width='50%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td></tr></table>";
1708+ }
1709+ print "</td></tr></table>";
1710+
1711+ print "<table width='100%' cellspacing=0 cellpadding=3>";
1712+ $x = 0;
1713+
1714+ sort($pluginslist);
1715+ foreach ($pluginslist as $plugin) {
1716+ if (isset($cinfo[$plugin])) {
1717+
1718+ if ($x == 0) {
1719+ print "<tr><td width='50%' valign=top>";
1720+ } else {
1721+ print "</td><td valign=top>";
1722+ }
1723+ if (!isset($info[$plugin]['version']))
1724+ $info[$plugin]['version'] = '';
1725+
1726+ print "<table width='100%'>";
1727+ html_header(array((isset($cinfo[$plugin]['name']) ? $cinfo[$plugin]['name'] : $plugin)), 2);
1728+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1729+ print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1730+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1731+ 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>";
1732+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1733+ 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>";
1734+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1735+ 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>";
1736+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1737+ print "<td><strong>Status:</strong></td><td>" . $status_names[$cinfo[$plugin]['status']] . "</td>";
1738+
1739+ if ($cinfo[$plugin]['status'] > -1) {
1740+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1741+
1742+ $links = array('install' => 'Install', 'uninstall' => 'Uninstall', 'enable' => 'Enable', 'disable' => 'Disable', 'check' => 'Check');
1743+
1744+ switch ($cinfo[$plugin]['status']) {
1745+ case 0: //Not Installed
1746+ $links['install'] = "<a href='plugins.php?mode=install&id=$plugin'><b>Install</b></a>";
1747+ break;
1748+ case 1: // Currently Active
1749+ $links['uninstall'] = "<a href='plugins.php?mode=uninstall&id=$plugin'><b>Uninstall</b></a>";
1750+ $links['disable'] = "<a href='plugins.php?mode=disable&id=$plugin'><b>Disable</b></a>";
1751+ break;
1752+ case 2: // Needs Configuring
1753+ $links['check'] = "<a href='plugins.php?mode=check&id=$plugin'><b>Check</b></a>";
1754+ break;
1755+ case 3: // Needs Upgrade
1756+ $links['check'] = "<a href='plugins.php?mode=check&id=$plugin'><b>Check</b></a>";
1757+ break;
1758+ case 4: // Installed but not active
1759+ $links['uninstall'] = "<a href='plugins.php?mode=uninstall&id=$plugin'><b>Uninstall</b></a>";
1760+ $links['enable'] = "<a href='plugins.php?mode=enable&id=$plugin'><b>Enable</b></a>";
1761+ break;
1762+ }
1763+
1764+ print "<td></td><td>";
1765+ $c = 1;
1766+ foreach ($links as $temp => $link) {
1767+ print $link;
1768+ if ($c < count($links))
1769+ print ' | ';
1770+ $c++;
1771+ }
1772+ print "</td>";
1773+ print "</tr>";
1774+ }
1775+
1776+ print "</table>";
1777+ if ($x == 1) {
1778+ print "</td></tr>";
1779+ }
1780+ $x++;
1781+ if ($x > 1) $x = 0;
1782+ }
1783+ }
1784+ if ($x == 1)
1785+ print "</td><td></td></tr>";
1786+ print "</table>";
1787+ html_end_box(TRUE);
1788+}
1789+
1790+
1791+function update_show_uninstalled () {
1792+ global $pluginslist, $colors, $plugin_architecture, $config, $status_names;
1793+
1794+ $cinfo = array();
1795+ sort($pluginslist);
1796+
1797+ print "<table width='100%' cellspacing=0 cellpadding=3>";
1798+ $x = 0;
1799+
1800+ $newplugins = array();
1801+ $cinfo = array ();
1802+
1803+ $path = $config['base_path'] . '/plugins/';
1804+ $dh = opendir($path);
1805+ while (($file = readdir($dh)) !== false) {
1806+ if (is_dir("$path/$file")) {
1807+ if (file_exists("$path/$file/setup.php") && !in_array($file, $pluginslist)) {
1808+ include_once("$path/$file/setup.php");
1809+ if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
1810+ $function = 'plugin_' . $file . '_version';
1811+ $cinfo[$file] = $function();
1812+ $cinfo[$file]['status'] = 0;
1813+ $newplugins[] = $file;
1814+ }
1815+ }
1816+ }
1817+ }
1818+ closedir($dh);
1819+
1820+ if (count($newplugins)) {
1821+ foreach ($newplugins as $plugin) {
1822+ if (isset($cinfo[$plugin])) {
1823+
1824+ if ($x == 0) {
1825+ print "<tr><td width='50%'>";
1826+ } else {
1827+ print "</td><td>";
1828+ }
1829+ if (!isset($info[$plugin]['version']))
1830+ $info[$plugin]['version'] = '';
1831+
1832+ print "<table width='100%'>";
1833+ html_header(array((isset($cinfo[$plugin]['name']) ? $cinfo[$plugin]['name'] : $plugin)), 2);
1834+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1835+ print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1836+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1837+ 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>";
1838+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1839+ 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>";
1840+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1841+ 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>";
1842+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1843+ print "<td><strong>Status:</strong></td><td>" . $status_names[$cinfo[$plugin]['status']] . "</td>";
1844+ form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1845+
1846+ $links = array('install' => 'Install', 'uninstall' => 'Uninstall', 'enable' => 'Enable', 'disable' => 'Disable', 'check' => 'Check');
1847+
1848+ switch ($cinfo[$plugin]['status']) {
1849+ case 0: //Not Installed
1850+ $links['install'] = "<a href='plugins.php?mode=install&id=$plugin&tab=uninstalled'><b>Install</b></a>";
1851+ break;
1852+ case 1: // Currently Active
1853+ $links['uninstall'] = "<a href='plugins.php?mode=uninstall&id=$plugin&tab=uninstalled'><b>Uninstall</b></a>";
1854+ $links['disable'] = "<a href='plugins.php?mode=disable&id=$plugin&tab=uninstalled'><b>Disable</b></a>";
1855+ break;
1856+ case 2: // Needs Configuring
1857+ $links['check'] = "<a href='plugins.php?mode=check&id=$plugin&tab=uninstalled'><b>Check</b></a>";
1858+ break;
1859+ case 3: // Needs Upgrade
1860+ $links['check'] = "<a href='plugins.php?mode=check&id=$plugin&tab=uninstalled'><b>Check</b></a>";
1861+ break;
1862+ case 4: // Installed but not active
1863+ $links['enable'] = "<a href='plugins.php?mode=enable&id=$plugin&tab=uninstalled'><b>Enable</b></a>";
1864+ break;
1865+ }
1866+
1867+ print "<td></td><td>";
1868+ $c = 1;
1869+ foreach ($links as $temp => $link) {
1870+ print $link;
1871+ if ($c < count($links))
1872+ print ' | ';
1873+ $c++;
1874+ }
1875+
1876+ print "</td>";
1877+ print "</tr></table>";
1878+ if ($x == 1) {
1879+ print "</td></tr>";
1880+ }
1881+ $x++;
1882+ if ($x > 1) $x = 0;
1883+ }
1884+ }
1885+ } else {
1886+ print "<center>There are no Uninstalled Plugins</center>";
1887+ }
1888+ if ($x == 1)
1889+ print "</td><td></td></tr>";
1890+ print "</table>";
1891+ html_end_box(TRUE);
1892+}
1893+
1894+function update_get_plugin_info () {
1895+ $cinfo = array();
1896+ $info = db_fetch_assoc("SELECT * from plugin_config");
1897+ if (is_array($info)) {
1898+ foreach($info as $inf) {
1899+ $cinfo[$inf['directory']] = $inf;
1900+ $cinfo[$inf['directory']]['changes']='';
1901+ }
1902+ }
1903+ return $cinfo;
1904+}
1905+
1906diff -Naur cacti-0.8.7e-old/poller.php cacti-0.8.7e/poller.php
1907--- cacti-0.8.7e-old/poller.php 2009-06-28 11:07:11.000000000 -0500
1908+++ cacti-0.8.7e/poller.php 2009-11-21 23:06:16.000000000 -0600
1909@@ -73,6 +73,8 @@
1910 }
1911 }
1912
1913+api_plugin_hook('poller_top');
1914+
1915 /* record the start time */
1916 list($micro,$seconds) = split(" ", microtime());
1917 $poller_start = $seconds + $micro;
1918@@ -261,6 +263,8 @@
1919 $total_procs = $concurrent_processes;
1920 }
1921
1922+ $extra_args = api_plugin_hook_function ('poller_command_args', $extra_args);
1923+
1924 /* Populate each execution file with appropriate information */
1925 foreach ($polling_hosts as $item) {
1926 if ($host_count == 1) {
1927@@ -403,9 +407,11 @@
1928
1929 /* sleep the appripriate amount of time */
1930 if ($poller_runs_completed < $poller_runs) {
1931+ api_plugin_hook('poller_bottom');
1932 db_close();
1933 usleep($sleep_time * 1000000);
1934 db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
1935+ api_plugin_hook('poller_top');
1936 }
1937 }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM) {
1938 cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER");
1939@@ -452,4 +458,6 @@
1940 echo " --debug|-d Output debug information. Similar to cacti's DEBUG logging level.\n\n";
1941 }
1942
1943+api_plugin_hook('poller_bottom');
1944+
1945 ?>
1946diff -Naur cacti-0.8.7e-old/user_admin.php cacti-0.8.7e/user_admin.php
1947--- cacti-0.8.7e-old/user_admin.php 2009-06-28 11:07:11.000000000 -0500
1948+++ cacti-0.8.7e/user_admin.php 2009-11-21 23:06:16.000000000 -0600
1949@@ -72,9 +72,11 @@
1950 break;
1951
1952 default:
1953- include_once("include/top_header.php");
1954- user();
1955- include_once("include/bottom_footer.php");
1956+ if (!api_plugin_hook_function('user_admin_action', get_request_var_request("action"))) {
1957+ include_once("include/top_header.php");
1958+ user();
1959+ include_once("include/bottom_footer.php");
1960+ }
1961 break;
1962 }
1963
1964@@ -418,6 +420,7 @@
1965 $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);
1966 $save["realm"] = get_request_var_post("realm", 0);
1967 $save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3);
1968+ $save = api_plugin_hook_function('user_admin_setup_sql_save', $save);
1969
1970 if (!is_error_message()) {
1971 $user_id = sql_save($save, "user_auth");
1972@@ -460,6 +463,8 @@
1973 policy_hosts = " . get_request_var_post("policy_hosts") . ",
1974 policy_graph_templates = " . get_request_var_post("policy_graph_templates") . "
1975 WHERE id = " . get_request_var_post("id"));
1976+ } else {
1977+ api_plugin_hook('user_admin_user_save');
1978 }
1979 }
1980 }
1981@@ -910,6 +915,8 @@
1982 $header_label = "[new]";
1983 }
1984
1985+ api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0));
1986+
1987 html_start_box("<strong>User Management</strong> $header_label", "100%", $colors["header"], "3", "center", "");
1988
1989 draw_edit_form(array(
1990@@ -936,6 +943,7 @@
1991 <td <?php print ((get_request_var("action") == "graph_settings_edit") ? "bgcolor='silver'" : "bgcolor='#DFDFDF'");?> nowrap='nowrap' width='130' align='center' class='tab'>
1992 <span class='textHeader'><a href='user_admin.php?action=graph_settings_edit&id=<?php print $_GET["id"];?>'>Graph Settings</a></span>
1993 </td>
1994+ <?php api_plugin_hook('user_admin_tab');?>
1995 <td></td>
1996 </tr>
1997 </table>
1998@@ -949,7 +957,9 @@
1999 }elseif (get_request_var("action") == "graph_perms_edit") {
2000 graph_perms_edit();
2001 }else{
2002- user_realms_edit();
2003+ if (api_plugin_hook_function('user_admin_run_action', get_request_var_request("action"))) {
2004+ user_realms_edit();
2005+ }
2006 }
2007
2008 form_save_button("user_admin.php");
2009diff -Naur cacti-0.8.7e-old/utilities.php cacti-0.8.7e/utilities.php
2010--- cacti-0.8.7e-old/utilities.php 2009-06-28 11:07:11.000000000 -0500
2011+++ cacti-0.8.7e/utilities.php 2009-11-21 23:06:16.000000000 -0600
2012@@ -129,11 +129,14 @@
2013 include_once("./include/bottom_footer.php");
2014 break;
2015 default:
2016- include_once("./include/top_header.php");
2017
2018- utilities();
2019+ if (!api_plugin_hook_function('utilities_action', $_REQUEST['action'])) {
2020+ include_once('./include/top_header.php');
2021
2022- include_once("./include/bottom_footer.php");
2023+ utilities();
2024+
2025+ include_once('./include/bottom_footer.php');
2026+ }
2027 break;
2028 }
2029
2030@@ -1642,6 +1645,8 @@
2031
2032 <?php
2033
2034+ api_plugin_hook('utilities_list');
2035+
2036 html_end_box();
2037 }
2038
This page took 0.372312 seconds and 4 git commands to generate.