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
5 header("Location: index.php"); break;
6 case '3': /* default graph page */
7 header("Location: graph_view.php"); break;
9 + api_plugin_hook_function('login_options_navigate', $user['login_opts']);
12 header("Location: graph_view.php");
13 diff -Naur 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
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)) {
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");
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");
40 - if (isset($_SERVER["HTTP_REFERER"])) {
41 - $referer = $_SERVER["HTTP_REFERER"];
42 - if (basename($referer) == "logout.php") {
43 - $referer = "index.php";
45 - } else if (isset($_SERVER["REQUEST_URI"])) {
46 - $referer = $_SERVER["REQUEST_URI"];
47 - if (basename($referer) == "logout.php") {
48 - $referer = "index.php";
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
55 + if (isset($_SERVER["HTTP_REFERER"])) {
56 + $referer = $_SERVER["HTTP_REFERER"];
57 + if (basename($referer) == "logout.php") {
58 + $referer = $config['url_path'] . "index.php";
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";
66 + $referer = $config['url_path'] . "index.php";
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");
74 + header("Location: $referer");
78 case '2': /* default console page */
79 - header("Location: index.php"); break;
80 + header("Location: " . $config['url_path'] . "index.php");
83 case '3': /* default graph page */
84 - header("Location: graph_view.php"); break;
85 + header("Location: " . $config['url_path'] . "graph_view.php");
89 + api_plugin_hook_function('login_options_navigate', $user['login_opts']);
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">
99 +api_plugin_hook("login_before");
101 +$cacti_logo = $config['url_path'] . 'images/auth_login.gif';
102 +$cacti_logo = api_plugin_hook_function('cacti_image', $cacti_logo);
105 <table align="center">
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>
112 @@ -303,22 +326,29 @@
113 <td><input type="password" name="login_password" size="40" style="width: 295px;"></td>
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)));
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";
138 <tr style="height:10px;"><td></td></tr>
140 <td><input type="submit" value="Login"></td>
143 +<?php api_plugin_hook('login_after'); ?>
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
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));
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
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');
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
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"]));
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
187 +$ds_actions = api_plugin_hook_function('data_source_action_array', $ds_actions);
189 /* set default action */
190 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
193 api_reapply_suggested_data_source_title($selected_items[$i]);
194 update_data_source_title_cache($selected_items[$i]);
197 + api_plugin_hook_function('data_source_action_execute', $_POST['drp_action']);
199 header("Location: data_sources.php");
204 $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Reapply Suggested Naming to Data Source(s)'>";
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()'> <input type='submit' value='Continue'>";
213 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one data source.</span></td></tr>\n";
215 input_validate_input_number(get_request_var("host_id"));
216 /* ==================================================== */
218 + api_plugin_hook('data_source_edit_top');
220 $use_data_template = true;
225 form_save_button("data_sources.php");
227 - include_once("./include/bottom_footer.php");
228 + api_plugin_hook('data_source_edit_bottom');
230 + include_once("./include/bottom_footer.php");
233 function get_poller_interval($seconds) {
234 @@ -1310,8 +1323,10 @@
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
250 /* flush the headers now */
253 +api_plugin_hook_function('graph_image');
255 session_write_close();
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
262 include_once("./lib/html_tree.php");
263 include_once("./include/top_graph_header.php");
265 +api_plugin_hook_function('graph');
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"));
272 switch ($_REQUEST["action"]) {
274 + do_hook_function('page_buttons',
275 + array('lgid' => $_GET["local_graph_id"],
276 + 'leafid' => '',//$leaf_id,
278 + 'rraid' => $_GET["rra_id"])
281 <tr bgcolor='#<?php print $colors["header"];?>'>
282 <td colspan='3' class='textHeaderDark'>
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'])); ?>
295 + do_hook_function('tree_view_page_end');
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'])); ?>
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'])); ?>
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
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'); ?>
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
332 4 => "Convert to Graph Template"
335 +$graph_actions = api_plugin_hook_function('graphs_action_array', $graph_actions);
337 /* set default action */
338 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
342 api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
345 + api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
348 header("Location: graphs.php");
352 $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Resize Selected Graph(s)'>";
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()'> <input type='submit' value='Continue'>";
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
366 6 => "Change Availability Options"
369 +$device_actions = api_plugin_hook_function('device_action_array', $device_actions);
371 /* set default action */
372 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
375 /* ==================================================== */
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"]));
380 header("Location: host.php?action=edit&id=" . $_POST["id"]);
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);
387 + api_plugin_hook_function('device_action_execute', $_POST['drp_action']);
390 header("Location: host.php");
392 <input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
394 $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Place Device(s) on Tree'>";
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()'> <input type='submit' value='Continue'>";
403 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one device.</span></td></tr>\n";
405 input_validate_input_number(get_request_var("id"));
406 /* ==================================================== */
408 + api_plugin_hook('host_edit_top');
410 if (!empty($_GET["id"])) {
411 $host = db_fetch_row("select * from host where id=" . $_GET["id"]);
412 $header_label = "[edit: " . htmlspecialchars($host["description"]) . "]";
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'); ?>
421 @@ -1107,6 +1121,8 @@
424 form_save_button("host.php", "return");
426 + api_plugin_hook('host_edit_bottom');
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
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/");
449 if (read_config_option("auth_method") != 0) {
450 + /* handle alternate authentication realms */
451 + api_plugin_hook_function('auth_alternate_realms');
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"));
461 and user_auth_realm.realm_id='$realm_id'")) || (empty($realm_id)))) {
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>";
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>";
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">
482 <table width="450" align='center'>
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>
487 <tr style='height:10px;'><td></td></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
493 | http://www.cacti.net/ |
494 +-------------------------------------------------------------------------+
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)) {
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
517 $database_password = "cactiuser";
518 $database_port = "3306";
520 +/* load up old style plugins here */
522 +//$plugins[] = 'thold';
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/
531 /* Default session name - Session name must contain alpha characters */
532 #$cacti_session_name = "Cacti";
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
538 +-------------------------------------------------------------------------+
545 "message" => 'Save Successful.',
550 +$plugin_architecture = array(
554 +api_plugin_hook('config_arrays');
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
561 define("SNMP_CMDPHP", 1);
562 define("SNMP_WEBUI", 2);
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);
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
574 +-------------------------------------------------------------------------+
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);
584 /* file: cdef.php, action: edit */
585 @@ -1190,4 +1191,7 @@
586 "dropdown_sql" => "select id,name from snmp_query order by name"
592 +api_plugin_hook('config_form');
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
598 /* built-in snmp support */
599 $config["php_snmp_support"] = function_exists("snmpget");
602 +if (! isset($url_path)) {
605 +$config['url_path'] = $url_path;
606 +define('URL_PATH', $url_path);
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");
620 /* connect to the database server */
621 db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
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");
634 include_once($config["library_path"] . "/variables.php");
635 include_once($config["library_path"] . "/auth.php");
637 +api_plugin_hook("config_insert");
639 /* current cacti version */
640 $config["cacti_version"] = "0.8.7g";
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 @@
649 +api_plugin_hook('config_settings');
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
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.
663 +global $plugin_hooks, $plugins_system, $plugins;
664 +$plugin_hooks = array();
665 +$plugins_system = array('settings', 'boost', 'dsstats');
667 +function use_plugin ($name) {
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)) {
679 + * This function executes a hook.
680 + * @param string $name Name of hook to fire
681 + * @return mixed $data
683 +if (!is_array($plugins)) {
684 + $plugins = array();
687 +$oldplugins = read_config_option('oldplugins');
688 +if (strlen(trim($oldplugins))) {
689 + $oldplugins = explode(',', $oldplugins);
690 + $plugins = array_merge($plugins, $oldplugins);
693 +/* On startup, register all plugins configured for use. */
694 +if (isset($plugins) && is_array($plugins)) {
695 + foreach ($plugins as $name) {
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
703 $using_guest_account = false;
704 $show_console_tab = true;
706 +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
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"));
712 $_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all";
715 +$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title"));
718 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
721 - <title><?php echo draw_navigation_text("title");?></title>
722 + <title><?php echo $page_title; ?></title>
724 if (isset($_SESSION["custom"]) && $_SESSION["custom"] == true) {
725 print "<meta http-equiv=refresh content='99999'>\r\n";
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";
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'); ?>
753 +<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
754 +<body <?php print api_plugin_hook_function("body_style", "");?>>
755 <a name='page_top'></a>
757 +<body <?php print api_plugin_hook_function("body_style", "");?>>
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 - <?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>
769 + <?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');
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>';}?> <?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 }?> <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>';}?> <?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 }?> <br>
781 +<?php } elseif ($oper_mode == OPER_MODE_NOTABS) { api_plugin_hook_function('print_top_header'); } ?>
782 <tr style="height:2px;" bgcolor="#183c8f" class="noprint">
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>
788 <tr style="height:5px;" bgcolor="#e9e9e9" class="noprint">
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>)
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>)
798 @@ -114,10 +129,10 @@
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>
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;">
817 + global $graph_views;
818 load_current_session_value("action", "sess_cacti_graph_action", $graph_views[read_graph_config_option("default_tree_view_mode")]);
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
825 +-------------------------------------------------------------------------+
829 +global $colors, $config;
831 +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
832 +if ($oper_mode == OPER_MODE_RESKIN || $oper_mode == OPER_MODE_NOTABS) {
836 +$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title"));
839 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
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"] . "'\">";
855 + api_plugin_hook('page_head'); ?>
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", "");?>>
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", "");?>>
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 - <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>
875 + <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');
882 <tr style="height:2px;" bgcolor="#183c8f">
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>
888 <tr style="height:5px;" bgcolor="#e9e9e9">
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>)
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>)
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>
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">
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>
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'>
927 + <td width="100%" valign="top"><?php display_output_messages();?>
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
933 include("./include/auth.php");
934 include("./include/top_header.php");
936 +api_plugin_hook('console_before');
939 <table width="100%" align="center">
945 +api_plugin_hook('console_after');
947 include("./include/bottom_footer.php");
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
954 +-------------------------------------------------------------------------+
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) {
963 - include_once($config["library_path"] . "/tree.php");
965 - $parent_order_key = db_fetch_cell("select order_key from graph_tree_items where id=$parent_tree_item_id");
967 - /* fetch some cache variables */
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");
972 - /* edit/save - use old order_key */
973 - $order_key = db_fetch_cell("select order_key from graph_tree_items where id=$id");
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)) . "'");
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)) . "'");
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);
1001 - if (!is_error_message()) {
1002 - $tree_item_id = sql_save($save, "graph_tree_items");
1004 - if ($tree_item_id) {
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);
1012 - $tree_sort_type = db_fetch_cell("select sort_type from graph_tree where id='$tree_id'");
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");
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);
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);
1027 - /* tree ordering */
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);
1033 - sort_tree(SORT_TYPE_TREE_ITEM, $parent_tree_item_id, $tree_sort_type);
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);
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'");
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"] . "'");
1054 - if ($sort_children_type != TREE_ORDERING_NONE) {
1055 - sort_tree(SORT_TYPE_TREE_ITEM, $item["id"], $sort_children_type);
1065 - return $tree_item_id;
1068 function getHostTemplates() {
1069 $tmpArray = db_fetch_assoc("select id, name from host_template order by id");
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
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);
1078 + $save = api_plugin_hook_function('api_device_save', $save);
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"]));
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);
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
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
1110 function api_reapply_suggested_graph_title($local_graph_id) {
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"])) {
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"]);
1128 + /* no snmp query graph id found */
1129 + if ($snmp_query_graph_id == 0) {
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");
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
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)) {
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)) . "'");
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)) . "'");
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)) . "'");
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
1170 + api_plugin_hook_function('copy_user', array('template_id' => $template_id, 'new_id' => $new_id));
1177 db_execute("delete from settings_graphs where user_id=" . $user_id);
1178 db_execute("delete from settings_tree where user_id=" . $user_id);
1180 + api_plugin_hook_function('user_remove', $user_id);
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
1188 /* update the poller cache */
1189 update_poller_cache_from_query($host_id, $snmp_query_id);
1191 + api_plugin_hook_function('run_data_query', array("host_id" => $host_id, "snmp_query_id" => $snmp_query_id));
1193 return (isset($result) ? $result : true);
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"]) : "";
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") {
1214 $nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : 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"),
1232 + $nav = api_plugin_hook_function('draw_navigation_text', $nav);
1234 $current_page = basename($_SERVER["PHP_SELF"]);
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
1244 +-------------------------------------------------------------------------+
1245 | Copyright (C) 2004-2010 The Cacti Group |
1246 @@ -530,6 +531,13 @@
1247 $form_previous_value = $form_default_value;
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]);
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) {
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'>
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'>
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>" : "");?>
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>
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 = "") {
1306 $i = 0; $k = 0; $j = 0;
1308 $num_graphs = sizeof($graph_array);
1309 @@ -268,14 +270,15 @@
1310 <table align='center' cellpadding='0'>
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>" : "");?>
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>
1331 print "<td style='$this_row_style'>" . $item["hex"] . "</td>\n";
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";
1346 while (list($item_sub_url, $item_sub_title) = each($item_title)) {
1347 + $item_sub_url = $config['url_path'] . $item_sub_url;
1349 /* indent sub-items */
1351 $prepend_string = "--- ";
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";
1361 @@ -744,17 +749,18 @@
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";
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";
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";
1381 print "</table></td></tr>";
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) {
1389 <table align='center' width='100%'>
1391 <td width='1' valign='top'>
1392 - <img src='images/arrow.gif' alt=''>
1393 + <img src='<?php echo $config['url_path']; ?>images/arrow.gif' alt='' align='middle'>
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
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";
1409 @@ -985,6 +985,16 @@
1413 + do_hook_function('graph_tree_page_buttons',
1415 + 'treeid' => $tree_id,
1416 + 'leafid' => $leaf_id,
1418 + 'timespan' => $_SESSION["sess_current_timespan"],
1419 + 'starttime' => get_current_graph_start(),
1420 + 'endtime' => get_current_graph_end())
1423 html_start_box("", "100%", $colors["header"], "3", "center", "");
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());
1432 + if (!empty($leaf_id)) {
1433 + do_hook_function('tree_after',$host_name.','.get_request_var("leaf_id"));
1437 + //print "</td></tr>";
1439 + do_hook_function('tree_view_page_end');
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
1454 +function do_hook ($name) {
1455 + $data = func_get_args();
1456 + $data = api_plugin_hook ($name, $data);
1460 +function do_hook_function($name,$parm=NULL) {
1461 + return api_plugin_hook_function ($name, $parm);
1464 +function api_user_realm_auth ($filename = '') {
1465 + return api_plugin_user_realm_auth ($filename);
1469 + * This function executes a hook.
1470 + * @param string $name Name of hook to fire
1471 + * @return mixed $data
1473 +function api_plugin_hook ($name) {
1474 + global $config, $plugin_hooks, $plugins_system;
1475 + $data = func_get_args();
1480 + if (sizeof($plugins_system)) {
1481 + foreach($plugins_system as $plugin) {
1482 + $ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin;
1484 + $ps_where .= "')";
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
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);
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']);
1509 + $function = $hdata['function'];
1510 + if (function_exists($function)) {
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)) {
1524 + /* Variable-length argument lists have a slight problem when */
1525 + /* passing values by reference. Pity. This is a workaround. */
1529 +function api_plugin_hook_function ($name, $parm=NULL) {
1530 + global $config, $plugin_hooks, $plugins_system;
1535 + if (sizeof($plugins_system)) {
1536 + foreach($plugins_system as $plugin) {
1537 + $ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin;
1539 + $ps_where .= "')";
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
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);
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']);
1564 + $function = $hdata['function'];
1565 + if (function_exists($function)) {
1566 + $ret = $function($ret);
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);
1579 + /* Variable-length argument lists have a slight problem when */
1580 + /* passing values by reference. Pity. This is a workaround. */
1584 +function api_plugin_db_table_create ($plugin, $table, $data) {
1585 + global $config, $database_default;
1586 + include_once($config["library_path"] . "/database.php");
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) {
1595 + if (!in_array($table, $tables)) {
1597 + $sql = 'CREATE TABLE `' . $table . "` (\n";
1598 + foreach ($data['columns'] as $column) {
1599 + if (isset($column['name'])) {
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';
1619 + if (isset($data['primary'])) {
1620 + $sql .= ",\n PRIMARY KEY (`" . $data['primary'] . '`)';
1623 + if (sizeof($data['keys'])) {
1624 + foreach ($data['keys'] as $key) {
1625 + if (isset($key['name'])) {
1626 + $sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)';
1630 + $sql .= ') TYPE = ' . $data['type'];
1632 + if (isset($data['comment'])) {
1633 + $sql .= " COMMENT = '" . $data['comment'] . "'";
1635 + if (db_execute($sql)) {
1636 + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1639 + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1643 +function api_plugin_db_changes_remove ($plugin) {
1644 + // Example: api_plugin_db_changes_remove ('thold');
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'] . "`;");
1651 + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false);
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'] . '`');
1658 + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false);
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));
1665 + global $config, $database_default;
1666 + include_once($config['library_path'] . '/database.php');
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) {
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'];
1692 + if (db_execute($sql)) {
1693 + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')");
1698 +function api_plugin_install ($plugin) {
1700 + include_once($config['base_path'] . "/plugins/$plugin/setup.php");
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'");
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'];
1717 + $webpage = "Not Stated";
1719 + $author = $info['author'];
1720 + $version = $info['version'];
1723 + db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')");
1725 + $function = 'plugin_' . $plugin . '_install';
1726 + if (function_exists($function)){
1728 + $ready = api_plugin_check_config ($plugin);
1730 + // Set the plugin as "disabled" so it can go live
1731 + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1733 + // Set the plugin as "needs configuration"
1734 + db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'");
1739 +function api_plugin_uninstall ($plugin) {
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)) {
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);
1753 +function api_plugin_check_config ($plugin) {
1755 + include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1756 + $function = 'plugin_' . $plugin . '_check_config';
1757 + if (function_exists($function)) {
1758 + return $function();
1763 +function api_plugin_enable ($plugin) {
1764 + $ready = api_plugin_check_config ($plugin);
1766 + api_plugin_enable_hooks ($plugin);
1767 + db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'");
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')
1778 +function api_plugin_disable ($plugin) {
1779 + api_plugin_disable_hooks ($plugin);
1780 + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1783 +function api_plugin_moveup($plugin) {
1784 + global $plugins_system;
1787 + if (sizeof($plugins_system)) {
1788 + foreach($plugins_system as $s) {
1789 + $sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
1792 + $sql_where .= ")";
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:""));
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");
1805 +function api_plugin_movedown($plugin) {
1806 + global $plugins_system;
1809 + if (sizeof($plugins_system)) {
1810 + foreach($plugins_system as $s) {
1811 + $sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
1814 + $sql_where .= ")";
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:""));
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");
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')");
1834 + db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)");
1839 +function api_plugin_remove_hooks ($plugin) {
1840 + db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'");
1843 +function api_plugin_enable_hooks ($plugin) {
1844 + db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'");
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'");
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')");
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)");
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'");
1876 + db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'");
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;
1888 + $user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display'];
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");
1901 + $user_realms = $user_auth_realms;
1904 + if ($filename != '' && isset($user_auth_realm_filenames[basename($filename)])) {
1905 + if (isset($user_realms[$user_auth_realm_filenames[basename($filename)]]))
1911 +function plugin_config_arrays () {
1913 + $menu['Configuration']['plugins.php'] = 'Plugin Management';
1914 + api_plugin_load_realms ();
1917 +function plugin_draw_navigation_text ($nav) {
1918 + $nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1");
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 @@
1935 + api_plugin_hook_function('poller_output', $rrd_update_array);
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);
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
1949 $data_source_path = get_data_source_path($local_data_id, true);
1951 + /* update the rrdfile if performing a fetch */
1952 + api_plugin_hook_function('rrdtool_function_fetch_cache_check', $local_data_id);
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 @@
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'];
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 @@
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'];
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);
1986 + $graph_data_array = api_plugin_hook_function('prep_graph_array', $graph_data_array);
1988 if (isset($graph_data_array["output_flag"])) {
1989 $output_flag = $graph_data_array["output_flag"];
1991 $output_flag = RRDTOOL_OUTPUT_GRAPH_DATA;
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);
1997 + api_plugin_hook_function('rrdtool_function_graph_set_file', array('output' => $output, 'local_graph_id' => $local_graph_id, 'rra_id' => $rra_id));
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"]);
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"];
2017 + $save["snmp_query_id"] = 0;
2018 + $save["snmp_index"] = 0;
2020 + api_plugin_hook_function('create_complete_graph_from_template', $save);
2022 return $cache_array;
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
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);
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'];
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
2044 +header("Location:../index.php");
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
2053 + +-------------------------------------------------------------------------+
2054 + | Copyright (C) 2004-2010 The Cacti Group |
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. |
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 + +-------------------------------------------------------------------------+
2075 +include("./include/auth.php");
2077 +define("MAX_DISPLAY_PAGES", 21);
2079 +$actions = array("install" => "Install",
2080 + "enable" => "Enable",
2081 + "disable" => "Disable",
2082 + "uninstall" => "Uninstall",
2083 +// "check" => "Check"
2086 +$status_names = array(
2089 + 0 => 'Not Installed',
2091 + 2 => 'Awaiting Configuration',
2092 + 3 => 'Awaiting Upgrade',
2096 +/* get the comprehensive list of plugins */
2097 +$pluginslist = retrieve_plugin_list();
2099 +/* Check to see if we are installing, etc... */
2100 +$modes = array('installold', 'uninstallold', 'install', 'uninstall', 'disable', 'enable', 'check', 'moveup', 'movedown');
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]+)$");
2105 + $mode = $_GET['mode'];
2106 + $id = sanitize_search_string($_GET['id']);
2109 + case 'installold':
2110 + api_plugin_install_old($id);
2111 + header("Location: plugins.php");
2114 + case 'uninstallold':
2115 + api_plugin_uninstall_old($id);
2116 + header("Location: plugins.php");
2120 + api_plugin_install($id);
2121 + header("Location: plugins.php");
2125 + if (!in_array($id, $pluginslist)) break;
2126 + api_plugin_uninstall($id);
2127 + header("Location: plugins.php");
2131 + if (!in_array($id, $pluginslist)) break;
2132 + api_plugin_disable($id);
2133 + header("Location: plugins.php");
2137 + if (!in_array($id, $pluginslist)) break;
2138 + api_plugin_enable($id);
2139 + header("Location: plugins.php");
2143 + if (!in_array($id, $pluginslist)) break;
2146 + if (!in_array($id, $pluginslist)) break;
2147 + if (is_system_plugin($id)) break;
2148 + api_plugin_moveup($id);
2149 + header("Location: plugins.php");
2153 + if (!in_array($id, $pluginslist)) break;
2154 + if (is_system_plugin($id)) break;
2155 + api_plugin_movedown($id);
2156 + header("Location: plugins.php");
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'];
2168 + return $pluginslist;
2171 +include("./include/top_header.php");
2173 +update_show_current();
2175 +include("./include/bottom_footer.php");
2177 +function api_plugin_install_old ($plugin) {
2179 + if (!file_exists($config['base_path'] . "/plugins/$plugin/setup.php")) {
2182 + $oldplugins = read_config_option('oldplugins');
2183 + if (strlen(trim($oldplugins))) {
2184 + $oldplugins = explode(',', $oldplugins);
2186 + $oldplugins = array();
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']);
2204 +function api_plugin_uninstall_old ($plugin) {
2206 + $oldplugins = read_config_option('oldplugins');
2207 + if (strlen(trim($oldplugins))) {
2208 + $oldplugins = explode(',', $oldplugins);
2210 + $oldplugins = array();
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]);
2220 + $oldplugins = implode(',', $oldplugins);
2221 + set_config_option('oldplugins', $oldplugins);
2222 + unset($_SESSION['sess_config_array']['oldplugins']);
2229 +function update_show_updates () {
2230 + global $pluginslist, $colors, $config, $plugin_architecture;
2233 + sort($pluginslist);
2235 + $cinfo = update_get_plugin_info ();
2239 + $info = update_get_cached_plugin_info();
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']);
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>";
2257 + if (isset($plugin_architecture['version']) && $archnew) {
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>";
2266 + print "<table width='100%' cellspacing=0 cellpadding=3>";
2268 + foreach ($pluginslist as $plugin) {
2269 + if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) {
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>";
2284 + print "</tr></table>";
2288 + print "<br><center><b>There are currently no Updates!</b></center><br>";
2290 + html_end_box(TRUE);
2293 +function update_check_if_newer() {
2297 +function plugins_temp_table_exists($table) {
2298 + return sizeof(db_fetch_row("SHOW TABLES LIKE '$table'"));
2301 +function plugins_load_temp_table() {
2302 + global $config, $plugins;
2304 + $pluginslist = retrieve_plugin_list();
2306 + if (isset($_SESSION["plugin_temp_table"])) {
2307 + $table = $_SESSION["plugin_temp_table"];
2309 + $table = "plugin_temp_table_" . rand();
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");
2319 + $table = "plugin_temp_table_" . rand();
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;
2339 + db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
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);
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;
2367 + db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
2370 + $cinfo[$file]['longname'] . "', '" .
2371 + $cinfo[$file]['status'] . "', '" .
2372 + $cinfo[$file]['author'] . "', '" .
2373 + $cinfo[$file]['homepage'] . "', '" .
2374 + $cinfo[$file]['version'] . "')");
2375 + $pluginslist[] = $file;
2384 +function update_show_current () {
2385 + global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names, $actions;
2387 + /* ================= input validation ================= */
2388 + input_validate_input_number(get_request_var_request("page"));
2389 + /* ==================================================== */
2391 + /* clean up search string */
2392 + if (isset($_REQUEST["filter"])) {
2393 + $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
2396 + /* clean up sort_column */
2397 + if (isset($_REQUEST["sort_column"])) {
2398 + $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
2401 + /* clean up search string */
2402 + if (isset($_REQUEST["sort_direction"])) {
2403 + $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
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");
2412 + unset($_REQUEST["page"]);
2413 + unset($_REQUEST["filter"]);
2414 + unset($_REQUEST["sort_column"]);
2415 + unset($_REQUEST["sort_direction"]);
2416 + $_REQUEST["page"] = 1;
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");
2425 + $table = plugins_load_temp_table();
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", "");
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">
2441 + <input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>">
2443 + <td nowrap style='white-space: nowrap;'>
2444 + <input type="submit" value="Go" title="Set/Refresh Filters">
2445 + <input type="submit" name="clear_x" value="Clear" title="Clear Filters">
2449 + <input type='hidden' name='page' value='1'>
2457 + /* print checkbox form for validation */
2458 + print "<form name='chk' method='post' action='plugins.php'>\n";
2460 + html_start_box("", "100%", $colors["header"], "3", "center", "");
2462 + /* form the 'where' clause for our main sql query */
2463 + $sql_where = "WHERE ($table.name LIKE '%%" . get_request_var_request("filter") . "%%')";
2465 + if (get_request_var_request("sort_column") == "version") {
2466 + $sortc = "version+0";
2468 + $sortc = get_request_var_request("sort_column");
2471 + if (get_request_var_request("sort_column") == "id") {
2474 + $sortd = get_request_var_request("sort_direction");
2477 + $total_rows = db_fetch_cell("SELECT
2482 + $plugins = db_fetch_assoc("SELECT *
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"));
2488 + db_execute("DROP TABLE $table");
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"));
2493 + if ($total_rows == 0) {
2494 + $nav = "<tr bgcolor='#" . $colors["header"] . "'>
2496 + <table width='100%' cellspacing='0' cellpadding='0' border='0'>
2498 + <td align='center' class='textHeaderDark'>
2505 + }elseif ($total_rows < read_config_option("num_rows_device")) {
2506 + $nav = "<tr bgcolor='#" . $colors["header"] . "'>
2508 + <table width='100%' cellspacing='0' cellpadding='0' border='0'>
2510 + <td align='center' class='textHeaderDark'>
2511 + Showing All $total_rows Rows
2518 + $nav = "<tr bgcolor='#" . $colors["header"] . "'>
2520 + <table width='100%' cellspacing='0' cellpadding='0' border='0'>
2522 + <td align='left' class='textHeaderDark'>
2523 + <strong><< "; 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>
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]
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 .= " >></strong>
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"));
2550 + html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), 1);
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);
2565 + foreach ($plugins as $plugin) {
2566 + if ((isset($plugins[$j+1]) && $plugins[$j+1]['status'] < 0) || (!isset($plugins[$j+1]))) {
2567 + $last_plugin = true;
2569 + $last_plugin = false;
2571 + if ($plugin['status'] <= 0 || is_system_plugin($plugin) || (get_request_var_request('sort_column') != 'id')) {
2572 + $load_ordering = false;
2574 + $load_ordering = true;
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);
2584 + form_alternate_row_color($colors["alternate"], $colors["light"], $i);
2585 + print format_plugin_row($plugin, $last_plugin, $load_ordering, is_system_plugin($plugin));
2594 + print "<tr><td><em>No Plugins Found</em></td></tr>";
2597 + html_end_box(false);
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>";
2603 + print "</form>\n";
2606 +function format_plugin_row($plugin, $last_plugin, $include_ordering, $system_plugin) {
2607 + global $status_names;
2608 + static $first_plugin = true;
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>";
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>";
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>";
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>";
2624 + $row .= "</td>\n";
2626 + $row .= "<td></td>\n";
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";
2637 + if ($include_ordering) {
2638 + $first_plugin = false;
2644 +function plugin_actions($plugin) {
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'>";
2651 + case "-1": // Old PA Currently Active
2652 + $oldplugins = read_config_option('oldplugins');
2653 + if (strlen(trim($oldplugins))) {
2654 + $oldplugins = explode(',', $oldplugins);
2656 + $oldplugins = array();
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>";
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>";
2663 + $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
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'>";
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>";
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>";
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>";
2687 +function is_system_plugin($plugin) {
2688 + global $plugins_system;
2690 + if (is_array($plugin)) {
2691 + $plugin = $plugin["directory"];
2694 + if (!in_array($plugin, $plugins_system)) {
2701 +function get_system_plugins($plugins) {
2702 + $inst_system_plugins = array();
2704 + if (sizeof($plugins)) {
2705 + foreach($plugins as $plugin) {
2706 + if (is_system_plugin($plugin)) {
2707 + $inst_system_plugins[] = $plugin;
2712 + return $inst_system_plugins;
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
2720 pcntl_signal(SIGINT, "sig_handler");
2723 +api_plugin_hook('poller_top');
2725 /* record the start time */
2726 list($micro,$seconds) = explode(" ", microtime());
2727 $poller_start = $seconds + $micro;
2729 $total_procs = $concurrent_processes;
2732 + $extra_args = api_plugin_hook_function ('poller_command_args', $extra_args);
2734 /* Populate each execution file with appropriate information */
2735 foreach ($polling_hosts as $item) {
2736 if ($host_count == 1) {
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;
2745 if ($loop_time < $poller_interval) {
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');
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");
2757 echo " --debug|-d Output debug information. Similar to cacti's DEBUG logging level.\n\n";
2760 +api_plugin_hook('poller_bottom');
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
2770 - include_once("include/top_header.php");
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");
2776 + include_once("include/bottom_footer.php");
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);
2787 if (!is_error_message()) {
2788 $user_id = sql_save($save, "user_auth");
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"));
2794 + api_plugin_hook('user_admin_user_save');
2799 $header_label = "[new]";
2802 + api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0));
2804 html_start_box("<strong>User Management</strong> $header_label", "100%", $colors["header"], "3", "center", "");
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");
2814 - include_once("./include/top_header.php");
2817 + if (!api_plugin_hook_function('utilities_action', $_REQUEST['action'])) {
2818 + include_once('./include/top_header.php');
2820 - include_once("./include/bottom_footer.php");
2823 + include_once('./include/bottom_footer.php');
2828 @@ -1644,6 +1647,8 @@
2832 + api_plugin_hook('utilities_list');