1 diff -Naur cacti-0.8.7g-old/auth_changepassword.php cacti-0.8.7g/auth_changepassword.php
2 --- cacti-0.8.7g-old/auth_changepassword.php 2010-07-09 18:33:46.000000000 -0400
3 +++ cacti-0.8.7g/auth_changepassword.php 2010-07-09 18:34:11.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-old/auth_login.php cacti-0.8.7g/auth_login.php
14 --- cacti-0.8.7g-old/auth_login.php 2010-07-09 18:33:46.000000000 -0400
15 +++ cacti-0.8.7g/auth_login.php 2010-07-09 18:34:11.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 --- cacti-0.8.7g/data_sources.php~ 2010-12-13 11:59:32.000000000 +0200
148 +++ cacti-0.8.7g/data_sources.php 2010-12-13 12:00:13.152496733 +0200
153 +$ds_actions = api_plugin_hook_function('data_source_action_array', $ds_actions);
155 /* set default action */
156 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
159 api_reapply_suggested_data_source_title($selected_items[$i]);
160 update_data_source_title_cache($selected_items[$i]);
163 + api_plugin_hook_function('data_source_action_execute', $_POST['drp_action']);
165 header("Location: data_sources.php");
170 $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Reapply Suggested Naming to Data Source(s)'>";
172 + $save['drp_action'] = $_POST['drp_action'];
173 + $save['ds_list'] = $ds_list;
174 + $save['ds_array'] = (isset($ds_array)? $ds_array : array());
175 + api_plugin_hook_function('data_source_action_prepare', $save);
176 + $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue'>";
179 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one data source.</span></td></tr>\n";
181 input_validate_input_number(get_request_var("host_id"));
182 /* ==================================================== */
184 + api_plugin_hook('data_source_edit_top');
186 $use_data_template = true;
191 form_save_button("data_sources.php");
193 - include_once("./include/bottom_footer.php");
194 + api_plugin_hook('data_source_edit_bottom');
196 + include_once("./include/bottom_footer.php");
199 function get_poller_interval($seconds) {
200 @@ -1323,6 +1323,7 @@
202 if (sizeof($data_sources) > 0) {
203 foreach ($data_sources as $data_source) {
204 + $data_source = api_plugin_hook_function('data_sources_table', $data_source);
205 /* we're escaping strings here, so no need to escape them on form_selectable_cell */
206 $data_template_name = ((empty($data_source["data_template_name"])) ? "<em>None</em>" : htmlspecialchars($data_source["data_template_name"]));
207 $data_input_name = ((empty($data_source["data_input_name"])) ? "<em>External</em>" : htmlspecialchars($data_source["data_input_name"]));
208 diff -Naur cacti-0.8.7g-old/graph_image.php cacti-0.8.7g/graph_image.php
209 --- cacti-0.8.7g-old/graph_image.php 2010-07-09 18:33:46.000000000 -0400
210 +++ cacti-0.8.7g/graph_image.php 2010-07-09 18:34:11.000000000 -0400
212 /* flush the headers now */
215 +api_plugin_hook_function('graph_image');
217 session_write_close();
219 $graph_data_array = array();
220 diff -Naur cacti-0.8.7g-old/graph.php cacti-0.8.7g/graph.php
221 --- cacti-0.8.7g-old/graph.php 2010-07-09 18:33:46.000000000 -0400
222 +++ cacti-0.8.7g/graph.php 2010-07-09 18:34:11.000000000 -0400
224 include_once("./lib/html_tree.php");
225 include_once("./include/top_graph_header.php");
227 +api_plugin_hook_function('graph');
229 /* ================= input validation ================= */
230 input_validate_input_regex(get_request_var("rra_id"), "^([0-9]+|all)$");
231 input_validate_input_number(get_request_var("local_graph_id"));
233 <table width='1' cellpadding='0'>
236 - <img class='graphimage' id='graph_<?php print $_GET["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?action=view&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"]);?>' border='0' alt='<?php print htmlspecialchars($graph_title);?>'>
237 + <img class='graphimage' id='graph_<?php print $_GET["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?action=view&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"]);?>' border='0' alt='<?php print htmlspecialchars($graph_title);?>'>
239 <td valign='top' style='padding: 3px;' class='noprint'>
240 <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>
241 <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>
242 <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>
243 + <?php api_plugin_hook('graph_buttons', array('hook' => 'view', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $rra['id'], 'view_type' => $_REQUEST['view_type'])); ?>
247 <td colspan='2' align='center'>
248 - <strong><?php print htmlspecialchars($rra["name"]);?></strong>
249 + <strong><?php print htmlspecialchars($rra["name"]);?></strong>
254 <td valign='top' style='padding: 3px;' class='noprint'>
255 <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>
256 <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>
257 + <?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'])); ?>
262 <td valign='top' style='padding: 3px;'>
263 <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>
264 <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>
265 + <?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'])); ?>
269 diff -Naur cacti-0.8.7g-old/graphs_new.php cacti-0.8.7g/graphs_new.php
270 --- cacti-0.8.7g-old/graphs_new.php 2010-07-09 18:33:46.000000000 -0400
271 +++ cacti-0.8.7g/graphs_new.php 2010-07-09 18:34:11.000000000 -0400
274 <td nowrap style='white-space: nowrap;' class="textInfo" align="center" valign="top">
275 <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>
276 - <span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit");?>">Create New Host</a>
277 + <span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit");?>">Create New Host</a><br>
278 + <?php api_plugin_hook('graphs_new_top_links'); ?>
282 diff -Naur cacti-0.8.7g-old/graphs.php cacti-0.8.7g/graphs.php
283 --- cacti-0.8.7g-old/graphs.php 2010-07-09 18:33:46.000000000 -0400
284 +++ cacti-0.8.7g/graphs.php 2010-07-09 18:34:11.000000000 -0400
286 4 => "Convert to Graph Template"
289 +$graph_actions = api_plugin_hook_function('graphs_action_array', $graph_actions);
291 /* set default action */
292 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
296 api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
299 + api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
302 header("Location: graphs.php");
306 $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Resize Selected Graph(s)'>";
308 + $save['drp_action'] = $_POST['drp_action'];
309 + $save['graph_list'] = $graph_list;
310 + $save['graph_array'] = (isset($graph_array) ? $graph_array : array());
311 + api_plugin_hook_function('graphs_action_prepare', $save);
312 + $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue'>";
315 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one graph.</span></td></tr>\n";
316 diff -Naur cacti-0.8.7g-old/host.php cacti-0.8.7g/host.php
317 --- cacti-0.8.7g-old/host.php 2010-07-09 18:33:46.000000000 -0400
318 +++ cacti-0.8.7g/host.php 2010-07-09 18:34:11.000000000 -0400
320 6 => "Change Availability Options"
323 +$device_actions = api_plugin_hook_function('device_action_array', $device_actions);
325 /* set default action */
326 if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
330 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);
333 + api_plugin_hook_function('device_action_execute', $_POST['drp_action']);
336 header("Location: host.php");
338 <input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
340 $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Place Device(s) on Tree'>";
342 + $save['drp_action'] = $_POST['drp_action'];
343 + $save['host_list'] = $host_list;
344 + $save['host_array'] = (isset($host_array)? $host_array : array());
345 + api_plugin_hook_function('device_action_prepare', $save);
346 + $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue'>";
349 print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one device.</span></td></tr>\n";
351 input_validate_input_number(get_request_var("id"));
352 /* ==================================================== */
354 + api_plugin_hook('host_edit_top');
356 if (!empty($_GET["id"])) {
357 $host = db_fetch_row("select * from host where id=" . $_GET["id"]);
358 $header_label = "[edit: " . htmlspecialchars($host["description"]) . "]";
360 <span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs_new.php?host_id=" . $host["id"]);?>">Create Graphs for this Host</a><br>
361 <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>
362 <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>
363 + <?php api_plugin_hook('device_edit_top_links'); ?>
367 @@ -1107,6 +1120,8 @@
370 form_save_button("host.php", "return");
372 + api_plugin_hook('host_edit_bottom');
376 diff -Naur cacti-0.8.7g-old/include/auth.php cacti-0.8.7g/include/auth.php
377 --- cacti-0.8.7g-old/include/auth.php 2010-07-09 18:33:46.000000000 -0400
378 +++ cacti-0.8.7g/include/auth.php 2010-07-09 18:34:11.000000000 -0400
382 if (read_config_option("auth_method") != 0) {
383 + /* handle alternate authentication realms */
384 + api_plugin_hook_function('auth_alternate_realms');
386 /* handle change password dialog */
387 if ((isset($_SESSION['sess_change_password'])) && (read_config_option("webbasic_enabled") != "on")) {
388 header ("Location: auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php"));
390 and user_auth_realm.realm_id='$realm_id'")) || (empty($realm_id)))) {
392 if (isset($_SERVER["HTTP_REFERER"])) {
393 - $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . htmlspecialchars($_SERVER["HTTP_REFERER"]) . "'>Return</a> | <a href='logout.php'>Login Again</a> )</td>";
394 + $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>";
396 - $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='logout.php'>Login Again</a> )</td>";
397 + $goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . $config['url_path'] . "logout.php'>Login Again</a> )</td>";
404 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
405 - <link href="include/main.css" type="text/css" rel="stylesheet">
406 + <link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
411 <table width="450" align='center'>
413 - <td colspan='2'><img src='images/auth_deny.gif' border='0' alt='Access Denied'></td>
414 + <td colspan='2'><img src='<?php echo $config['url_path']; ?>images/auth_deny.gif' border='0' alt='Access Denied'></td>
416 <tr style='height:10px;'><td></td></tr>
418 diff -Naur cacti-0.8.7g-old/include/bottom_footer.php cacti-0.8.7g/include/bottom_footer.php
419 --- cacti-0.8.7g-old/include/bottom_footer.php 2010-07-09 18:33:46.000000000 -0400
420 +++ cacti-0.8.7g/include/bottom_footer.php 2010-07-09 18:34:11.000000000 -0400
422 | http://www.cacti.net/ |
423 +-------------------------------------------------------------------------+
426 +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
427 +if (($oper_mode == OPER_MODE_NATIVE) || ($oper_mode == OPER_MODE_IFRAME_NONAV)) {
439 /* we use this session var to store field values for when a save fails,
440 this way we can restore the field's previous values. we reset it here, because
441 they only need to be stored for a single page */
442 diff -Naur cacti-0.8.7g-old/include/config.php cacti-0.8.7g/include/config.php
443 --- cacti-0.8.7g-old/include/config.php 2010-07-09 18:33:46.000000000 -0400
444 +++ cacti-0.8.7g/include/config.php 2010-07-09 18:34:11.000000000 -0400
446 $database_password = "cactiuser";
447 $database_port = "3306";
449 +/* load up old style plugins here */
451 +//$plugins[] = 'thold';
454 + Edit this to point to the default URL of your Cacti install
455 + ex: if your cacti install as at http://serverip/cacti/ this
456 + would be set to /cacti/
460 /* Default session name - Session name must contain alpha characters */
461 #$cacti_session_name = "Cacti";
463 diff -Naur cacti-0.8.7g-old/include/global_arrays.php cacti-0.8.7g/include/global_arrays.php
464 --- cacti-0.8.7g-old/include/global_arrays.php 2010-07-09 18:33:46.000000000 -0400
465 +++ cacti-0.8.7g/include/global_arrays.php 2010-07-09 18:34:11.000000000 -0400
467 +-------------------------------------------------------------------------+
474 "message" => 'Save Successful.',
479 +$plugin_architecture = array(
483 +api_plugin_hook('config_arrays');
486 diff -Naur cacti-0.8.7g-old/include/global_constants.php cacti-0.8.7g/include/global_constants.php
487 --- cacti-0.8.7g-old/include/global_constants.php 2010-07-09 18:33:46.000000000 -0400
488 +++ cacti-0.8.7g/include/global_constants.php 2010-07-09 18:34:11.000000000 -0400
490 define("SNMP_CMDPHP", 1);
491 define("SNMP_WEBUI", 2);
494 +define('OPER_MODE_NATIVE', 0);
495 +define('OPER_MODE_RESKIN', 1);
496 +define('OPER_MODE_IFRAME_NONAV', 2);
499 \ No newline at end of file
500 diff -Naur cacti-0.8.7g-old/include/global_form.php cacti-0.8.7g/include/global_form.php
501 --- cacti-0.8.7g-old/include/global_form.php 2010-07-09 18:33:46.000000000 -0400
502 +++ cacti-0.8.7g/include/global_form.php 2010-07-09 18:34:11.000000000 -0400
504 +-------------------------------------------------------------------------+
507 -if (!defined("VALID_HOST_FIELDS")) {
508 - 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)");
509 +if (!defined('VALID_HOST_FIELDS')) {
510 + $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)');
511 + define('VALID_HOST_FIELDS', $string);
514 /* file: cdef.php, action: edit */
515 @@ -1190,4 +1191,7 @@
516 "dropdown_sql" => "select id,name from snmp_query order by name"
522 +api_plugin_hook('config_form');
524 diff -Naur cacti-0.8.7g-old/include/global.php cacti-0.8.7g/include/global.php
525 --- cacti-0.8.7g-old/include/global.php 2010-07-09 18:33:46.000000000 -0400
526 +++ cacti-0.8.7g/include/global.php 2010-07-09 18:34:11.000000000 -0400
528 /* built-in snmp support */
529 $config["php_snmp_support"] = function_exists("snmpget");
532 +if (! isset($url_path)) {
535 +$config['url_path'] = $url_path;
536 +define('URL_PATH', $url_path);
538 /* used for includes */
539 $config["base_path"] = strtr(ereg_replace("(.*)[\\\/]include", "\\1", dirname(__FILE__)), "\\", "/");
540 $config["library_path"] = ereg_replace("(.*[\\\/])include", "\\1lib", dirname(__FILE__));
541 @@ -188,15 +195,17 @@
542 /* include base modules */
543 include($config["library_path"] . "/adodb/adodb.inc.php");
544 include($config["library_path"] . "/database.php");
545 -include_once($config["library_path"] . "/functions.php");
546 -include_once($config["include_path"] . "/global_constants.php");
547 -include_once($config["include_path"] . "/global_arrays.php");
548 -include_once($config["include_path"] . "/global_settings.php");
550 /* connect to the database server */
551 db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
553 /* include additional modules */
554 +include_once($config["library_path"] . "/functions.php");
555 +include_once($config["include_path"] . "/global_constants.php");
556 +include_once($config["library_path"] . "/plugins.php");
557 +include_once($config["include_path"] . "/plugins.php");
558 +include_once($config["include_path"] . "/global_arrays.php");
559 +include_once($config["include_path"] . "/global_settings.php");
560 include_once($config["include_path"] . "/global_form.php");
561 include_once($config["library_path"] . "/html.php");
562 include_once($config["library_path"] . "/html_form.php");
564 include_once($config["library_path"] . "/variables.php");
565 include_once($config["library_path"] . "/auth.php");
567 +api_plugin_hook("config_insert");
569 /* current cacti version */
570 $config["cacti_version"] = "0.8.7g";
572 diff -Naur cacti-0.8.7g-old/include/global_settings.php cacti-0.8.7g/include/global_settings.php
573 --- cacti-0.8.7g-old/include/global_settings.php 2010-07-09 18:33:46.000000000 -0400
574 +++ cacti-0.8.7g/include/global_settings.php 2010-07-09 18:34:11.000000000 -0400
575 @@ -1190,4 +1190,6 @@
579 +api_plugin_hook('config_settings');
582 diff -Naur cacti-0.8.7g-old/include/plugins.php cacti-0.8.7g/include/plugins.php
583 --- cacti-0.8.7g-old/include/plugins.php 1969-12-31 19:00:00.000000000 -0500
584 +++ cacti-0.8.7g/include/plugins.php 2010-07-09 18:34:11.000000000 -0400
589 + * Copyright (c) 1999-2005 The SquirrelMail Project Team (http://squirrelmail.org)
590 + * Licensed under the GNU GPL. For full terms see the file COPYING.
593 +global $plugin_hooks, $plugins_system;
594 +$plugin_hooks = array();
595 +$plugins_system = array('settings', 'boost', 'dsstats');
597 +function use_plugin ($name) {
599 + if (file_exists($config['base_path'] . "/plugins/$name/setup.php")) {
600 + include_once($config['base_path'] . "/plugins/$name/setup.php");
601 + $function = "plugin_init_$name";
602 + if (function_exists($function)) {
609 + * This function executes a hook.
610 + * @param string $name Name of hook to fire
611 + * @return mixed $data
614 +$oldplugins = read_config_option('oldplugins');
615 +$oldplugins = explode(',', $oldplugins);
616 +$plugins = array_merge($plugins, $oldplugins);
618 +/* On startup, register all plugins configured for use. */
619 +if (isset($plugins) && is_array($plugins)) {
620 + foreach ($plugins as $name) {
624 diff -Naur cacti-0.8.7g-old/include/top_graph_header.php cacti-0.8.7g/include/top_graph_header.php
625 --- cacti-0.8.7g-old/include/top_graph_header.php 2010-07-09 18:33:46.000000000 -0400
626 +++ cacti-0.8.7g/include/top_graph_header.php 2010-07-09 18:34:11.000000000 -0400
628 $using_guest_account = false;
629 $show_console_tab = true;
631 +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
632 +if ($oper_mode == OPER_MODE_RESKIN) {
636 /* ================= input validation ================= */
637 input_validate_input_number(get_request_var_request("local_graph_id"));
638 input_validate_input_number(get_request_var_request("graph_start"));
640 $_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all";
643 +$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title"));
646 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
649 - <title><?php echo draw_navigation_text("title");?></title>
650 + <title><?php echo $page_title; ?></title>
652 if (isset($_SESSION["custom"]) && $_SESSION["custom"] == true) {
653 print "<meta http-equiv=refresh content='99999'>\r\n";
655 - print "<meta http-equiv=refresh content='" . htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES) . "'>\r\n";
656 + $refresh = api_plugin_hook_function('top_graph_refresh', htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES));
657 + print "<meta http-equiv=refresh content='" . $refresh . "'>\r\n";
660 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
661 - <link href="include/main.css" type="text/css" rel="stylesheet">
662 - <link href="images/favicon.ico" rel="shortcut icon"/>
663 - <script type="text/javascript" src="include/layout.js"></script>
664 - <script type="text/javascript" src="include/treeview/ua.js"></script>
665 - <script type="text/javascript" src="include/treeview/ftiens4.js"></script>
666 - <script type="text/javascript" src="include/jscalendar/calendar.js"></script>
667 - <script type="text/javascript" src="include/jscalendar/lang/calendar-en.js"></script>
668 - <script type="text/javascript" src="include/jscalendar/calendar-setup.js"></script>
669 + <link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
670 + <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
671 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
672 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ua.js"></script>
673 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ftiens4.js"></script>
674 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar.js"></script>
675 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/lang/calendar-en.js"></script>
676 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar-setup.js"></script>
677 + <?php api_plugin_hook('page_head'); ?>
681 +<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
682 +<body <?php print api_plugin_hook_function("body_style", "");?>>
683 <a name='page_top'></a>
685 +<body <?php print api_plugin_hook_function("body_style", "");?>>
688 <table style="width:100%;height:100%;" cellspacing="0" cellpadding="0">
689 +<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
690 <tr style="height:25px;" bgcolor="#a9a9a9" class="noprint">
691 <td colspan="2" valign="bottom" nowrap>
692 <table width="100%" cellspacing="0" cellpadding="0">
693 - <tr style="background: transparent url('images/cacti_backdrop2.gif') no-repeat center right;">
694 + <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop2.gif') no-repeat center right;">
695 <td id="tabs" nowrap>
696 - <?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>
697 + <?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
698 + api_plugin_hook('top_graph_header_tabs');
701 <td id="gtabs" align="right" nowrap>
702 - <?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>
703 + <?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>
709 <tr style="height:2px;" bgcolor="#183c8f" class="noprint">
711 - <img src="images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br>
712 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br>
715 <tr style="height:5px;" bgcolor="#e9e9e9" class="noprint">
719 <?php if ((isset($_SESSION["sess_user_id"])) && ($using_guest_account == false)) { ?>
720 - 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>)
721 + 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>)
725 @@ -114,10 +131,10 @@
729 - <td bgcolor="#efefef" colspan="1" style="height:8px;background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
730 - <img src="images/transparent_line.gif" width="<?php print htmlspecialchars(read_graph_config_option("default_dual_pane_width"));?>" style="height:2px;" border="0"><br>
731 + <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;">
732 + <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>
734 - <td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(images/shadow.gif); background-repeat: repeat-x;">
735 + <td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;">
744 + global $graph_views;
745 load_current_session_value("action", "sess_cacti_graph_action", $graph_views[read_graph_config_option("default_tree_view_mode")]);
748 diff -Naur cacti-0.8.7g-old/include/top_header.php cacti-0.8.7g/include/top_header.php
749 --- cacti-0.8.7g-old/include/top_header.php 2010-07-09 18:33:46.000000000 -0400
750 +++ cacti-0.8.7g/include/top_header.php 2010-07-09 18:34:11.000000000 -0400
752 +-------------------------------------------------------------------------+
756 +global $colors, $config;
758 +$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
759 +if ($oper_mode == OPER_MODE_RESKIN) {
763 +$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title"));
766 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
769 - <title><?php echo draw_navigation_text("title");?></title>
770 - <link href="include/main.css" type="text/css" rel="stylesheet">
771 - <link href="images/favicon.ico" rel="shortcut icon"/>
772 + <title><?php echo $page_title; ?></title>
773 + <link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
774 + <link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon">
775 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
776 - <script type="text/javascript" src="include/layout.js"></script>
777 + <script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
778 <?php if (isset($refresh)) {
779 print "<meta http-equiv=refresh content=\"" . $refresh["seconds"] . "; url='" . $refresh["page"] . "'\">";
782 + api_plugin_hook('page_head'); ?>
785 -<body style="background-image:url('images/left_border.gif');background-repeat:repeat-y;">
786 +<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
787 +<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", "");?>>
789 +<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", "");?>>
792 <table width="100%" cellspacing="0" cellpadding="0">
793 +<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
794 <tr style="height:1px;" bgcolor="#a9a9a9">
795 <td valign="bottom" colspan="3" nowrap>
796 <table width="100%" cellspacing="0" cellpadding="0">
797 - <tr style="background: transparent url('images/cacti_backdrop.gif') no-repeat center right;">
798 + <tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop.gif') no-repeat center right;">
799 <td id="tabs" valign="bottom">
800 - <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>
802 + <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
803 + api_plugin_hook('top_header_tabs');
809 <tr style="height:2px;" bgcolor="#183c8f">
811 - <img src="images/transparent_line.gif" style="height:2px;" border="0"><br>
812 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;" border="0"><br>
815 <tr style="height:5px;" bgcolor="#e9e9e9">
819 <?php if (read_config_option("auth_method") != 0) { ?>
820 - 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>)
821 + 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>)
829 - <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;">
830 - <img src="images/transparent_line.gif" style="height:2px;width:135px;" border="0"><br>
831 + <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;">
832 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;width:135px;" border="0"><br>
834 - <td colspan="2" style="height:8px;background-image: url(images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
835 + <td colspan="2" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
843 - <img src="images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
844 - <p align="center"><a href='about.php'><img src="images/cacti_logo.gif" border="0"></a></p>
845 - <img src="images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
846 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
847 + <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>
848 + <img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
850 <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'>
854 + <td width="100%" valign="top"><?php display_output_messages();?>
856 diff -Naur cacti-0.8.7g-old/index.php cacti-0.8.7g/index.php
857 --- cacti-0.8.7g-old/index.php 2010-07-09 18:33:46.000000000 -0400
858 +++ cacti-0.8.7g/index.php 2010-07-09 18:34:11.000000000 -0400
860 include("./include/auth.php");
861 include("./include/top_header.php");
863 +api_plugin_hook('console_before');
866 <table width="100%" align="center">
872 +api_plugin_hook('console_after');
874 include("./include/bottom_footer.php");
877 diff -Naur cacti-0.8.7g-old/lib/api_device.php cacti-0.8.7g/lib/api_device.php
878 --- cacti-0.8.7g-old/lib/api_device.php 2010-07-09 18:33:46.000000000 -0400
879 +++ cacti-0.8.7g/lib/api_device.php 2010-07-09 18:34:11.000000000 -0400
881 $save["ping_retries"] = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3);
882 $save["max_oids"] = form_input_validate($max_oids, "max_oids", "^[0-9]+$", true, 3);
884 + $save = api_plugin_hook_function('api_device_save', $save);
888 if (!is_error_message()) {
889 diff -Naur cacti-0.8.7g-old/lib/auth.php cacti-0.8.7g/lib/auth.php
890 --- cacti-0.8.7g-old/lib/auth.php 2010-07-09 18:33:46.000000000 -0400
891 +++ cacti-0.8.7g/lib/auth.php 2010-07-09 18:34:11.000000000 -0400
897 + api_plugin_hook_function('copy_user', array('template_id' => $template_id, 'new_id' => $new_id));
904 db_execute("delete from settings_graphs where user_id=" . $user_id);
905 db_execute("delete from settings_tree where user_id=" . $user_id);
907 + api_plugin_hook_function('user_remove', $user_id);
910 /* user_disable - disable a user account
911 diff -Naur cacti-0.8.7g-old/lib/functions.php cacti-0.8.7g/lib/functions.php
912 --- cacti-0.8.7g-old/lib/functions.php 2010-07-09 18:33:46.000000000 -0400
913 +++ cacti-0.8.7g/lib/functions.php 2010-07-09 18:34:11.000000000 -0400
914 @@ -1689,6 +1689,8 @@
915 @arg $type - (string) Either 'url' or 'title'
916 @returns (string> Either the navigation text or title */
917 function draw_navigation_text($type = "url") {
920 $nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : array());
923 @@ -1701,8 +1703,8 @@
924 "graph.php:zoom" => array("title" => "Zoom", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
925 "graph.php:properties" => array("title" => "Properties", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
926 "graph_settings.php:" => array("title" => "Settings", "mapping" => "graph_view.php:", "url" => "graph_settings.php", "level" => "1"),
927 - "index.php:" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
928 - "index.php:login" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
929 + "index.php:" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
930 + "index.php:login" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
931 "graphs.php:" => array("title" => "Graph Management", "mapping" => "index.php:", "url" => "graphs.php", "level" => "1"),
932 "graphs.php:graph_edit" => array("title" => "(Edit)", "mapping" => "index.php:,graphs.php:", "url" => "", "level" => "2"),
933 "graphs.php:graph_diff" => array("title" => "Change Graph Template", "mapping" => "index.php:,graphs.php:,graphs.php:graph_edit", "url" => "", "level" => "3"),
934 @@ -1780,6 +1782,8 @@
935 "templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"),
938 + $nav = api_plugin_hook_function('draw_navigation_text', $nav);
940 $current_page = basename($_SERVER["PHP_SELF"]);
942 input_validate_input_regex(get_request_var_request("action"), "^([a-zA-Z0-9_-]+)$");
943 diff -Naur cacti-0.8.7g-old/lib/html_form.php cacti-0.8.7g/lib/html_form.php
944 --- cacti-0.8.7g-old/lib/html_form.php 2010-07-09 18:33:46.000000000 -0400
945 +++ cacti-0.8.7g/lib/html_form.php 2010-07-09 18:34:11.000000000 -0400
946 @@ -722,11 +722,13 @@
947 on a confirmation form
948 @arg $cancel_url - the url to go to when the user clicks 'cancel'
949 @arg $action_url - the url to go to when the user clicks 'delete' */
950 -function form_confirm_buttons($action_url, $cancel_url) { ?>
951 +function form_confirm_buttons($action_url, $cancel_url) {
955 <td bgcolor="#E1E1E1">
956 - <input type='button' onClick='cactiReturnTo("<?php print $cancel_url;?>")' value='Cancel'>
957 - <input type='submit' onClick='cactiReturnTo("<?php print $action_url;?>&confirm=true")' value='Delete'>
958 + <input type='button' onClick='cactiReturnTo("<?php print $config['url_path'] . $cancel_url;?>")' value='Cancel'>
959 + <input type='submit' onClick='cactiReturnTo("<?php print $config['url_path'] . $action_url;?>&confirm=true")' value='Delete'>
963 diff -Naur cacti-0.8.7g-old/lib/html.php cacti-0.8.7g/lib/html.php
964 --- cacti-0.8.7g-old/lib/html.php 2010-07-09 18:33:46.000000000 -0400
965 +++ cacti-0.8.7g/lib/html.php 2010-07-09 18:34:11.000000000 -0400
966 @@ -144,14 +144,15 @@
967 <table align='center' cellpadding='0'>
970 - <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>
971 + <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>
972 <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?>
974 <td valign='top' style='align: left; padding: 3px;' class='noprint'>
975 - <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>
976 - <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>
977 - <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>
978 - <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
979 + <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>
980 + <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>
981 + <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>
982 + <?php api_plugin_hook('graph_buttons', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => 'view')); ?>
983 + <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>
988 @arg $extra_url_args - extra arguments to append to the url
989 @arg $header - html to use as a header */
990 function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
992 $i = 0; $k = 0; $j = 0;
994 $num_graphs = sizeof($graph_array);
995 @@ -268,14 +270,15 @@
996 <table align='center' cellpadding='0'>
999 - <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>
1000 + <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>
1001 <?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?>
1003 <td valign='top' style='align: left; padding: 3px;'>
1004 - <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>
1005 - <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>
1006 - <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>
1007 - <a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
1008 + <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>
1009 + <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>
1010 + <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>
1011 + <?php api_plugin_hook('graph_buttons_thumbnails', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' => 0, 'view_type' => '')); ?>
1012 + <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>
1017 print "<td style='$this_row_style'>" . $item["hex"] . "</td>\n";
1019 if ($disable_controls == false) {
1020 - 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>
1021 - <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";
1022 - 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";
1023 + 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>
1024 + <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";
1025 + 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";
1032 while (list($item_sub_url, $item_sub_title) = each($item_title)) {
1033 + $item_sub_url = $config['url_path'] . $item_sub_url;
1035 /* indent sub-items */
1037 $prepend_string = "--- ";
1040 /* do not put a line between each sub-item */
1041 if (($i == 0) || ($draw_sub_items == false)) {
1042 - $background = "images/menu_line.gif";
1043 + $background = $config['url_path'] . "images/menu_line.gif";
1047 @@ -744,17 +749,18 @@
1049 if ($current_realm_id == -1 || (isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) {
1050 /* draw normal (non sub-item) menu item */
1051 + $item_url = $config['url_path'] . $item_url;
1052 if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) {
1053 - 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";
1054 + 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";
1056 - print "<tr><td class='textMenuItem' style='background-image:url(\"images/menu_line.gif\");'><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></td></tr>\n";
1057 + 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";
1064 - print "<tr><td class='textMenuItem' style='background-image:url(\"images/menu_line.gif\");'></td></tr>\n";
1065 + print "<tr><td class='textMenuItem' style='background-image:url(\"" . $config['url_path'] . "images/menu_line.gif\");'></td></tr>\n";
1067 print "</table></td></tr>";
1069 @@ -764,11 +770,12 @@
1070 @arg $actions_array - an array that contains a list of possible actions. this array should
1071 be compatible with the form_dropdown() function */
1072 function draw_actions_dropdown($actions_array) {
1075 <table align='center' width='100%'>
1077 <td width='1' valign='top'>
1078 - <img src='images/arrow.gif' alt=''>
1079 + <img src='<?php echo $config['url_path']; ?>images/arrow.gif' alt='' align='middle'>
1083 diff -Naur cacti-0.8.7g-old/lib/plugins.php cacti-0.8.7g/lib/plugins.php
1084 --- cacti-0.8.7g-old/lib/plugins.php 1969-12-31 19:00:00.000000000 -0500
1085 +++ cacti-0.8.7g/lib/plugins.php 2010-07-09 18:34:11.000000000 -0400
1091 +function do_hook ($name) {
1092 + $data = func_get_args();
1093 + $data = api_plugin_hook ($name, $data);
1097 +function do_hook_function($name,$parm=NULL) {
1098 + return api_plugin_hook_function ($name, $parm);
1101 +function api_user_realm_auth ($filename = '') {
1102 + return api_plugin_user_realm_auth ($filename);
1106 + * This function executes a hook.
1107 + * @param string $name Name of hook to fire
1108 + * @return mixed $data
1110 +function api_plugin_hook ($name) {
1111 + global $config, $plugin_hooks, $plugins_system;
1112 + $data = func_get_args();
1117 + if (sizeof($plugins_system)) {
1118 + foreach($plugins_system as $plugin) {
1119 + $ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin;
1121 + $ps_where .= "')";
1124 + /* order the plugin functions by system first, then followed by order */
1125 + $result = db_fetch_assoc("SELECT 1 AS id, ph.name, ph.file, ph.function
1126 + FROM plugin_hooks AS ph
1127 + LEFT JOIN plugin_config AS pc
1128 + ON pc.directory=ph.name
1129 + WHERE ph.status = 1 AND hook = '$name'
1130 + AND ph.name IN $ps_where
1132 + SELECT pc.id, ph.name, ph.file, ph.function
1133 + FROM plugin_hooks AS ph
1134 + LEFT JOIN plugin_config AS pc
1135 + ON pc.directory=ph.name
1136 + WHERE ph.status = 1 AND hook = '$name'
1137 + AND ph.name NOT IN $ps_where
1138 + ORDER BY id ASC", true);
1140 + if (count($result)) {
1141 + foreach ($result as $hdata) {
1142 + $p[] = $hdata['name'];
1143 + if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
1144 + include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
1146 + $function = $hdata['function'];
1147 + if (function_exists($function)) {
1153 + if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
1154 + foreach ($plugin_hooks[$name] as $pname => $function) {
1155 + if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
1161 + /* Variable-length argument lists have a slight problem when */
1162 + /* passing values by reference. Pity. This is a workaround. */
1166 +function api_plugin_hook_function ($name, $parm=NULL) {
1167 + global $config, $plugin_hooks, $plugins_system;
1172 + if (sizeof($plugins_system)) {
1173 + foreach($plugins_system as $plugin) {
1174 + $ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin;
1176 + $ps_where .= "')";
1179 + /* order the plugin functions by system first, then followed by order */
1180 + $result = db_fetch_assoc("SELECT 1 AS id, ph.name, ph.file, ph.function
1181 + FROM plugin_hooks AS ph
1182 + LEFT JOIN plugin_config AS pc
1183 + ON pc.directory=ph.name
1184 + WHERE ph.status = 1 AND hook = '$name'
1185 + AND ph.name IN $ps_where
1187 + SELECT pc.id, ph.name, ph.file, ph.function
1188 + FROM plugin_hooks AS ph
1189 + LEFT JOIN plugin_config AS pc
1190 + ON pc.directory=ph.name
1191 + WHERE ph.status = 1 AND hook = '$name'
1192 + AND ph.name NOT IN $ps_where
1193 + ORDER BY id ASC", true);
1195 + if (count($result)) {
1196 + foreach ($result as $hdata) {
1197 + $p[] = $hdata['name'];
1198 + if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
1199 + include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
1201 + $function = $hdata['function'];
1202 + if (function_exists($function)) {
1203 + $ret = $function($ret);
1208 + if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
1209 + foreach ($plugin_hooks[$name] as $pname => $function) {
1210 + if (function_exists($function) && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
1211 + $ret = $function($ret);
1216 + /* Variable-length argument lists have a slight problem when */
1217 + /* passing values by reference. Pity. This is a workaround. */
1221 +function api_plugin_db_table_create ($plugin, $table, $data) {
1222 + global $config, $database_default;
1223 + include_once($config["library_path"] . "/database.php");
1225 + $result = db_fetch_assoc("show tables from `" . $database_default . "`") or die (mysql_error());
1226 + $tables = array();
1227 + foreach($result as $index => $arr) {
1228 + foreach ($arr as $t) {
1232 + if (!in_array($table, $tables)) {
1234 + $sql = 'CREATE TABLE `' . $table . "` (\n";
1235 + foreach ($data['columns'] as $column) {
1236 + if (isset($column['name'])) {
1239 + $sql .= '`' . $column['name'] . '`';
1240 + if (isset($column['type']))
1241 + $sql .= ' ' . $column['type'];
1242 + if (isset($column['unsigned']))
1243 + $sql .= ' unsigned';
1244 + if (isset($column['NULL']) && $column['NULL'] == false)
1245 + $sql .= ' NOT NULL';
1246 + if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
1247 + $sql .= ' default NULL';
1248 + if (isset($column['default']))
1249 + $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
1250 + if (isset($column['auto_increment']))
1251 + $sql .= ' auto_increment';
1256 + if (isset($data['primary'])) {
1257 + $sql .= ",\n PRIMARY KEY (`" . $data['primary'] . '`)';
1260 + foreach ($data['keys'] as $key) {
1261 + if (isset($key['name'])) {
1262 + $sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)';
1265 + $sql .= ') TYPE = ' . $data['type'];
1267 + if (isset($data['comment'])) {
1268 + $sql .= " COMMENT = '" . $data['comment'] . "'";
1270 + if (db_execute($sql)) {
1271 + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1274 + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
1278 +function api_plugin_db_changes_remove ($plugin) {
1279 + // Example: api_plugin_db_changes_remove ('thold');
1281 + $tables = db_fetch_assoc("SELECT `table` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='create'", false);
1282 + if (count($tables)) {
1283 + foreach ($tables as $table) {
1284 + db_execute("DROP TABLE IF EXISTS `" . $table['table'] . "`;");
1286 + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false);
1288 + $columns = db_fetch_assoc("SELECT `table`, `column` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='addcolumn'", false);
1289 + if (count($columns)) {
1290 + foreach ($columns as $column) {
1291 + db_execute('ALTER TABLE `' . $column['table'] . '` DROP `' . $column['column'] . '`');
1293 + db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false);
1297 +function api_plugin_db_add_column ($plugin, $table, $column) {
1298 + // Example: api_plugin_db_add_column ('thold', 'plugin_config', array('name' => 'test' . rand(1, 200), 'type' => 'varchar (255)', 'NULL' => false));
1300 + global $config, $database_default;
1301 + include_once($config['library_path'] . '/database.php');
1303 + $result = db_fetch_assoc('show columns from `' . $table . '`') or die (mysql_error());
1304 + $columns = array();
1305 + foreach($result as $index => $arr) {
1306 + foreach ($arr as $t) {
1310 + if (isset($column['name']) && !in_array($column['name'], $columns)) {
1311 + $sql = 'ALTER TABLE `' . $table . '` ADD `' . $column['name'] . '`';
1312 + if (isset($column['type']))
1313 + $sql .= ' ' . $column['type'];
1314 + if (isset($column['unsigned']))
1315 + $sql .= ' unsigned';
1316 + if (isset($column['NULL']) && $column['NULL'] == false)
1317 + $sql .= ' NOT NULL';
1318 + if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
1319 + $sql .= ' default NULL';
1320 + if (isset($column['default']))
1321 + $sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
1322 + if (isset($column['auto_increment']))
1323 + $sql .= ' auto_increment';
1324 + if (isset($column['after']))
1325 + $sql .= ' AFTER ' . $column['after'];
1327 + if (db_execute($sql)) {
1328 + db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')");
1333 +function api_plugin_install ($plugin) {
1335 + include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1337 + $exists = db_fetch_assoc("SELECT id FROM plugin_config WHERE directory = '$plugin'", false);
1338 + if (sizeof($exists)) {
1339 + db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1342 + $name = $author = $webpage = $version = '';
1343 + $function = 'plugin_' . $plugin . '_version';
1344 + if (function_exists($function)){
1345 + $info = $function();
1346 + $name = $info['longname'];
1347 + if (isset($info['homepage'])) {
1348 + $webpage = $info['homepage'];
1349 + }elseif (isset($info['webpage'])) {
1350 + $webpage = $info['webpage'];
1352 + $webpage = "Not Stated";
1354 + $author = $info['author'];
1355 + $version = $info['version'];
1358 + db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')");
1360 + $function = 'plugin_' . $plugin . '_install';
1361 + if (function_exists($function)){
1363 + $ready = api_plugin_check_config ($plugin);
1365 + // Set the plugin as "disabled" so it can go live
1366 + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1368 + // Set the plugin as "needs configuration"
1369 + db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'");
1374 +function api_plugin_uninstall ($plugin) {
1376 + include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1377 + // Run the Plugin's Uninstall Function first
1378 + $function = 'plugin_' . $plugin . '_uninstall';
1379 + if (function_exists($function)) {
1382 + api_plugin_remove_hooks ($plugin);
1383 + api_plugin_remove_realms ($plugin);
1384 + db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
1385 + api_plugin_db_changes_remove ($plugin);
1388 +function api_plugin_check_config ($plugin) {
1390 + include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1391 + $function = 'plugin_' . $plugin . '_check_config';
1392 + if (function_exists($function)) {
1393 + return $function();
1398 +function api_plugin_enable ($plugin) {
1399 + $ready = api_plugin_check_config ($plugin);
1401 + api_plugin_enable_hooks ($plugin);
1402 + db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'");
1406 +function api_plugin_is_enabled ($plugin) {
1407 + $status = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = '$plugin'", false);
1408 + if ($status == '1')
1413 +function api_plugin_disable ($plugin) {
1414 + api_plugin_disable_hooks ($plugin);
1415 + db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
1418 +function api_plugin_moveup($plugin) {
1419 + global $plugins_system;
1422 + if (sizeof($plugins_system)) {
1423 + foreach($plugins_system as $s) {
1424 + $sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
1427 + $sql_where .= ")";
1430 + $id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:""));
1431 + $temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1;
1432 + $prior_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config WHERE id<$id" . (strlen($sql_where) ? " AND " . $sql_where:""));
1434 + /* update the above plugin to the prior temp id */
1435 + db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$prior_id");
1436 + db_execute("UPDATE plugin_config SET id=$prior_id WHERE id=$id");
1437 + db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id");
1440 +function api_plugin_movedown($plugin) {
1441 + global $plugins_system;
1444 + if (sizeof($plugins_system)) {
1445 + foreach($plugins_system as $s) {
1446 + $sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
1449 + $sql_where .= ")";
1452 + $id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:""));
1453 + $temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1;
1454 + $next_id = db_fetch_cell("SELECT MIN(id) FROM plugin_config WHERE id>$id" . (strlen($sql_where) ? " AND " . $sql_where:""));
1456 + /* update the above plugin to the prior temp id */
1457 + db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$next_id");
1458 + db_execute("UPDATE plugin_config SET id=$next_id WHERE id=$id");
1459 + db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id");
1462 +function api_plugin_register_hook ($plugin, $hook, $function, $file) {
1463 + $exists = db_fetch_assoc("SELECT id FROM plugin_hooks WHERE name = '$plugin' AND hook = '$hook'", false);
1464 + if (!count($exists)) {
1465 + $settings = array('config_settings', 'config_arrays', 'config_form');
1466 + if (!in_array($hook, $settings)) {
1467 + db_execute("INSERT INTO plugin_hooks (name, hook, function, file) VALUES ('$plugin', '$hook', '$function', '$file')");
1469 + db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)");
1474 +function api_plugin_remove_hooks ($plugin) {
1475 + db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'");
1478 +function api_plugin_enable_hooks ($plugin) {
1479 + db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'");
1482 +function api_plugin_disable_hooks ($plugin) {
1483 + db_execute("UPDATE plugin_hooks SET status = 0 WHERE name = '$plugin' AND hook != 'config_settings' AND hook != 'config_arrays' AND hook != 'config_form'");
1486 +function api_plugin_register_realm ($plugin, $file, $display, $admin = false) {
1487 + $exists = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1488 + if (!count($exists)) {
1489 + db_execute("INSERT INTO plugin_realms (plugin, file, display) VALUES ('$plugin', '$file', '$display')");
1491 + $realm_id = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
1492 + $realm_id = $realm_id[0]['id'] + 100;
1493 + $user_id = db_fetch_assoc("SELECT id FROM user_auth WHERE username = 'admin'", false);
1494 + if (count($user_id)) {
1495 + $user_id = $user_id[0]['id'];
1496 + $exists = db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id = $user_id and realm_id = $realm_id", false);
1497 + if (!count($exists)) {
1498 + db_execute("INSERT INTO user_auth_realm (user_id, realm_id) VALUES ($user_id, $realm_id)");
1505 +function api_plugin_remove_realms ($plugin) {
1506 + $realms = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin'", false);
1507 + foreach ($realms as $realm) {
1508 + $id = $realm['id'] + 100;
1509 + db_execute("DELETE FROM user_auth_realm WHERE realm_id = '$id'");
1511 + db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'");
1514 +function api_plugin_load_realms () {
1515 + global $user_auth_realms, $user_auth_realm_filenames;
1516 + $plugin_realms = db_fetch_assoc("SELECT * FROM plugin_realms ORDER BY plugin, display", false);
1517 + if (count($plugin_realms)) {
1518 + foreach ($plugin_realms as $plugin_realm) {
1519 + $plugin_files = explode(',', $plugin_realm['file']);
1520 + foreach($plugin_files as $plugin_file) {
1521 + $user_auth_realm_filenames[$plugin_file] = $plugin_realm['id'] + 100;
1523 + $user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display'];
1528 +function api_plugin_user_realm_auth ($filename = '') {
1529 + global $user_realms, $user_auth_realms, $user_auth_realm_filenames;
1530 + /* list all realms that this user has access to */
1531 + if (!isset($user_realms)) {
1532 + if (read_config_option('global_auth') == 'on' || read_config_option('auth_method') != 0) {
1533 + $user_realms = db_fetch_assoc("select realm_id from user_auth_realm where user_id=" . $_SESSION["sess_user_id"], false);
1534 + $user_realms = array_rekey($user_realms, "realm_id", "realm_id");
1536 + $user_realms = $user_auth_realms;
1539 + if ($filename != '') {
1540 + if (isset($user_realms[$user_auth_realm_filenames{basename($filename)}]))
1546 +function plugin_config_arrays () {
1548 + $menu['Configuration']['plugins.php'] = 'Plugin Management';
1549 + api_plugin_load_realms ();
1552 +function plugin_draw_navigation_text ($nav) {
1553 + $nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1");
1563 diff -Naur cacti-0.8.7g-old/lib/poller.php cacti-0.8.7g/lib/poller.php
1564 --- cacti-0.8.7g-old/lib/poller.php 2010-07-09 18:33:46.000000000 -0400
1565 +++ cacti-0.8.7g/lib/poller.php 2010-07-09 18:34:11.000000000 -0400
1566 @@ -344,8 +344,11 @@
1570 + api_plugin_hook_function('poller_output', $rrd_update_array);
1572 - $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1573 + if (api_plugin_hook_function('poller_on_demand', $results)) {
1574 + $rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
1578 return $rrds_processed;
1579 diff -Naur cacti-0.8.7g-old/lib/rrd.php cacti-0.8.7g/lib/rrd.php
1580 --- cacti-0.8.7g-old/lib/rrd.php 2010-07-09 18:33:46.000000000 -0400
1581 +++ cacti-0.8.7g/lib/rrd.php 2010-07-09 18:34:11.000000000 -0400
1584 $data_source_path = get_data_source_path($local_data_id, true);
1586 + /* update the rrdfile if performing a fetch */
1587 + api_plugin_hook_function('rrdtool_function_fetch_cache_check', $local_data_id);
1589 /* build and run the rrdtool fetch command with all of our data */
1590 $cmd_line = "fetch $data_source_path AVERAGE -s $start_time -e $end_time";
1591 if ($resolution > 0) {
1592 @@ -539,6 +542,10 @@
1596 + $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));
1597 + if (isset($data['return']) && $data['return'] != false)
1598 + return $data['return'];
1600 /* find the step and how often this graph is updated with new data */
1601 $ds_step = db_fetch_cell("select
1602 data_template_data.rrd_step
1603 @@ -1376,6 +1383,13 @@
1607 + $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));
1608 + if (!empty($graph_array)) {
1609 + $graph_defs = $graph_array['graph_defs'];
1610 + $txt_graph_items = $graph_array['txt_graph_items'];
1611 + $graph_opts = $graph_array['graph_opts'];
1614 /* either print out the source or pass the source onto rrdtool to get us a nice PNG */
1615 if (isset($graph_data_array["print_source"])) {
1616 print "<PRE>" . htmlspecialchars(read_config_option("path_rrdtool") . " graph " . $graph_opts . $graph_defs . $txt_graph_items) . "</PRE>";
1617 @@ -1384,13 +1398,19 @@
1618 @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrdtool_pipe);
1621 + $graph_data_array = api_plugin_hook_function('prep_graph_array', $graph_data_array);
1623 if (isset($graph_data_array["output_flag"])) {
1624 $output_flag = $graph_data_array["output_flag"];
1626 $output_flag = RRDTOOL_OUTPUT_GRAPH_DATA;
1629 - return @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrdtool_pipe);
1630 + $output = @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrdtool_pipe);
1632 + api_plugin_hook_function('rrdtool_function_graph_set_file', array('output' => $output, 'local_graph_id' => $local_graph_id, 'rra_id' => $rra_id));
1638 diff -Naur cacti-0.8.7g-old/lib/variables.php cacti-0.8.7g/lib/variables.php
1639 --- cacti-0.8.7g-old/lib/variables.php 2010-07-09 18:33:46.000000000 -0400
1640 +++ cacti-0.8.7g/lib/variables.php 2010-07-09 18:34:11.000000000 -0400
1642 $string = str_replace($l_escape_string . "host_max_oids" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["max_oids"], $string);
1643 $string = str_replace($l_escape_string . "host_id" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["id"], $string);
1645 + $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));
1646 + $string = $temp['string'];
1651 diff -Naur cacti-0.8.7g-old/plugins/index.php cacti-0.8.7g/plugins/index.php
1652 --- cacti-0.8.7g-old/plugins/index.php 1969-12-31 19:00:00.000000000 -0500
1653 +++ cacti-0.8.7g/plugins/index.php 2010-07-09 18:34:11.000000000 -0400
1657 +header("Location:../index.php");
1660 diff -Naur cacti-0.8.7g-old/plugins.php cacti-0.8.7g/plugins.php
1661 --- cacti-0.8.7g-old/plugins.php 1969-12-31 19:00:00.000000000 -0500
1662 +++ cacti-0.8.7g/plugins.php 2010-07-09 18:34:11.000000000 -0400
1666 + +-------------------------------------------------------------------------+
1667 + | Copyright (C) 2004-2010 The Cacti Group |
1669 + | This program is free software; you can redistribute it and/or |
1670 + | modify it under the terms of the GNU General Public License |
1671 + | as published by the Free Software Foundation; either version 2 |
1672 + | of the License, or (at your option) any later version. |
1674 + | This program is distributed in the hope that it will be useful, |
1675 + | but WITHOUT ANY WARRANTY; without even the implied warranty of |
1676 + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1677 + | GNU General Public License for more details. |
1678 + +-------------------------------------------------------------------------+
1679 + | Cacti: The Complete RRDTool-based Graphing Solution |
1680 + +-------------------------------------------------------------------------+
1681 + | This code is designed, written, and maintained by the Cacti Group. See |
1682 + | about.php and/or the AUTHORS file for specific developer information. |
1683 + +-------------------------------------------------------------------------+
1684 + | http://www.cacti.net/ |
1685 + +-------------------------------------------------------------------------+
1688 +include("./include/auth.php");
1690 +define("MAX_DISPLAY_PAGES", 21);
1692 +$actions = array("install" => "Install",
1693 + "enable" => "Enable",
1694 + "disable" => "Disable",
1695 + "uninstall" => "Uninstall",
1696 +// "check" => "Check"
1699 +$status_names = array(
1702 + 0 => 'Not Installed',
1704 + 2 => 'Awaiting Configuration',
1705 + 3 => 'Awaiting Upgrade',
1709 +/* get the comprehensive list of plugins */
1710 +$pluginslist = retrieve_plugin_list();
1712 +/* Check to see if we are installing, etc... */
1713 +$modes = array('installold', 'uninstallold', 'install', 'uninstall', 'disable', 'enable', 'check', 'moveup', 'movedown');
1715 +if (isset($_GET['mode']) && in_array($_GET['mode'], $modes) && isset($_GET['id'])) {
1716 + input_validate_input_regex(get_request_var("id"), "^([a-zA-Z0-9]+)$");
1718 + $mode = $_GET['mode'];
1719 + $id = sanitize_search_string($_GET['id']);
1722 + case 'installold':
1723 + api_plugin_install_old($id);
1724 + header("Location: plugins.php");
1727 + case 'uninstallold':
1728 + api_plugin_uninstall_old($id);
1729 + header("Location: plugins.php");
1733 + api_plugin_install($id);
1734 + header("Location: plugins.php");
1738 + if (!in_array($id, $pluginslist)) break;
1739 + api_plugin_uninstall($id);
1740 + header("Location: plugins.php");
1744 + if (!in_array($id, $pluginslist)) break;
1745 + api_plugin_disable($id);
1746 + header("Location: plugins.php");
1750 + if (!in_array($id, $pluginslist)) break;
1751 + api_plugin_enable($id);
1752 + header("Location: plugins.php");
1756 + if (!in_array($id, $pluginslist)) break;
1759 + if (!in_array($id, $pluginslist)) break;
1760 + if (is_system_plugin($id)) break;
1761 + api_plugin_moveup($id);
1762 + header("Location: plugins.php");
1766 + if (!in_array($id, $pluginslist)) break;
1767 + if (is_system_plugin($id)) break;
1768 + api_plugin_movedown($id);
1769 + header("Location: plugins.php");
1775 +function retrieve_plugin_list () {
1776 + $pluginslist = array();
1777 + $temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name');
1778 + foreach ($temp as $t) {
1779 + $pluginslist[] = $t['directory'];
1781 + return $pluginslist;
1784 +include("./include/top_header.php");
1786 +update_show_current();
1788 +include("./include/bottom_footer.php");
1791 +function api_plugin_install_old ($plugin) {
1793 + if (!file_exists($config['base_path'] . "/plugins/$plugin/setup.php")) {
1796 + $oldplugins = read_config_option('oldplugins');
1797 + $oldplugins = explode(',', $oldplugins);
1798 + if (!in_array($plugin, $oldplugins)) {
1799 + include_once($config['base_path'] . "/plugins/$plugin/setup.php");
1800 + $function = 'plugin_init_' . $plugin;
1801 + if (function_exists($function)){
1802 + $oldplugins[] = $plugin;
1803 + $oldplugins = implode(',', $oldplugins);
1804 + set_config_option('oldplugins', $oldplugins);
1805 + unset($_SESSION['sess_config_array']['oldplugins']);
1814 +function api_plugin_uninstall_old ($plugin) {
1816 + $oldplugins = read_config_option('oldplugins');
1817 + $oldplugins = explode(',', $oldplugins);
1818 + if (!empty($oldplugins)) {
1819 + if (in_array($plugin, $oldplugins)) {
1820 + for ($a = 0; $a < count($oldplugins); $a++) {
1821 + if ($oldplugins[$a] == $plugin) {
1822 + unset($oldplugins[$a]);
1826 + $oldplugins = implode(',', $oldplugins);
1827 + set_config_option('oldplugins', $oldplugins);
1828 + unset($_SESSION['sess_config_array']['oldplugins']);
1835 +function update_show_updates () {
1836 + global $pluginslist, $colors, $config, $plugin_architecture;
1839 + sort($pluginslist);
1841 + $cinfo = update_get_plugin_info ();
1845 + $info = update_get_cached_plugin_info();
1847 + $cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ;
1848 + if (isset($cinfo['cacti_plugin_arch']['version'])) {
1849 + $archnew = update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']);
1856 + print "<tr><td width='25%' valign=top><table width='100%'>";
1857 + html_header(array("Cacti"), 2);
1858 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1859 + print "<td width='25%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr>";
1860 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1861 + print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti']['changes']) . "</td></tr></table>";
1863 + if (isset($plugin_architecture['version']) && $archnew) {
1865 + print "<table width='100%'>";
1866 + html_header(array("Plugin Architecture"), 2);
1867 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1868 + print "<td width='25%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td>";
1869 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1870 + print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti_plugin_arch']['changes']) . "</td></tr></table>";
1872 + print "<table width='100%' cellspacing=0 cellpadding=3>";
1874 + foreach ($pluginslist as $plugin) {
1875 + if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) {
1877 + print "<table width='100%'>";
1878 + html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2);
1879 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1880 + print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
1881 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1882 + print "<td><strong>Version:</strong></td><td>" . $info[$plugin]['version'] . "</td>";
1883 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1884 + 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>";
1885 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1886 + 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>";
1887 + form_alternate_row_color($colors["alternate"],$colors["light"], 0);
1888 + print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info[$plugin]['changes']) . "</td>";
1890 + print "</tr></table>";
1894 + print "<br><center><b>There are currently no Updates!</b></center><br>";
1896 + html_end_box(TRUE);
1899 +function update_check_if_newer() {
1903 +function plugins_temp_table_exists($table) {
1904 + return sizeof(db_fetch_row("SHOW TABLES LIKE '$table'"));
1907 +function plugins_load_temp_table() {
1908 + global $config, $plugins;
1910 + $pluginslist = retrieve_plugin_list();
1912 + if (isset($_SESSION["plugin_temp_table"])) {
1913 + $table = $_SESSION["plugin_temp_table"];
1915 + $table = "plugin_temp_table_" . rand();
1919 + if (!plugins_temp_table_exists($table)) {
1920 + $_SESSION["plugin_temp_table"] = $table;
1921 + db_execute("CREATE TEMPORARY TABLE $table LIKE plugin_config");
1922 + db_execute("INSERT INTO $table SELECT * FROM plugin_config");
1925 + $table = "plugin_temp_table_" . rand();
1929 + $path = $config['base_path'] . '/plugins/';
1930 + $dh = opendir($path);
1931 + while (($file = readdir($dh)) !== false) {
1932 + if ((is_dir("$path/$file")) && (file_exists("$path/$file/setup.php")) && (!in_array($file, $pluginslist))) {
1933 + if (!function_exists('plugin_' . $file . '_install')) {
1934 + include_once("$path/$file/setup.php");
1935 + if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) {
1936 + $function = $file . '_version';
1937 + $cinfo[$file] = $function();
1938 + if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown';
1939 + if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
1940 + if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
1941 + if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['longname'] = ucfirst($file);
1942 + $cinfo[$file]['status'] = -2;
1943 + if (in_array($file, $plugins)) {
1944 + $cinfo[$file]['status'] = -1;
1946 + db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
1949 + $cinfo[$file]['longname'] . "', '" .
1950 + $cinfo[$file]['status'] . "', '" .
1951 + $cinfo[$file]['author'] . "', '" .
1952 + $cinfo[$file]['homepage'] . "', '" .
1953 + $cinfo[$file]['version'] . "')");
1954 + $pluginslist[] = $file;
1955 + } else if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
1956 + $function = $file . '_version';
1957 + $cinfo[$file] = $function();
1958 + $cinfo[$file]['status'] = 0;
1959 + if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown';
1960 + if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
1961 + if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
1962 + if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['homepage'] = ucfirst($file);
1963 + db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
1966 + $cinfo[$file]['longname'] . "', '" .
1967 + $cinfo[$file]['status'] . "', '" .
1968 + $cinfo[$file]['author'] . "', '" .
1969 + $cinfo[$file]['homepage'] . "', '" .
1970 + $cinfo[$file]['version'] . "')");
1971 + $pluginslist[] = $file;
1974 + cacti_log("WARNING: Install function already exists for plugin directory '$file'", false);
1983 +function update_show_current () {
1984 + global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names, $actions;
1986 + /* ================= input validation ================= */
1987 + input_validate_input_number(get_request_var_request("page"));
1988 + /* ==================================================== */
1990 + /* clean up search string */
1991 + if (isset($_REQUEST["filter"])) {
1992 + $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
1995 + /* clean up sort_column */
1996 + if (isset($_REQUEST["sort_column"])) {
1997 + $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
2000 + /* clean up search string */
2001 + if (isset($_REQUEST["sort_direction"])) {
2002 + $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
2005 + /* if the user pushed the 'clear' button */
2006 + if (isset($_REQUEST["clear_x"])) {
2007 + kill_session_var("sess_plugins_filter");
2008 + kill_session_var("sess_plugins_sort_column");
2009 + kill_session_var("sess_plugins_sort_direction");
2011 + unset($_REQUEST["page"]);
2012 + unset($_REQUEST["filter"]);
2013 + unset($_REQUEST["sort_column"]);
2014 + unset($_REQUEST["sort_direction"]);
2015 + $_REQUEST["page"] = 1;
2018 + /* remember these search fields in session vars so we don't have to keep passing them around */
2019 + load_current_session_value("filter", "sess_plugins_filter", "");
2020 + load_current_session_value("sort_column", "sess_plugins_sort_column", "name");
2021 + load_current_session_value("sort_direction", "sess_plugins_sort_direction", "ASC");
2022 + load_current_session_value("page", "sess_plugins_current_page", "1");
2024 + $table = plugins_load_temp_table();
2026 + html_start_box("<strong>Plugin Management</strong> (Cacti Version: " . $config["cacti_version"] .
2027 + (isset($plugin_architecture['version']) ? ", Plugin Architecture Version: " . $plugin_architecture['version']:"") .
2028 + ")", "100%", $colors["header"], "3", "center", "");
2031 + <tr bgcolor="#<?php print $colors['panel'];?>">
2032 + <td class="noprint">
2033 + <form name="form_plugins" method="get" action="plugins.php">
2034 + <table width="100%" cellpadding="0" cellspacing="0">
2035 + <tr class="noprint">
2036 + <td nowrap style='white-space: nowrap;' width="50">
2040 + <input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>">
2042 + <td nowrap style='white-space: nowrap;'>
2043 + <input type="submit" value="Go" title="Set/Refresh Filters">
2044 + <input type="submit" name="clear_x" value="Clear" title="Clear Filters">
2048 + <input type='hidden' name='page' value='1'>
2056 + /* print checkbox form for validation */
2057 + print "<form name='chk' method='post' action='plugins.php'>\n";
2059 + html_start_box("", "100%", $colors["header"], "3", "center", "");
2061 + /* form the 'where' clause for our main sql query */
2062 + $sql_where = "WHERE ($table.name LIKE '%%" . get_request_var_request("filter") . "%%')";
2064 + if (get_request_var_request("sort_column") == "version") {
2065 + $sortc = "version+0";
2067 + $sortc = get_request_var_request("sort_column");
2070 + if (get_request_var_request("sort_column") == "id") {
2073 + $sortd = get_request_var_request("sort_direction");
2076 + $total_rows = db_fetch_cell("SELECT
2081 + $plugins = db_fetch_assoc("SELECT *
2084 + ORDER BY " . $sortc . " " . $sortd . "
2085 + LIMIT " . (read_config_option("num_rows_device")*(get_request_var_request("page")-1)) . "," . read_config_option("num_rows_device"));
2087 + db_execute("DROP TABLE $table");
2089 + /* generate page list */
2090 + $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"));
2092 + if ($total_rows == 0) {
2093 + $nav = "<tr bgcolor='#" . $colors["header"] . "'>
2095 + <table width='100%' cellspacing='0' cellpadding='0' border='0'>
2097 + <td align='center' class='textHeaderDark'>
2104 + }elseif ($total_rows < read_config_option("num_rows_device")) {
2105 + $nav = "<tr bgcolor='#" . $colors["header"] . "'>
2107 + <table width='100%' cellspacing='0' cellpadding='0' border='0'>
2109 + <td align='center' class='textHeaderDark'>
2110 + Showing All $total_rows Rows
2117 + $nav = "<tr bgcolor='#" . $colors["header"] . "'>
2119 + <table width='100%' cellspacing='0' cellpadding='0' border='0'>
2121 + <td align='left' class='textHeaderDark'>
2122 + <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>
2124 + <td align='center' class='textHeaderDark'>
2125 + 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]
2127 + <td align='right' class='textHeaderDark'>
2128 + <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>
2138 + $display_text = array(
2139 + "nosort" => array("Actions", ""),
2140 + "directory" => array("Name", "ASC"),
2141 + "id" => array("Load Order", "ASC"),
2142 + "name" => array("Description", "ASC"),
2143 + "nosort1" => array("Type", "ASC"),
2144 + "status" => array("Status", "ASC"),
2145 + "author" => array("Author", "ASC"),
2146 + "webpage" => array("Web Page", "ASC"),
2147 + "version" => array("Version", "ASC"));
2149 + html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), 1);
2152 + if (sizeof($plugins)) {
2153 + if (get_request_var_request("sort_column") == "id") {
2154 + $inst_system_plugins = get_system_plugins($plugins);
2155 + if (sizeof($inst_system_plugins)) {
2156 + foreach($inst_system_plugins as $plugin) {
2157 + form_alternate_row_color($colors["alternate"], $colors["light"], $i); $i++;
2158 + print format_plugin_row($plugin, false, false, true);
2164 + foreach ($plugins as $plugin) {
2165 + if ((isset($plugins[$j+1]) && $plugins[$j+1]['status'] < 0) || (!isset($plugins[$j+1]))) {
2166 + $last_plugin = true;
2168 + $last_plugin = false;
2170 + if ($plugin['status'] <= 0 || is_system_plugin($plugin) || (get_request_var_request('sort_column') != 'id')) {
2171 + $load_ordering = false;
2173 + $load_ordering = true;
2176 + if (get_request_var_request("sort_column") == "id") {
2177 + if (!is_system_plugin($plugin)) {
2178 + form_alternate_row_color($colors["alternate"], $colors["light"], $i);
2179 + print format_plugin_row($plugin, $last_plugin, $load_ordering, false);
2183 + form_alternate_row_color($colors["alternate"], $colors["light"], $i);
2184 + print format_plugin_row($plugin, $last_plugin, $load_ordering, is_system_plugin($plugin));
2193 + print "<tr><td><em>No Plugins Found</em></td></tr>";
2196 + html_end_box(false);
2198 + html_start_box("", "100%", $colors["header"], "3", "center", "");
2199 + 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>";
2202 + print "</form>\n";
2205 +function format_plugin_row($plugin, $last_plugin, $include_ordering, $system_plugin) {
2206 + global $status_names;
2207 + static $first_plugin = true;
2209 + $row = plugin_actions($plugin);
2210 + $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>";
2211 + if ($include_ordering) {
2212 + $row .= "<td style='white-space:nowrap;'>";
2213 + if (!$first_plugin) {
2214 + $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>";
2216 + $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>";
2218 + if (!$last_plugin) {
2219 + $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>";
2221 + $row .= "<a href='#' title='Can Increase Load Order' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'></a>";
2223 + $row .= "</td>\n";
2225 + $row .= "<td></td>\n";
2228 + $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";
2229 + $row .= "<td style='white-space:nowrap;'>" . ($system_plugin ? "System": ($plugin['status'] < 0 ? "Old PIA":"General")) . "</td>\n";
2230 + $row .= "<td style='white-space:nowrap;'>" . $status_names[$plugin["status"]] . "</td>\n";
2231 + $row .= "<td style='white-space:nowrap;'>" . $plugin["author"] . "</td>\n";
2232 + $row .= "<td><a href='" . htmlspecialchars($plugin["webpage"]) . "'>" . htmlspecialchars($plugin["webpage"]) . "</a></td>\n";
2233 + $row .= "<td>" . $plugin["version"] . "</td>\n";
2234 + $row .= "</tr>\n";
2236 + if ($include_ordering) {
2237 + $first_plugin = false;
2243 +function plugin_actions($plugin) {
2245 + switch ($plugin['status']) {
2246 + case "-2": // Old PA Not Installed
2247 + $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>";
2248 + $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
2250 + case "-1": // Old PA Currently Active
2251 + $oldplugins = read_config_option('oldplugins');
2252 + $oldplugins = explode(',', $oldplugins);
2253 + if (in_array($plugin['directory'], $oldplugins)) {
2254 + $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>";
2256 + $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>";
2258 + $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
2260 + case "0": // Not Installed
2261 + $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>";
2262 + $link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
2264 + case "1": // Currently Active
2265 + $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>";
2266 + $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>";
2268 + case "4": // Installed but not active
2269 + $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>";
2270 + $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>";
2272 + default: // Old PIA
2273 + $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>";
2274 + $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>";
2282 +function is_system_plugin($plugin) {
2283 + global $plugins_system;
2285 + if (is_array($plugin)) {
2286 + $plugin = $plugin["directory"];
2289 + if (!in_array($plugin, $plugins_system)) {
2296 +function get_system_plugins($plugins) {
2297 + $inst_system_plugins = array();
2299 + if (sizeof($plugins)) {
2300 + foreach($plugins as $plugin) {
2301 + if (is_system_plugin($plugin)) {
2302 + $inst_system_plugins[] = $plugin;
2307 + return $inst_system_plugins;
2311 diff -Naur cacti-0.8.7g-old/poller.php cacti-0.8.7g/poller.php
2312 --- cacti-0.8.7g-old/poller.php 2010-07-09 18:33:46.000000000 -0400
2313 +++ cacti-0.8.7g/poller.php 2010-07-09 18:34:11.000000000 -0400
2315 pcntl_signal(SIGINT, "sig_handler");
2318 +api_plugin_hook('poller_top');
2320 /* record the start time */
2321 list($micro,$seconds) = split(" ", microtime());
2322 $poller_start = $seconds + $micro;
2324 $total_procs = $concurrent_processes;
2327 + $extra_args = api_plugin_hook_function ('poller_command_args', $extra_args);
2329 /* Populate each execution file with appropriate information */
2330 foreach ($polling_hosts as $item) {
2331 if ($host_count == 1) {
2333 echo " --debug|-d Output debug information. Similar to cacti's DEBUG logging level.\n\n";
2336 +api_plugin_hook('poller_bottom');
2339 diff -Naur cacti-0.8.7g-old/user_admin.php cacti-0.8.7g/user_admin.php
2340 --- cacti-0.8.7g-old/user_admin.php 2010-07-09 18:33:46.000000000 -0400
2341 +++ cacti-0.8.7g/user_admin.php 2010-07-09 18:34:11.000000000 -0400
2346 - include_once("include/top_header.php");
2348 - include_once("include/bottom_footer.php");
2349 + if (!api_plugin_hook_function('user_admin_action', get_request_var_request("action"))) {
2350 + include_once("include/top_header.php");
2352 + include_once("include/bottom_footer.php");
2358 $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);
2359 $save["realm"] = get_request_var_post("realm", 0);
2360 $save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3);
2361 + $save = api_plugin_hook_function('user_admin_setup_sql_save', $save);
2363 if (!is_error_message()) {
2364 $user_id = sql_save($save, "user_auth");
2366 policy_hosts = " . get_request_var_post("policy_hosts") . ",
2367 policy_graph_templates = " . get_request_var_post("policy_graph_templates") . "
2368 WHERE id = " . get_request_var_post("id"));
2370 + api_plugin_hook('user_admin_user_save');
2375 $header_label = "[new]";
2378 + api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0));
2380 html_start_box("<strong>User Management</strong> $header_label", "100%", $colors["header"], "3", "center", "");
2382 draw_edit_form(array(
2383 diff -Naur cacti-0.8.7g-old/utilities.php cacti-0.8.7g/utilities.php
2384 --- cacti-0.8.7g-old/utilities.php 2010-07-09 18:33:46.000000000 -0400
2385 +++ cacti-0.8.7g/utilities.php 2010-07-09 18:34:11.000000000 -0400
2386 @@ -123,11 +123,14 @@
2387 include_once("./include/bottom_footer.php");
2390 - include_once("./include/top_header.php");
2393 + if (!api_plugin_hook_function('utilities_action', $_REQUEST['action'])) {
2394 + include_once('./include/top_header.php');
2396 - include_once("./include/bottom_footer.php");
2399 + include_once('./include/bottom_footer.php');
2404 @@ -1644,6 +1647,8 @@
2408 + api_plugin_hook('utilities_list');