]> git.pld-linux.org Git - packages/cacti.git/blob - cacti-PA.patch
- updated Plugin Archidecture to 2.9
[packages/cacti.git] / cacti-PA.patch
1 diff -Naur cacti-0.8.7g/auth_changepassword.php cacti-0.8.7g-PA-v2.9/auth_changepassword.php
2 --- cacti-0.8.7g/auth_changepassword.php        2010-07-09 18:33:46.000000000 -0400
3 +++ cacti-0.8.7g-PA-v2.9/auth_changepassword.php        2010-10-17 20:09:52.000000000 -0400
4 @@ -59,6 +59,8 @@
5                                         header("Location: index.php"); break;
6                                 case '3': /* default graph page */
7                                         header("Location: graph_view.php"); break;
8 +                               default:
9 +                                       api_plugin_hook_function('login_options_navigate', $user['login_opts']);
10                         }
11                 }else{
12                         header("Location: graph_view.php");
13 diff -Naur cacti-0.8.7g/auth_login.php cacti-0.8.7g-PA-v2.9/auth_login.php
14 --- cacti-0.8.7g/auth_login.php 2010-07-09 18:33:46.000000000 -0400
15 +++ cacti-0.8.7g-PA-v2.9/auth_login.php 2010-10-17 20:09:52.000000000 -0400
16 @@ -124,10 +124,12 @@
17                 }
18  
19         default:
20 -               /* Builtin Auth */
21 -               if ((!$user_auth) && (!$ldap_error)) {
22 -                       /* if auth has not occured process for builtin - AKA Ldap fall through */
23 -                       $user = db_fetch_row("SELECT * FROM user_auth WHERE username = '" . $username . "' AND password = '" . md5(get_request_var_post("login_password")) . "' AND realm = 0");
24 +               if (!api_plugin_hook_function('login_process', false)) {
25 +                       /* Builtin Auth */
26 +                       if ((!$user_auth) && (!$ldap_error)) {
27 +                               /* if auth has not occured process for builtin - AKA Ldap fall through */
28 +                               $user = db_fetch_row("SELECT * FROM user_auth WHERE username = '" . $username . "' AND password = '" . md5(get_request_var_post("login_password")) . "' AND realm = 0");
29 +                       }
30                 }
31         }
32         /* end of switch */
33 @@ -189,29 +191,42 @@
34                 decide what to do next */
35                 switch ($user["login_opts"]) {
36                         case '1': /* referer */
37 -                               if (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE realm_id = 8 AND user_id = " . $_SESSION["sess_user_id"])) == 0) {
38 -                                       header("Location: graph_view.php");
39 -                               }else{
40 -                                       if (isset($_SERVER["HTTP_REFERER"])) {
41 -                                               $referer = $_SERVER["HTTP_REFERER"];
42 -                                               if (basename($referer) == "logout.php") {
43 -                                                       $referer = "index.php";
44 -                                               }
45 -                                       } else if (isset($_SERVER["REQUEST_URI"])) {
46 -                                               $referer = $_SERVER["REQUEST_URI"];
47 -                                               if (basename($referer) == "logout.php") {
48 -                                                       $referer = "index.php";
49 -                                               }
50 -                                       } else {
51 -                                               $referer = "index.php";
52 +                               /* because we use plugins, we can't redirect back to graph_view.php if they don't
53 +                                * have console access
54 +                                */
55 +                               if (isset($_SERVER["HTTP_REFERER"])) {
56 +                                       $referer = $_SERVER["HTTP_REFERER"];
57 +                                       if (basename($referer) == "logout.php") {
58 +                                               $referer = $config['url_path'] . "index.php";
59 +                                       }
60 +                               } else if (isset($_SERVER["REQUEST_URI"])) {
61 +                                       $referer = $_SERVER["REQUEST_URI"];
62 +                                       if (basename($referer) == "logout.php") {
63 +                                               $referer = $config['url_path'] . "index.php";
64                                         }
65 +                               } else {
66 +                                       $referer = $config['url_path'] . "index.php";
67 +                               }
68 +
69 +                               if (substr_count($referer, "plugins")) {
70                                         header("Location: " . $referer);
71 +                               } elseif (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE realm_id = 8 AND user_id = " . $_SESSION["sess_user_id"])) == 0) {
72 +                                       header("Location: graph_view.php");
73 +                               } else {
74 +                                       header("Location: $referer");
75                                 }
76 +
77                                 break;
78                         case '2': /* default console page */
79 -                               header("Location: index.php"); break;
80 +                               header("Location: " . $config['url_path'] . "index.php");
81 +
82 +                               break;
83                         case '3': /* default graph page */
84 -                               header("Location: graph_view.php"); break;
85 +                               header("Location: " . $config['url_path'] . "graph_view.php");
86 +
87 +                               break;
88 +                       default:
89 +                               api_plugin_hook_function('login_options_navigate', $user['login_opts']);
90                 }
91                 exit;
92         }else{
93 @@ -264,9 +279,17 @@
94  <body bgcolor="#FFFFFF" onload="document.login.login_username.focus()">
95         <form name="login" method="post" action="<?php print basename($_SERVER["PHP_SELF"]);?>">
96         <input type="hidden" name="action" value="login">
97 +<?php
98 +
99 +api_plugin_hook("login_before");
100 +
101 +$cacti_logo = $config['url_path'] . 'images/auth_login.gif';
102 +$cacti_logo = api_plugin_hook_function('cacti_image', $cacti_logo);
103 +
104 +?>
105         <table align="center">
106                 <tr>
107 -                       <td colspan="2"><img src="images/auth_login.gif" border="0" alt=""></td>
108 +                       <td colspan="2"><center><?php if ($cacti_logo != '') { ?><img src="<?php echo $cacti_logo; ?>" border="0" alt=""><?php } ?></center></td>
109                 </tr>
110                 <?php
111  
112 @@ -303,22 +326,29 @@
113                         <td><input type="password" name="login_password" size="40" style="width: 295px;"></td>
114                 </tr>
115                 <?php
116 -               if (read_config_option("auth_method") == "3") {?>
117 +               if (read_config_option("auth_method") == "3" || api_plugin_hook_function('login_realms_exist')) {
118 +                       $realms = api_plugin_hook_function('login_realms', array("local" => array("name" => "Local", "selected" => false), "ldap" => array("name" => "LDAP", "selected" => true)));
119 +                       ?>
120                 <tr>
121                         <td>Realm:</td>
122                         <td>
123 -                               <select name="realm" style="width: 295px;">
124 -                                       <option value="local">Local</option>
125 -                                       <option value="ldap" selected>LDAP</option>
126 +                               <select name="realm" style="width: 295px;"><?php
127 +                               if (sizeof($realms)) {
128 +                               foreach($realms as $name => $realm) {
129 +                                       print "\t\t\t\t\t<option value='" . $name . "'" . ($realm["selected"] ? " selected":"") . ">" . htmlspecialchars($realm["name"]) . "</option>\n";
130 +                               }
131 +                               }
132 +                               ?>
133                                 </select>
134                         </td>
135 -                       </tr>
136 +               </tr>
137                 <?php }?>
138                 <tr style="height:10px;"><td></td></tr>
139                 <tr>
140                         <td><input type="submit" value="Login"></td>
141                 </tr>
142         </table>
143 +<?php api_plugin_hook('login_after'); ?>
144         </form>
145  </body>
146  </html>
147 diff -Naur cacti-0.8.7g/cli/add_graph_template.php cacti-0.8.7g-PA-v2.9/cli/add_graph_template.php
148 --- cacti-0.8.7g/cli/add_graph_template.php     2010-07-09 18:33:46.000000000 -0400
149 +++ cacti-0.8.7g-PA-v2.9/cli/add_graph_template.php     2010-10-17 20:09:52.000000000 -0400
150 @@ -144,6 +144,7 @@
151                 exit(1);
152         }else{
153                 db_execute("replace into host_graph (host_id,graph_template_id) values (" . $host_id . "," . $graph_template_id . ")");
154 +               api_plugin_hook_function('add_graph_template_to_host', array("host_id" => $host_id, "graph_template_id" => $graph_template_id));
155         }
156  
157         if (is_error_message()) {
158 diff -Naur cacti-0.8.7g/cli/add_tree.php cacti-0.8.7g-PA-v2.9/cli/add_tree.php
159 --- cacti-0.8.7g/cli/add_tree.php       2010-07-09 18:33:46.000000000 -0400
160 +++ cacti-0.8.7g-PA-v2.9/cli/add_tree.php       2010-10-17 20:09:52.000000000 -0400
161 @@ -33,6 +33,7 @@
162  include(dirname(__FILE__)."/../include/global.php");
163  include_once($config["base_path"]."/lib/api_automation_tools.php");
164  include_once($config["base_path"].'/lib/tree.php');
165 +include_once($config["base_path"].'/lib/api_tree.php');
166  
167  /* process calling arguments */
168  $parms = $_SERVER["argv"];
169 diff -Naur cacti-0.8.7g/cli/host_update_template.php cacti-0.8.7g-PA-v2.9/cli/host_update_template.php
170 --- cacti-0.8.7g/cli/host_update_template.php   2010-07-09 18:33:46.000000000 -0400
171 +++ cacti-0.8.7g-PA-v2.9/cli/host_update_template.php   2010-10-17 20:09:52.000000000 -0400
172 @@ -136,6 +136,7 @@
173  
174                         foreach ($graph_templates as $graph_template) {
175                                 db_execute("REPLACE INTO host_graph (host_id, graph_template_id) VALUES (" . $host["id"] . ", " . $graph_template["graph_template_id"] . ")");
176 +                               api_plugin_hook_function('add_graph_template_to_host', array("host_id" => $host_id, "graph_template_id" => $graph_template["graph_template_id"]));
177                         }
178                 }
179         }
180 diff -Naur cacti-0.8.7g/data_sources.php cacti-0.8.7g-PA-v2.9/data_sources.php
181 --- cacti-0.8.7g/data_sources.php       2010-09-19 21:39:05.000000000 -0400
182 +++ cacti-0.8.7g-PA-v2.9/data_sources.php       2010-10-17 20:09:52.000000000 -0400
183 @@ -44,6 +44,8 @@
184         7 => "Disable"
185         );
186  
187 +$ds_actions = api_plugin_hook_function('data_source_action_array', $ds_actions);
188 +
189  /* set default action */
190  if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
191  
192 @@ -402,6 +404,8 @@
193                                 api_reapply_suggested_data_source_title($selected_items[$i]);
194                                 update_data_source_title_cache($selected_items[$i]);
195                         }
196 +               } else {
197 +                       api_plugin_hook_function('data_source_action_execute', $_POST['drp_action']);
198                 }
199                 header("Location: data_sources.php");
200                 exit;
201 @@ -545,6 +549,12 @@
202                                 </tr>\n
203                                 ";
204                         $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Reapply Suggested Naming to Data Source(s)'>";
205 +               }else{
206 +                       $save['drp_action'] = $_POST['drp_action'];
207 +                       $save['ds_list'] = $ds_list;
208 +                       $save['ds_array'] = (isset($ds_array)? $ds_array : array());
209 +                       api_plugin_hook_function('data_source_action_prepare', $save);
210 +                       $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
211                 }
212         }else{
213                 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one data source.</span></td></tr>\n";
214 @@ -683,6 +693,8 @@
215         input_validate_input_number(get_request_var("host_id"));
216         /* ==================================================== */
217  
218 +       api_plugin_hook('data_source_edit_top');
219 +
220         $use_data_template = true;
221         $host_id = 0;
222  
223 @@ -975,8 +987,9 @@
224  
225         form_save_button("data_sources.php");
226  
227 -       include_once("./include/bottom_footer.php");
228 +       api_plugin_hook('data_source_edit_bottom');
229  
230 +       include_once("./include/bottom_footer.php");
231  }
232  
233  function get_poller_interval($seconds) {
234 @@ -1310,8 +1323,10 @@
235         $i = 0;
236         if (sizeof($data_sources) > 0) {
237                 foreach ($data_sources as $data_source) {
238 +                       $data_source["data_template_name"] = htmlspecialchars($data_source["data_template_name"]);
239 +                       $data_source = api_plugin_hook_function('data_sources_table', $data_source);
240                         /* we're escaping strings here, so no need to escape them on form_selectable_cell */
241 -                       $data_template_name = ((empty($data_source["data_template_name"])) ? "<em>None</em>" : htmlspecialchars($data_source["data_template_name"]));
242 +                       $data_template_name = ((empty($data_source["data_template_name"])) ? "<em>None</em>" : $data_source["data_template_name"]);
243                         $data_input_name    = ((empty($data_source["data_input_name"])) ? "<em>External</em>" : htmlspecialchars($data_source["data_input_name"]));
244                         $poller_interval    = ((isset($poller_intervals[$data_source["local_data_id"]])) ? $poller_intervals[$data_source["local_data_id"]] : 0);
245                         form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $data_source["local_data_id"]); $i++;
246 diff -Naur cacti-0.8.7g/graph_image.php cacti-0.8.7g-PA-v2.9/graph_image.php
247 --- cacti-0.8.7g/graph_image.php        2010-07-09 18:33:46.000000000 -0400
248 +++ cacti-0.8.7g-PA-v2.9/graph_image.php        2010-10-17 20:09:52.000000000 -0400
249 @@ -44,6 +44,8 @@
250  /* flush the headers now */
251  ob_end_clean();
252  
253 +api_plugin_hook_function('graph_image');
254 +
255  session_write_close();
256  
257  $graph_data_array = array();
258 diff -Naur cacti-0.8.7g/graph.php cacti-0.8.7g-PA-v2.9/graph.php
259 --- cacti-0.8.7g/graph.php      2010-07-09 18:33:46.000000000 -0400
260 +++ cacti-0.8.7g-PA-v2.9/graph.php      2010-10-17 20:09:52.000000000 -0400
261 @@ -32,6 +32,8 @@
262  include_once("./lib/html_tree.php");
263  include_once("./include/top_graph_header.php");
264  
265 +api_plugin_hook_function('graph');
266 +
267  /* ================= input validation ================= */
268  input_validate_input_regex(get_request_var("rra_id"), "^([0-9]+|all)$");
269  input_validate_input_number(get_request_var("local_graph_id"));
270 @@ -77,6 +79,12 @@
271  
272  switch ($_REQUEST["action"]) {
273  case 'view':
274 +       do_hook_function('page_buttons',
275 +               array('lgid' => $_GET["local_graph_id"],
276 +                       'leafid' => '',//$leaf_id,
277 +                       'mode' => 'mrtg',
278 +                       'rraid' => $_GET["rra_id"])
279 +               );
280         ?>
281         <tr bgcolor='#<?php print $colors["header"];?>'>
282                 <td colspan='3' class='textHeaderDark'>
283 @@ -100,6 +108,7 @@
284                                                                 <a href='<?php print htmlspecialchars("graph.php?action=zoom&local_graph_id=" . $_GET["local_graph_id"]. "&rra_id=" . $rra["id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
285                                                                 <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
286                                                                 <a href='<?php print htmlspecialchars("graph.php?action=properties&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a>
287 +                                                               <?php api_plugin_hook('graph_buttons', array('hook' => 'view', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $rra['id'], 'view_type' => $_REQUEST['view_type'])); ?>
288                                                         </td>
289                                                 </tr>
290                                                 <tr>
291 @@ -113,6 +122,7 @@
292                         <?php
293                         $i++;
294                 }
295 +               do_hook_function('tree_view_page_end');
296         }
297  
298         break;
299 @@ -215,6 +225,7 @@
300                                         <td valign='top' style='padding: 3px;' class='noprint'>
301                                                 <a href='<?php print htmlspecialchars("graph.php?action=properties&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_REQUEST["view_type"] . "&graph_start=" . $graph_start . "&graph_end=" . $graph_end);?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a>
302                                                 <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_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>
303 +                                               <?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'])); ?>
304                                         </td>
305                                 </tr>
306                                 <tr>
307 @@ -247,6 +258,7 @@
308                                         <td valign='top' style='padding: 3px;'>
309                                                 <a href='<?php print htmlspecialchars("graph.php?action=zoom&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
310                                                 <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_REQUEST["view_type"]);?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
311 +                                               <?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'])); ?>
312                                         </td>
313                                 </tr>
314                                 <tr>
315 diff -Naur cacti-0.8.7g/graphs_new.php cacti-0.8.7g-PA-v2.9/graphs_new.php
316 --- cacti-0.8.7g/graphs_new.php 2010-07-09 18:33:46.000000000 -0400
317 +++ cacti-0.8.7g-PA-v2.9/graphs_new.php 2010-10-17 20:09:52.000000000 -0400
318 @@ -511,7 +511,8 @@
319                         </td>
320                         <td nowrap style='white-space: nowrap;' class="textInfo" align="center" valign="top">
321                                 <span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit&id=" . $_REQUEST["host_id"]);?>">Edit this Host</a><br>
322 -                               <span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit");?>">Create New Host</a>
323 +                               <span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit");?>">Create New Host</a><br>
324 +                               <?php api_plugin_hook('graphs_new_top_links'); ?>
325                         </td>
326                 </tr>
327         </table>
328 diff -Naur cacti-0.8.7g/graphs.php cacti-0.8.7g-PA-v2.9/graphs.php
329 --- cacti-0.8.7g/graphs.php     2010-09-19 21:39:05.000000000 -0400
330 +++ cacti-0.8.7g-PA-v2.9/graphs.php     2010-10-17 20:09:52.000000000 -0400
331 @@ -45,6 +45,8 @@
332         4 => "Convert to Graph Template"
333         );
334  
335 +$graph_actions = api_plugin_hook_function('graphs_action_array', $graph_actions);
336 +
337  /* set default action */
338  if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
339  
340 @@ -362,6 +364,8 @@
341  
342                                 api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
343                         }
344 +               } else {
345 +                       api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
346                 }
347  
348                 header("Location: graphs.php");
349 @@ -514,6 +518,12 @@
350                                 ";
351  
352                         $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Resize Selected Graph(s)'>";
353 +               } else {
354 +                       $save['drp_action'] = $_POST['drp_action'];
355 +                       $save['graph_list'] = $graph_list;
356 +                       $save['graph_array'] = (isset($graph_array) ? $graph_array : array());
357 +                       api_plugin_hook_function('graphs_action_prepare', $save);
358 +                       $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
359                 }
360         }else{
361                 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one graph.</span></td></tr>\n";
362 diff -Naur cacti-0.8.7g/host.php cacti-0.8.7g-PA-v2.9/host.php
363 --- cacti-0.8.7g/host.php       2010-07-09 18:33:46.000000000 -0400
364 +++ cacti-0.8.7g-PA-v2.9/host.php       2010-10-17 20:09:52.000000000 -0400
365 @@ -44,6 +44,8 @@
366         6 => "Change Availability Options"
367         );
368  
369 +$device_actions = api_plugin_hook_function('device_action_array', $device_actions);
370 +
371  /* set default action */
372  if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
373  
374 @@ -137,6 +139,7 @@
375                 /* ==================================================== */
376  
377                 db_execute("replace into host_graph (host_id,graph_template_id) values (" . $_POST["id"] . "," . $_POST["graph_template_id"] . ")");
378 +               api_plugin_hook_function('add_graph_template_to_host', array("host_id" => $_POST["id"], "graph_template_id" => $_POST["graph_template_id"]));
379  
380                 header("Location: host.php?action=edit&id=" . $_POST["id"]);
381                 exit;
382 @@ -305,6 +308,8 @@
383  
384                                 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);
385                         }
386 +               } else {
387 +                       api_plugin_hook_function('device_action_execute', $_POST['drp_action']);
388                 }
389  
390                 header("Location: host.php");
391 @@ -450,6 +455,12 @@
392                                 <input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
393                                 ";
394                         $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Place Device(s) on Tree'>";
395 +               } else {
396 +                       $save['drp_action'] = $_POST['drp_action'];
397 +                       $save['host_list'] = $host_list;
398 +                       $save['host_array'] = (isset($host_array)? $host_array : array());
399 +                       api_plugin_hook_function('device_action_prepare', $save);
400 +                       $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
401                 }
402         }else{
403                 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one device.</span></td></tr>\n";
404 @@ -532,6 +543,8 @@
405         input_validate_input_number(get_request_var("id"));
406         /* ==================================================== */
407  
408 +       api_plugin_hook('host_edit_top');
409 +
410         if (!empty($_GET["id"])) {
411                 $host = db_fetch_row("select * from host where id=" . $_GET["id"]);
412                 $header_label = "[edit: " . htmlspecialchars($host["description"]) . "]";
413 @@ -643,6 +656,7 @@
414                                         <span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs_new.php?host_id=" . $host["id"]);?>">Create Graphs for this Host</a><br>
415                                         <span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("data_sources.php?host_id=" . $host["id"] . "&ds_rows=30&filter=&template_id=-1&method_id=-1&page=1");?>">Data Source List</a><br>
416                                         <span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs.php?host_id=" . $host["id"] . "&graph_rows=30&filter=&template_id=-1&page=1");?>">Graph List</a>
417 +                                       <?php api_plugin_hook('device_edit_top_links'); ?>
418                                 </td>
419                         </tr>
420                 </table>
421 @@ -1107,6 +1121,8 @@
422         }
423  
424         form_save_button("host.php", "return");
425 +
426 +       api_plugin_hook('host_edit_bottom');
427  }
428  
429  function host() {
430 diff -Naur cacti-0.8.7g/images/disable_icon.png cacti-0.8.7g-PA-v2.9/images/disable_icon.png
431 diff -Naur cacti-0.8.7g/images/enable_icon_disabled.png cacti-0.8.7g-PA-v2.9/images/enable_icon_disabled.png
432 diff -Naur cacti-0.8.7g/images/enable_icon.png cacti-0.8.7g-PA-v2.9/images/enable_icon.png
433 diff -Naur cacti-0.8.7g/images/install_icon_disabled.png cacti-0.8.7g-PA-v2.9/images/install_icon_disabled.png
434 diff -Naur cacti-0.8.7g/images/install_icon.png cacti-0.8.7g-PA-v2.9/images/install_icon.png
435 diff -Naur cacti-0.8.7g/images/uninstall_icon.gif cacti-0.8.7g-PA-v2.9/images/uninstall_icon.gif
436 diff -Naur cacti-0.8.7g/images/view_none.gif cacti-0.8.7g-PA-v2.9/images/view_none.gif
437 diff -Naur cacti-0.8.7g/include/auth.php cacti-0.8.7g-PA-v2.9/include/auth.php
438 --- cacti-0.8.7g/include/auth.php       2010-07-09 18:33:46.000000000 -0400
439 +++ cacti-0.8.7g-PA-v2.9/include/auth.php       2010-10-17 20:09:52.000000000 -0400
440 @@ -26,14 +26,17 @@
441  
442  /* check to see if this is a new installation */
443  if (db_fetch_cell("select cacti from version") != $config["cacti_version"]) {
444 -       header ("Location: install/");
445 +       header ("Location: " . $config['url_path'] . "install/");
446         exit;
447  }
448  
449  if (read_config_option("auth_method") != 0) {
450 +       /* handle alternate authentication realms */
451 +       api_plugin_hook_function('auth_alternate_realms');
452 +
453         /* handle change password dialog */
454         if ((isset($_SESSION['sess_change_password'])) && (read_config_option("webbasic_enabled") != "on")) {
455 -               header ("Location: auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php"));
456 +               header ("Location: " . $config['url_path'] . "auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php"));
457                 exit;
458         }
459  
460 @@ -72,9 +75,9 @@
461                         and user_auth_realm.realm_id='$realm_id'")) || (empty($realm_id)))) {
462  
463                         if (isset($_SERVER["HTTP_REFERER"])) {
464 -                               $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . htmlspecialchars($_SERVER["HTTP_REFERER"]) . "'>Return</a> | <a href='logout.php'>Login Again</a> )</td>";
465 +                               $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . htmlspecialchars($_SERVER["HTTP_REFERER"]) . "'>Return</a> | <a href='" . $config['url_path'] . "logout.php'>Login Again</a> )</td>";
466                         }else{
467 -                               $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='logout.php'>Login Again</a> )</td>";
468 +                               $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . $config['url_path'] . "logout.php'>Login Again</a> )</td>";
469                         }
470  
471                         ?>
472 @@ -83,14 +86,14 @@
473                         <head>
474                                 <title>Cacti</title>
475                                 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
476 -                               <link href="include/main.css" type="text/css" rel="stylesheet">
477 +                               <link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
478                         </head>
479                         <body>
480                         <br><br>
481  
482                         <table width="450" align='center'>
483                                 <tr>
484 -                                       <td colspan='2'><img src='images/auth_deny.gif' border='0' alt='Access Denied'></td>
485 +                                       <td colspan='2'><img src='<?php echo $config['url_path']; ?>images/auth_deny.gif' border='0' alt='Access Denied'></td>
486                                 </tr>
487                                 <tr style='height:10px;'><td></td></tr>
488                                 <tr>
489 diff -Naur cacti-0.8.7g/include/bottom_footer.php cacti-0.8.7g-PA-v2.9/include/bottom_footer.php
490 --- cacti-0.8.7g/include/bottom_footer.php      2010-07-09 18:33:46.000000000 -0400
491 +++ cacti-0.8.7g-PA-v2.9/include/bottom_footer.php      2010-10-17 20:09:52.000000000 -0400
492 @@ -21,6 +21,10 @@
493   | http://www.cacti.net/                                                   |
494   +-------------------------------------------------------------------------+
495  */
496 +
497 +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
498 +if (($oper_mode == OPER_MODE_NATIVE) || ($oper_mode == OPER_MODE_IFRAME_NONAV)) {
499 +
500  ?>
501                         </div>
502                         <br>
503 @@ -32,6 +36,9 @@
504  </html>
505  
506  <?php
507 +
508 +}
509 +
510  /* we use this session var to store field values for when a save fails,
511  this way we can restore the field's previous values. we reset it here, because
512  they only need to be stored for a single page */
513 diff -Naur cacti-0.8.7g/include/config.php cacti-0.8.7g-PA-v2.9/include/config.php
514 --- cacti-0.8.7g/include/config.php     2010-07-09 18:33:46.000000000 -0400
515 +++ cacti-0.8.7g-PA-v2.9/include/config.php     2010-10-17 20:09:52.000000000 -0400
516 @@ -30,6 +30,17 @@
517  $database_password = "cactiuser";
518  $database_port = "3306";
519  
520 +/* load up old style plugins here */
521 +$plugins = array();
522 +//$plugins[] = 'thold';
523 +
524 +/*
525 +   Edit this to point to the default URL of your Cacti install
526 +   ex: if your cacti install as at http://serverip/cacti/ this
527 +   would be set to /cacti/
528 +*/
529 +$url_path = "/";
530 +
531  /* Default session name - Session name must contain alpha characters */
532  #$cacti_session_name = "Cacti";
533  
534 diff -Naur cacti-0.8.7g/include/global_arrays.php cacti-0.8.7g-PA-v2.9/include/global_arrays.php
535 --- cacti-0.8.7g/include/global_arrays.php      2010-07-09 18:33:46.000000000 -0400
536 +++ cacti-0.8.7g-PA-v2.9/include/global_arrays.php      2010-10-17 20:09:52.000000000 -0400
537 @@ -22,6 +22,8 @@
538   +-------------------------------------------------------------------------+
539  */
540  
541 +global $menu;
542 +
543  $messages = array(
544         1  => array(
545                 "message" => 'Save Successful.',
546 @@ -654,4 +656,10 @@
547         GDC_SLASH => "/"
548         );
549  
550 +$plugin_architecture = array(
551 +       'version' => '2.9'
552 +       );
553 +
554 +api_plugin_hook('config_arrays');
555 +
556  ?>
557 diff -Naur cacti-0.8.7g/include/global_constants.php cacti-0.8.7g-PA-v2.9/include/global_constants.php
558 --- cacti-0.8.7g/include/global_constants.php   2010-07-09 18:33:46.000000000 -0400
559 +++ cacti-0.8.7g-PA-v2.9/include/global_constants.php   2010-10-17 20:09:52.000000000 -0400
560 @@ -173,4 +173,9 @@
561  define("SNMP_CMDPHP", 1);
562  define("SNMP_WEBUI", 2);
563  
564 +define('OPER_MODE_NATIVE', 0);
565 +define('OPER_MODE_RESKIN', 1);
566 +define('OPER_MODE_IFRAME_NONAV', 2);
567 +define('OPER_MODE_NOTABS', 3);
568 +
569  ?>
570 diff -Naur cacti-0.8.7g/include/global_form.php cacti-0.8.7g-PA-v2.9/include/global_form.php
571 --- cacti-0.8.7g/include/global_form.php        2010-07-09 18:33:46.000000000 -0400
572 +++ cacti-0.8.7g-PA-v2.9/include/global_form.php        2010-10-17 20:09:52.000000000 -0400
573 @@ -22,8 +22,9 @@
574   +-------------------------------------------------------------------------+
575  */
576  
577 -if (!defined("VALID_HOST_FIELDS")) {
578 -       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)");
579 +if (!defined('VALID_HOST_FIELDS')) {
580 +       $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)');
581 +       define('VALID_HOST_FIELDS', $string);
582  }
583  
584  /* file: cdef.php, action: edit */
585 @@ -1190,4 +1191,7 @@
586                 "dropdown_sql" => "select id,name from snmp_query order by name"
587                 )
588         );
589 -?>
590 +
591 +
592 +api_plugin_hook('config_form');
593 +
594 diff -Naur cacti-0.8.7g/include/global.php cacti-0.8.7g-PA-v2.9/include/global.php
595 --- cacti-0.8.7g/include/global.php     2010-07-09 18:33:46.000000000 -0400
596 +++ cacti-0.8.7g-PA-v2.9/include/global.php     2010-10-17 20:09:52.000000000 -0400
597 @@ -93,6 +93,13 @@
598  /* built-in snmp support */
599  $config["php_snmp_support"] = function_exists("snmpget");
600  
601 +/* set URL path */
602 +if (! isset($url_path)) { 
603 +       $url_path = "";
604 +}
605 +$config['url_path'] = $url_path;
606 +define('URL_PATH', $url_path);
607 +
608  /* used for includes */
609  $config["base_path"] = strtr(ereg_replace("(.*)[\\\/]include", "\\1", dirname(__FILE__)), "\\", "/");
610  $config["library_path"] = ereg_replace("(.*[\\\/])include", "\\1lib", dirname(__FILE__));
611 @@ -188,15 +195,17 @@
612  /* include base modules */
613  include($config["library_path"] . "/adodb/adodb.inc.php");
614  include($config["library_path"] . "/database.php");
615 -include_once($config["library_path"] . "/functions.php");
616 -include_once($config["include_path"] . "/global_constants.php");
617 -include_once($config["include_path"] . "/global_arrays.php");
618 -include_once($config["include_path"] . "/global_settings.php");
619  
620  /* connect to the database server */
621  db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
622  
623  /* include additional modules */
624 +include_once($config["library_path"] . "/functions.php");
625 +include_once($config["include_path"] . "/global_constants.php");
626 +include_once($config["library_path"] . "/plugins.php");
627 +include_once($config["include_path"] . "/plugins.php");
628 +include_once($config["include_path"] . "/global_arrays.php");
629 +include_once($config["include_path"] . "/global_settings.php");
630  include_once($config["include_path"] . "/global_form.php");
631  include_once($config["library_path"] . "/html.php");
632  include_once($config["library_path"] . "/html_form.php");
633 @@ -205,6 +214,8 @@
634  include_once($config["library_path"] . "/variables.php");
635  include_once($config["library_path"] . "/auth.php");
636  
637 +api_plugin_hook("config_insert");
638 +
639  /* current cacti version */
640  $config["cacti_version"] = "0.8.7g";
641  
642 diff -Naur cacti-0.8.7g/include/global_settings.php cacti-0.8.7g-PA-v2.9/include/global_settings.php
643 --- cacti-0.8.7g/include/global_settings.php    2010-07-09 18:33:46.000000000 -0400
644 +++ cacti-0.8.7g-PA-v2.9/include/global_settings.php    2010-10-17 20:09:52.000000000 -0400
645 @@ -1190,4 +1190,6 @@
646                 )
647         );
648  
649 +api_plugin_hook('config_settings');
650 +
651  ?>
652 diff -Naur cacti-0.8.7g/include/plugins.php cacti-0.8.7g-PA-v2.9/include/plugins.php
653 --- cacti-0.8.7g/include/plugins.php    1969-12-31 19:00:00.000000000 -0500
654 +++ cacti-0.8.7g-PA-v2.9/include/plugins.php    2010-10-17 20:09:52.000000000 -0400
655 @@ -0,0 +1,43 @@
656 +<?php
657 +
658 +/*
659 + * Copyright (c) 1999-2005 The SquirrelMail Project Team (http://squirrelmail.org)
660 + * Licensed under the GNU GPL. For full terms see the file COPYING.
661 + */
662 +
663 +global $plugin_hooks, $plugins_system, $plugins;
664 +$plugin_hooks = array();
665 +$plugins_system = array('settings', 'boost', 'dsstats');
666 +
667 +function use_plugin ($name) {
668 +       global $config;
669 +       if (file_exists($config['base_path'] . "/plugins/$name/setup.php")) {
670 +               include_once($config['base_path'] . "/plugins/$name/setup.php");
671 +               $function = "plugin_init_$name";
672 +               if (function_exists($function)) {
673 +                       $function();
674 +               }
675 +       }
676 +}
677 +
678 +/**
679 + * This function executes a hook.
680 + * @param string $name Name of hook to fire
681 + * @return mixed $data
682 + */
683 +if (!is_array($plugins)) {
684 +       $plugins = array();
685 +}
686 +
687 +$oldplugins = read_config_option('oldplugins');
688 +if (strlen(trim($oldplugins))) {
689 +       $oldplugins = explode(',', $oldplugins);
690 +       $plugins    = array_merge($plugins, $oldplugins);
691 +}
692 +
693 +/* On startup, register all plugins configured for use. */
694 +if (isset($plugins) && is_array($plugins)) {
695 +       foreach ($plugins as $name) {
696 +               use_plugin($name);
697 +       }
698 +}
699 diff -Naur cacti-0.8.7g/include/top_graph_header.php cacti-0.8.7g-PA-v2.9/include/top_graph_header.php
700 --- cacti-0.8.7g/include/top_graph_header.php   2010-07-09 18:33:46.000000000 -0400
701 +++ cacti-0.8.7g-PA-v2.9/include/top_graph_header.php   2010-10-17 20:09:52.000000000 -0400
702 @@ -25,6 +25,8 @@
703  $using_guest_account = false;
704  $show_console_tab = true;
705  
706 +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
707 +
708  /* ================= input validation ================= */
709  input_validate_input_number(get_request_var_request("local_graph_id"));
710  input_validate_input_number(get_request_var_request("graph_start"));
711 @@ -52,49 +54,62 @@
712         $_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all";
713  }
714  
715 +$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title"));
716 +
717  ?>
718  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
719  <html>
720  <head>
721 -       <title><?php echo draw_navigation_text("title");?></title>
722 +       <title><?php echo $page_title; ?></title>
723         <?php
724         if (isset($_SESSION["custom"]) && $_SESSION["custom"] == true) {
725                 print "<meta http-equiv=refresh content='99999'>\r\n";
726         }else{
727 -               print "<meta http-equiv=refresh content='" . htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES) . "'>\r\n";
728 +               $refresh = api_plugin_hook_function('top_graph_refresh', htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES));
729 +               print "<meta http-equiv=refresh content='" . $refresh . "'>\r\n";
730         }
731         ?>
732         <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
733 -       <link href="include/main.css" type="text/css" rel="stylesheet">
734 -       <link href="images/favicon.ico" rel="shortcut icon"/>
735 -       <script type="text/javascript" src="include/layout.js"></script>
736 -       <script type="text/javascript" src="include/treeview/ua.js"></script>
737 -       <script type="text/javascript" src="include/treeview/ftiens4.js"></script>
738 -       <script type="text/javascript" src="include/jscalendar/calendar.js"></script>
739 -       <script type="text/javascript" src="include/jscalendar/lang/calendar-en.js"></script>
740 -       <script type="text/javascript" src="include/jscalendar/calendar-setup.js"></script>
741 +       <link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
742 +       <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
743 +       <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
744 +       <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ua.js"></script>
745 +       <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ftiens4.js"></script>
746 +       <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar.js"></script>
747 +       <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/lang/calendar-en.js"></script>
748 +       <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar-setup.js"></script>
749 +       <?php api_plugin_hook('page_head'); ?>
750  </head>
751  
752 -<body>
753 +<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
754 +<body <?php print api_plugin_hook_function("body_style", "");?>>
755  <a name='page_top'></a>
756 +<?php }else{?>
757 +<body <?php print api_plugin_hook_function("body_style", "");?>>
758 +<?php }?>
759 +
760  <table style="width:100%;height:100%;" cellspacing="0" cellpadding="0">
761 +<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
762         <tr style="height:25px;" bgcolor="#a9a9a9" class="noprint">
763                 <td colspan="2" valign="bottom" nowrap>
764                         <table width="100%" cellspacing="0" cellpadding="0">
765 -                               <tr style="background: transparent url('images/cacti_backdrop2.gif') no-repeat center right;">
766 +                               <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop2.gif') no-repeat center right;">
767                                         <td id="tabs" nowrap>
768 -                                               &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;
769 +                                               &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
770 +                                               api_plugin_hook('top_graph_header_tabs');
771 +                                               ?>
772                                         </td>
773                                         <td id="gtabs" align="right" nowrap>
774 -                                               <?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="<?php print htmlspecialchars("graph_view.php?action=tree");?>"><img src="images/tab_mode_tree<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "tree") { print "_down"; }?>.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_list"] == "on")) {?><a href="graph_view.php?action=list"><img src="images/tab_mode_list<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "list") { print "_down"; }?>.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_preview"] == "on")) {?><a href="graph_view.php?action=preview"><img src="images/tab_mode_preview<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?>&nbsp;<br>
775 +                                               <?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 print htmlspecialchars($config['url_path'] . "graph_view.php?action=tree");?>"><img src="<?php echo $config['url_path']; ?>images/tab_mode_tree<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "tree") { print "_down"; }?>.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_list"] == "on")) {?><a href="<?php print htmlspecialchars($config['url_path'] . "graph_view.php?action=list");?>"><img src="<?php echo $config['url_path']; ?>images/tab_mode_list<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "list") { print "_down"; }?>.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_preview"] == "on")) {?><a href="<?php print htmlspecialchars($config['url_path'] . "graph_view.php?action=preview");?>"><img src="<?php echo $config['url_path']; ?>images/tab_mode_preview<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?>&nbsp;<br>
776                                         </td>
777                                 </tr>
778                         </table>
779                 </td>
780         </tr>
781 +<?php } elseif ($oper_mode == OPER_MODE_NOTABS) { api_plugin_hook_function('print_top_header'); } ?>
782         <tr style="height:2px;" bgcolor="#183c8f" class="noprint">
783                 <td colspan="2">
784 -                       <img src="images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br>
785 +                       <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br>
786                 </td>
787         </tr>
788         <tr style="height:5px;" bgcolor="#e9e9e9" class="noprint">
789 @@ -106,7 +121,7 @@
790                                         </td>
791                                         <td align="right">
792                                                 <?php if ((isset($_SESSION["sess_user_id"])) && ($using_guest_account == false)) { ?>
793 -                                               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;
794 +                                               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;
795                                                 <?php } ?>
796                                         </td>
797                                 </tr>
798 @@ -114,10 +129,10 @@
799                 </td>
800         </tr>
801         <tr class="noprint">
802 -               <td bgcolor="#efefef" colspan="1" style="height:8px;background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
803 -                       <img src="images/transparent_line.gif" width="<?php print htmlspecialchars(read_graph_config_option("default_dual_pane_width"));?>" style="height:2px;" border="0"><br>
804 +               <td bgcolor="#efefef" colspan="1" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
805 +                       <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" width="<?php print htmlspecialchars(read_graph_config_option("default_dual_pane_width"));?>" style="height:2px;" border="0"><br>
806                 </td>
807 -               <td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(images/shadow.gif); background-repeat: repeat-x;">
808 +               <td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;">
809  
810                 </td>
811         </tr>
812 @@ -143,6 +158,8 @@
813                 </td>
814         </tr>
815         <?php }
816 +
817 +       global $graph_views;
818         load_current_session_value("action", "sess_cacti_graph_action", $graph_views[read_graph_config_option("default_tree_view_mode")]);
819         ?>
820         <tr>
821 diff -Naur cacti-0.8.7g/include/top_header.php cacti-0.8.7g-PA-v2.9/include/top_header.php
822 --- cacti-0.8.7g/include/top_header.php 2010-07-09 18:33:46.000000000 -0400
823 +++ cacti-0.8.7g-PA-v2.9/include/top_header.php 2010-10-17 20:09:52.000000000 -0400
824 @@ -22,38 +22,53 @@
825   +-------------------------------------------------------------------------+
826  */
827  
828 -global $colors;
829 +global $colors, $config;
830 +
831 +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
832 +if ($oper_mode == OPER_MODE_RESKIN || $oper_mode == OPER_MODE_NOTABS) {
833 +       return;
834 +}
835 +
836 +$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title"));
837 +
838  ?>
839  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
840  <html>
841  <head>
842 -       <title><?php echo draw_navigation_text("title");?></title>
843 -       <link href="include/main.css" type="text/css" rel="stylesheet">
844 -       <link href="images/favicon.ico" rel="shortcut icon"/>
845 +       <title><?php echo $page_title; ?></title>
846 +       <link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
847 +       <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon">
848         <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
849 -       <script type="text/javascript" src="include/layout.js"></script>
850 +       <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
851         <?php if (isset($refresh)) {
852         print "<meta http-equiv=refresh content=\"" . $refresh["seconds"] . "; url='" . $refresh["page"] . "'\">";
853 -       }?>
854 +       }
855 +       api_plugin_hook('page_head'); ?>
856  </head>
857  
858 -<body style="background-image:url('images/left_border.gif');background-repeat:repeat-y;">
859 +<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
860 +<body style="background-image:url('<?php print $config['url_path'];?>images/left_border.gif');background-repeat:repeat-y;" <?php print api_plugin_hook_function("body_style", "");?>>
861 +<?php }else{?>
862 +<body style="background-image:url('<?php print $config['url_path'];?>images/left_border.gif');background-repeat:repeat-y;" <?php print api_plugin_hook_function("body_style", "");?>>
863 +<?php }?>
864  
865  <table width="100%" cellspacing="0" cellpadding="0">
866 +<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
867         <tr style="height:1px;" bgcolor="#a9a9a9">
868                 <td valign="bottom" colspan="3" nowrap>
869                         <table width="100%" cellspacing="0" cellpadding="0">
870 -                               <tr style="background: transparent url('images/cacti_backdrop.gif') no-repeat center right;">
871 +                               <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop.gif') no-repeat center right;">
872                                         <td id="tabs" valign="bottom">
873 -                                               &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>
874 -                                       </td>
875 +                                               &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
876 +                                               api_plugin_hook('top_header_tabs');
877 +                                       ?></td>
878                                 </tr>
879                         </table>
880                 </td>
881         </tr>
882         <tr style="height:2px;" bgcolor="#183c8f">
883                 <td colspan="3">
884 -                       <img src="images/transparent_line.gif" style="height:2px;" border="0"><br>
885 +                       <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;" border="0"><br>
886                 </td>
887         </tr>
888         <tr style="height:5px;" bgcolor="#e9e9e9">
889 @@ -65,7 +80,7 @@
890                                         </td>
891                                         <td align="right">
892                                                 <?php if (read_config_option("auth_method") != 0) { ?>
893 -                                               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;
894 +                                               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;
895                                                 <?php } ?>
896                                         </td>
897                                 </tr>
898 @@ -73,10 +88,10 @@
899                 </td>
900         </tr>
901         <tr>
902 -               <td bgcolor="#f5f5f5" colspan="1" style="height:8px;width:135px;background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
903 -                       <img src="images/transparent_line.gif" style="height:2px;width:135px;" border="0"><br>
904 +               <td bgcolor="#f5f5f5" colspan="1" style="height:8px;width:135px;background-image: url(<?php echo $config['url_path']; ?>images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
905 +                       <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;width:135px;" border="0"><br>
906                 </td>
907 -               <td colspan="2" style="height:8px;background-image: url(images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
908 +               <td colspan="2" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
909  
910                 </td>
911         </tr>
912 @@ -86,9 +101,12 @@
913                                 <?php draw_menu();?>
914                         </table>
915  
916 -                       <img src="images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
917 -                       <p align="center"><a href='about.php'><img src="images/cacti_logo.gif" border="0"></a></p>
918 -                       <img src="images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
919 +                       <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
920 +                       <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>
921 +                       <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
922                 </td>
923                 <td width="100%" colspan="2" valign="top" style="padding: 5px; border-right: #aaaaaa 1px solid;"><?php display_output_messages();?><div style='position:relative;' id='main'>
924 -
925 +<?php }else{ ?>
926 +       <tr>
927 +               <td width="100%" valign="top"><?php display_output_messages();?>
928 +<?php } ?>
929 diff -Naur cacti-0.8.7g/index.php cacti-0.8.7g-PA-v2.9/index.php
930 --- cacti-0.8.7g/index.php      2010-07-09 18:33:46.000000000 -0400
931 +++ cacti-0.8.7g-PA-v2.9/index.php      2010-10-17 20:09:52.000000000 -0400
932 @@ -25,6 +25,8 @@
933  include("./include/auth.php");
934  include("./include/top_header.php");
935  
936 +api_plugin_hook('console_before');
937 +
938  ?>
939  <table width="100%" align="center">
940         <tr>
941 @@ -46,6 +48,8 @@
942  
943  <?php
944  
945 +api_plugin_hook('console_after');
946 +
947  include("./include/bottom_footer.php");
948  
949  ?>
950 diff -Naur cacti-0.8.7g/lib/api_automation_tools.php cacti-0.8.7g-PA-v2.9/lib/api_automation_tools.php
951 --- cacti-0.8.7g/lib/api_automation_tools.php   2010-07-09 18:33:46.000000000 -0400
952 +++ cacti-0.8.7g-PA-v2.9/lib/api_automation_tools.php   2010-10-17 20:09:52.000000000 -0400
953 @@ -22,117 +22,6 @@
954   +-------------------------------------------------------------------------+
955   */
956  
957 -function api_tree_item_save($id, $tree_id, $type, $parent_tree_item_id,
958 -       $title, $local_graph_id, $rra_id, $host_id, $host_grouping_type,
959 -       $sort_children_type, $propagate_changes) {
960 -
961 -       global $config;
962 -
963 -       include_once($config["library_path"] . "/tree.php");
964 -
965 -       $parent_order_key = db_fetch_cell("select order_key from graph_tree_items where id=$parent_tree_item_id");
966 -
967 -       /* fetch some cache variables */
968 -       if (empty($id)) {
969 -               /* new/save - generate new order key */
970 -               $order_key = get_next_tree_id($parent_order_key, "graph_tree_items", "order_key", "graph_tree_id=$tree_id");
971 -       }else{
972 -               /* edit/save - use old order_key */
973 -               $order_key = db_fetch_cell("select order_key from graph_tree_items where id=$id");
974 -       }
975 -
976 -       /* duplicate graph check */
977 -       $search_key = substr($parent_order_key, 0, (tree_tier($parent_order_key) * CHARS_PER_TIER));
978 -       if (($type == TREE_ITEM_TYPE_GRAPH) && (sizeof(db_fetch_assoc("select id from graph_tree_items where local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
979 -               return db_fetch_cell("select id from graph_tree_items where local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
980 -       }
981 -
982 -       /* Duplicate header check */
983 -       if (($type == TREE_ITEM_TYPE_HEADER)) {
984 -               if ((sizeof(db_fetch_assoc("select id from graph_tree_items where title='$title' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
985 -                       return db_fetch_cell("select id from graph_tree_items where title='$title' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
986 -               }
987 -       }
988 -
989 -       $save["id"]                 = $id;
990 -       $save["graph_tree_id"]      = $tree_id;
991 -       $save["title"]              = form_input_validate($title, "title", "", ($type == TREE_ITEM_TYPE_HEADER ? false : true), 3);
992 -       $save["order_key"]          = $order_key;
993 -       $save["local_graph_id"]     = form_input_validate($local_graph_id, "local_graph_id", "", true, 3);
994 -       $save["rra_id"]             = form_input_validate($rra_id, "rra_id", "", true, 3);
995 -       $save["host_id"]            = form_input_validate($host_id, "host_id", "", true, 3);
996 -       $save["host_grouping_type"] = form_input_validate($host_grouping_type, "host_grouping_type", "", true, 3);
997 -       $save["sort_children_type"] = form_input_validate($sort_children_type, "sort_children_type", "", true, 3);
998 -
999 -       $tree_item_id = 0;
1000 -
1001 -       if (!is_error_message()) {
1002 -               $tree_item_id = sql_save($save, "graph_tree_items");
1003 -
1004 -               if ($tree_item_id) {
1005 -                       raise_message(1);
1006 -
1007 -                       /* re-parent the branch if the parent item has changed */
1008 -                       if ($parent_tree_item_id != $tree_item_id) {
1009 -                               reparent_branch($parent_tree_item_id, $tree_item_id);
1010 -                       }
1011 -
1012 -                       $tree_sort_type = db_fetch_cell("select sort_type from graph_tree where id='$tree_id'");
1013 -
1014 -                       /* tree item ordering */
1015 -                       if ($tree_sort_type == TREE_ORDERING_NONE) {
1016 -                               /* resort our parent */
1017 -                               $parent_sorting_type = db_fetch_cell("select sort_children_type from graph_tree_items where id=$parent_tree_item_id");
1018 -
1019 -                               if ((!empty($parent_tree_item_id)) && ($parent_sorting_type != TREE_ORDERING_NONE)) {
1020 -                                       sort_tree(SORT_TYPE_TREE_ITEM, $parent_tree_item_id, $parent_sorting_type);
1021 -                               }
1022 -
1023 -                               /* if this is a header, sort direct children */
1024 -                               if (($type == TREE_ITEM_TYPE_HEADER) && ($sort_children_type != TREE_ORDERING_NONE)) {
1025 -                                       sort_tree(SORT_TYPE_TREE_ITEM, $tree_item_id, $sort_children_type);
1026 -                               }
1027 -                               /* tree ordering */
1028 -                       }else{
1029 -                               /* potential speed savings for large trees */
1030 -                               if (tree_tier($save["order_key"]) == 1) {
1031 -                                       sort_tree(SORT_TYPE_TREE, $tree_id, $tree_sort_type);
1032 -                               }else{
1033 -                                       sort_tree(SORT_TYPE_TREE_ITEM, $parent_tree_item_id, $tree_sort_type);
1034 -                               }
1035 -                       }
1036 -
1037 -                       /* if the user checked the 'Propagate Changes' box */
1038 -                       if (($type == TREE_ITEM_TYPE_HEADER) && ($propagate_changes == true)) {
1039 -                               $search_key = preg_replace("/0+$/", "", $order_key);
1040 -
1041 -                               $tree_items = db_fetch_assoc("select
1042 -                                       graph_tree_items.id
1043 -                                       from graph_tree_items
1044 -                                       where graph_tree_items.host_id = 0
1045 -                                       and graph_tree_items.local_graph_id = 0
1046 -                                       and graph_tree_items.title != ''
1047 -                                       and graph_tree_items.order_key like '$search_key%%'
1048 -                                       and graph_tree_items.graph_tree_id='$tree_id'");
1049 -
1050 -                               if (sizeof($tree_items) > 0) {
1051 -                                       foreach ($tree_items as $item) {
1052 -                                               db_execute("update graph_tree_items set sort_children_type = '$sort_children_type' where id = '" . $item["id"] . "'");
1053 -
1054 -                                               if ($sort_children_type != TREE_ORDERING_NONE) {
1055 -                                                       sort_tree(SORT_TYPE_TREE_ITEM, $item["id"], $sort_children_type);
1056 -                                               }
1057 -                                       }
1058 -                               }
1059 -                       }
1060 -               }else{
1061 -                       raise_message(2);
1062 -               }
1063 -       }
1064 -
1065 -       return $tree_item_id;
1066 -}
1067 -
1068  function getHostTemplates() {
1069         $tmpArray = db_fetch_assoc("select id, name from host_template order by id");
1070  
1071 diff -Naur cacti-0.8.7g/lib/api_device.php cacti-0.8.7g-PA-v2.9/lib/api_device.php
1072 --- cacti-0.8.7g/lib/api_device.php     2010-07-09 18:33:46.000000000 -0400
1073 +++ cacti-0.8.7g-PA-v2.9/lib/api_device.php     2010-10-17 20:09:52.000000000 -0400
1074 @@ -137,6 +137,8 @@
1075         $save["ping_retries"]         = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3);
1076         $save["max_oids"]             = form_input_validate($max_oids, "max_oids", "^[0-9]+$", true, 3);
1077  
1078 +       $save = api_plugin_hook_function('api_device_save', $save);
1079 +
1080         $host_id = 0;
1081  
1082         if (!is_error_message()) {
1083 @@ -176,11 +178,16 @@
1084                         if (sizeof($graph_templates) > 0) {
1085                         foreach ($graph_templates as $graph_template) {
1086                                 db_execute("replace into host_graph (host_id,graph_template_id) values ($host_id," . $graph_template["graph_template_id"] . ")");
1087 +                               api_plugin_hook_function('add_graph_template_to_host', array("host_id" => $host_id, "graph_template_id" => $graph_template["graph_template_id"]));
1088                         }
1089                         }
1090                 }
1091         }
1092  
1093 +       # now that we have the id of the new host, we may plugin postprocessing code
1094 +       $save["id"] = $host_id;
1095 +       api_plugin_hook_function('api_device_new', $save);
1096 +
1097         return $host_id;
1098  }
1099  
1100 diff -Naur cacti-0.8.7g/lib/api_graph.php cacti-0.8.7g-PA-v2.9/lib/api_graph.php
1101 --- cacti-0.8.7g/lib/api_graph.php      2010-07-09 18:33:46.000000000 -0400
1102 +++ cacti-0.8.7g-PA-v2.9/lib/api_graph.php      2010-10-17 20:09:52.000000000 -0400
1103 @@ -82,7 +82,7 @@
1104  }
1105  
1106  /* api_reapply_suggested_graph_title - reapplies the suggested name to a graph title
1107 -   @arg $graph_templates_graph_id - the id of the graph to reapply the name to
1108 +   @param int $graph_templates_graph_id - the id of the graph to reapply the name to
1109  */
1110  function api_reapply_suggested_graph_title($local_graph_id) {
1111         global $config;
1112 @@ -95,11 +95,21 @@
1113                 return;
1114         }
1115  
1116 -       /* get the host associated with this graph */
1117 -       $graph_local = db_fetch_row("select host_id, graph_template_id, snmp_query_id, snmp_index from graph_local where id=" . $local_graph_id);
1118 +       /* get the host associated with this graph for data queries only
1119 +        * there's no "reapply suggested title" for "simple" graph templates */
1120 +       $graph_local = db_fetch_row("select host_id, graph_template_id, snmp_query_id, snmp_index from graph_local where snmp_query_id>0 AND id=" . $local_graph_id);
1121 +       /* if this is not a data query graph, simply return */
1122 +       if (!isset($graph_local["host_id"])) {
1123 +               return;
1124 +       }
1125         $snmp_query_graph_id = db_fetch_cell("select id from snmp_query_graph where graph_template_id=" . $graph_local["graph_template_id"] .
1126                                                                                 " and snmp_query_id=" . $graph_local["snmp_query_id"]);
1127  
1128 +       /* no snmp query graph id found */
1129 +       if ($snmp_query_graph_id == 0) {
1130 +               return;
1131 +       }
1132 +
1133         /* get the suggested values from the suggested values cache */
1134         $suggested_values = db_fetch_assoc("select text,field_name from snmp_query_graph_sv where snmp_query_graph_id=" . $snmp_query_graph_id . " order by sequence");
1135  
1136 diff -Naur cacti-0.8.7g/lib/api_tree.php cacti-0.8.7g-PA-v2.9/lib/api_tree.php
1137 --- cacti-0.8.7g/lib/api_tree.php       2010-07-09 18:33:46.000000000 -0400
1138 +++ cacti-0.8.7g-PA-v2.9/lib/api_tree.php       2010-10-17 20:09:52.000000000 -0400
1139 @@ -44,8 +44,20 @@
1140  
1141         /* duplicate graph check */
1142         $search_key = substr($parent_order_key, 0, (tree_tier($parent_order_key) * CHARS_PER_TIER));
1143 -       if (($type == TREE_ITEM_TYPE_GRAPH) && (sizeof(db_fetch_assoc("select id from graph_tree_items where local_graph_id='$local_graph_id' and rra_id='$rra_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
1144 -               return 0;
1145 +       if (($type == TREE_ITEM_TYPE_GRAPH) && (sizeof(db_fetch_assoc("select id from graph_tree_items where local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
1146 +               return db_fetch_cell("select id from graph_tree_items where local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
1147 +       }
1148 +
1149 +       /* Duplicate header check */
1150 +       if (($type == TREE_ITEM_TYPE_HEADER)) {
1151 +               if ((sizeof(db_fetch_assoc("select id from graph_tree_items where title='$title' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
1152 +                       return db_fetch_cell("select id from graph_tree_items where title='$title' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
1153 +               }
1154 +       }
1155 +
1156 +       /* Duplicate host check */
1157 +       if (($type == TREE_ITEM_TYPE_HOST) && (sizeof(db_fetch_assoc("select id from graph_tree_items where host_id='$host_id' and local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
1158 +                       return db_fetch_cell("select id from graph_tree_items where host_id='$host_id' and local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
1159         }
1160  
1161         $save["id"] = $id;
1162 diff -Naur cacti-0.8.7g/lib/auth.php cacti-0.8.7g-PA-v2.9/lib/auth.php
1163 --- cacti-0.8.7g/lib/auth.php   2010-07-09 18:33:46.000000000 -0400
1164 +++ cacti-0.8.7g-PA-v2.9/lib/auth.php   2010-10-17 20:09:52.000000000 -0400
1165 @@ -121,8 +121,9 @@
1166                 }
1167         }
1168  
1169 -       return true;
1170 +       api_plugin_hook_function('copy_user', array('template_id' => $template_id, 'new_id' => $new_id));
1171  
1172 +       return true;
1173  }
1174  
1175  
1176 @@ -152,6 +153,7 @@
1177         db_execute("delete from settings_graphs where user_id=" . $user_id);
1178         db_execute("delete from settings_tree where user_id=" . $user_id);
1179  
1180 +       api_plugin_hook_function('user_remove', $user_id);
1181  }
1182  
1183  /* user_disable - disable a user account
1184 diff -Naur cacti-0.8.7g/lib/data_query.php cacti-0.8.7g-PA-v2.9/lib/data_query.php
1185 --- cacti-0.8.7g/lib/data_query.php     2010-09-19 21:39:05.000000000 -0400
1186 +++ cacti-0.8.7g-PA-v2.9/lib/data_query.php     2010-10-17 20:09:52.000000000 -0400
1187 @@ -56,6 +56,8 @@
1188         /* update the poller cache */
1189         update_poller_cache_from_query($host_id, $snmp_query_id);
1190  
1191 +       api_plugin_hook_function('run_data_query', array("host_id" => $host_id, "snmp_query_id" => $snmp_query_id));
1192 +
1193         return (isset($result) ? $result : true);
1194  }
1195  
1196 @@ -215,7 +217,7 @@
1197                                 for ($i=0; $i<sizeof($snmp_indexes); $i++) {
1198                                         $oid = $field_array["oid"] .  "." . $snmp_indexes[$i]["value"];
1199                                         $oid .= isset($field_array["oid_suffix"]) ? ("." . $field_array["oid_suffix"]) : "";
1200 -                                       
1201 +
1202                                         $value = cacti_snmp_get($host["hostname"], $host["snmp_community"], $oid,
1203                                                 $host["snmp_version"], $host["snmp_username"], $host["snmp_password"],
1204                                                 $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"],
1205 diff -Naur cacti-0.8.7g/lib/functions.php cacti-0.8.7g-PA-v2.9/lib/functions.php
1206 --- cacti-0.8.7g/lib/functions.php      2010-07-09 18:33:46.000000000 -0400
1207 +++ cacti-0.8.7g-PA-v2.9/lib/functions.php      2010-10-17 20:09:52.000000000 -0400
1208 @@ -1689,6 +1689,8 @@
1209     @arg $type - (string) Either 'url' or 'title'
1210     @returns (string> Either the navigation text or title */
1211  function draw_navigation_text($type = "url") {
1212 +       global $config;
1213 +
1214         $nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : array());
1215  
1216         $nav = array(
1217 @@ -1701,8 +1703,8 @@
1218                 "graph.php:zoom" => array("title" => "Zoom", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
1219                 "graph.php:properties" => array("title" => "Properties", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
1220                 "graph_settings.php:" => array("title" => "Settings", "mapping" => "graph_view.php:", "url" => "graph_settings.php", "level" => "1"),
1221 -               "index.php:" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
1222 -               "index.php:login" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
1223 +               "index.php:" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
1224 +               "index.php:login" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
1225                 "graphs.php:" => array("title" => "Graph Management", "mapping" => "index.php:", "url" => "graphs.php", "level" => "1"),
1226                 "graphs.php:graph_edit" => array("title" => "(Edit)", "mapping" => "index.php:,graphs.php:", "url" => "", "level" => "2"),
1227                 "graphs.php:graph_diff" => array("title" => "Change Graph Template", "mapping" => "index.php:,graphs.php:,graphs.php:graph_edit", "url" => "", "level" => "3"),
1228 @@ -1780,6 +1782,8 @@
1229                 "templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"),
1230                 );
1231  
1232 +       $nav =  api_plugin_hook_function('draw_navigation_text', $nav);
1233 +
1234         $current_page = basename($_SERVER["PHP_SELF"]);
1235  
1236         input_validate_input_regex(get_request_var_request("action"), "^([a-zA-Z0-9_-]+)$");
1237 diff -Naur cacti-0.8.7g/lib/html_form.php cacti-0.8.7g-PA-v2.9/lib/html_form.php
1238 --- cacti-0.8.7g/lib/html_form.php      2010-09-19 21:39:05.000000000 -0400
1239 +++ cacti-0.8.7g-PA-v2.9/lib/html_form.php      2010-10-17 20:24:33.000000000 -0400
1240 @@ -1,4 +1,5 @@
1241  <?php
1242 +// $Id$
1243  /*
1244   +-------------------------------------------------------------------------+
1245   | Copyright (C) 2004-2010 The Cacti Group                                 |
1246 @@ -530,6 +531,13 @@
1247                 $form_previous_value = $form_default_value;
1248         }
1249  
1250 +       if (isset($_SESSION["sess_error_fields"])) {
1251 +               if (!empty($_SESSION["sess_error_fields"][$form_name])) {
1252 +                       $class .= (strlen($class) ? " ":"") . "txtErrorTextBox";
1253 +                       unset($_SESSION["sess_error_fields"][$form_name]);
1254 +               }
1255 +       }
1256 +
1257         if (isset($_SESSION["sess_field_values"])) {
1258                 if (!empty($_SESSION["sess_field_values"][$form_name])) {
1259                         $form_previous_value = $_SESSION["sess_field_values"][$form_name];
1260 @@ -722,11 +730,13 @@
1261       on a confirmation form
1262     @arg $cancel_url - the url to go to when the user clicks 'cancel'
1263     @arg $action_url - the url to go to when the user clicks 'delete' */
1264 -function form_confirm_buttons($action_url, $cancel_url) { ?>
1265 +function form_confirm_buttons($action_url, $cancel_url) {
1266 +       global $config;
1267 +       ?>
1268         <tr>
1269                 <td bgcolor="#E1E1E1">
1270 -                       <input type='button' onClick='cactiReturnTo("<?php print $cancel_url;?>")' value='Cancel'>
1271 -                       <input type='submit' onClick='cactiReturnTo("<?php print $action_url;?>&confirm=true")' value='Delete'>
1272 +                       <input type='button' onClick='cactiReturnTo("<?php print $config['url_path'] . $cancel_url;?>")' value='Cancel'>
1273 +                       <input type='submit' onClick='cactiReturnTo("<?php print $config['url_path'] . $action_url;?>&confirm=true")' value='Delete'>
1274                 </td>
1275         </tr>
1276  <?php }
1277 diff -Naur cacti-0.8.7g/lib/html.php cacti-0.8.7g-PA-v2.9/lib/html.php
1278 --- cacti-0.8.7g/lib/html.php   2010-07-09 18:33:46.000000000 -0400
1279 +++ cacti-0.8.7g-PA-v2.9/lib/html.php   2010-10-17 20:09:52.000000000 -0400
1280 @@ -144,14 +144,15 @@
1281                                         <table align='center' cellpadding='0'>
1282                                                 <tr>
1283                                                         <td align='center'>
1284 -                                                               <div style="min-height: <?php echo (1.6 * $graph["height"]) . "px"?>;"><a href='<?php print htmlspecialchars("graph.php?action=view&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=all");?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0" . (($extra_url_args == "") ? "" : "&$extra_url_args"));?>' border='0' alt='<?php print htmlspecialchars($graph["title_cache"]);?>'></a></div>
1285 +                                                               <div style="min-height: <?php echo (1.6 * $graph["height"]) . "px"?>;"><a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=view&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=all");?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print htmlspecialchars($config['url_path'] . "graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0" . (($extra_url_args == "") ? "" : "&$extra_url_args"));?>' border='0' alt='<?php print htmlspecialchars($graph["title_cache"]);?>'></a></div>
1286                                                                 <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?>
1287                                                         </td>
1288                                                         <td valign='top' style='align: left; padding: 3px;' class='noprint'>
1289 -                                                               <a href='<?php print htmlspecialchars("graph.php?action=zoom&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&". $extra_url_args);?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
1290 -                                                               <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
1291 -                                                               <a href='<?php print htmlspecialchars("graph.php?action=properties&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br>
1292 -                                                               <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
1293 +                                                               <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=zoom&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&". $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>
1294 +                                                               <a href='<?php print htmlspecialchars($config['url_path'] . "graph_xport.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $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>
1295 +                                                               <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=properties&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br>
1296 +                                                               <?php api_plugin_hook('graph_buttons', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' =>  0, 'view_type' => 'view')); ?>
1297 +                                                               <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>
1298                                                         </td>
1299                                                 </tr>
1300                                         </table>
1301 @@ -177,6 +178,7 @@
1302     @arg $extra_url_args - extra arguments to append to the url
1303     @arg $header - html to use as a header */
1304  function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
1305 +       global $config;
1306         $i = 0; $k = 0; $j = 0;
1307  
1308         $num_graphs = sizeof($graph_array);
1309 @@ -268,14 +270,15 @@
1310                                 <table align='center' cellpadding='0'>
1311                                         <tr>
1312                                                 <td align='center'>
1313 -                                                       <div style="min-height: <?php echo (1.6 * read_graph_config_option("default_height")) . "px"?>;"><a href='<?php print htmlspecialchars("graph.php?action=view&rra_id=all&local_graph_id=" . $graph["local_graph_id"]);?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width") . "&graph_nolegend=true" . (($extra_url_args == "") ? "" : "&$extra_url_args"));?>' border='0' alt='<?php print htmlspecialchars($graph["title_cache"]);?>'></a></div>
1314 +                                                       <div style="min-height: <?php echo (1.6 * read_graph_config_option("default_height")) . "px"?>;"><a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=view&rra_id=all&local_graph_id=" . $graph["local_graph_id"]);?>'><img class='graphimage' id='graph_<?php print $graph["local_graph_id"] ?>' src='<?php print htmlspecialchars($config["url_path"] . "graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width") . "&graph_nolegend=true" . (($extra_url_args == "") ? "" : "&$extra_url_args"));?>' border='0' alt='<?php print htmlspecialchars($graph["title_cache"]);?>'></a></div>
1315                                                         <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?>
1316                                                 </td>
1317                                                 <td valign='top' style='align: left; padding: 3px;'>
1318 -                                                       <a href='<?php print htmlspecialchars("graph.php?action=zoom&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
1319 -                                                       <a href='<?php print htmlspecialchars("graph_xport.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
1320 -                                                       <a href='<?php print htmlspecialchars("graph.php?action=properties&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br>
1321 -                                                       <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
1322 +                                                       <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=zoom&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $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>
1323 +                                                       <a href='<?php print htmlspecialchars($config['url_path'] . "graph_xport.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $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>
1324 +                                                       <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=properties&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br>
1325 +                                                       <?php api_plugin_hook('graph_buttons_thumbnails', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' =>  0, 'view_type' => '')); ?>
1326 +                                                       <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>
1327                                                 </td>
1328                                         </tr>
1329                                 </table>
1330 @@ -638,9 +641,9 @@
1331                 print "<td style='$this_row_style'>" . $item["hex"] . "</td>\n";
1332  
1333                 if ($disable_controls == false) {
1334 -                       print "<td><a href='" . htmlspecialchars("$filename?action=item_movedown&id=" . $item["id"] . "&$url_data") . "'><img src='images/move_down.gif' border='0' alt='Move Down'></a>
1335 -                                       <a href='" . htmlspecialchars("$filename?action=item_moveup&id=" . $item["id"] . "&$url_data") . "'><img src='images/move_up.gif' border='0' alt='Move Up'></a></td>\n";
1336 -                       print "<td align='right'><a href='" . htmlspecialchars("$filename?action=item_remove&id=" . $item["id"] . "&$url_data") . "'><img src='images/delete_icon.gif' style='height:10px;width:10px;' border='0' alt='Delete'></a></td>\n";
1337 +                       print "<td><a href='" . htmlspecialchars("$filename?action=item_movedown&id=" . $item["id"] . "&$url_data") . "'><img src='" . $config['url_path'] . "images/move_down.gif' border='0' alt='Move Down'></a>
1338 +                                       <a href='" . htmlspecialchars("$filename?action=item_moveup&id=" . $item["id"] . "&$url_data") . "'><img src='" . $config['url_path'] . "images/move_up.gif' border='0' alt='Move Up'></a></td>\n";
1339 +                       print "<td align='right'><a href='" . htmlspecialchars("$filename?action=item_remove&id=" . $item["id"] . "&$url_data") . "'><img src='" . $config['url_path'] . "images/delete_icon.gif' style='height:10px;width:10px;' border='0' alt='Delete'></a></td>\n";
1340                 }
1341  
1342                 print "</tr>";
1343 @@ -706,6 +709,8 @@
1344                                         }
1345  
1346                                         while (list($item_sub_url, $item_sub_title) = each($item_title)) {
1347 +                                               $item_sub_url = $config['url_path'] . $item_sub_url;
1348 +
1349                                                 /* indent sub-items */
1350                                                 if ($i > 0) {
1351                                                         $prepend_string = "---&nbsp;";
1352 @@ -715,7 +720,7 @@
1353  
1354                                                 /* do not put a line between each sub-item */
1355                                                 if (($i == 0) || ($draw_sub_items == false)) {
1356 -                                                       $background = "images/menu_line.gif";
1357 +                                                       $background = $config['url_path'] . "images/menu_line.gif";
1358                                                 }else{
1359                                                         $background = "";
1360                                                 }
1361 @@ -744,17 +749,18 @@
1362                         }else{
1363                                 if ($current_realm_id == -1 || (isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) {
1364                                         /* draw normal (non sub-item) menu item */
1365 +                                       $item_url = $config['url_path'] . $item_url;
1366                                         if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) {
1367 -                                               print "<tr><td class='textMenuItemSelected' style='background-image:url(\"images/menu_line.gif\");'><strong><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></strong></td></tr>\n";
1368 +                                               print "<tr><td class='textMenuItemSelected' style='background-image:url(\"" . $config['url_path'] . "images/menu_line.gif\");'><strong><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></strong></td></tr>\n";
1369                                         }else{
1370 -                                               print "<tr><td class='textMenuItem' style='background-image:url(\"images/menu_line.gif\");'><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></td></tr>\n";
1371 +                                               print "<tr><td class='textMenuItem' style='background-image:url(\"" . $config['url_path'] . "images/menu_line.gif\");'><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></td></tr>\n";
1372                                         }
1373                                 }
1374                         }
1375                 }
1376         }
1377  
1378 -       print "<tr><td class='textMenuItem' style='background-image:url(\"images/menu_line.gif\");'></td></tr>\n";
1379 +       print "<tr><td class='textMenuItem' style='background-image:url(\"" . $config['url_path'] . "images/menu_line.gif\");'></td></tr>\n";
1380  
1381         print "</table></td></tr>";
1382  }
1383 @@ -764,11 +770,12 @@
1384     @arg $actions_array - an array that contains a list of possible actions. this array should
1385       be compatible with the form_dropdown() function */
1386  function draw_actions_dropdown($actions_array) {
1387 +       global $config;
1388         ?>
1389         <table align='center' width='100%'>
1390                 <tr>
1391                         <td width='1' valign='top'>
1392 -                               <img src='images/arrow.gif' alt=''>&nbsp;
1393 +                               <img src='<?php echo $config['url_path']; ?>images/arrow.gif' alt='' align='middle'>&nbsp;
1394                         </td>
1395                         <td align='right'>
1396                                 Choose an action:
1397 diff -Naur cacti-0.8.7g/lib/html_tree.php cacti-0.8.7g-PA-v2.9/lib/html_tree.php
1398 --- cacti-0.8.7g/lib/html_tree.php      2010-07-09 18:33:46.000000000 -0400
1399 +++ cacti-0.8.7g-PA-v2.9/lib/html_tree.php      2010-10-17 20:09:52.000000000 -0400
1400 @@ -543,7 +543,7 @@
1401  
1402         $dhtml_tree[0] = $start;
1403         $dhtml_tree[1] = read_graph_config_option("expand_hosts");
1404 -       $dhtml_tree[2] = "foldersTree = gFld(\"\", \"\")\n";
1405 +       $dhtml_tree[2] = "var foldersTree = gFld(\"\", \"\")\n";
1406         $dhtml_tree[3] = "foldersTree.xID = \"root\"\n";
1407         $i = 3;
1408  
1409 @@ -985,6 +985,16 @@
1410         <?php
1411         html_end_box();
1412  
1413 +       do_hook_function('graph_tree_page_buttons',
1414 +               array(
1415 +                       'treeid' => $tree_id,
1416 +                       'leafid' => $leaf_id,
1417 +                       'mode' => 'tree',
1418 +                       'timespan' => $_SESSION["sess_current_timespan"],
1419 +                       'starttime' => get_current_graph_start(),
1420 +                       'endtime' => get_current_graph_end())
1421 +       );
1422 +
1423         html_start_box("", "100%", $colors["header"], "3", "center", "");
1424  
1425         $graph_list = array();
1426 @@ -1189,6 +1199,19 @@
1427                 html_graph_area($new_graph_list, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end());
1428         }
1429  
1430 +
1431 +       /* nmid start */
1432 +       if (!empty($leaf_id)) {
1433 +               do_hook_function('tree_after',$host_name.','.get_request_var("leaf_id"));
1434 +       }
1435 +
1436 +        //print '</div>';
1437 +        //print "</td></tr>";
1438 +
1439 +       do_hook_function('tree_view_page_end');
1440 +
1441 +       /* nmid end */
1442 +
1443         print $nav;
1444  
1445         html_end_box();
1446 diff -Naur cacti-0.8.7g/lib/plugins.php cacti-0.8.7g-PA-v2.9/lib/plugins.php
1447 --- cacti-0.8.7g/lib/plugins.php        1969-12-31 19:00:00.000000000 -0500
1448 +++ cacti-0.8.7g-PA-v2.9/lib/plugins.php        2010-10-17 20:09:52.000000000 -0400
1449 @@ -0,0 +1,478 @@
1450 +<?php
1451 +
1452 +
1453 +
1454 +function do_hook ($name) {
1455 +       $data = func_get_args();
1456 +       $data = api_plugin_hook ($name, $data);
1457 +       return $data;
1458 +}
1459 +
1460 +function do_hook_function($name,$parm=NULL) {
1461 +       return api_plugin_hook_function ($name, $parm);
1462 +}
1463 +
1464 +function api_user_realm_auth ($filename = '') {
1465 +       return api_plugin_user_realm_auth ($filename);
1466 +}
1467 +
1468 +/**
1469 + * This function executes a hook.
1470 + * @param string $name Name of hook to fire
1471 + * @return mixed $data
1472 + */
1473 +function api_plugin_hook ($name) {
1474 +       global $config, $plugin_hooks, $plugins_system;
1475 +       $data = func_get_args();
1476 +       $ret = '';
1477 +       $p = array();
1478 +
1479 +       $ps_where = '';
1480 +       if (sizeof($plugins_system)) {
1481 +               foreach($plugins_system as $plugin) {
1482 +                       $ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin;
1483 +               }
1484 +               $ps_where .= "')";
1485 +       }
1486 +
1487 +       /* order the plugin functions by system first, then followed by order */
1488 +       $result = db_fetch_assoc("SELECT 1 AS id, ph.name, ph.file, ph.function
1489 +               FROM plugin_hooks AS ph
1490 +               LEFT JOIN plugin_config AS pc
1491 +               ON pc.directory=ph.name
1492 +               WHERE ph.status = 1 AND hook = '$name'
1493 +               AND ph.name IN $ps_where
1494 +               UNION
1495 +               SELECT pc.id, ph.name, ph.file, ph.function
1496 +               FROM plugin_hooks AS ph
1497 +               LEFT JOIN plugin_config AS pc
1498 +               ON pc.directory=ph.name
1499 +               WHERE ph.status = 1 AND hook = '$name'
1500 +               AND ph.name NOT IN $ps_where
1501 +               ORDER BY id ASC", true);
1502 +
1503 +       if (count($result)) {
1504 +               foreach ($result as $hdata) {
1505 +                       $p[] = $hdata['name'];
1506 +                       if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
1507 +                               include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
1508 +                       }
1509 +                       $function = $hdata['function'];
1510 +                       if (function_exists($function)) {
1511 +                               $function($data);
1512 +                       }
1513 +               }
1514 +       }
1515 +
1516 +       if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
1517 +               foreach ($plugin_hooks[$name] as $pname => $function) {
1518 +                       if (function_exists($function)  && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
1519 +                               $function($data);
1520 +                       }
1521 +               }
1522 +       }
1523 +
1524 +       /* Variable-length argument lists have a slight problem when */
1525 +       /* passing values by reference. Pity. This is a workaround.  */
1526 +       return $data;
1527 +}
1528 +
1529 +function api_plugin_hook_function ($name, $parm=NULL) {
1530 +       global $config, $plugin_hooks, $plugins_system;
1531 +       $ret = $parm;
1532 +       $p = array();
1533 +       $ps_where = '';
1534 +
1535 +       if (sizeof($plugins_system)) {
1536 +               foreach($plugins_system as $plugin) {
1537 +                       $ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin;
1538 +               }
1539 +               $ps_where .= "')";
1540 +       }
1541 +
1542 +       /* order the plugin functions by system first, then followed by order */
1543 +       $result = db_fetch_assoc("SELECT 1 AS id, ph.name, ph.file, ph.function
1544 +               FROM plugin_hooks AS ph
1545 +               LEFT JOIN plugin_config AS pc
1546 +               ON pc.directory=ph.name
1547 +               WHERE ph.status = 1 AND hook = '$name'
1548 +               AND ph.name IN $ps_where
1549 +               UNION
1550 +               SELECT pc.id, ph.name, ph.file, ph.function
1551 +               FROM plugin_hooks AS ph
1552 +               LEFT JOIN plugin_config AS pc
1553 +               ON pc.directory=ph.name
1554 +               WHERE ph.status = 1 AND hook = '$name'
1555 +               AND ph.name NOT IN $ps_where
1556 +               ORDER BY id ASC", true);
1557 +
1558 +       if (count($result)) {
1559 +               foreach ($result as $hdata) {
1560 +                       $p[] = $hdata['name'];
1561 +                       if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
1562 +                               include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
1563 +                       }
1564 +                       $function = $hdata['function'];
1565 +                       if (function_exists($function)) {
1566 +                               $ret = $function($ret);
1567 +                       }
1568 +               }
1569 +       }
1570 +
1571 +       if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
1572 +               foreach ($plugin_hooks[$name] as $pname => $function) {
1573 +                       if (function_exists($function)  && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
1574 +                               $ret = $function($ret);
1575 +                       }
1576 +               }
1577 +       }
1578 +
1579 +       /* Variable-length argument lists have a slight problem when */
1580 +       /* passing values by reference. Pity. This is a workaround.  */
1581 +       return $ret;
1582 +}
1583 +
1584 +function api_plugin_db_table_create ($plugin, $table, $data) {
1585 +       global $config, $database_default;
1586 +       include_once($config["library_path"] . "/database.php");
1587 +
1588 +       $result = db_fetch_assoc("show tables from `" . $database_default . "`") or die (mysql_error());
1589 +       $tables = array();
1590 +       foreach($result as $index => $arr) {
1591 +               foreach ($arr as $t) {
1592 +                       $tables[] = $t;
1593 +               }
1594 +       }
1595 +       if (!in_array($table, $tables)) {
1596 +               $c = 0;
1597 +               $sql = 'CREATE TABLE `' . $table . "` (\n";
1598 +               foreach ($data['columns'] as $column) {
1599 +                       if (isset($column['name'])) {
1600 +                               if ($c > 0)
1601 +                                       $sql .= ",\n";
1602 +                               $sql .= '`' . $column['name'] . '`';
1603 +                               if (isset($column['type']))
1604 +                                       $sql .= ' ' . $column['type'];
1605 +                               if (isset($column['unsigned']))
1606 +                                       $sql .= ' unsigned';
1607 +                               if (isset($column['NULL']) && $column['NULL'] == false)
1608 +                                       $sql .= ' NOT NULL';
1609 +                               if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
1610 +                                       $sql .= ' default NULL';
1611 +                               if (isset($column['default']))
1612 +                                       $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
1613 +                               if (isset($column['auto_increment']))
1614 +                                       $sql .= ' auto_increment';
1615 +                               $c++;
1616 +                       }
1617 +               }
1618 +
1619 +               if (isset($data['primary'])) {
1620 +                       $sql .= ",\n PRIMARY KEY (`" . $data['primary'] . '`)';
1621 +               }
1622 +
1623 +               if (sizeof($data['keys'])) {
1624 +               foreach ($data['keys'] as $key) {
1625 +                       if (isset($key['name'])) {
1626 +                               $sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)';
1627 +                       }
1628 +               }
1629 +               }
1630 +               $sql .= ') TYPE = ' . $data['type'];
1631 +
1632 +               if (isset($data['comment'])) {
1633 +                       $sql .= " COMMENT = '" . $data['comment'] . "'";
1634 +               }
1635 +               if (db_execute($sql)) {
1636 +                       db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1637 +               }
1638 +       } else {
1639 +               db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1640 +       }
1641 +}
1642 +
1643 +function api_plugin_db_changes_remove ($plugin) {
1644 +       // Example: api_plugin_db_changes_remove ('thold');
1645 +
1646 +       $tables = db_fetch_assoc("SELECT `table` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='create'", false);
1647 +       if (count($tables)) {
1648 +               foreach ($tables as $table) {
1649 +                       db_execute("DROP TABLE IF EXISTS `" . $table['table'] . "`;");
1650 +               }
1651 +               db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false);
1652 +       }
1653 +       $columns = db_fetch_assoc("SELECT `table`, `column` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='addcolumn'", false);
1654 +       if (count($columns)) {
1655 +               foreach ($columns as $column) {
1656 +                       db_execute('ALTER TABLE `' . $column['table'] . '` DROP `' . $column['column'] . '`');
1657 +               }
1658 +               db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false);
1659 +       }
1660 +}
1661 +
1662 +function api_plugin_db_add_column ($plugin, $table, $column) {
1663 +       // Example: api_plugin_db_add_column ('thold', 'plugin_config', array('name' => 'test' . rand(1, 200), 'type' => 'varchar (255)', 'NULL' => false));
1664 +
1665 +       global $config, $database_default;
1666 +       include_once($config['library_path'] . '/database.php');
1667 +
1668 +       $result = db_fetch_assoc('show columns from `' . $table . '`') or die (mysql_error());
1669 +       $columns = array();
1670 +       foreach($result as $index => $arr) {
1671 +               foreach ($arr as $t) {
1672 +                       $columns[] = $t;
1673 +               }
1674 +       }
1675 +       if (isset($column['name']) && !in_array($column['name'], $columns)) {
1676 +               $sql = 'ALTER TABLE `' . $table . '` ADD `' . $column['name'] . '`';
1677 +               if (isset($column['type']))
1678 +                       $sql .= ' ' . $column['type'];
1679 +               if (isset($column['unsigned']))
1680 +                       $sql .= ' unsigned';
1681 +               if (isset($column['NULL']) && $column['NULL'] == false)
1682 +                       $sql .= ' NOT NULL';
1683 +               if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
1684 +                       $sql .= ' default NULL';
1685 +               if (isset($column['default']))
1686 +                       $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
1687 +               if (isset($column['auto_increment']))
1688 +                       $sql .= ' auto_increment';
1689 +               if (isset($column['after']))
1690 +                       $sql .= ' AFTER ' . $column['after'];
1691 +
1692 +               if (db_execute($sql)) {
1693 +                       db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')");
1694 +               }
1695 +       }
1696 +}
1697 +
1698 +function api_plugin_install ($plugin) {
1699 +       global $config;
1700 +       include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1701 +
1702 +       $exists = db_fetch_assoc("SELECT id FROM plugin_config WHERE directory = '$plugin'", false);
1703 +       if (sizeof($exists)) {
1704 +               db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1705 +       }
1706 +
1707 +       $name = $author = $webpage = $version = '';
1708 +       $function = 'plugin_' . $plugin . '_version';
1709 +       if (function_exists($function)){
1710 +               $info = $function();
1711 +               $name = $info['longname'];
1712 +               if (isset($info['homepage'])) {
1713 +                       $webpage = $info['homepage'];
1714 +               }elseif (isset($info['webpage'])) {
1715 +                       $webpage = $info['webpage'];
1716 +               }else{
1717 +                       $webpage = "Not Stated";
1718 +               }
1719 +               $author = $info['author'];
1720 +               $version = $info['version'];
1721 +       }
1722 +
1723 +       db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')");
1724 +
1725 +       $function = 'plugin_' . $plugin . '_install';
1726 +       if (function_exists($function)){
1727 +               $function();
1728 +               $ready = api_plugin_check_config ($plugin);
1729 +               if ($ready) {
1730 +                       // Set the plugin as "disabled" so it can go live
1731 +                       db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1732 +               } else {
1733 +                       // Set the plugin as "needs configuration"
1734 +                       db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'");
1735 +               }
1736 +       }
1737 +}
1738 +
1739 +function api_plugin_uninstall ($plugin) {
1740 +       global $config;
1741 +       include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1742 +       // Run the Plugin's Uninstall Function first
1743 +       $function = 'plugin_' . $plugin . '_uninstall';
1744 +       if (function_exists($function)) {
1745 +               $function();
1746 +       }
1747 +       api_plugin_remove_hooks ($plugin);
1748 +       api_plugin_remove_realms ($plugin);
1749 +       db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1750 +       api_plugin_db_changes_remove ($plugin);
1751 +}
1752 +
1753 +function api_plugin_check_config ($plugin) {
1754 +       global $config;
1755 +       include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1756 +       $function = 'plugin_' . $plugin . '_check_config';
1757 +       if (function_exists($function)) {
1758 +               return $function();
1759 +       }
1760 +       return TRUE;
1761 +}
1762 +
1763 +function api_plugin_enable ($plugin) {
1764 +       $ready = api_plugin_check_config ($plugin);
1765 +       if ($ready) {
1766 +               api_plugin_enable_hooks ($plugin);
1767 +               db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'");
1768 +       }
1769 +}
1770 +
1771 +function api_plugin_is_enabled ($plugin) {
1772 +       $status = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = '$plugin'", false);
1773 +       if ($status == '1')
1774 +               return true;
1775 +       return false;
1776 +}
1777 +
1778 +function api_plugin_disable ($plugin) {
1779 +       api_plugin_disable_hooks ($plugin);
1780 +       db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1781 +}
1782 +
1783 +function api_plugin_moveup($plugin) {
1784 +       global $plugins_system;
1785 +
1786 +       $sql_where = "";
1787 +       if (sizeof($plugins_system)) {
1788 +               foreach($plugins_system as $s) {
1789 +                       $sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
1790 +               }
1791 +
1792 +               $sql_where .= ")";
1793 +       }
1794 +
1795 +       $id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:""));
1796 +       $temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1;
1797 +       $prior_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config WHERE id<$id" . (strlen($sql_where) ? " AND " . $sql_where:""));
1798 +
1799 +       /* update the above plugin to the prior temp id */
1800 +       db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$prior_id");
1801 +       db_execute("UPDATE plugin_config SET id=$prior_id WHERE id=$id");
1802 +       db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id");
1803 +}
1804 +
1805 +function api_plugin_movedown($plugin) {
1806 +       global $plugins_system;
1807 +
1808 +       $sql_where = "";
1809 +       if (sizeof($plugins_system)) {
1810 +               foreach($plugins_system as $s) {
1811 +                       $sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
1812 +               }
1813 +
1814 +               $sql_where .= ")";
1815 +       }
1816 +
1817 +       $id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:""));
1818 +       $temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1;
1819 +       $next_id = db_fetch_cell("SELECT MIN(id) FROM plugin_config WHERE id>$id" . (strlen($sql_where) ? " AND " . $sql_where:""));
1820 +
1821 +       /* update the above plugin to the prior temp id */
1822 +       db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$next_id");
1823 +       db_execute("UPDATE plugin_config SET id=$next_id WHERE id=$id");
1824 +       db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id");
1825 +}
1826 +
1827 +function api_plugin_register_hook ($plugin, $hook, $function, $file) {
1828 +       $exists = db_fetch_assoc("SELECT id FROM plugin_hooks WHERE name = '$plugin' AND hook = '$hook'", false);
1829 +       if (!count($exists)) {
1830 +               $settings = array('config_settings', 'config_arrays', 'config_form');
1831 +               if (!in_array($hook, $settings)) {
1832 +                       db_execute("INSERT INTO plugin_hooks (name, hook, function, file) VALUES ('$plugin', '$hook', '$function', '$file')");
1833 +               } else {
1834 +                       db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)");
1835 +               }
1836 +       }
1837 +}
1838 +
1839 +function api_plugin_remove_hooks ($plugin) {
1840 +       db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'");
1841 +}
1842 +
1843 +function api_plugin_enable_hooks ($plugin) {
1844 +       db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'");
1845 +}
1846 +
1847 +function api_plugin_disable_hooks ($plugin) {
1848 +       db_execute("UPDATE plugin_hooks SET status = 0 WHERE name = '$plugin' AND hook != 'config_settings' AND hook != 'config_arrays' AND hook != 'config_form'");
1849 +}
1850 +
1851 +function api_plugin_register_realm ($plugin, $file, $display, $admin = false) {
1852 +       $exists = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1853 +       if (!count($exists)) {
1854 +               db_execute("INSERT INTO plugin_realms (plugin, file, display) VALUES ('$plugin', '$file', '$display')");
1855 +               if ($admin) {
1856 +                       $realm_id = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1857 +                       $realm_id = $realm_id[0]['id'] + 100;
1858 +                       $user_id = db_fetch_assoc("SELECT id FROM user_auth WHERE username = 'admin'", false);
1859 +                       if (count($user_id)) {
1860 +                               $user_id = $user_id[0]['id'];
1861 +                               $exists = db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id = $user_id and realm_id = $realm_id", false);
1862 +                               if (!count($exists)) {
1863 +                                       db_execute("INSERT INTO user_auth_realm (user_id, realm_id) VALUES ($user_id, $realm_id)");
1864 +                               }
1865 +                       }
1866 +               }
1867 +       }
1868 +}
1869 +
1870 +function api_plugin_remove_realms ($plugin) {
1871 +       $realms = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin'", false);
1872 +       foreach ($realms as $realm) {
1873 +               $id = $realm['id'] + 100;
1874 +               db_execute("DELETE FROM user_auth_realm WHERE realm_id = '$id'");
1875 +       }
1876 +       db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'");
1877 +}
1878 +
1879 +function api_plugin_load_realms () {
1880 +       global $user_auth_realms, $user_auth_realm_filenames;
1881 +       $plugin_realms = db_fetch_assoc("SELECT * FROM plugin_realms ORDER BY plugin, display", false);
1882 +       if (count($plugin_realms)) {
1883 +               foreach ($plugin_realms as $plugin_realm) {
1884 +                       $plugin_files = explode(',', $plugin_realm['file']);
1885 +                       foreach($plugin_files as $plugin_file) {
1886 +                               $user_auth_realm_filenames[$plugin_file] = $plugin_realm['id'] + 100;
1887 +                       }
1888 +                       $user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display'];
1889 +               }
1890 +       }
1891 +}
1892 +
1893 +function api_plugin_user_realm_auth ($filename = '') {
1894 +       global $user_realms, $user_auth_realms, $user_auth_realm_filenames;
1895 +       /* list all realms that this user has access to */
1896 +       if (!isset($user_realms)) {
1897 +               if (read_config_option('global_auth') == 'on' || read_config_option('auth_method') != 0) {
1898 +                       $user_realms = db_fetch_assoc("select realm_id from user_auth_realm where user_id=" . $_SESSION["sess_user_id"], false);
1899 +                       $user_realms = array_rekey($user_realms, "realm_id", "realm_id");
1900 +               }else{
1901 +                       $user_realms = $user_auth_realms;
1902 +               }
1903 +       }
1904 +       if ($filename != '' && isset($user_auth_realm_filenames[basename($filename)])) {
1905 +               if (isset($user_realms[$user_auth_realm_filenames[basename($filename)]]))
1906 +                       return TRUE;
1907 +       }
1908 +       return FALSE;
1909 +}
1910 +
1911 +function plugin_config_arrays () {
1912 +       global $menu;
1913 +       $menu['Configuration']['plugins.php'] = 'Plugin Management';
1914 +       api_plugin_load_realms ();
1915 +}
1916 +
1917 +function plugin_draw_navigation_text ($nav) {
1918 +       $nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1");
1919 +       return $nav;
1920 +}
1921 +
1922 +
1923 +
1924 +
1925 +
1926 +
1927 +
1928 diff -Naur cacti-0.8.7g/lib/poller.php cacti-0.8.7g-PA-v2.9/lib/poller.php
1929 --- cacti-0.8.7g/lib/poller.php 2010-07-09 18:33:46.000000000 -0400
1930 +++ cacti-0.8.7g-PA-v2.9/lib/poller.php 2010-10-17 20:09:52.000000000 -0400
1931 @@ -344,8 +344,11 @@
1932                                 }
1933                         }
1934                 }
1935 +               api_plugin_hook_function('poller_output', $rrd_update_array);
1936  
1937 -               $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1938 +               if (api_plugin_hook_function('poller_on_demand', $results)) {
1939 +                       $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1940 +               }
1941         }
1942  
1943         return $rrds_processed;
1944 diff -Naur cacti-0.8.7g/lib/rrd.php cacti-0.8.7g-PA-v2.9/lib/rrd.php
1945 --- cacti-0.8.7g/lib/rrd.php    2010-07-09 18:33:46.000000000 -0400
1946 +++ cacti-0.8.7g-PA-v2.9/lib/rrd.php    2010-10-17 20:09:52.000000000 -0400
1947 @@ -419,6 +419,9 @@
1948  
1949         $data_source_path = get_data_source_path($local_data_id, true);
1950  
1951 +       /* update the rrdfile if performing a fetch */
1952 +       api_plugin_hook_function('rrdtool_function_fetch_cache_check', $local_data_id);
1953 +
1954         /* build and run the rrdtool fetch command with all of our data */
1955         $cmd_line = "fetch $data_source_path AVERAGE -s $start_time -e $end_time";
1956         if ($resolution > 0) {
1957 @@ -539,6 +542,10 @@
1958                 }
1959         }
1960  
1961 +       $data = api_plugin_hook_function('rrdtool_function_graph_cache_check', array('local_graph_id' => $local_graph_id,'rra_id' => $rra_id,'rrd_struc' => $rrdtool_pipe,'graph_data_array' => $graph_data_array, 'return' => false));
1962 +       if (isset($data['return']) && $data['return'] != false)
1963 +               return $data['return'];
1964 +
1965         /* find the step and how often this graph is updated with new data */
1966         $ds_step = db_fetch_cell("select
1967                 data_template_data.rrd_step
1968 @@ -1376,6 +1383,13 @@
1969         }
1970         }
1971  
1972 +       $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));
1973 +       if (!empty($graph_array)) {
1974 +               $graph_defs = $graph_array['graph_defs'];
1975 +               $txt_graph_items = $graph_array['txt_graph_items'];
1976 +               $graph_opts = $graph_array['graph_opts'];
1977 +       }
1978 +
1979         /* either print out the source or pass the source onto rrdtool to get us a nice PNG */
1980         if (isset($graph_data_array["print_source"])) {
1981                 print "<PRE>" . htmlspecialchars(read_config_option("path_rrdtool") . " graph " . $graph_opts . $graph_defs . $txt_graph_items) . "</PRE>";
1982 @@ -1384,13 +1398,19 @@
1983                         @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrdtool_pipe);
1984                         return 0;
1985                 }else{
1986 +                       $graph_data_array = api_plugin_hook_function('prep_graph_array', $graph_data_array);
1987 +
1988                         if (isset($graph_data_array["output_flag"])) {
1989                                 $output_flag = $graph_data_array["output_flag"];
1990                         }else{
1991                                 $output_flag = RRDTOOL_OUTPUT_GRAPH_DATA;
1992                         }
1993  
1994 -                       return @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrdtool_pipe);
1995 +                       $output = @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrdtool_pipe);
1996 +
1997 +                       api_plugin_hook_function('rrdtool_function_graph_set_file', array('output' => $output, 'local_graph_id' => $local_graph_id, 'rra_id' => $rra_id));
1998 +
1999 +                       return $output;
2000                 }
2001         }
2002  }
2003 diff -Naur cacti-0.8.7g/lib/template.php cacti-0.8.7g-PA-v2.9/lib/template.php
2004 --- cacti-0.8.7g/lib/template.php       2010-07-09 18:33:46.000000000 -0400
2005 +++ cacti-0.8.7g-PA-v2.9/lib/template.php       2010-10-17 20:09:52.000000000 -0400
2006 @@ -786,6 +786,18 @@
2007                 update_graph_data_query_cache($cache_array["local_graph_id"]);
2008         }
2009  
2010 +       # now that we have the id of the new host, we may plugin postprocessing code
2011 +       $save["id"] = $cache_array["local_graph_id"];
2012 +       $save["graph_template_id"] = $graph_template_id;        // attention: unset!
2013 +       if (is_array($snmp_query_array)) {
2014 +               $save["snmp_query_id"] = $snmp_query_array["snmp_query_id"];
2015 +               $save["snmp_index"] = $snmp_query_array["snmp_index"];
2016 +       } else {
2017 +               $save["snmp_query_id"] = 0;
2018 +               $save["snmp_index"] = 0;
2019 +       }
2020 +       api_plugin_hook_function('create_complete_graph_from_template', $save);
2021 +
2022         return $cache_array;
2023  }
2024  
2025 diff -Naur cacti-0.8.7g/lib/variables.php cacti-0.8.7g-PA-v2.9/lib/variables.php
2026 --- cacti-0.8.7g/lib/variables.php      2010-07-09 18:33:46.000000000 -0400
2027 +++ cacti-0.8.7g-PA-v2.9/lib/variables.php      2010-10-17 20:09:52.000000000 -0400
2028 @@ -183,6 +183,9 @@
2029         $string = str_replace($l_escape_string . "host_max_oids" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["max_oids"], $string);
2030         $string = str_replace($l_escape_string . "host_id" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["id"], $string);
2031  
2032 +       $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));
2033 +       $string = $temp['string'];
2034 +
2035         return $string;
2036  }
2037  
2038 diff -Naur cacti-0.8.7g/plugins/index.php cacti-0.8.7g-PA-v2.9/plugins/index.php
2039 --- cacti-0.8.7g/plugins/index.php      1969-12-31 19:00:00.000000000 -0500
2040 +++ cacti-0.8.7g-PA-v2.9/plugins/index.php      2010-10-17 20:09:52.000000000 -0400
2041 @@ -0,0 +1,5 @@
2042 +<?php
2043 +
2044 +header("Location:../index.php");
2045 +
2046 +?>
2047 diff -Naur cacti-0.8.7g/plugins.php cacti-0.8.7g-PA-v2.9/plugins.php
2048 --- cacti-0.8.7g/plugins.php    1969-12-31 19:00:00.000000000 -0500
2049 +++ cacti-0.8.7g-PA-v2.9/plugins.php    2010-10-17 20:09:52.000000000 -0400
2050 @@ -0,0 +1,665 @@
2051 +<?php
2052 +/*
2053 + +-------------------------------------------------------------------------+
2054 + | Copyright (C) 2004-2010 The Cacti Group                                 |
2055 + |                                                                         |
2056 + | This program is free software; you can redistribute it and/or           |
2057 + | modify it under the terms of the GNU General Public License             |
2058 + | as published by the Free Software Foundation; either version 2          |
2059 + | of the License, or (at your option) any later version.                  |
2060 + |                                                                         |
2061 + | This program is distributed in the hope that it will be useful,         |
2062 + | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
2063 + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
2064 + | GNU General Public License for more details.                            |
2065 + +-------------------------------------------------------------------------+
2066 + | Cacti: The Complete RRDTool-based Graphing Solution                     |
2067 + +-------------------------------------------------------------------------+
2068 + | This code is designed, written, and maintained by the Cacti Group. See  |
2069 + | about.php and/or the AUTHORS file for specific developer information.   |
2070 + +-------------------------------------------------------------------------+
2071 + | http://www.cacti.net/                                                   |
2072 + +-------------------------------------------------------------------------+
2073 +*/
2074 +
2075 +include("./include/auth.php");
2076 +
2077 +define("MAX_DISPLAY_PAGES", 21);
2078 +
2079 +$actions = array("install" => "Install",
2080 +       "enable" => "Enable",
2081 +       "disable" => "Disable",
2082 +       "uninstall" => "Uninstall",
2083 +//     "check" => "Check"
2084 +);
2085 +
2086 +$status_names = array(
2087 +       -2 => 'Disabled',
2088 +       -1 => 'Active',
2089 +       0 => 'Not Installed',
2090 +       1 => 'Active',
2091 +       2 => 'Awaiting Configuration',
2092 +       3 => 'Awaiting Upgrade',
2093 +       4 => 'Installed'
2094 +);
2095 +
2096 +/* get the comprehensive list of plugins */
2097 +$pluginslist = retrieve_plugin_list();
2098 +
2099 +/* Check to see if we are installing, etc... */
2100 +$modes = array('installold', 'uninstallold', 'install', 'uninstall', 'disable', 'enable', 'check', 'moveup', 'movedown');
2101 +
2102 +if (isset($_GET['mode']) && in_array($_GET['mode'], $modes)  && isset($_GET['id'])) {
2103 +       input_validate_input_regex(get_request_var("id"), "^([a-zA-Z0-9]+)$");
2104 +
2105 +       $mode = $_GET['mode'];
2106 +       $id   = sanitize_search_string($_GET['id']);
2107 +
2108 +       switch ($mode) {
2109 +               case 'installold':
2110 +                       api_plugin_install_old($id);
2111 +                       header("Location: plugins.php");
2112 +                       exit;
2113 +                       break;
2114 +               case 'uninstallold':
2115 +                       api_plugin_uninstall_old($id);
2116 +                       header("Location: plugins.php");
2117 +                       exit;
2118 +                       break;
2119 +               case 'install':
2120 +                       api_plugin_install($id);
2121 +                       header("Location: plugins.php");
2122 +                       exit;
2123 +                       break;
2124 +               case 'uninstall':
2125 +                       if (!in_array($id, $pluginslist)) break;
2126 +                       api_plugin_uninstall($id);
2127 +                       header("Location: plugins.php");
2128 +                       exit;
2129 +                       break;
2130 +               case 'disable':
2131 +                       if (!in_array($id, $pluginslist)) break;
2132 +                       api_plugin_disable($id);
2133 +                       header("Location: plugins.php");
2134 +                       exit;
2135 +                       break;
2136 +               case 'enable':
2137 +                       if (!in_array($id, $pluginslist)) break;
2138 +                       api_plugin_enable($id);
2139 +                       header("Location: plugins.php");
2140 +                       exit;
2141 +                       break;
2142 +               case 'check':
2143 +                       if (!in_array($id, $pluginslist)) break;
2144 +                       break;
2145 +               case 'moveup':
2146 +                       if (!in_array($id, $pluginslist)) break;
2147 +                       if (is_system_plugin($id)) break;
2148 +                       api_plugin_moveup($id);
2149 +                       header("Location: plugins.php");
2150 +                       exit;
2151 +                       break;
2152 +               case 'movedown':
2153 +                       if (!in_array($id, $pluginslist)) break;
2154 +                       if (is_system_plugin($id)) break;
2155 +                       api_plugin_movedown($id);
2156 +                       header("Location: plugins.php");
2157 +                       exit;
2158 +                       break;
2159 +       }
2160 +}
2161 +
2162 +function retrieve_plugin_list () {
2163 +       $pluginslist = array();
2164 +       $temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name');
2165 +       foreach ($temp as $t) {
2166 +               $pluginslist[] = $t['directory'];
2167 +       }
2168 +       return $pluginslist;
2169 +}
2170 +
2171 +include("./include/top_header.php");
2172 +
2173 +update_show_current();
2174 +
2175 +include("./include/bottom_footer.php");
2176 +
2177 +function api_plugin_install_old ($plugin) {
2178 +       global $config;
2179 +       if (!file_exists($config['base_path'] . "/plugins/$plugin/setup.php")) {
2180 +               return false;
2181 +       }
2182 +       $oldplugins = read_config_option('oldplugins');
2183 +       if (strlen(trim($oldplugins))) {
2184 +       $oldplugins = explode(',', $oldplugins);
2185 +       }else{
2186 +               $oldplugins = array();
2187 +       }
2188 +       if (!in_array($plugin, $oldplugins)) {
2189 +               include_once($config['base_path'] . "/plugins/$plugin/setup.php");
2190 +               $function = 'plugin_init_' . $plugin;
2191 +               if (function_exists($function)){
2192 +                       $oldplugins[] = $plugin;
2193 +                       $oldplugins   = implode(',', $oldplugins);
2194 +                       set_config_option('oldplugins', $oldplugins);
2195 +                       unset($_SESSION['sess_config_array']['oldplugins']);
2196 +                       return true;
2197 +               } else {
2198 +                       return false;
2199 +               }
2200 +       }
2201 +       return false;
2202 +}
2203 +
2204 +function api_plugin_uninstall_old ($plugin) {
2205 +       global $config;
2206 +       $oldplugins = read_config_option('oldplugins');
2207 +       if (strlen(trim($oldplugins))) {
2208 +       $oldplugins = explode(',', $oldplugins);
2209 +       }else{
2210 +               $oldplugins = array();
2211 +       }
2212 +       if (!empty($oldplugins)) {
2213 +               if (in_array($plugin, $oldplugins)) {
2214 +                       for ($a = 0; $a < count($oldplugins); $a++) {
2215 +                               if ($oldplugins[$a] == $plugin) {
2216 +                                       unset($oldplugins[$a]);
2217 +                                       break;
2218 +                               }
2219 +                       }
2220 +                       $oldplugins = implode(',', $oldplugins);
2221 +                       set_config_option('oldplugins', $oldplugins);
2222 +                       unset($_SESSION['sess_config_array']['oldplugins']);
2223 +                       return true;
2224 +               }
2225 +       }
2226 +       return false;
2227 +}
2228 +
2229 +function update_show_updates () {
2230 +       global $pluginslist, $colors, $config, $plugin_architecture;
2231 +
2232 +       $cinfo = array();
2233 +       sort($pluginslist);
2234 +
2235 +       $cinfo = update_get_plugin_info ();
2236 +
2237 +       $x = 0;
2238 +
2239 +       $info = update_get_cached_plugin_info();
2240 +
2241 +       $cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ;
2242 +       if (isset($cinfo['cacti_plugin_arch']['version'])) {
2243 +               $archnew =  update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']);
2244 +       } else {
2245 +               $archnew = 0;
2246 +       }
2247 +
2248 +       if ($cactinew) {
2249 +               $x++;
2250 +               print "<tr><td width='25%' valign=top><table width='100%'>";
2251 +               html_header(array("Cacti"), 2);
2252 +               form_alternate_row_color($colors["alternate"],$colors["light"], 0);
2253 +               print "<td width='25%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr>";
2254 +               form_alternate_row_color($colors["alternate"],$colors["light"], 0);
2255 +               print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti']['changes']) . "</td></tr></table>";
2256 +       }
2257 +       if (isset($plugin_architecture['version']) && $archnew) {
2258 +               $x++;
2259 +               print "<table width='100%'>";
2260 +               html_header(array("Plugin Architecture"), 2);
2261 +               form_alternate_row_color($colors["alternate"],$colors["light"], 0);
2262 +               print "<td width='25%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td>";
2263 +               form_alternate_row_color($colors["alternate"],$colors["light"], 0);
2264 +               print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti_plugin_arch']['changes']) . "</td></tr></table>";
2265 +       }
2266 +       print "<table width='100%' cellspacing=0 cellpadding=3>";
2267 +
2268 +       foreach ($pluginslist as $plugin) {
2269 +               if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) {
2270 +                       $x++;
2271 +                       print "<table width='100%'>";
2272 +                       html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2);
2273 +                       form_alternate_row_color($colors["alternate"],$colors["light"], 0);
2274 +                       print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
2275 +                       form_alternate_row_color($colors["alternate"],$colors["light"], 0);
2276 +                       print "<td><strong>Version:</strong></td><td>" . $info[$plugin]['version'] . "</td>";
2277 +                       form_alternate_row_color($colors["alternate"],$colors["light"], 0);
2278 +                       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>";
2279 +                       form_alternate_row_color($colors["alternate"],$colors["light"], 0);
2280 +                       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>";
2281 +                       form_alternate_row_color($colors["alternate"],$colors["light"], 0);
2282 +                       print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info[$plugin]['changes']) . "</td>";
2283 +
2284 +                       print "</tr></table>";
2285 +               }
2286 +       }
2287 +       if ($x == 0)
2288 +               print "<br><center><b>There are currently no Updates!</b></center><br>";
2289 +       print "</table>";
2290 +       html_end_box(TRUE);
2291 +}
2292 +
2293 +function update_check_if_newer() {
2294 +       return false;
2295 +}
2296 +
2297 +function plugins_temp_table_exists($table) {
2298 +       return sizeof(db_fetch_row("SHOW TABLES LIKE '$table'"));
2299 +}
2300 +
2301 +function plugins_load_temp_table() {
2302 +       global $config, $plugins;
2303 +
2304 +       $pluginslist = retrieve_plugin_list();
2305 +
2306 +       if (isset($_SESSION["plugin_temp_table"])) {
2307 +               $table = $_SESSION["plugin_temp_table"];
2308 +       }else{
2309 +               $table = "plugin_temp_table_" . rand();
2310 +       }
2311 +
2312 +       while (true) {
2313 +               if (!plugins_temp_table_exists($table)) {
2314 +                       $_SESSION["plugin_temp_table"] = $table;
2315 +                       db_execute("CREATE TEMPORARY TABLE $table LIKE plugin_config");
2316 +                       db_execute("INSERT INTO $table SELECT * FROM plugin_config");
2317 +                       break;
2318 +               }else{
2319 +                       $table = "plugin_temp_table_" . rand();
2320 +               }
2321 +       }
2322 +
2323 +       $path = $config['base_path'] . '/plugins/';
2324 +       $dh = opendir($path);
2325 +       while (($file = readdir($dh)) !== false) {
2326 +               if ((is_dir("$path/$file")) && (file_exists("$path/$file/setup.php")) && (!in_array($file, $pluginslist))) {
2327 +                       include_once("$path/$file/setup.php");
2328 +                       if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) {
2329 +                               $function = $file . '_version';
2330 +                               $cinfo[$file] = $function();
2331 +                               if (!isset($cinfo[$file]['author']))   $cinfo[$file]['author']   = 'Unknown';
2332 +                               if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
2333 +                               if (isset($cinfo[$file]['webpage']))   $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
2334 +                               if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['longname'] = ucfirst($file);
2335 +                               $cinfo[$file]['status'] = -2;
2336 +                               if (in_array($file, $plugins)) {
2337 +                                       $cinfo[$file]['status'] = -1;
2338 +                               }
2339 +                               db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
2340 +                                       VALUES ('" .
2341 +                                               $file . "', '" .
2342 +                                               $cinfo[$file]['longname'] . "', '" .
2343 +                                               $cinfo[$file]['status']   . "', '" .
2344 +                                               $cinfo[$file]['author']   . "', '" .
2345 +                                               $cinfo[$file]['homepage'] . "', '" .
2346 +                                               $cinfo[$file]['version']  . "')");
2347 +                               $pluginslist[] = $file;
2348 +                       } elseif (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
2349 +                               $function               = $file . '_version';
2350 +                               $cinfo[$file]           = $function();
2351 +                               $cinfo[$file]['status'] = 0;
2352 +                               if (!isset($cinfo[$file]['author']))   $cinfo[$file]['author']   = 'Unknown';
2353 +                               if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
2354 +                               if (isset($cinfo[$file]['webpage']))   $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
2355 +                               if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['homepage'] = ucfirst($file);
2356 +
2357 +                               /* see if it's been installed as old, if so, remove from oldplugins array and session */
2358 +                               $oldplugins = read_config_option("oldplugins");
2359 +                               if (substr_count($oldplugins, $file)) {
2360 +                                       $oldplugins = str_replace($file, "", $oldplugins);
2361 +                                       $oldplugins = str_replace(",,", ",", $oldplugins);
2362 +                                       $oldplugins = trim($oldplugins, ",");
2363 +                                       set_config_option('oldplugins', $oldplugins);
2364 +                                       $_SESSION['sess_config_array']['oldplugins'] = $oldplugins;
2365 +                               }
2366 +
2367 +                               db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
2368 +                                       VALUES ('" .
2369 +                                               $file . "', '" .
2370 +                                               $cinfo[$file]['longname'] . "', '" .
2371 +                                               $cinfo[$file]['status'] . "', '" .
2372 +                                               $cinfo[$file]['author'] . "', '" .
2373 +                                               $cinfo[$file]['homepage'] . "', '" .
2374 +                                               $cinfo[$file]['version'] . "')");
2375 +                               $pluginslist[] = $file;
2376 +                       }
2377 +               }
2378 +       }
2379 +       closedir($dh);
2380 +
2381 +       return $table;
2382 +}
2383 +
2384 +function update_show_current () {
2385 +       global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names, $actions;
2386 +
2387 +       /* ================= input validation ================= */
2388 +       input_validate_input_number(get_request_var_request("page"));
2389 +       /* ==================================================== */
2390 +
2391 +       /* clean up search string */
2392 +       if (isset($_REQUEST["filter"])) {
2393 +               $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
2394 +       }
2395 +
2396 +       /* clean up sort_column */
2397 +       if (isset($_REQUEST["sort_column"])) {
2398 +               $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
2399 +       }
2400 +
2401 +       /* clean up search string */
2402 +       if (isset($_REQUEST["sort_direction"])) {
2403 +               $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
2404 +       }
2405 +
2406 +       /* if the user pushed the 'clear' button */
2407 +       if (isset($_REQUEST["clear_x"])) {
2408 +               kill_session_var("sess_plugins_filter");
2409 +               kill_session_var("sess_plugins_sort_column");
2410 +               kill_session_var("sess_plugins_sort_direction");
2411 +
2412 +               unset($_REQUEST["page"]);
2413 +               unset($_REQUEST["filter"]);
2414 +               unset($_REQUEST["sort_column"]);
2415 +               unset($_REQUEST["sort_direction"]);
2416 +               $_REQUEST["page"] = 1;
2417 +       }
2418 +
2419 +       /* remember these search fields in session vars so we don't have to keep passing them around */
2420 +       load_current_session_value("filter", "sess_plugins_filter", "");
2421 +       load_current_session_value("sort_column", "sess_plugins_sort_column", "name");
2422 +       load_current_session_value("sort_direction", "sess_plugins_sort_direction", "ASC");
2423 +       load_current_session_value("page", "sess_plugins_current_page", "1");
2424 +
2425 +       $table = plugins_load_temp_table();
2426 +
2427 +       html_start_box("<strong>Plugin Management</strong> (Cacti Version: " . $config["cacti_version"] .
2428 +               (isset($plugin_architecture['version']) ? ", Plugin Architecture Version: " . $plugin_architecture['version']:"") .
2429 +               ")", "100%", $colors["header"], "3", "center", "");
2430 +
2431 +       ?>
2432 +       <tr bgcolor="#<?php print $colors['panel'];?>">
2433 +               <td class="noprint">
2434 +               <form name="form_plugins" method="get" action="plugins.php">
2435 +                       <table width="100%" cellpadding="0" cellspacing="0">
2436 +                               <tr class="noprint">
2437 +                                       <td nowrap style='white-space: nowrap;' width="50">
2438 +                                               Search:&nbsp;
2439 +                                       </td>
2440 +                                       <td width="1">
2441 +                                               <input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>">
2442 +                                       </td>
2443 +                                       <td nowrap style='white-space: nowrap;'>
2444 +                                               &nbsp;<input type="submit" value="Go" title="Set/Refresh Filters">
2445 +                                               <input type="submit" name="clear_x" value="Clear" title="Clear Filters">
2446 +                                       </td>
2447 +                               </tr>
2448 +                       </table>
2449 +                       <input type='hidden' name='page' value='1'>
2450 +               </form>
2451 +               </td>
2452 +       </tr>
2453 +       <?php
2454 +
2455 +       html_end_box();
2456 +
2457 +       /* print checkbox form for validation */
2458 +       print "<form name='chk' method='post' action='plugins.php'>\n";
2459 +
2460 +       html_start_box("", "100%", $colors["header"], "3", "center", "");
2461 +
2462 +       /* form the 'where' clause for our main sql query */
2463 +       $sql_where = "WHERE ($table.name LIKE '%%" . get_request_var_request("filter") . "%%')";
2464 +
2465 +       if (get_request_var_request("sort_column") == "version") {
2466 +               $sortc = "version+0";
2467 +       }else{
2468 +               $sortc = get_request_var_request("sort_column");
2469 +       }
2470 +
2471 +       if (get_request_var_request("sort_column") == "id") {
2472 +               $sortd = "ASC";
2473 +       }else{
2474 +               $sortd = get_request_var_request("sort_direction");
2475 +       }
2476 +
2477 +       $total_rows = db_fetch_cell("SELECT
2478 +               count(*)
2479 +               FROM $table
2480 +               $sql_where");
2481 +
2482 +       $plugins = db_fetch_assoc("SELECT *
2483 +               FROM $table
2484 +               $sql_where
2485 +               ORDER BY " . $sortc . " " . $sortd . "
2486 +               LIMIT " . (read_config_option("num_rows_device")*(get_request_var_request("page")-1)) . "," . read_config_option("num_rows_device"));
2487 +
2488 +       db_execute("DROP TABLE $table");
2489 +
2490 +       /* generate page list */
2491 +       $url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "plugins.php?filter=" . get_request_var_request("filter"));
2492 +
2493 +       if ($total_rows == 0) {
2494 +               $nav = "<tr bgcolor='#" . $colors["header"] . "'>
2495 +                               <td colspan='9'>
2496 +                                       <table width='100%' cellspacing='0' cellpadding='0' border='0'>
2497 +                                               <tr>
2498 +                                                       <td align='center' class='textHeaderDark'>
2499 +                                                               No Plugins Found
2500 +                                                       </td>\n
2501 +                                               </tr>
2502 +                                       </table>
2503 +                               </td>
2504 +                       </tr>\n";
2505 +       }elseif ($total_rows < read_config_option("num_rows_device")) {
2506 +               $nav = "<tr bgcolor='#" . $colors["header"] . "'>
2507 +                               <td colspan='9'>
2508 +                                       <table width='100%' cellspacing='0' cellpadding='0' border='0'>
2509 +                                               <tr>
2510 +                                                       <td align='center' class='textHeaderDark'>
2511 +                                                               Showing All $total_rows Rows
2512 +                                                       </td>\n
2513 +                                               </tr>
2514 +                                       </table>
2515 +                               </td>
2516 +                       </tr>\n";
2517 +       }else{
2518 +               $nav = "<tr bgcolor='#" . $colors["header"] . "'>
2519 +                               <td colspan='9'>
2520 +                                       <table width='100%' cellspacing='0' cellpadding='0' border='0'>
2521 +                                               <tr>
2522 +                                                       <td align='left' class='textHeaderDark'>
2523 +                                                               <strong>&lt;&lt; "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("plugins.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page")-1)) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong>
2524 +                                                       </td>\n
2525 +                                                       <td align='center' class='textHeaderDark'>
2526 +                                                               Showing Rows " . ((read_config_option("num_rows_device")*(get_request_var_request("page")-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_device")) || ($total_rows < (read_config_option("num_rows_device")*get_request_var_request("page")))) ? $total_rows : (read_config_option("num_rows_device")*get_request_var_request("page"))) . " of $total_rows [$url_page_select]
2527 +                                                       </td>\n
2528 +                                                       <td align='right' class='textHeaderDark'>
2529 +                                                               <strong>"; if ((get_request_var_request("page") * read_config_option("num_rows_device")) < $total_rows) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("plugins.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page")+1)) . "'>"; } $nav .= "Next"; if ((get_request_var_request("page") * read_config_option("num_rows_device")) < $total_rows) { $nav .= "</a>"; } $nav .= " &gt;&gt;</strong>
2530 +                                                       </td>\n
2531 +                                               </tr>
2532 +                                       </table>
2533 +                               </td>
2534 +                       </tr>\n";
2535 +       }
2536 +
2537 +       print $nav;
2538 +
2539 +       $display_text = array(
2540 +               "nosort" => array("Actions", ""),
2541 +               "directory" => array("Name", "ASC"),
2542 +               "id" => array("Load Order", "ASC"),
2543 +               "name" => array("Description", "ASC"),
2544 +               "nosort1" => array("Type", "ASC"),
2545 +               "status" => array("Status", "ASC"),
2546 +               "author" => array("Author", "ASC"),
2547 +               "webpage" => array("Web Page", "ASC"),
2548 +               "version" => array("Version", "ASC"));
2549 +
2550 +       html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), 1);
2551 +
2552 +       $i = 0;
2553 +       if (sizeof($plugins)) {
2554 +               if (get_request_var_request("sort_column") == "id") {
2555 +                       $inst_system_plugins = get_system_plugins($plugins);
2556 +                       if (sizeof($inst_system_plugins)) {
2557 +                               foreach($inst_system_plugins as $plugin) {
2558 +                                       form_alternate_row_color($colors["alternate"], $colors["light"], $i); $i++;
2559 +                                       print format_plugin_row($plugin, false, false, true);
2560 +                               }
2561 +                       }
2562 +               }
2563 +
2564 +               $j = 0;
2565 +               foreach ($plugins as $plugin) {
2566 +                       if ((isset($plugins[$j+1]) && $plugins[$j+1]['status'] < 0) || (!isset($plugins[$j+1]))) {
2567 +                               $last_plugin = true;
2568 +                       }else{
2569 +                               $last_plugin = false;
2570 +                       }
2571 +                       if ($plugin['status'] <= 0 || is_system_plugin($plugin) || (get_request_var_request('sort_column') != 'id')) {
2572 +                               $load_ordering = false;
2573 +                       }else{
2574 +                               $load_ordering = true;
2575 +                       }
2576 +
2577 +                       if (get_request_var_request("sort_column") == "id") {
2578 +                               if (!is_system_plugin($plugin)) {
2579 +                                       form_alternate_row_color($colors["alternate"], $colors["light"], $i);
2580 +                                       print format_plugin_row($plugin, $last_plugin, $load_ordering, false);
2581 +                                       $i++;
2582 +                               }
2583 +                       }else{
2584 +                               form_alternate_row_color($colors["alternate"], $colors["light"], $i);
2585 +                               print format_plugin_row($plugin, $last_plugin, $load_ordering, is_system_plugin($plugin));
2586 +                               $i++;
2587 +                       }
2588 +
2589 +                       $j++;
2590 +               }
2591 +
2592 +               print $nav;
2593 +       }else{
2594 +               print "<tr><td><em>No Plugins Found</em></td></tr>";
2595 +       }
2596 +
2597 +       html_end_box(false);
2598 +
2599 +       html_start_box("", "100%", $colors["header"], "3", "center", "");
2600 +       echo "<tr><td colspan=10><strong>NOTE:</strong> Please sort by 'Load Order' to change plugin load ordering.<br><strong>NOTE:</strong> SYSTEM plugins can not be ordered.</td></tr>";
2601 +       html_end_box();
2602 +
2603 +       print "</form>\n";
2604 +}
2605 +
2606 +function format_plugin_row($plugin, $last_plugin, $include_ordering, $system_plugin) {
2607 +       global $status_names;
2608 +       static $first_plugin = true;
2609 +
2610 +       $row = plugin_actions($plugin);
2611 +       $row .= "<td><strong>" . (strlen(get_request_var_request("filter")) ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", ucfirst($plugin["directory"])) : ucfirst($plugin["directory"])) . "</strong></td>";
2612 +       if ($include_ordering) {
2613 +               $row .= "<td style='white-space:nowrap;'>";
2614 +               if (!$first_plugin) {
2615 +                       $row .= "<a href='" . htmlspecialchars("plugins.php?mode=moveup&id=" . $plugin['directory']) . "' title='Order Before Prevous Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/move_up.gif'></a>";
2616 +               }else{
2617 +                       $row .= "<a href='#' title='Can NOT Reduce Load Order' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'></a>";
2618 +               }
2619 +               if (!$last_plugin) {
2620 +                       $row .= "<a href='" . htmlspecialchars("plugins.php?mode=movedown&id=" . $plugin['directory']) . "' title='Order After Next Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/move_down.gif'></a>";
2621 +               }else{
2622 +                       $row .= "<a href='#' title='Can Increase Load Order' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'></a>";
2623 +               }
2624 +               $row .= "</td>\n";
2625 +       }else{
2626 +               $row .= "<td></td>\n";
2627 +       }
2628 +
2629 +       $row .= "<td style='white-space:nowrap;'>" . (strlen(get_request_var_request("filter")) ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $plugin["name"]) : $plugin["name"]) . "</td>\n";
2630 +       $row .= "<td style='white-space:nowrap;'>" . ($system_plugin ? "System": ($plugin['status'] < 0 ? "Old PIA":"General")) . "</td>\n";
2631 +       $row .= "<td style='white-space:nowrap;'>" . $status_names[$plugin["status"]] . "</td>\n";
2632 +       $row .= "<td style='white-space:nowrap;'>" . $plugin["author"] . "</td>\n";
2633 +       $row .= "<td><a href='" . htmlspecialchars($plugin["webpage"]) . "'>" . htmlspecialchars($plugin["webpage"]) . "</a></td>\n";
2634 +       $row .= "<td>" . $plugin["version"] . "</td>\n";
2635 +       $row .= "</tr>\n";
2636 +
2637 +       if ($include_ordering) {
2638 +               $first_plugin = false;
2639 +       }
2640 +
2641 +       return $row;
2642 +}
2643 +
2644 +function plugin_actions($plugin) {
2645 +       $link = "<td>";
2646 +       switch ($plugin['status']) {
2647 +               case "-2": // Old PA Not Installed
2648 +                       $link .= "<a href='" . htmlspecialchars("plugins.php?mode=installold&id=" . $plugin['directory']) . "' title='Install Old Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/install_icon.png'></a>";
2649 +                       $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
2650 +                       break;
2651 +               case "-1":      // Old PA Currently Active
2652 +                       $oldplugins = read_config_option('oldplugins');
2653 +                       if (strlen(trim($oldplugins))) {
2654 +                               $oldplugins = explode(',', $oldplugins);
2655 +                       }else{
2656 +                               $oldplugins = array();
2657 +                       }
2658 +                       if (in_array($plugin['directory'], $oldplugins)) {
2659 +                               $link .= "<a href='" . htmlspecialchars("plugins.php?mode=uninstallold&id=" . $plugin['directory']) . "' title='Uninstall Old Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/uninstall_icon.gif'></a>";
2660 +                       } else {
2661 +                               $link .= "<a href='#' title='Please Uninstall from config.php' class='linkEditMain'><img style='padding:1px;' align='absmiddle' border='0' src='images/install_icon_disabled.png'></a>";
2662 +                       }
2663 +                       $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
2664 +                       break;
2665 +               case "0": // Not Installed
2666 +                       $link .= "<a href='" . htmlspecialchars("plugins.php?mode=install&id=" . $plugin['directory']) . "' title='Install Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/install_icon.png'></a>";
2667 +                       $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
2668 +                       break;
2669 +               case "1":       // Currently Active
2670 +                       $link .= "<a href='" . htmlspecialchars("plugins.php?mode=uninstall&id=" . $plugin['directory']) . "' title='Uninstall Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/uninstall_icon.gif'></a>";
2671 +                       $link .= "<a href='" . htmlspecialchars("plugins.php?mode=disable&id=" . $plugin['directory']) . "' title='Disable Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/disable_icon.png'></a>";
2672 +                       break;
2673 +               case "4":       // Installed but not active
2674 +                       $link .= "<a href='" . htmlspecialchars("plugins.php?mode=uninstall&id=" . $plugin['directory']) . "' title='Uninstall Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/uninstall_icon.gif'></a>";
2675 +                       $link .= "<a href='" . htmlspecialchars("plugins.php?mode=enable&id=" . $plugin['directory']) . "' title='Enable Plugin' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/enable_icon.png'></a>";
2676 +                       break;
2677 +               default: // Old PIA
2678 +                       $link .= "<a href='#' title='Please Install/Uninstall from config.php' class='linkEditMain'><img style='padding:1px;' align='absmiddle' border='0' src='images/install_icon_disabled.png'></a>";
2679 +                       $link .= "<a href='#' title='Enabling from the UI is not supported' class='linkEditMain'><img style='padding:1px;' align='absmiddle' border='0' src='images/enable_icon_disabled.png'></a>";
2680 +                       break;
2681 +       }
2682 +       $link .= "</td>";
2683 +
2684 +       return $link;
2685 +}
2686 +
2687 +function is_system_plugin($plugin) {
2688 +       global $plugins_system;
2689 +
2690 +       if (is_array($plugin)) {
2691 +               $plugin = $plugin["directory"];
2692 +       }
2693 +
2694 +       if (!in_array($plugin, $plugins_system)) {
2695 +               return false;
2696 +       }else{
2697 +               return true;
2698 +       }
2699 +}
2700 +
2701 +function get_system_plugins($plugins) {
2702 +       $inst_system_plugins = array();
2703 +
2704 +       if (sizeof($plugins)) {
2705 +               foreach($plugins as $plugin) {
2706 +                       if (is_system_plugin($plugin)) {
2707 +                               $inst_system_plugins[] = $plugin;
2708 +                       }
2709 +               }
2710 +       }
2711 +
2712 +       return $inst_system_plugins;
2713 +}
2714 +
2715 +
2716 diff -Naur cacti-0.8.7g/poller.php cacti-0.8.7g-PA-v2.9/poller.php
2717 --- cacti-0.8.7g/poller.php     2010-09-19 21:39:06.000000000 -0400
2718 +++ cacti-0.8.7g-PA-v2.9/poller.php     2010-10-17 20:09:52.000000000 -0400
2719 @@ -108,6 +108,8 @@
2720         pcntl_signal(SIGINT, "sig_handler");
2721  }
2722  
2723 +api_plugin_hook('poller_top');
2724 +
2725  /* record the start time */
2726  list($micro,$seconds) = explode(" ", microtime());
2727  $poller_start         = $seconds + $micro;
2728 @@ -303,6 +305,8 @@
2729                         $total_procs    = $concurrent_processes;
2730                 }
2731  
2732 +               $extra_args = api_plugin_hook_function ('poller_command_args', $extra_args);
2733 +
2734                 /* Populate each execution file with appropriate information */
2735                 foreach ($polling_hosts as $item) {
2736                         if ($host_count == 1) {
2737 @@ -427,7 +431,7 @@
2738  
2739         /* record the start time for this loop */
2740         list($micro,$seconds) = explode(" ", microtime());
2741 -       $loop_end = $seconds + $micro;
2742 +       $loop_end  = $seconds + $micro;
2743         $loop_time = $loop_end - $loop_start;
2744  
2745         if ($loop_time < $poller_interval) {
2746 @@ -446,7 +450,9 @@
2747  
2748                 /* sleep the appripriate amount of time */
2749                 if ($poller_runs_completed < $poller_runs) {
2750 +                       api_plugin_hook('poller_bottom');
2751                         usleep($sleep_time * 1000000);
2752 +                       api_plugin_hook('poller_top');
2753                 }
2754         }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
2755                 cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER");
2756 @@ -493,4 +499,6 @@
2757         echo "    --debug|-d     Output debug information.  Similar to cacti's DEBUG logging level.\n\n";
2758  }
2759  
2760 +api_plugin_hook('poller_bottom');
2761 +
2762  ?>
2763 diff -Naur cacti-0.8.7g/user_admin.php cacti-0.8.7g-PA-v2.9/user_admin.php
2764 --- cacti-0.8.7g/user_admin.php 2010-07-09 18:33:46.000000000 -0400
2765 +++ cacti-0.8.7g-PA-v2.9/user_admin.php 2010-10-17 20:09:52.000000000 -0400
2766 @@ -57,9 +57,11 @@
2767                 break;
2768  
2769         default:
2770 -               include_once("include/top_header.php");
2771 -               user();
2772 -               include_once("include/bottom_footer.php");
2773 +               if (!api_plugin_hook_function('user_admin_action', get_request_var_request("action"))) {
2774 +                       include_once("include/top_header.php");
2775 +                       user();
2776 +                       include_once("include/bottom_footer.php");
2777 +               }
2778                 break;
2779  }
2780  
2781 @@ -402,6 +404,7 @@
2782                 $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);
2783                 $save["realm"] = get_request_var_post("realm", 0);
2784                 $save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3);
2785 +               $save = api_plugin_hook_function('user_admin_setup_sql_save', $save);
2786  
2787                 if (!is_error_message()) {
2788                         $user_id = sql_save($save, "user_auth");
2789 @@ -444,6 +447,8 @@
2790                                         policy_hosts = " . get_request_var_post("policy_hosts") . ",
2791                                         policy_graph_templates = " . get_request_var_post("policy_graph_templates") . "
2792                                         WHERE id = " . get_request_var_post("id"));
2793 +                       } else {
2794 +                               api_plugin_hook('user_admin_user_save');
2795                         }
2796                 }
2797         }
2798 @@ -889,6 +894,8 @@
2799                 $header_label = "[new]";
2800         }
2801  
2802 +       api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0));
2803 +
2804         html_start_box("<strong>User Management</strong> $header_label", "100%", $colors["header"], "3", "center", "");
2805  
2806         draw_edit_form(array(
2807 diff -Naur cacti-0.8.7g/utilities.php cacti-0.8.7g-PA-v2.9/utilities.php
2808 --- cacti-0.8.7g/utilities.php  2010-07-09 18:33:46.000000000 -0400
2809 +++ cacti-0.8.7g-PA-v2.9/utilities.php  2010-10-17 20:09:52.000000000 -0400
2810 @@ -123,11 +123,14 @@
2811                 include_once("./include/bottom_footer.php");
2812                 break;
2813         default:
2814 -               include_once("./include/top_header.php");
2815  
2816 -               utilities();
2817 +               if (!api_plugin_hook_function('utilities_action', $_REQUEST['action'])) {
2818 +                       include_once('./include/top_header.php');
2819  
2820 -               include_once("./include/bottom_footer.php");
2821 +                       utilities();
2822 +
2823 +                       include_once('./include/bottom_footer.php');
2824 +               }
2825                 break;
2826  }
2827  
2828 @@ -1644,6 +1647,8 @@
2829  
2830         <?php
2831  
2832 +       api_plugin_hook('utilities_list');
2833 +
2834         html_end_box();
2835  }
2836  
This page took 0.577833 seconds and 3 git commands to generate.