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