Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 346741 | Differences between
and this patch

Collapse All | Expand All

(-)cacti-0.8.7g.orig//auth_changepassword.php (+2 lines)
Lines 59-64 Link Here
59
					header("Location: index.php"); break;
59
					header("Location: index.php"); break;
60
				case '3': /* default graph page */
60
				case '3': /* default graph page */
61
					header("Location: graph_view.php"); break;
61
					header("Location: graph_view.php"); break;
62
				default:
63
					api_plugin_hook_function('login_options_navigate', $user['login_opts']);
62
			}
64
			}
63
		}else{
65
		}else{
64
			header("Location: graph_view.php");
66
			header("Location: graph_view.php");
(-)cacti-0.8.7g.orig//auth_login.php (-27 / +57 lines)
Lines 124-133 Link Here
124
		}
124
		}
125
125
126
	default:
126
	default:
127
		/* Builtin Auth */
127
		if (!api_plugin_hook_function('login_process', false)) {
128
		if ((!$user_auth) && (!$ldap_error)) {
128
			/* Builtin Auth */
129
			/* if auth has not occured process for builtin - AKA Ldap fall through */
129
			if ((!$user_auth) && (!$ldap_error)) {
130
			$user = db_fetch_row("SELECT * FROM user_auth WHERE username = '" . $username . "' AND password = '" . md5(get_request_var_post("login_password")) . "' AND realm = 0");
130
				/* if auth has not occured process for builtin - AKA Ldap fall through */
131
				$user = db_fetch_row("SELECT * FROM user_auth WHERE username = '" . $username . "' AND password = '" . md5(get_request_var_post("login_password")) . "' AND realm = 0");
132
			}
131
		}
133
		}
132
	}
134
	}
133
	/* end of switch */
135
	/* end of switch */
Lines 189-217 Link Here
189
		decide what to do next */
191
		decide what to do next */
190
		switch ($user["login_opts"]) {
192
		switch ($user["login_opts"]) {
191
			case '1': /* referer */
193
			case '1': /* referer */
192
				if (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE realm_id = 8 AND user_id = " . $_SESSION["sess_user_id"])) == 0) {
194
				/* because we use plugins, we can't redirect back to graph_view.php if they don't
193
					header("Location: graph_view.php");
195
				 * have console access
194
				}else{
196
				 */
195
					if (isset($_SERVER["HTTP_REFERER"])) {
197
				if (isset($_SERVER["HTTP_REFERER"])) {
196
						$referer = $_SERVER["HTTP_REFERER"];
198
					$referer = $_SERVER["HTTP_REFERER"];
197
						if (basename($referer) == "logout.php") {
199
					if (basename($referer) == "logout.php") {
198
							$referer = "index.php";
200
						$referer = $config['url_path'] . "index.php";
199
						}
201
					}
200
					} else if (isset($_SERVER["REQUEST_URI"])) {
202
				} else if (isset($_SERVER["REQUEST_URI"])) {
201
						$referer = $_SERVER["REQUEST_URI"];
203
					$referer = $_SERVER["REQUEST_URI"];
202
						if (basename($referer) == "logout.php") {
204
					if (basename($referer) == "logout.php") {
203
							$referer = "index.php";
205
						$referer = $config['url_path'] . "index.php";
204
						}
205
					} else {
206
						$referer = "index.php";
207
					}
206
					}
207
				} else {
208
					$referer = $config['url_path'] . "index.php";
209
				}
210
211
				if (substr_count($referer, "plugins")) {
208
					header("Location: " . $referer);
212
					header("Location: " . $referer);
213
				} elseif (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE realm_id = 8 AND user_id = " . $_SESSION["sess_user_id"])) == 0) {
214
					header("Location: graph_view.php");
215
				} else {
216
					header("Location: $referer");
209
				}
217
				}
218
210
				break;
219
				break;
211
			case '2': /* default console page */
220
			case '2': /* default console page */
212
				header("Location: index.php"); break;
221
				header("Location: " . $config['url_path'] . "index.php");
222
223
				break;
213
			case '3': /* default graph page */
224
			case '3': /* default graph page */
214
				header("Location: graph_view.php"); break;
225
				header("Location: " . $config['url_path'] . "graph_view.php");
226
227
				break;
228
			default:
229
				api_plugin_hook_function('login_options_navigate', $user['login_opts']);
215
		}
230
		}
216
		exit;
231
		exit;
217
	}else{
232
	}else{
Lines 264-272 Link Here
264
<body bgcolor="#FFFFFF" onload="document.login.login_username.focus()">
279
<body bgcolor="#FFFFFF" onload="document.login.login_username.focus()">
265
	<form name="login" method="post" action="<?php print basename($_SERVER["PHP_SELF"]);?>">
280
	<form name="login" method="post" action="<?php print basename($_SERVER["PHP_SELF"]);?>">
266
	<input type="hidden" name="action" value="login">
281
	<input type="hidden" name="action" value="login">
282
<?php
283
284
api_plugin_hook("login_before");
285
286
$cacti_logo = $config['url_path'] . 'images/auth_login.gif';
287
$cacti_logo = api_plugin_hook_function('cacti_image', $cacti_logo);
288
289
?>
267
	<table align="center">
290
	<table align="center">
268
		<tr>
291
		<tr>
269
			<td colspan="2"><img src="images/auth_login.gif" border="0" alt=""></td>
292
			<td colspan="2"><center><?php if ($cacti_logo != '') { ?><img src="<?php echo $cacti_logo; ?>" border="0" alt=""><?php } ?></center></td>
270
		</tr>
293
		</tr>
271
		<?php
294
		<?php
272
295
Lines 303-324 Link Here
303
			<td><input type="password" name="login_password" size="40" style="width: 295px;"></td>
326
			<td><input type="password" name="login_password" size="40" style="width: 295px;"></td>
304
		</tr>
327
		</tr>
305
		<?php
328
		<?php
306
		if (read_config_option("auth_method") == "3") {?>
329
		if (read_config_option("auth_method") == "3" || api_plugin_hook_function('login_realms_exist')) {
330
			$realms = api_plugin_hook_function('login_realms', array("local" => array("name" => "Local", "selected" => false), "ldap" => array("name" => "LDAP", "selected" => true)));
331
			?>
307
		<tr>
332
		<tr>
308
			<td>Realm:</td>
333
			<td>Realm:</td>
309
			<td>
334
			<td>
310
				<select name="realm" style="width: 295px;">
335
				<select name="realm" style="width: 295px;"><?php
311
					<option value="local">Local</option>
336
				if (sizeof($realms)) {
312
					<option value="ldap" selected>LDAP</option>
337
				foreach($realms as $name => $realm) {
338
					print "\t\t\t\t\t<option value='" . $name . "'" . ($realm["selected"] ? " selected":"") . ">" . htmlspecialchars($realm["name"]) . "</option>\n";
339
				}
340
				}
341
				?>
313
				</select>
342
				</select>
314
			</td>
343
			</td>
315
			</tr>
344
		</tr>
316
		<?php }?>
345
		<?php }?>
317
		<tr style="height:10px;"><td></td></tr>
346
		<tr style="height:10px;"><td></td></tr>
318
		<tr>
347
		<tr>
319
			<td><input type="submit" value="Login"></td>
348
			<td><input type="submit" value="Login"></td>
320
		</tr>
349
		</tr>
321
	</table>
350
	</table>
351
<?php api_plugin_hook('login_after'); ?>
322
	</form>
352
	</form>
323
</body>
353
</body>
324
</html>
354
</html>
(-)cacti-0.8.7g.orig//cli/add_graph_template.php (+1 lines)
Lines 144-149 Link Here
144
		exit(1);
144
		exit(1);
145
	}else{
145
	}else{
146
		db_execute("replace into host_graph (host_id,graph_template_id) values (" . $host_id . "," . $graph_template_id . ")");
146
		db_execute("replace into host_graph (host_id,graph_template_id) values (" . $host_id . "," . $graph_template_id . ")");
147
		api_plugin_hook_function('add_graph_template_to_host', array("host_id" => $host_id, "graph_template_id" => $graph_template_id));
147
	}
148
	}
148
149
149
	if (is_error_message()) {
150
	if (is_error_message()) {
(-)cacti-0.8.7g.orig//cli/add_tree.php (+1 lines)
Lines 33-38 Link Here
33
include(dirname(__FILE__)."/../include/global.php");
33
include(dirname(__FILE__)."/../include/global.php");
34
include_once($config["base_path"]."/lib/api_automation_tools.php");
34
include_once($config["base_path"]."/lib/api_automation_tools.php");
35
include_once($config["base_path"].'/lib/tree.php');
35
include_once($config["base_path"].'/lib/tree.php');
36
include_once($config["base_path"].'/lib/api_tree.php');
36
37
37
/* process calling arguments */
38
/* process calling arguments */
38
$parms = $_SERVER["argv"];
39
$parms = $_SERVER["argv"];
(-)cacti-0.8.7g.orig//cli/host_update_template.php (+1 lines)
Lines 136-141 Link Here
136
136
137
			foreach ($graph_templates as $graph_template) {
137
			foreach ($graph_templates as $graph_template) {
138
				db_execute("REPLACE INTO host_graph (host_id, graph_template_id) VALUES (" . $host["id"] . ", " . $graph_template["graph_template_id"] . ")");
138
				db_execute("REPLACE INTO host_graph (host_id, graph_template_id) VALUES (" . $host["id"] . ", " . $graph_template["graph_template_id"] . ")");
139
				api_plugin_hook_function('add_graph_template_to_host', array("host_id" => $host_id, "graph_template_id" => $graph_template["graph_template_id"]));
139
			}
140
			}
140
		}
141
		}
141
	}
142
	}
(-)cacti-0.8.7g.orig//data_sources.php (-2 / +17 lines)
Lines 44-49 Link Here
44
	7 => "Disable"
44
	7 => "Disable"
45
	);
45
	);
46
46
47
$ds_actions = api_plugin_hook_function('data_source_action_array', $ds_actions);
48
47
/* set default action */
49
/* set default action */
48
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
50
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
49
51
Lines 402-407 Link Here
402
				api_reapply_suggested_data_source_title($selected_items[$i]);
404
				api_reapply_suggested_data_source_title($selected_items[$i]);
403
				update_data_source_title_cache($selected_items[$i]);
405
				update_data_source_title_cache($selected_items[$i]);
404
			}
406
			}
407
		} else {
408
			api_plugin_hook_function('data_source_action_execute', $_POST['drp_action']);
405
		}
409
		}
406
		header("Location: data_sources.php");
410
		header("Location: data_sources.php");
407
		exit;
411
		exit;
Lines 545-550 Link Here
545
				</tr>\n
549
				</tr>\n
546
				";
550
				";
547
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Reapply Suggested Naming to Data Source(s)'>";
551
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Reapply Suggested Naming to Data Source(s)'>";
552
		}else{
553
			$save['drp_action'] = $_POST['drp_action'];
554
			$save['ds_list'] = $ds_list;
555
			$save['ds_array'] = (isset($ds_array)? $ds_array : array());
556
			api_plugin_hook_function('data_source_action_prepare', $save);
557
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
548
		}
558
		}
549
	}else{
559
	}else{
550
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one data source.</span></td></tr>\n";
560
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one data source.</span></td></tr>\n";
Lines 683-688 Link Here
683
	input_validate_input_number(get_request_var("host_id"));
693
	input_validate_input_number(get_request_var("host_id"));
684
	/* ==================================================== */
694
	/* ==================================================== */
685
695
696
	api_plugin_hook('data_source_edit_top');
697
686
	$use_data_template = true;
698
	$use_data_template = true;
687
	$host_id = 0;
699
	$host_id = 0;
688
700
Lines 975-982 Link Here
975
987
976
	form_save_button("data_sources.php");
988
	form_save_button("data_sources.php");
977
989
978
	include_once("./include/bottom_footer.php");
990
	api_plugin_hook('data_source_edit_bottom');
979
991
992
	include_once("./include/bottom_footer.php");
980
}
993
}
981
994
982
function get_poller_interval($seconds) {
995
function get_poller_interval($seconds) {
Lines 1310-1317 Link Here
1310
	$i = 0;
1323
	$i = 0;
1311
	if (sizeof($data_sources) > 0) {
1324
	if (sizeof($data_sources) > 0) {
1312
		foreach ($data_sources as $data_source) {
1325
		foreach ($data_sources as $data_source) {
1326
			$data_source["data_template_name"] = htmlspecialchars($data_source["data_template_name"]);
1327
			$data_source = api_plugin_hook_function('data_sources_table', $data_source);
1313
			/* we're escaping strings here, so no need to escape them on form_selectable_cell */
1328
			/* we're escaping strings here, so no need to escape them on form_selectable_cell */
1314
			$data_template_name = ((empty($data_source["data_template_name"])) ? "<em>None</em>" : htmlspecialchars($data_source["data_template_name"]));
1329
			$data_template_name = ((empty($data_source["data_template_name"])) ? "<em>None</em>" : $data_source["data_template_name"]);
1315
			$data_input_name    = ((empty($data_source["data_input_name"])) ? "<em>External</em>" : htmlspecialchars($data_source["data_input_name"]));
1330
			$data_input_name    = ((empty($data_source["data_input_name"])) ? "<em>External</em>" : htmlspecialchars($data_source["data_input_name"]));
1316
			$poller_interval    = ((isset($poller_intervals[$data_source["local_data_id"]])) ? $poller_intervals[$data_source["local_data_id"]] : 0);
1331
			$poller_interval    = ((isset($poller_intervals[$data_source["local_data_id"]])) ? $poller_intervals[$data_source["local_data_id"]] : 0);
1317
			form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $data_source["local_data_id"]); $i++;
1332
			form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $data_source["local_data_id"]); $i++;
(-)cacti-0.8.7g.orig//graph.php (+12 lines)
Lines 32-37 Link Here
32
include_once("./lib/html_tree.php");
32
include_once("./lib/html_tree.php");
33
include_once("./include/top_graph_header.php");
33
include_once("./include/top_graph_header.php");
34
34
35
api_plugin_hook_function('graph');
36
35
/* ================= input validation ================= */
37
/* ================= input validation ================= */
36
input_validate_input_regex(get_request_var("rra_id"), "^([0-9]+|all)$");
38
input_validate_input_regex(get_request_var("rra_id"), "^([0-9]+|all)$");
37
input_validate_input_number(get_request_var("local_graph_id"));
39
input_validate_input_number(get_request_var("local_graph_id"));
Lines 77-82 Link Here
77
79
78
switch ($_REQUEST["action"]) {
80
switch ($_REQUEST["action"]) {
79
case 'view':
81
case 'view':
82
	do_hook_function('page_buttons',
83
		array('lgid' => $_GET["local_graph_id"],
84
			'leafid' => '',//$leaf_id,
85
			'mode' => 'mrtg',
86
			'rraid' => $_GET["rra_id"])
87
		);
80
	?>
88
	?>
81
	<tr bgcolor='#<?php print $colors["header"];?>'>
89
	<tr bgcolor='#<?php print $colors["header"];?>'>
82
		<td colspan='3' class='textHeaderDark'>
90
		<td colspan='3' class='textHeaderDark'>
Lines 100-105 Link Here
100
								<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>
108
								<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>
101
								<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>
109
								<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>
102
								<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>
110
								<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>
111
								<?php api_plugin_hook('graph_buttons', array('hook' => 'view', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $rra['id'], 'view_type' => $_REQUEST['view_type'])); ?>
103
							</td>
112
							</td>
104
						</tr>
113
						</tr>
105
						<tr>
114
						<tr>
Lines 113-118 Link Here
113
			<?php
122
			<?php
114
			$i++;
123
			$i++;
115
		}
124
		}
125
		do_hook_function('tree_view_page_end');
116
	}
126
	}
117
127
118
	break;
128
	break;
Lines 215-220 Link Here
215
					<td valign='top' style='padding: 3px;' class='noprint'>
225
					<td valign='top' style='padding: 3px;' class='noprint'>
216
						<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>
226
						<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>
217
						<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>
227
						<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>
228
						<?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'])); ?>
218
					</td>
229
					</td>
219
				</tr>
230
				</tr>
220
				<tr>
231
				<tr>
Lines 247-252 Link Here
247
					<td valign='top' style='padding: 3px;'>
258
					<td valign='top' style='padding: 3px;'>
248
						<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>
259
						<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>
249
						<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>
260
						<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>
261
						<?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'])); ?>
250
					</td>
262
					</td>
251
				</tr>
263
				</tr>
252
				<tr>
264
				<tr>
(-)cacti-0.8.7g.orig//graph_image.php (+2 lines)
Lines 44-49 Link Here
44
/* flush the headers now */
44
/* flush the headers now */
45
ob_end_clean();
45
ob_end_clean();
46
46
47
api_plugin_hook_function('graph_image');
48
47
session_write_close();
49
session_write_close();
48
50
49
$graph_data_array = array();
51
$graph_data_array = array();
(-)cacti-0.8.7g.orig//graphs.php (+10 lines)
Lines 45-50 Link Here
45
	4 => "Convert to Graph Template"
45
	4 => "Convert to Graph Template"
46
	);
46
	);
47
47
48
$graph_actions = api_plugin_hook_function('graphs_action_array', $graph_actions);
49
48
/* set default action */
50
/* set default action */
49
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
51
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
50
52
Lines 362-367 Link Here
362
364
363
				api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
365
				api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
364
			}
366
			}
367
		} else {
368
			api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
365
		}
369
		}
366
370
367
		header("Location: graphs.php");
371
		header("Location: graphs.php");
Lines 514-519 Link Here
514
				";
518
				";
515
519
516
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Resize Selected Graph(s)'>";
520
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Resize Selected Graph(s)'>";
521
		} else {
522
			$save['drp_action'] = $_POST['drp_action'];
523
			$save['graph_list'] = $graph_list;
524
			$save['graph_array'] = (isset($graph_array) ? $graph_array : array());
525
			api_plugin_hook_function('graphs_action_prepare', $save);
526
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
517
		}
527
		}
518
	}else{
528
	}else{
519
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one graph.</span></td></tr>\n";
529
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one graph.</span></td></tr>\n";
(-)cacti-0.8.7g.orig//graphs_new.php (-1 / +2 lines)
Lines 511-517 Link Here
511
			</td>
511
			</td>
512
			<td nowrap style='white-space: nowrap;' class="textInfo" align="center" valign="top">
512
			<td nowrap style='white-space: nowrap;' class="textInfo" align="center" valign="top">
513
				<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>
513
				<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>
514
				<span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit");?>">Create New Host</a>
514
				<span style="white-space: nowrap; color: #c16921;">*</span><a href="<?php print htmlspecialchars("host.php?action=edit");?>">Create New Host</a><br>
515
				<?php api_plugin_hook('graphs_new_top_links'); ?>
515
			</td>
516
			</td>
516
		</tr>
517
		</tr>
517
	</table>
518
	</table>
(-)cacti-0.8.7g.orig//host.php (+16 lines)
Lines 44-49 Link Here
44
	6 => "Change Availability Options"
44
	6 => "Change Availability Options"
45
	);
45
	);
46
46
47
$device_actions = api_plugin_hook_function('device_action_array', $device_actions);
48
47
/* set default action */
49
/* set default action */
48
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
50
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
49
51
Lines 137-142 Link Here
137
		/* ==================================================== */
139
		/* ==================================================== */
138
140
139
		db_execute("replace into host_graph (host_id,graph_template_id) values (" . $_POST["id"] . "," . $_POST["graph_template_id"] . ")");
141
		db_execute("replace into host_graph (host_id,graph_template_id) values (" . $_POST["id"] . "," . $_POST["graph_template_id"] . ")");
142
		api_plugin_hook_function('add_graph_template_to_host', array("host_id" => $_POST["id"], "graph_template_id" => $_POST["graph_template_id"]));
140
143
141
		header("Location: host.php?action=edit&id=" . $_POST["id"]);
144
		header("Location: host.php?action=edit&id=" . $_POST["id"]);
142
		exit;
145
		exit;
Lines 305-310 Link Here
305
308
306
				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);
309
				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);
307
			}
310
			}
311
		} else {
312
			api_plugin_hook_function('device_action_execute', $_POST['drp_action']);
308
		}
313
		}
309
314
310
		header("Location: host.php");
315
		header("Location: host.php");
Lines 450-455 Link Here
450
				<input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
455
				<input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
451
				";
456
				";
452
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Place Device(s) on Tree'>";
457
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Place Device(s) on Tree'>";
458
		} else {
459
			$save['drp_action'] = $_POST['drp_action'];
460
			$save['host_list'] = $host_list;
461
			$save['host_array'] = (isset($host_array)? $host_array : array());
462
			api_plugin_hook_function('device_action_prepare', $save);
463
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
453
		}
464
		}
454
	}else{
465
	}else{
455
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one device.</span></td></tr>\n";
466
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one device.</span></td></tr>\n";
Lines 532-537 Link Here
532
	input_validate_input_number(get_request_var("id"));
543
	input_validate_input_number(get_request_var("id"));
533
	/* ==================================================== */
544
	/* ==================================================== */
534
545
546
	api_plugin_hook('host_edit_top');
547
535
	if (!empty($_GET["id"])) {
548
	if (!empty($_GET["id"])) {
536
		$host = db_fetch_row("select * from host where id=" . $_GET["id"]);
549
		$host = db_fetch_row("select * from host where id=" . $_GET["id"]);
537
		$header_label = "[edit: " . htmlspecialchars($host["description"]) . "]";
550
		$header_label = "[edit: " . htmlspecialchars($host["description"]) . "]";
Lines 643-648 Link Here
643
					<span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs_new.php?host_id=" . $host["id"]);?>">Create Graphs for this Host</a><br>
656
					<span style="color: #c16921;">*</span><a href="<?php print htmlspecialchars("graphs_new.php?host_id=" . $host["id"]);?>">Create Graphs for this Host</a><br>
644
					<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>
657
					<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>
645
					<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>
658
					<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>
659
					<?php api_plugin_hook('device_edit_top_links'); ?>
646
				</td>
660
				</td>
647
			</tr>
661
			</tr>
648
		</table>
662
		</table>
Lines 1107-1112 Link Here
1107
	}
1121
	}
1108
1122
1109
	form_save_button("host.php", "return");
1123
	form_save_button("host.php", "return");
1124
1125
	api_plugin_hook('host_edit_bottom');
1110
}
1126
}
1111
1127
1112
function host() {
1128
function host() {
(-)cacti-0.8.7g.orig//include/auth.php (-6 / +9 lines)
Lines 26-39 Link Here
26
26
27
/* check to see if this is a new installation */
27
/* check to see if this is a new installation */
28
if (db_fetch_cell("select cacti from version") != $config["cacti_version"]) {
28
if (db_fetch_cell("select cacti from version") != $config["cacti_version"]) {
29
	header ("Location: install/");
29
	header ("Location: " . $config['url_path'] . "install/");
30
	exit;
30
	exit;
31
}
31
}
32
32
33
if (read_config_option("auth_method") != 0) {
33
if (read_config_option("auth_method") != 0) {
34
	/* handle alternate authentication realms */
35
	api_plugin_hook_function('auth_alternate_realms');
36
34
	/* handle change password dialog */
37
	/* handle change password dialog */
35
	if ((isset($_SESSION['sess_change_password'])) && (read_config_option("webbasic_enabled") != "on")) {
38
	if ((isset($_SESSION['sess_change_password'])) && (read_config_option("webbasic_enabled") != "on")) {
36
		header ("Location: auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php"));
39
		header ("Location: " . $config['url_path'] . "auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php"));
37
		exit;
40
		exit;
38
	}
41
	}
39
42
Lines 72-80 Link Here
72
			and user_auth_realm.realm_id='$realm_id'")) || (empty($realm_id)))) {
75
			and user_auth_realm.realm_id='$realm_id'")) || (empty($realm_id)))) {
73
76
74
			if (isset($_SERVER["HTTP_REFERER"])) {
77
			if (isset($_SERVER["HTTP_REFERER"])) {
75
				$goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . htmlspecialchars($_SERVER["HTTP_REFERER"]) . "'>Return</a> | <a href='logout.php'>Login Again</a> )</td>";
78
				$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>";
76
			}else{
79
			}else{
77
				$goBack = "<td class='textArea' colspan='2' align='center'>( <a href='logout.php'>Login Again</a> )</td>";
80
				$goBack = "<td class='textArea' colspan='2' align='center'>( <a href='" . $config['url_path'] . "logout.php'>Login Again</a> )</td>";
78
			}
81
			}
79
82
80
			?>
83
			?>
Lines 83-96 Link Here
83
			<head>
86
			<head>
84
				<title>Cacti</title>
87
				<title>Cacti</title>
85
				<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
88
				<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
86
				<link href="include/main.css" type="text/css" rel="stylesheet">
89
				<link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
87
			</head>
90
			</head>
88
			<body>
91
			<body>
89
			<br><br>
92
			<br><br>
90
93
91
			<table width="450" align='center'>
94
			<table width="450" align='center'>
92
				<tr>
95
				<tr>
93
					<td colspan='2'><img src='images/auth_deny.gif' border='0' alt='Access Denied'></td>
96
					<td colspan='2'><img src='<?php echo $config['url_path']; ?>images/auth_deny.gif' border='0' alt='Access Denied'></td>
94
				</tr>
97
				</tr>
95
				<tr style='height:10px;'><td></td></tr>
98
				<tr style='height:10px;'><td></td></tr>
96
				<tr>
99
				<tr>
(-)cacti-0.8.7g.orig//include/bottom_footer.php (+7 lines)
Lines 21-26 Link Here
21
 | http://www.cacti.net/                                                   |
21
 | http://www.cacti.net/                                                   |
22
 +-------------------------------------------------------------------------+
22
 +-------------------------------------------------------------------------+
23
*/
23
*/
24
25
$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
26
if (($oper_mode == OPER_MODE_NATIVE) || ($oper_mode == OPER_MODE_IFRAME_NONAV)) {
27
24
?>
28
?>
25
			</div>
29
			</div>
26
			<br>
30
			<br>
Lines 32-37 Link Here
32
</html>
36
</html>
33
37
34
<?php
38
<?php
39
40
}
41
35
/* we use this session var to store field values for when a save fails,
42
/* we use this session var to store field values for when a save fails,
36
this way we can restore the field's previous values. we reset it here, because
43
this way we can restore the field's previous values. we reset it here, because
37
they only need to be stored for a single page */
44
they only need to be stored for a single page */
(-)cacti-0.8.7g.orig//include/config.php (+11 lines)
Lines 30-35 Link Here
30
$database_password = "cactiuser";
30
$database_password = "cactiuser";
31
$database_port = "3306";
31
$database_port = "3306";
32
32
33
/* load up old style plugins here */
34
$plugins = array();
35
//$plugins[] = 'thold';
36
37
/*
38
   Edit this to point to the default URL of your Cacti install
39
   ex: if your cacti install as at http://serverip/cacti/ this
40
   would be set to /cacti/
41
*/
42
$url_path = "/";
43
33
/* Default session name - Session name must contain alpha characters */
44
/* Default session name - Session name must contain alpha characters */
34
#$cacti_session_name = "Cacti";
45
#$cacti_session_name = "Cacti";
35
46
(-)cacti-0.8.7g.orig//include/global.php (-4 / +15 lines)
Lines 93-98 Link Here
93
/* built-in snmp support */
93
/* built-in snmp support */
94
$config["php_snmp_support"] = function_exists("snmpget");
94
$config["php_snmp_support"] = function_exists("snmpget");
95
95
96
/* set URL path */
97
if (! isset($url_path)) { 
98
	$url_path = "";
99
}
100
$config['url_path'] = $url_path;
101
define('URL_PATH', $url_path);
102
96
/* used for includes */
103
/* used for includes */
97
$config["base_path"] = strtr(ereg_replace("(.*)[\\\/]include", "\\1", dirname(__FILE__)), "\\", "/");
104
$config["base_path"] = strtr(ereg_replace("(.*)[\\\/]include", "\\1", dirname(__FILE__)), "\\", "/");
98
$config["library_path"] = ereg_replace("(.*[\\\/])include", "\\1lib", dirname(__FILE__));
105
$config["library_path"] = ereg_replace("(.*[\\\/])include", "\\1lib", dirname(__FILE__));
Lines 188-202 Link Here
188
/* include base modules */
195
/* include base modules */
189
include("adodb/adodb.inc.php");
196
include("adodb/adodb.inc.php");
190
include($config["library_path"] . "/database.php");
197
include($config["library_path"] . "/database.php");
191
include_once($config["library_path"] . "/functions.php");
192
include_once($config["include_path"] . "/global_constants.php");
193
include_once($config["include_path"] . "/global_arrays.php");
194
include_once($config["include_path"] . "/global_settings.php");
195
198
196
/* connect to the database server */
199
/* connect to the database server */
197
db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
200
db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
198
201
199
/* include additional modules */
202
/* include additional modules */
203
include_once($config["library_path"] . "/functions.php");
204
include_once($config["include_path"] . "/global_constants.php");
205
include_once($config["library_path"] . "/plugins.php");
206
include_once($config["include_path"] . "/plugins.php");
207
include_once($config["include_path"] . "/global_arrays.php");
208
include_once($config["include_path"] . "/global_settings.php");
200
include_once($config["include_path"] . "/global_form.php");
209
include_once($config["include_path"] . "/global_form.php");
201
include_once($config["library_path"] . "/html.php");
210
include_once($config["library_path"] . "/html.php");
202
include_once($config["library_path"] . "/html_form.php");
211
include_once($config["library_path"] . "/html_form.php");
Lines 205-210 Link Here
205
include_once($config["library_path"] . "/variables.php");
214
include_once($config["library_path"] . "/variables.php");
206
include_once($config["library_path"] . "/auth.php");
215
include_once($config["library_path"] . "/auth.php");
207
216
217
api_plugin_hook("config_insert");
218
208
/* current cacti version */
219
/* current cacti version */
209
$config["cacti_version"] = "0.8.7g";
220
$config["cacti_version"] = "0.8.7g";
210
221
(-)cacti-0.8.7g.orig//include/global.php.orig (+211 lines)
Line 0 Link Here
1
<?php
2
/*
3
 +-------------------------------------------------------------------------+
4
 | Copyright (C) 2004-2010 The Cacti Group                                 |
5
 |                                                                         |
6
 | This program is free software; you can redistribute it and/or           |
7
 | modify it under the terms of the GNU General Public License             |
8
 | as published by the Free Software Foundation; either version 2          |
9
 | of the License, or (at your option) any later version.                  |
10
 |                                                                         |
11
 | This program is distributed in the hope that it will be useful,         |
12
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
13
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
14
 | GNU General Public License for more details.                            |
15
 +-------------------------------------------------------------------------+
16
 | Cacti: The Complete RRDTool-based Graphing Solution                     |
17
 +-------------------------------------------------------------------------+
18
 | This code is designed, written, and maintained by the Cacti Group. See  |
19
 | about.php and/or the AUTHORS file for specific developer information.   |
20
 +-------------------------------------------------------------------------+
21
 | http://www.cacti.net/                                                   |
22
 +-------------------------------------------------------------------------+
23
*/
24
25
/*
26
   !!! IMPORTANT !!!
27
28
   The following defaults are not to be altered.  Please refer to
29
   include/config.php for user configurable database settings.
30
31
*/
32
33
/* Default database settings*/
34
$database_type = "mysql";
35
$database_default = "cacti";
36
$database_hostname = "localhost";
37
$database_username = "cactiuser";
38
$database_password = "cactiuser";
39
$database_port = "3306";
40
41
/* Default session name - Session name must contain alpha characters */
42
$cacti_session_name = "Cacti";
43
44
/* Include configuration */
45
include(dirname(__FILE__) . "/config.php");
46
47
if (isset($config["cacti_version"])) {
48
	die("Invalid include/config.php file detected.");
49
	exit;
50
}
51
52
/* display ALL errors,
53
 * but suppress deprecated warnings as a workaround until 088 */
54
if (defined("E_DEPRECATED")) {
55
	error_reporting(E_ALL ^ E_DEPRECATED);
56
}else{
57
	error_reporting(E_ALL);
58
}
59
60
/* Files that do not need http header information - Command line scripts */
61
$no_http_header_files = array(
62
	"cmd.php",
63
	"poller.php",
64
	"poller_commands.php",
65
	"script_server.php",
66
	"query_host_cpu.php",
67
	"query_host_partitions.php",
68
	"sql.php",
69
	"ss_host_cpu.php",
70
	"ss_host_disk.php",
71
	"ss_sql.php",
72
	"add_device.php",
73
	"add_graphs.php",
74
	"add_perms.php",
75
	"add_tree.php",
76
	"copy_user.php",
77
	"host_update_template.php",
78
	"poller_export.php",
79
	"poller_graphs_reapply_names.php",
80
	"poller_output_empty.php",
81
	"poller_reindex_hosts.php",
82
	"rebuild_poller_cache.php",
83
	"repair_database.php",
84
	"structure_rra_paths.php"
85
);
86
87
$config = array();
88
$colors = array();
89
90
/* this should be auto-detected, set it manually if needed */
91
$config["cacti_server_os"] = (strstr(PHP_OS, "WIN")) ? "win32" : "unix";
92
93
/* built-in snmp support */
94
$config["php_snmp_support"] = function_exists("snmpget");
95
96
/* used for includes */
97
$config["base_path"] = strtr(ereg_replace("(.*)[\\\/]include", "\\1", dirname(__FILE__)), "\\", "/");
98
$config["library_path"] = ereg_replace("(.*[\\\/])include", "\\1lib", dirname(__FILE__));
99
$config["include_path"] = dirname(__FILE__);
100
$config["rra_path"] = $config["base_path"] . '/rra';
101
102
/* colors */
103
$colors["dark_outline"] = "454E53";
104
$colors["dark_bar"] = "AEB4B7";
105
$colors["panel"] = "E5E5E5";
106
$colors["panel_text"] = "000000";
107
$colors["panel_link"] = "000000";
108
$colors["light"] = "F5F5F5";
109
$colors["alternate"] = "E7E9F2";
110
$colors["panel_dark"] = "C5C5C5";
111
112
$colors["header"] = "00438C";
113
$colors["header_panel"] = "6d88ad";
114
$colors["header_text"] = "ffffff";
115
$colors["form_background_dark"] = "E1E1E1";
116
117
$colors["form_alternate1"] = "F5F5F5";
118
$colors["form_alternate2"] = "E5E5E5";
119
120
if ((!in_array(basename($_SERVER["PHP_SELF"]), $no_http_header_files, true)) && ($_SERVER["PHP_SELF"] != "")) {
121
	/* Sanity Check on "Corrupt" PHP_SELF */
122
	if ($_SERVER["SCRIPT_NAME"] != $_SERVER["PHP_SELF"]) {
123
		echo "\nInvalid PHP_SELF Path \n";
124
		exit;
125
	}
126
127
	/* we don't want these pages cached */
128
	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
129
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
130
	header("Cache-Control: no-store, no-cache, must-revalidate");
131
	header("Cache-Control: post-check=0, pre-check=0", false);
132
	header("Pragma: no-cache");
133
	/* prevent IE from silently rejects cookies sent from third party sites. */
134
	header('P3P: CP="CAO PSA OUR"');
135
136
	/* initilize php session */
137
	session_name($cacti_session_name);
138
	session_start();
139
140
	/* detect and handle get_magic_quotes */
141
	if (!get_magic_quotes_gpc()) {
142
		function addslashes_deep($value) {
143
			$value = is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value);
144
			return $value;
145
		}
146
147
		$_POST   = array_map('addslashes_deep', $_POST);
148
		$_GET    = array_map('addslashes_deep', $_GET);
149
		$_COOKIE = array_map('addslashes_deep', $_COOKIE);
150
	}
151
152
	/* make sure to start only only Cacti session at a time */
153
	if (!isset($_SESSION["cacti_cwd"])) {
154
		$_SESSION["cacti_cwd"] = $config["base_path"];
155
	}else{
156
		if ($_SESSION["cacti_cwd"] != $config["base_path"]) {
157
			session_unset();
158
			session_destroy();
159
		}
160
	}
161
}
162
163
/* emulate 'register_globals' = 'off' if turned on */
164
if ((bool)ini_get("register_globals")) {
165
	$not_unset = array("_GET", "_POST", "_COOKIE", "_SERVER", "_SESSION", "_ENV", "_FILES", "database_type", "database_default", "database_hostname", "database_username", "database_password", "config", "colors");
166
167
	/* Not only will array_merge give a warning if a parameter is not an array, it will
168
	* actually fail. So we check if HTTP_SESSION_VARS has been initialised. */
169
	if (!isset($_SESSION)) {
170
		$_SESSION = array();
171
	}
172
173
	/* Merge all into one extremely huge array; unset this later */
174
	$input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_SESSION, $_ENV, $_FILES);
175
176
	unset($input["input"]);
177
	unset($input["not_unset"]);
178
179
	while (list($var,) = @each($input)) {
180
		if (!in_array($var, $not_unset)) {
181
			unset($$var);
182
		}
183
	}
184
185
	unset($input);
186
}
187
188
/* include base modules */
189
include("adodb/adodb.inc.php");
190
include($config["library_path"] . "/database.php");
191
include_once($config["library_path"] . "/functions.php");
192
include_once($config["include_path"] . "/global_constants.php");
193
include_once($config["include_path"] . "/global_arrays.php");
194
include_once($config["include_path"] . "/global_settings.php");
195
196
/* connect to the database server */
197
db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
198
199
/* include additional modules */
200
include_once($config["include_path"] . "/global_form.php");
201
include_once($config["library_path"] . "/html.php");
202
include_once($config["library_path"] . "/html_form.php");
203
include_once($config["library_path"] . "/html_utility.php");
204
include_once($config["library_path"] . "/html_validate.php");
205
include_once($config["library_path"] . "/variables.php");
206
include_once($config["library_path"] . "/auth.php");
207
208
/* current cacti version */
209
$config["cacti_version"] = "0.8.7g";
210
211
?>
(-)cacti-0.8.7g.orig//include/global_arrays.php (+8 lines)
Lines 22-27 Link Here
22
 +-------------------------------------------------------------------------+
22
 +-------------------------------------------------------------------------+
23
*/
23
*/
24
24
25
global $menu;
26
25
$messages = array(
27
$messages = array(
26
	1  => array(
28
	1  => array(
27
		"message" => 'Save Successful.',
29
		"message" => 'Save Successful.',
Lines 654-657 Link Here
654
	GDC_SLASH => "/"
656
	GDC_SLASH => "/"
655
	);
657
	);
656
658
659
$plugin_architecture = array(
660
	'version' => '2.9'
661
	);
662
663
api_plugin_hook('config_arrays');
664
657
?>
665
?>
(-)cacti-0.8.7g.orig//include/global_constants.php (+5 lines)
Lines 173-176 Link Here
173
define("SNMP_CMDPHP", 1);
173
define("SNMP_CMDPHP", 1);
174
define("SNMP_WEBUI", 2);
174
define("SNMP_WEBUI", 2);
175
175
176
define('OPER_MODE_NATIVE', 0);
177
define('OPER_MODE_RESKIN', 1);
178
define('OPER_MODE_IFRAME_NONAV', 2);
179
define('OPER_MODE_NOTABS', 3);
180
176
?>
181
?>
(-)cacti-0.8.7g.orig//include/global_form.php (-3 / +7 lines)
Lines 22-29 Link Here
22
 +-------------------------------------------------------------------------+
22
 +-------------------------------------------------------------------------+
23
*/
23
*/
24
24
25
if (!defined("VALID_HOST_FIELDS")) {
25
if (!defined('VALID_HOST_FIELDS')) {
26
	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)");
26
	$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)');
27
	define('VALID_HOST_FIELDS', $string);
27
}
28
}
28
29
29
/* file: cdef.php, action: edit */
30
/* file: cdef.php, action: edit */
Lines 1190-1193 Link Here
1190
		"dropdown_sql" => "select id,name from snmp_query order by name"
1191
		"dropdown_sql" => "select id,name from snmp_query order by name"
1191
		)
1192
		)
1192
	);
1193
	);
1193
?>
1194
1195
1196
api_plugin_hook('config_form');
1197
(-)cacti-0.8.7g.orig//include/global_settings.php (+2 lines)
Lines 1190-1193 Link Here
1190
		)
1190
		)
1191
	);
1191
	);
1192
1192
1193
api_plugin_hook('config_settings');
1194
1193
?>
1195
?>
(-)cacti-0.8.7g.orig//include/plugins.php (+43 lines)
Line 0 Link Here
1
<?php
2
3
/*
4
 * Copyright (c) 1999-2005 The SquirrelMail Project Team (http://squirrelmail.org)
5
 * Licensed under the GNU GPL. For full terms see the file COPYING.
6
 */
7
8
global $plugin_hooks, $plugins_system, $plugins;
9
$plugin_hooks = array();
10
$plugins_system = array('settings', 'boost', 'dsstats');
11
12
function use_plugin ($name) {
13
	global $config;
14
	if (file_exists($config['base_path'] . "/plugins/$name/setup.php")) {
15
		include_once($config['base_path'] . "/plugins/$name/setup.php");
16
		$function = "plugin_init_$name";
17
		if (function_exists($function)) {
18
			$function();
19
		}
20
	}
21
}
22
23
/**
24
 * This function executes a hook.
25
 * @param string $name Name of hook to fire
26
 * @return mixed $data
27
 */
28
if (!is_array($plugins)) {
29
	$plugins = array();
30
}
31
32
$oldplugins = read_config_option('oldplugins');
33
if (strlen(trim($oldplugins))) {
34
	$oldplugins = explode(',', $oldplugins);
35
	$plugins    = array_merge($plugins, $oldplugins);
36
}
37
38
/* On startup, register all plugins configured for use. */
39
if (isset($plugins) && is_array($plugins)) {
40
	foreach ($plugins as $name) {
41
		use_plugin($name);
42
	}
43
}
(-)cacti-0.8.7g.orig//include/top_graph_header.php (-19 / +36 lines)
Lines 25-30 Link Here
25
$using_guest_account = false;
25
$using_guest_account = false;
26
$show_console_tab = true;
26
$show_console_tab = true;
27
27
28
$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
29
28
/* ================= input validation ================= */
30
/* ================= input validation ================= */
29
input_validate_input_number(get_request_var_request("local_graph_id"));
31
input_validate_input_number(get_request_var_request("local_graph_id"));
30
input_validate_input_number(get_request_var_request("graph_start"));
32
input_validate_input_number(get_request_var_request("graph_start"));
Lines 52-100 Link Here
52
	$_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all";
54
	$_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all";
53
}
55
}
54
56
57
$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title"));
58
55
?>
59
?>
56
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
60
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
57
<html>
61
<html>
58
<head>
62
<head>
59
	<title><?php echo draw_navigation_text("title");?></title>
63
	<title><?php echo $page_title; ?></title>
60
	<?php
64
	<?php
61
	if (isset($_SESSION["custom"]) && $_SESSION["custom"] == true) {
65
	if (isset($_SESSION["custom"]) && $_SESSION["custom"] == true) {
62
		print "<meta http-equiv=refresh content='99999'>\r\n";
66
		print "<meta http-equiv=refresh content='99999'>\r\n";
63
	}else{
67
	}else{
64
		print "<meta http-equiv=refresh content='" . htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES) . "'>\r\n";
68
		$refresh = api_plugin_hook_function('top_graph_refresh', htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES));
69
		print "<meta http-equiv=refresh content='" . $refresh . "'>\r\n";
65
	}
70
	}
66
	?>
71
	?>
67
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
72
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
68
	<link href="include/main.css" type="text/css" rel="stylesheet">
73
	<link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
69
	<link href="images/favicon.ico" rel="shortcut icon"/>
74
	<link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
70
	<script type="text/javascript" src="include/layout.js"></script>
75
	<script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
71
	<script type="text/javascript" src="include/treeview/ua.js"></script>
76
	<script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ua.js"></script>
72
	<script type="text/javascript" src="include/treeview/ftiens4.js"></script>
77
	<script type="text/javascript" src="<?php echo $config['url_path']; ?>include/treeview/ftiens4.js"></script>
73
	<script type="text/javascript" src="include/jscalendar/calendar.js"></script>
78
	<script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar.js"></script>
74
	<script type="text/javascript" src="include/jscalendar/lang/calendar-en.js"></script>
79
	<script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/lang/calendar-en.js"></script>
75
	<script type="text/javascript" src="include/jscalendar/calendar-setup.js"></script>
80
	<script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar-setup.js"></script>
81
	<?php api_plugin_hook('page_head'); ?>
76
</head>
82
</head>
77
83
78
<body>
84
<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
85
<body <?php print api_plugin_hook_function("body_style", "");?>>
79
<a name='page_top'></a>
86
<a name='page_top'></a>
87
<?php }else{?>
88
<body <?php print api_plugin_hook_function("body_style", "");?>>
89
<?php }?>
90
80
<table style="width:100%;height:100%;" cellspacing="0" cellpadding="0">
91
<table style="width:100%;height:100%;" cellspacing="0" cellpadding="0">
92
<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
81
	<tr style="height:25px;" bgcolor="#a9a9a9" class="noprint">
93
	<tr style="height:25px;" bgcolor="#a9a9a9" class="noprint">
82
		<td colspan="2" valign="bottom" nowrap>
94
		<td colspan="2" valign="bottom" nowrap>
83
			<table width="100%" cellspacing="0" cellpadding="0">
95
			<table width="100%" cellspacing="0" cellpadding="0">
84
				<tr style="background: transparent url('images/cacti_backdrop2.gif') no-repeat center right;">
96
				<tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop2.gif') no-repeat center right;">
85
					<td id="tabs" nowrap>
97
					<td id="tabs" nowrap>
86
						&nbsp;<?php if ($show_console_tab == true) {?><a href="index.php"><img src="images/tab_console.gif" alt="Console" align="absmiddle" border="0"></a><?php }?><a href="graph_view.php"><img src="images/tab_graphs<?php if ((substr(basename($_SERVER["PHP_SELF"]),0,5) == "graph") || (basename($_SERVER["PHP_SELF"]) == "graph_settings.php")) { print "_down"; } print ".gif";?>" alt="Graphs" align="absmiddle" border="0"></a>&nbsp;
98
						&nbsp;<?php if ($show_console_tab == true) {?><a href="<?php echo $config['url_path']; ?>index.php"><img src="<?php echo $config['url_path']; ?>images/tab_console.gif" alt="Console" align="absmiddle" border="0"></a><?php }?><a href="<?php echo $config['url_path']; ?>graph_view.php"><img src="<?php echo $config['url_path']; ?>images/tab_graphs<?php if ((substr(basename($_SERVER["PHP_SELF"]),0,5) == "graph") || (basename($_SERVER["PHP_SELF"]) == "graph_settings.php")) { print "_down"; } print ".gif";?>" alt="Graphs" align="absmiddle" border="0"></a><?php
99
						api_plugin_hook('top_graph_header_tabs');
100
						?>
87
					</td>
101
					</td>
88
					<td id="gtabs" align="right" nowrap>
102
					<td id="gtabs" align="right" nowrap>
89
						<?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["graph_settings"] == "on")) { print '<a href="graph_settings.php"><img src="images/tab_settings'; if (basename($_SERVER["PHP_SELF"]) == "graph_settings.php") { print "_down"; } print '.gif" border="0" alt="Settings" align="absmiddle"></a>';}?>&nbsp;&nbsp;<?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_tree"] == "on")) {?><a href="<?php print htmlspecialchars("graph_view.php?action=tree");?>"><img src="images/tab_mode_tree<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "tree") { print "_down"; }?>.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_list"] == "on")) {?><a href="graph_view.php?action=list"><img src="images/tab_mode_list<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "list") { print "_down"; }?>.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_preview"] == "on")) {?><a href="graph_view.php?action=preview"><img src="images/tab_mode_preview<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?>&nbsp;<br>
103
						<?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["graph_settings"] == "on")) { print '<a href="' . $config['url_path'] . 'graph_settings.php"><img src="' . $config['url_path'] . 'images/tab_settings'; if (basename($_SERVER["PHP_SELF"]) == "graph_settings.php") { print "_down"; } print '.gif" border="0" alt="Settings" align="absmiddle"></a>';}?>&nbsp;&nbsp;<?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_tree"] == "on")) {?><a href="<?php print htmlspecialchars($config['url_path'] . "graph_view.php?action=tree");?>"><img src="<?php echo $config['url_path']; ?>images/tab_mode_tree<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "tree") { print "_down"; }?>.gif" border="0" title="Tree View" alt="Tree View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_list"] == "on")) {?><a href="<?php print htmlspecialchars($config['url_path'] . "graph_view.php?action=list");?>"><img src="<?php echo $config['url_path']; ?>images/tab_mode_list<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "list") { print "_down"; }?>.gif" border="0" title="List View" alt="List View" align="absmiddle"></a><?php }?><?php if ((!isset($_SESSION["sess_user_id"])) || ($current_user["show_preview"] == "on")) {?><a href="<?php print htmlspecialchars($config['url_path'] . "graph_view.php?action=preview");?>"><img src="<?php echo $config['url_path']; ?>images/tab_mode_preview<?php if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "preview") { print "_down"; }?>.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"></a><?php }?>&nbsp;<br>
90
					</td>
104
					</td>
91
				</tr>
105
				</tr>
92
			</table>
106
			</table>
93
		</td>
107
		</td>
94
	</tr>
108
	</tr>
109
<?php } elseif ($oper_mode == OPER_MODE_NOTABS) { api_plugin_hook_function('print_top_header'); } ?>
95
	<tr style="height:2px;" bgcolor="#183c8f" class="noprint">
110
	<tr style="height:2px;" bgcolor="#183c8f" class="noprint">
96
		<td colspan="2">
111
		<td colspan="2">
97
			<img src="images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br>
112
			<img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br>
98
		</td>
113
		</td>
99
	</tr>
114
	</tr>
100
	<tr style="height:5px;" bgcolor="#e9e9e9" class="noprint">
115
	<tr style="height:5px;" bgcolor="#e9e9e9" class="noprint">
Lines 106-112 Link Here
106
					</td>
121
					</td>
107
					<td align="right">
122
					<td align="right">
108
						<?php if ((isset($_SESSION["sess_user_id"])) && ($using_guest_account == false)) { ?>
123
						<?php if ((isset($_SESSION["sess_user_id"])) && ($using_guest_account == false)) { ?>
109
						Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="logout.php">Logout</a>)&nbsp;
124
						Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="<?php echo $config['url_path']; ?>logout.php">Logout</a>)&nbsp;
110
						<?php } ?>
125
						<?php } ?>
111
					</td>
126
					</td>
112
				</tr>
127
				</tr>
Lines 114-123 Link Here
114
		</td>
129
		</td>
115
	</tr>
130
	</tr>
116
	<tr class="noprint">
131
	<tr class="noprint">
117
		<td bgcolor="#efefef" colspan="1" style="height:8px;background-image: url(images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
132
		<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;">
118
			<img src="images/transparent_line.gif" width="<?php print htmlspecialchars(read_graph_config_option("default_dual_pane_width"));?>" style="height:2px;" border="0"><br>
133
			<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>
119
		</td>
134
		</td>
120
		<td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(images/shadow.gif); background-repeat: repeat-x;">
135
		<td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;">
121
136
122
		</td>
137
		</td>
123
	</tr>
138
	</tr>
Lines 143-148 Link Here
143
		</td>
158
		</td>
144
	</tr>
159
	</tr>
145
	<?php }
160
	<?php }
161
162
	global $graph_views;
146
	load_current_session_value("action", "sess_cacti_graph_action", $graph_views[read_graph_config_option("default_tree_view_mode")]);
163
	load_current_session_value("action", "sess_cacti_graph_action", $graph_views[read_graph_config_option("default_tree_view_mode")]);
147
	?>
164
	?>
148
	<tr>
165
	<tr>
(-)cacti-0.8.7g.orig//include/top_header.php (-19 / +37 lines)
Lines 22-59 Link Here
22
 +-------------------------------------------------------------------------+
22
 +-------------------------------------------------------------------------+
23
*/
23
*/
24
24
25
global $colors;
25
global $colors, $config;
26
27
$oper_mode = api_plugin_hook_function('top_header', OPER_MODE_NATIVE);
28
if ($oper_mode == OPER_MODE_RESKIN || $oper_mode == OPER_MODE_NOTABS) {
29
	return;
30
}
31
32
$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title"));
33
26
?>
34
?>
27
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
35
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
28
<html>
36
<html>
29
<head>
37
<head>
30
	<title><?php echo draw_navigation_text("title");?></title>
38
	<title><?php echo $page_title; ?></title>
31
	<link href="include/main.css" type="text/css" rel="stylesheet">
39
	<link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
32
	<link href="images/favicon.ico" rel="shortcut icon"/>
40
	<link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon">
33
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
41
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
34
	<script type="text/javascript" src="include/layout.js"></script>
42
	<script type="text/javascript" src="<?php echo $config['url_path']; ?>include/layout.js"></script>
35
	<?php if (isset($refresh)) {
43
	<?php if (isset($refresh)) {
36
	print "<meta http-equiv=refresh content=\"" . $refresh["seconds"] . "; url='" . $refresh["page"] . "'\">";
44
	print "<meta http-equiv=refresh content=\"" . $refresh["seconds"] . "; url='" . $refresh["page"] . "'\">";
37
	}?>
45
	}
46
	api_plugin_hook('page_head'); ?>
38
</head>
47
</head>
39
48
40
<body style="background-image:url('images/left_border.gif');background-repeat:repeat-y;">
49
<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
50
<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", "");?>>
51
<?php }else{?>
52
<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", "");?>>
53
<?php }?>
41
54
42
<table width="100%" cellspacing="0" cellpadding="0">
55
<table width="100%" cellspacing="0" cellpadding="0">
56
<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
43
	<tr style="height:1px;" bgcolor="#a9a9a9">
57
	<tr style="height:1px;" bgcolor="#a9a9a9">
44
		<td valign="bottom" colspan="3" nowrap>
58
		<td valign="bottom" colspan="3" nowrap>
45
			<table width="100%" cellspacing="0" cellpadding="0">
59
			<table width="100%" cellspacing="0" cellpadding="0">
46
				<tr style="background: transparent url('images/cacti_backdrop.gif') no-repeat center right;">
60
				<tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop.gif') no-repeat center right;">
47
					<td id="tabs" valign="bottom">
61
					<td id="tabs" valign="bottom">
48
						&nbsp;<a href="index.php"><img src="images/tab_console_down.gif" alt="Console" align="absmiddle" border="0"></a><a href="graph_view.php"><img src="images/tab_graphs.gif" alt="Graphs" align="absmiddle" border="0"></a>
62
						&nbsp;<a href="<?php echo $config['url_path']; ?>index.php"><img src="<?php echo $config['url_path']; ?>images/tab_console_down.gif" alt="Console" align="absmiddle" border="0"></a><a href="<?php echo $config['url_path']; ?>graph_view.php"><img src="<?php echo $config['url_path']; ?>images/tab_graphs.gif" alt="Graphs" align="absmiddle" border="0"></a><?php
49
					</td>
63
						api_plugin_hook('top_header_tabs');
64
					?></td>
50
				</tr>
65
				</tr>
51
			</table>
66
			</table>
52
		</td>
67
		</td>
53
	</tr>
68
	</tr>
54
	<tr style="height:2px;" bgcolor="#183c8f">
69
	<tr style="height:2px;" bgcolor="#183c8f">
55
		<td colspan="3">
70
		<td colspan="3">
56
			<img src="images/transparent_line.gif" style="height:2px;" border="0"><br>
71
			<img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;" border="0"><br>
57
		</td>
72
		</td>
58
	</tr>
73
	</tr>
59
	<tr style="height:5px;" bgcolor="#e9e9e9">
74
	<tr style="height:5px;" bgcolor="#e9e9e9">
Lines 65-71 Link Here
65
					</td>
80
					</td>
66
					<td align="right">
81
					<td align="right">
67
						<?php if (read_config_option("auth_method") != 0) { ?>
82
						<?php if (read_config_option("auth_method") != 0) { ?>
68
						Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="logout.php">Logout</a>)&nbsp;
83
						Logged in as <strong><?php print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);?></strong> (<a href="<?php echo $config['url_path']; ?>logout.php">Logout</a>)&nbsp;
69
						<?php } ?>
84
						<?php } ?>
70
					</td>
85
					</td>
71
				</tr>
86
				</tr>
Lines 73-82 Link Here
73
		</td>
88
		</td>
74
	</tr>
89
	</tr>
75
	<tr>
90
	<tr>
76
		<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;">
91
		<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;">
77
			<img src="images/transparent_line.gif" style="height:2px;width:135px;" border="0"><br>
92
			<img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;width:135px;" border="0"><br>
78
		</td>
93
		</td>
79
		<td colspan="2" style="height:8px;background-image: url(images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
94
		<td colspan="2" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;" bgcolor="#ffffff">
80
95
81
		</td>
96
		</td>
82
	</tr>
97
	</tr>
Lines 86-94 Link Here
86
				<?php draw_menu();?>
101
				<?php draw_menu();?>
87
			</table>
102
			</table>
88
103
89
			<img src="images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
104
			<img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
90
			<p align="center"><a href='about.php'><img src="images/cacti_logo.gif" border="0"></a></p>
105
			<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>
91
			<img src="images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
106
			<img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:5px;width:135px;" border="0"><br>
92
		</td>
107
		</td>
93
		<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'>
108
		<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'>
94
109
<?php }else{ ?>
110
	<tr>
111
		<td width="100%" valign="top"><?php display_output_messages();?>
112
<?php } ?>
(-)cacti-0.8.7g.orig//index.php (+4 lines)
Lines 25-30 Link Here
25
include("./include/auth.php");
25
include("./include/auth.php");
26
include("./include/top_header.php");
26
include("./include/top_header.php");
27
27
28
api_plugin_hook('console_before');
29
28
?>
30
?>
29
<table width="100%" align="center">
31
<table width="100%" align="center">
30
	<tr>
32
	<tr>
Lines 46-51 Link Here
46
48
47
<?php
49
<?php
48
50
51
api_plugin_hook('console_after');
52
49
include("./include/bottom_footer.php");
53
include("./include/bottom_footer.php");
50
54
51
?>
55
?>
(-)cacti-0.8.7g.orig//lib/api_automation_tools.php (-111 lines)
Lines 22-138 Link Here
22
 +-------------------------------------------------------------------------+
22
 +-------------------------------------------------------------------------+
23
 */
23
 */
24
24
25
function api_tree_item_save($id, $tree_id, $type, $parent_tree_item_id,
26
	$title, $local_graph_id, $rra_id, $host_id, $host_grouping_type,
27
	$sort_children_type, $propagate_changes) {
28
29
	global $config;
30
31
	include_once($config["library_path"] . "/tree.php");
32
33
	$parent_order_key = db_fetch_cell("select order_key from graph_tree_items where id=$parent_tree_item_id");
34
35
	/* fetch some cache variables */
36
	if (empty($id)) {
37
		/* new/save - generate new order key */
38
		$order_key = get_next_tree_id($parent_order_key, "graph_tree_items", "order_key", "graph_tree_id=$tree_id");
39
	}else{
40
		/* edit/save - use old order_key */
41
		$order_key = db_fetch_cell("select order_key from graph_tree_items where id=$id");
42
	}
43
44
	/* duplicate graph check */
45
	$search_key = substr($parent_order_key, 0, (tree_tier($parent_order_key) * CHARS_PER_TIER));
46
	if (($type == TREE_ITEM_TYPE_GRAPH) && (sizeof(db_fetch_assoc("select id from graph_tree_items where local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
47
		return db_fetch_cell("select id from graph_tree_items where local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
48
	}
49
50
	/* Duplicate header check */
51
	if (($type == TREE_ITEM_TYPE_HEADER)) {
52
		if ((sizeof(db_fetch_assoc("select id from graph_tree_items where title='$title' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
53
			return db_fetch_cell("select id from graph_tree_items where title='$title' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
54
		}
55
	}
56
57
	$save["id"]                 = $id;
58
	$save["graph_tree_id"]      = $tree_id;
59
	$save["title"]              = form_input_validate($title, "title", "", ($type == TREE_ITEM_TYPE_HEADER ? false : true), 3);
60
	$save["order_key"]          = $order_key;
61
	$save["local_graph_id"]     = form_input_validate($local_graph_id, "local_graph_id", "", true, 3);
62
	$save["rra_id"]	            = form_input_validate($rra_id, "rra_id", "", true, 3);
63
	$save["host_id"]            = form_input_validate($host_id, "host_id", "", true, 3);
64
	$save["host_grouping_type"] = form_input_validate($host_grouping_type, "host_grouping_type", "", true, 3);
65
	$save["sort_children_type"] = form_input_validate($sort_children_type, "sort_children_type", "", true, 3);
66
67
	$tree_item_id = 0;
68
69
	if (!is_error_message()) {
70
		$tree_item_id = sql_save($save, "graph_tree_items");
71
72
		if ($tree_item_id) {
73
			raise_message(1);
74
75
			/* re-parent the branch if the parent item has changed */
76
			if ($parent_tree_item_id != $tree_item_id) {
77
				reparent_branch($parent_tree_item_id, $tree_item_id);
78
			}
79
80
			$tree_sort_type = db_fetch_cell("select sort_type from graph_tree where id='$tree_id'");
81
82
			/* tree item ordering */
83
			if ($tree_sort_type == TREE_ORDERING_NONE) {
84
				/* resort our parent */
85
				$parent_sorting_type = db_fetch_cell("select sort_children_type from graph_tree_items where id=$parent_tree_item_id");
86
87
				if ((!empty($parent_tree_item_id)) && ($parent_sorting_type != TREE_ORDERING_NONE)) {
88
					sort_tree(SORT_TYPE_TREE_ITEM, $parent_tree_item_id, $parent_sorting_type);
89
				}
90
91
				/* if this is a header, sort direct children */
92
				if (($type == TREE_ITEM_TYPE_HEADER) && ($sort_children_type != TREE_ORDERING_NONE)) {
93
					sort_tree(SORT_TYPE_TREE_ITEM, $tree_item_id, $sort_children_type);
94
				}
95
				/* tree ordering */
96
			}else{
97
				/* potential speed savings for large trees */
98
				if (tree_tier($save["order_key"]) == 1) {
99
					sort_tree(SORT_TYPE_TREE, $tree_id, $tree_sort_type);
100
				}else{
101
					sort_tree(SORT_TYPE_TREE_ITEM, $parent_tree_item_id, $tree_sort_type);
102
				}
103
			}
104
105
			/* if the user checked the 'Propagate Changes' box */
106
			if (($type == TREE_ITEM_TYPE_HEADER) && ($propagate_changes == true)) {
107
				$search_key = preg_replace("/0+$/", "", $order_key);
108
109
				$tree_items = db_fetch_assoc("select
110
					graph_tree_items.id
111
					from graph_tree_items
112
					where graph_tree_items.host_id = 0
113
					and graph_tree_items.local_graph_id = 0
114
					and graph_tree_items.title != ''
115
					and graph_tree_items.order_key like '$search_key%%'
116
					and graph_tree_items.graph_tree_id='$tree_id'");
117
118
				if (sizeof($tree_items) > 0) {
119
					foreach ($tree_items as $item) {
120
						db_execute("update graph_tree_items set sort_children_type = '$sort_children_type' where id = '" . $item["id"] . "'");
121
122
						if ($sort_children_type != TREE_ORDERING_NONE) {
123
							sort_tree(SORT_TYPE_TREE_ITEM, $item["id"], $sort_children_type);
124
						}
125
					}
126
				}
127
			}
128
		}else{
129
			raise_message(2);
130
		}
131
	}
132
133
	return $tree_item_id;
134
}
135
136
function getHostTemplates() {
25
function getHostTemplates() {
137
	$tmpArray = db_fetch_assoc("select id, name from host_template order by id");
26
	$tmpArray = db_fetch_assoc("select id, name from host_template order by id");
138
27
(-)cacti-0.8.7g.orig//lib/api_device.php (+7 lines)
Lines 137-142 Link Here
137
	$save["ping_retries"]         = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3);
137
	$save["ping_retries"]         = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3);
138
	$save["max_oids"]             = form_input_validate($max_oids, "max_oids", "^[0-9]+$", true, 3);
138
	$save["max_oids"]             = form_input_validate($max_oids, "max_oids", "^[0-9]+$", true, 3);
139
139
140
	$save = api_plugin_hook_function('api_device_save', $save);
141
140
	$host_id = 0;
142
	$host_id = 0;
141
143
142
	if (!is_error_message()) {
144
	if (!is_error_message()) {
Lines 176-186 Link Here
176
			if (sizeof($graph_templates) > 0) {
178
			if (sizeof($graph_templates) > 0) {
177
			foreach ($graph_templates as $graph_template) {
179
			foreach ($graph_templates as $graph_template) {
178
				db_execute("replace into host_graph (host_id,graph_template_id) values ($host_id," . $graph_template["graph_template_id"] . ")");
180
				db_execute("replace into host_graph (host_id,graph_template_id) values ($host_id," . $graph_template["graph_template_id"] . ")");
181
				api_plugin_hook_function('add_graph_template_to_host', array("host_id" => $host_id, "graph_template_id" => $graph_template["graph_template_id"]));
179
			}
182
			}
180
			}
183
			}
181
		}
184
		}
182
	}
185
	}
183
186
187
	# now that we have the id of the new host, we may plugin postprocessing code
188
	$save["id"] = $host_id;
189
	api_plugin_hook_function('api_device_new', $save);
190
184
	return $host_id;
191
	return $host_id;
185
}
192
}
186
193
(-)cacti-0.8.7g.orig//lib/api_graph.php (-3 / +13 lines)
Lines 82-88 Link Here
82
}
82
}
83
83
84
/* api_reapply_suggested_graph_title - reapplies the suggested name to a graph title
84
/* api_reapply_suggested_graph_title - reapplies the suggested name to a graph title
85
   @arg $graph_templates_graph_id - the id of the graph to reapply the name to
85
   @param int $graph_templates_graph_id - the id of the graph to reapply the name to
86
*/
86
*/
87
function api_reapply_suggested_graph_title($local_graph_id) {
87
function api_reapply_suggested_graph_title($local_graph_id) {
88
	global $config;
88
	global $config;
Lines 95-105 Link Here
95
		return;
95
		return;
96
	}
96
	}
97
97
98
	/* get the host associated with this graph */
98
	/* get the host associated with this graph for data queries only
99
	$graph_local = db_fetch_row("select host_id, graph_template_id, snmp_query_id, snmp_index from graph_local where id=" . $local_graph_id);
99
	 * there's no "reapply suggested title" for "simple" graph templates */
100
	$graph_local = db_fetch_row("select host_id, graph_template_id, snmp_query_id, snmp_index from graph_local where snmp_query_id>0 AND id=" . $local_graph_id);
101
	/* if this is not a data query graph, simply return */
102
	if (!isset($graph_local["host_id"])) {
103
		return;
104
	}
100
	$snmp_query_graph_id = db_fetch_cell("select id from snmp_query_graph where graph_template_id=" . $graph_local["graph_template_id"] .
105
	$snmp_query_graph_id = db_fetch_cell("select id from snmp_query_graph where graph_template_id=" . $graph_local["graph_template_id"] .
101
										" and snmp_query_id=" . $graph_local["snmp_query_id"]);
106
										" and snmp_query_id=" . $graph_local["snmp_query_id"]);
102
107
108
	/* no snmp query graph id found */
109
	if ($snmp_query_graph_id == 0) {
110
		return;
111
	}
112
103
	/* get the suggested values from the suggested values cache */
113
	/* get the suggested values from the suggested values cache */
104
	$suggested_values = db_fetch_assoc("select text,field_name from snmp_query_graph_sv where snmp_query_graph_id=" . $snmp_query_graph_id . " order by sequence");
114
	$suggested_values = db_fetch_assoc("select text,field_name from snmp_query_graph_sv where snmp_query_graph_id=" . $snmp_query_graph_id . " order by sequence");
105
115
(-)cacti-0.8.7g.orig//lib/api_tree.php (-2 / +14 lines)
Lines 44-51 Link Here
44
44
45
	/* duplicate graph check */
45
	/* duplicate graph check */
46
	$search_key = substr($parent_order_key, 0, (tree_tier($parent_order_key) * CHARS_PER_TIER));
46
	$search_key = substr($parent_order_key, 0, (tree_tier($parent_order_key) * CHARS_PER_TIER));
47
	if (($type == TREE_ITEM_TYPE_GRAPH) && (sizeof(db_fetch_assoc("select id from graph_tree_items where local_graph_id='$local_graph_id' and rra_id='$rra_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
47
	if (($type == TREE_ITEM_TYPE_GRAPH) && (sizeof(db_fetch_assoc("select id from graph_tree_items where local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
48
		return 0;
48
		return db_fetch_cell("select id from graph_tree_items where local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
49
	}
50
51
	/* Duplicate header check */
52
	if (($type == TREE_ITEM_TYPE_HEADER)) {
53
		if ((sizeof(db_fetch_assoc("select id from graph_tree_items where title='$title' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
54
			return db_fetch_cell("select id from graph_tree_items where title='$title' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
55
		}
56
	}
57
58
	/* Duplicate host check */
59
	if (($type == TREE_ITEM_TYPE_HOST) && (sizeof(db_fetch_assoc("select id from graph_tree_items where host_id='$host_id' and local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
60
			return db_fetch_cell("select id from graph_tree_items where host_id='$host_id' and local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'");
49
	}
61
	}
50
62
51
	$save["id"] = $id;
63
	$save["id"] = $id;
(-)cacti-0.8.7g.orig//lib/auth.php (-1 / +3 lines)
Lines 121-128 Link Here
121
		}
121
		}
122
	}
122
	}
123
123
124
	return true;
124
	api_plugin_hook_function('copy_user', array('template_id' => $template_id, 'new_id' => $new_id));
125
125
126
	return true;
126
}
127
}
127
128
128
129
Lines 152-157 Link Here
152
	db_execute("delete from settings_graphs where user_id=" . $user_id);
153
	db_execute("delete from settings_graphs where user_id=" . $user_id);
153
	db_execute("delete from settings_tree where user_id=" . $user_id);
154
	db_execute("delete from settings_tree where user_id=" . $user_id);
154
155
156
	api_plugin_hook_function('user_remove', $user_id);
155
}
157
}
156
158
157
/* user_disable - disable a user account
159
/* user_disable - disable a user account
(-)cacti-0.8.7g.orig//lib/data_query.php (-1 / +3 lines)
Lines 56-61 Link Here
56
	/* update the poller cache */
56
	/* update the poller cache */
57
	update_poller_cache_from_query($host_id, $snmp_query_id);
57
	update_poller_cache_from_query($host_id, $snmp_query_id);
58
58
59
	api_plugin_hook_function('run_data_query', array("host_id" => $host_id, "snmp_query_id" => $snmp_query_id));
60
59
	return (isset($result) ? $result : true);
61
	return (isset($result) ? $result : true);
60
}
62
}
61
63
Lines 215-221 Link Here
215
				for ($i=0; $i<sizeof($snmp_indexes); $i++) {
217
				for ($i=0; $i<sizeof($snmp_indexes); $i++) {
216
					$oid = $field_array["oid"] .  "." . $snmp_indexes[$i]["value"];
218
					$oid = $field_array["oid"] .  "." . $snmp_indexes[$i]["value"];
217
					$oid .= isset($field_array["oid_suffix"]) ? ("." . $field_array["oid_suffix"]) : "";
219
					$oid .= isset($field_array["oid_suffix"]) ? ("." . $field_array["oid_suffix"]) : "";
218
					
220
219
					$value = cacti_snmp_get($host["hostname"], $host["snmp_community"], $oid,
221
					$value = cacti_snmp_get($host["hostname"], $host["snmp_community"], $oid,
220
						$host["snmp_version"], $host["snmp_username"], $host["snmp_password"],
222
						$host["snmp_version"], $host["snmp_username"], $host["snmp_password"],
221
						$host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"],
223
						$host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"],
(-)cacti-0.8.7g.orig//lib/functions.php (-2 / +6 lines)
Lines 1689-1694 Link Here
1689
   @arg $type - (string) Either 'url' or 'title'
1689
   @arg $type - (string) Either 'url' or 'title'
1690
   @returns (string> Either the navigation text or title */
1690
   @returns (string> Either the navigation text or title */
1691
function draw_navigation_text($type = "url") {
1691
function draw_navigation_text($type = "url") {
1692
	global $config;
1693
1692
	$nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : array());
1694
	$nav_level_cache = (isset($_SESSION["sess_nav_level_cache"]) ? $_SESSION["sess_nav_level_cache"] : array());
1693
1695
1694
	$nav = array(
1696
	$nav = array(
Lines 1701-1708 Link Here
1701
		"graph.php:zoom" => array("title" => "Zoom", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
1703
		"graph.php:zoom" => array("title" => "Zoom", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
1702
		"graph.php:properties" => array("title" => "Properties", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
1704
		"graph.php:properties" => array("title" => "Properties", "mapping" => "graph_view.php:,?,graph.php:view", "level" => "3"),
1703
		"graph_settings.php:" => array("title" => "Settings", "mapping" => "graph_view.php:", "url" => "graph_settings.php", "level" => "1"),
1705
		"graph_settings.php:" => array("title" => "Settings", "mapping" => "graph_view.php:", "url" => "graph_settings.php", "level" => "1"),
1704
		"index.php:" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
1706
		"index.php:" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
1705
		"index.php:login" => array("title" => "Console", "mapping" => "", "url" => "index.php", "level" => "0"),
1707
		"index.php:login" => array("title" => "Console", "mapping" => "", "url" => $config['url_path'] . "index.php", "level" => "0"),
1706
		"graphs.php:" => array("title" => "Graph Management", "mapping" => "index.php:", "url" => "graphs.php", "level" => "1"),
1708
		"graphs.php:" => array("title" => "Graph Management", "mapping" => "index.php:", "url" => "graphs.php", "level" => "1"),
1707
		"graphs.php:graph_edit" => array("title" => "(Edit)", "mapping" => "index.php:,graphs.php:", "url" => "", "level" => "2"),
1709
		"graphs.php:graph_edit" => array("title" => "(Edit)", "mapping" => "index.php:,graphs.php:", "url" => "", "level" => "2"),
1708
		"graphs.php:graph_diff" => array("title" => "Change Graph Template", "mapping" => "index.php:,graphs.php:,graphs.php:graph_edit", "url" => "", "level" => "3"),
1710
		"graphs.php:graph_diff" => array("title" => "Change Graph Template", "mapping" => "index.php:,graphs.php:,graphs.php:graph_edit", "url" => "", "level" => "3"),
Lines 1780-1785 Link Here
1780
		"templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"),
1782
		"templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"),
1781
		);
1783
		);
1782
1784
1785
	$nav =  api_plugin_hook_function('draw_navigation_text', $nav);
1786
1783
	$current_page = basename($_SERVER["PHP_SELF"]);
1787
	$current_page = basename($_SERVER["PHP_SELF"]);
1784
1788
1785
	input_validate_input_regex(get_request_var_request("action"), "^([a-zA-Z0-9_-]+)$");
1789
	input_validate_input_regex(get_request_var_request("action"), "^([a-zA-Z0-9_-]+)$");
(-)cacti-0.8.7g.orig//lib/html.php (-18 / +25 lines)
Lines 144-157 Link Here
144
					<table align='center' cellpadding='0'>
144
					<table align='center' cellpadding='0'>
145
						<tr>
145
						<tr>
146
							<td align='center'>
146
							<td align='center'>
147
								<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>
147
								<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>
148
								<?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?>
148
								<?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?>
149
							</td>
149
							</td>
150
							<td valign='top' style='align: left; padding: 3px;' class='noprint'>
150
							<td valign='top' style='align: left; padding: 3px;' class='noprint'>
151
								<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>
151
								<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>
152
								<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>
152
								<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>
153
								<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>
153
								<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>
154
								<a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
154
								<?php api_plugin_hook('graph_buttons', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' =>  0, 'view_type' => 'view')); ?>
155
								<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>
155
							</td>
156
							</td>
156
						</tr>
157
						</tr>
157
					</table>
158
					</table>
Lines 177-182 Link Here
177
   @arg $extra_url_args - extra arguments to append to the url
178
   @arg $extra_url_args - extra arguments to append to the url
178
   @arg $header - html to use as a header */
179
   @arg $header - html to use as a header */
179
function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
180
function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") {
181
	global $config;
180
	$i = 0; $k = 0; $j = 0;
182
	$i = 0; $k = 0; $j = 0;
181
183
182
	$num_graphs = sizeof($graph_array);
184
	$num_graphs = sizeof($graph_array);
Lines 268-281 Link Here
268
				<table align='center' cellpadding='0'>
270
				<table align='center' cellpadding='0'>
269
					<tr>
271
					<tr>
270
						<td align='center'>
272
						<td align='center'>
271
							<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>
273
							<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>
272
							<?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?>
274
							<?php print (read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "");?>
273
						</td>
275
						</td>
274
						<td valign='top' style='align: left; padding: 3px;'>
276
						<td valign='top' style='align: left; padding: 3px;'>
275
							<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>
277
							<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>
276
							<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>
278
							<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>
277
							<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>
279
							<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>
278
							<a href='#page_top'><img src='images/graph_page_top.gif' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
280
							<?php api_plugin_hook('graph_buttons_thumbnails', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' =>  0, 'view_type' => '')); ?>
281
							<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>
279
						</td>
282
						</td>
280
					</tr>
283
					</tr>
281
				</table>
284
				</table>
Lines 638-646 Link Here
638
		print "<td style='$this_row_style'>" . $item["hex"] . "</td>\n";
641
		print "<td style='$this_row_style'>" . $item["hex"] . "</td>\n";
639
642
640
		if ($disable_controls == false) {
643
		if ($disable_controls == false) {
641
			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>
644
			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>
642
					<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";
645
					<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";
643
			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";
646
			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";
644
		}
647
		}
645
648
646
		print "</tr>";
649
		print "</tr>";
Lines 706-711 Link Here
706
					}
709
					}
707
710
708
					while (list($item_sub_url, $item_sub_title) = each($item_title)) {
711
					while (list($item_sub_url, $item_sub_title) = each($item_title)) {
712
						$item_sub_url = $config['url_path'] . $item_sub_url;
713
709
						/* indent sub-items */
714
						/* indent sub-items */
710
						if ($i > 0) {
715
						if ($i > 0) {
711
							$prepend_string = "---&nbsp;";
716
							$prepend_string = "---&nbsp;";
Lines 715-721 Link Here
715
720
716
						/* do not put a line between each sub-item */
721
						/* do not put a line between each sub-item */
717
						if (($i == 0) || ($draw_sub_items == false)) {
722
						if (($i == 0) || ($draw_sub_items == false)) {
718
							$background = "images/menu_line.gif";
723
							$background = $config['url_path'] . "images/menu_line.gif";
719
						}else{
724
						}else{
720
							$background = "";
725
							$background = "";
721
						}
726
						}
Lines 744-760 Link Here
744
			}else{
749
			}else{
745
				if ($current_realm_id == -1 || (isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) {
750
				if ($current_realm_id == -1 || (isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) {
746
					/* draw normal (non sub-item) menu item */
751
					/* draw normal (non sub-item) menu item */
752
					$item_url = $config['url_path'] . $item_url;
747
					if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) {
753
					if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) {
748
						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";
754
						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";
749
					}else{
755
					}else{
750
						print "<tr><td class='textMenuItem' style='background-image:url(\"images/menu_line.gif\");'><a href='" . htmlspecialchars($item_url) . "'>$item_title</a></td></tr>\n";
756
						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";
751
					}
757
					}
752
				}
758
				}
753
			}
759
			}
754
		}
760
		}
755
	}
761
	}
756
762
757
	print "<tr><td class='textMenuItem' style='background-image:url(\"images/menu_line.gif\");'></td></tr>\n";
763
	print "<tr><td class='textMenuItem' style='background-image:url(\"" . $config['url_path'] . "images/menu_line.gif\");'></td></tr>\n";
758
764
759
	print "</table></td></tr>";
765
	print "</table></td></tr>";
760
}
766
}
Lines 764-774 Link Here
764
   @arg $actions_array - an array that contains a list of possible actions. this array should
770
   @arg $actions_array - an array that contains a list of possible actions. this array should
765
     be compatible with the form_dropdown() function */
771
     be compatible with the form_dropdown() function */
766
function draw_actions_dropdown($actions_array) {
772
function draw_actions_dropdown($actions_array) {
773
	global $config;
767
	?>
774
	?>
768
	<table align='center' width='100%'>
775
	<table align='center' width='100%'>
769
		<tr>
776
		<tr>
770
			<td width='1' valign='top'>
777
			<td width='1' valign='top'>
771
				<img src='images/arrow.gif' alt=''>&nbsp;
778
				<img src='<?php echo $config['url_path']; ?>images/arrow.gif' alt='' align='middle'>&nbsp;
772
			</td>
779
			</td>
773
			<td align='right'>
780
			<td align='right'>
774
				Choose an action:
781
				Choose an action:
(-)cacti-0.8.7g.orig//lib/html_form.php (-3 / +13 lines)
Lines 1-4 Link Here
1
<?php
1
<?php
2
// $Id: html_form.php 2993 2010-10-14 14:30:36Z ladams $
2
/*
3
/*
3
 +-------------------------------------------------------------------------+
4
 +-------------------------------------------------------------------------+
4
 | Copyright (C) 2004-2010 The Cacti Group                                 |
5
 | Copyright (C) 2004-2010 The Cacti Group                                 |
Lines 530-535 Link Here
530
		$form_previous_value = $form_default_value;
531
		$form_previous_value = $form_default_value;
531
	}
532
	}
532
533
534
	if (isset($_SESSION["sess_error_fields"])) {
535
		if (!empty($_SESSION["sess_error_fields"][$form_name])) {
536
			$class .= (strlen($class) ? " ":"") . "txtErrorTextBox";
537
			unset($_SESSION["sess_error_fields"][$form_name]);
538
		}
539
	}
540
533
	if (isset($_SESSION["sess_field_values"])) {
541
	if (isset($_SESSION["sess_field_values"])) {
534
		if (!empty($_SESSION["sess_field_values"][$form_name])) {
542
		if (!empty($_SESSION["sess_field_values"][$form_name])) {
535
			$form_previous_value = $_SESSION["sess_field_values"][$form_name];
543
			$form_previous_value = $_SESSION["sess_field_values"][$form_name];
Lines 722-732 Link Here
722
     on a confirmation form
730
     on a confirmation form
723
   @arg $cancel_url - the url to go to when the user clicks 'cancel'
731
   @arg $cancel_url - the url to go to when the user clicks 'cancel'
724
   @arg $action_url - the url to go to when the user clicks 'delete' */
732
   @arg $action_url - the url to go to when the user clicks 'delete' */
725
function form_confirm_buttons($action_url, $cancel_url) { ?>
733
function form_confirm_buttons($action_url, $cancel_url) {
734
	global $config;
735
	?>
726
	<tr>
736
	<tr>
727
		<td bgcolor="#E1E1E1">
737
		<td bgcolor="#E1E1E1">
728
			<input type='button' onClick='cactiReturnTo("<?php print $cancel_url;?>")' value='Cancel'>
738
			<input type='button' onClick='cactiReturnTo("<?php print $config['url_path'] . $cancel_url;?>")' value='Cancel'>
729
			<input type='submit' onClick='cactiReturnTo("<?php print $action_url;?>&confirm=true")' value='Delete'>
739
			<input type='submit' onClick='cactiReturnTo("<?php print $config['url_path'] . $action_url;?>&confirm=true")' value='Delete'>
730
		</td>
740
		</td>
731
	</tr>
741
	</tr>
732
<?php }
742
<?php }
(-)cacti-0.8.7g.orig//lib/html_tree.php (-1 / +24 lines)
Lines 543-549 Link Here
543
543
544
	$dhtml_tree[0] = $start;
544
	$dhtml_tree[0] = $start;
545
	$dhtml_tree[1] = read_graph_config_option("expand_hosts");
545
	$dhtml_tree[1] = read_graph_config_option("expand_hosts");
546
	$dhtml_tree[2] = "foldersTree = gFld(\"\", \"\")\n";
546
	$dhtml_tree[2] = "var foldersTree = gFld(\"\", \"\")\n";
547
	$dhtml_tree[3] = "foldersTree.xID = \"root\"\n";
547
	$dhtml_tree[3] = "foldersTree.xID = \"root\"\n";
548
	$i = 3;
548
	$i = 3;
549
549
Lines 985-990 Link Here
985
	<?php
985
	<?php
986
	html_end_box();
986
	html_end_box();
987
987
988
	do_hook_function('graph_tree_page_buttons',
989
		array(
990
			'treeid' => $tree_id,
991
			'leafid' => $leaf_id,
992
			'mode' => 'tree',
993
			'timespan' => $_SESSION["sess_current_timespan"],
994
			'starttime' => get_current_graph_start(),
995
			'endtime' => get_current_graph_end())
996
	);
997
988
	html_start_box("", "100%", $colors["header"], "3", "center", "");
998
	html_start_box("", "100%", $colors["header"], "3", "center", "");
989
999
990
	$graph_list = array();
1000
	$graph_list = array();
Lines 1189-1194 Link Here
1189
		html_graph_area($new_graph_list, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end());
1199
		html_graph_area($new_graph_list, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end());
1190
	}
1200
	}
1191
1201
1202
1203
	/* nmid start */
1204
	if (!empty($leaf_id)) {
1205
		do_hook_function('tree_after',$host_name.','.get_request_var("leaf_id"));
1206
	}
1207
1208
        //print '</div>';
1209
        //print "</td></tr>";
1210
1211
	do_hook_function('tree_view_page_end');
1212
1213
	/* nmid end */
1214
1192
	print $nav;
1215
	print $nav;
1193
1216
1194
	html_end_box();
1217
	html_end_box();
(-)cacti-0.8.7g.orig//lib/plugins.php (+478 lines)
Line 0 Link Here
1
<?php
2
3
4
5
function do_hook ($name) {
6
	$data = func_get_args();
7
	$data = api_plugin_hook ($name, $data);
8
	return $data;
9
}
10
11
function do_hook_function($name,$parm=NULL) {
12
	return api_plugin_hook_function ($name, $parm);
13
}
14
15
function api_user_realm_auth ($filename = '') {
16
	return api_plugin_user_realm_auth ($filename);
17
}
18
19
/**
20
 * This function executes a hook.
21
 * @param string $name Name of hook to fire
22
 * @return mixed $data
23
 */
24
function api_plugin_hook ($name) {
25
	global $config, $plugin_hooks, $plugins_system;
26
	$data = func_get_args();
27
	$ret = '';
28
	$p = array();
29
30
	$ps_where = '';
31
	if (sizeof($plugins_system)) {
32
		foreach($plugins_system as $plugin) {
33
			$ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin;
34
		}
35
		$ps_where .= "')";
36
	}
37
38
	/* order the plugin functions by system first, then followed by order */
39
	$result = db_fetch_assoc("SELECT 1 AS id, ph.name, ph.file, ph.function
40
		FROM plugin_hooks AS ph
41
		LEFT JOIN plugin_config AS pc
42
		ON pc.directory=ph.name
43
		WHERE ph.status = 1 AND hook = '$name'
44
		AND ph.name IN $ps_where
45
		UNION
46
		SELECT pc.id, ph.name, ph.file, ph.function
47
		FROM plugin_hooks AS ph
48
		LEFT JOIN plugin_config AS pc
49
		ON pc.directory=ph.name
50
		WHERE ph.status = 1 AND hook = '$name'
51
		AND ph.name NOT IN $ps_where
52
		ORDER BY id ASC", true);
53
54
	if (count($result)) {
55
		foreach ($result as $hdata) {
56
			$p[] = $hdata['name'];
57
			if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
58
				include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
59
			}
60
			$function = $hdata['function'];
61
			if (function_exists($function)) {
62
				$function($data);
63
			}
64
		}
65
	}
66
67
	if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
68
		foreach ($plugin_hooks[$name] as $pname => $function) {
69
			if (function_exists($function)  && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
70
				$function($data);
71
			}
72
		}
73
	}
74
75
	/* Variable-length argument lists have a slight problem when */
76
	/* passing values by reference. Pity. This is a workaround.  */
77
	return $data;
78
}
79
80
function api_plugin_hook_function ($name, $parm=NULL) {
81
	global $config, $plugin_hooks, $plugins_system;
82
	$ret = $parm;
83
	$p = array();
84
	$ps_where = '';
85
86
	if (sizeof($plugins_system)) {
87
		foreach($plugins_system as $plugin) {
88
			$ps_where .= (strlen($ps_where) ? "', '":"('") . $plugin;
89
		}
90
		$ps_where .= "')";
91
	}
92
93
	/* order the plugin functions by system first, then followed by order */
94
	$result = db_fetch_assoc("SELECT 1 AS id, ph.name, ph.file, ph.function
95
		FROM plugin_hooks AS ph
96
		LEFT JOIN plugin_config AS pc
97
		ON pc.directory=ph.name
98
		WHERE ph.status = 1 AND hook = '$name'
99
		AND ph.name IN $ps_where
100
		UNION
101
		SELECT pc.id, ph.name, ph.file, ph.function
102
		FROM plugin_hooks AS ph
103
		LEFT JOIN plugin_config AS pc
104
		ON pc.directory=ph.name
105
		WHERE ph.status = 1 AND hook = '$name'
106
		AND ph.name NOT IN $ps_where
107
		ORDER BY id ASC", true);
108
109
	if (count($result)) {
110
		foreach ($result as $hdata) {
111
			$p[] = $hdata['name'];
112
			if (file_exists($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file'])) {
113
				include_once($config['base_path'] . '/plugins/' . $hdata['name'] . '/' . $hdata['file']);
114
			}
115
			$function = $hdata['function'];
116
			if (function_exists($function)) {
117
				$ret = $function($ret);
118
			}
119
		}
120
	}
121
122
	if (isset($plugin_hooks[$name]) && is_array($plugin_hooks[$name])) {
123
		foreach ($plugin_hooks[$name] as $pname => $function) {
124
			if (function_exists($function)  && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {
125
				$ret = $function($ret);
126
			}
127
		}
128
	}
129
130
	/* Variable-length argument lists have a slight problem when */
131
	/* passing values by reference. Pity. This is a workaround.  */
132
	return $ret;
133
}
134
135
function api_plugin_db_table_create ($plugin, $table, $data) {
136
	global $config, $database_default;
137
	include_once($config["library_path"] . "/database.php");
138
139
	$result = db_fetch_assoc("show tables from `" . $database_default . "`") or die (mysql_error());
140
	$tables = array();
141
	foreach($result as $index => $arr) {
142
		foreach ($arr as $t) {
143
			$tables[] = $t;
144
		}
145
	}
146
	if (!in_array($table, $tables)) {
147
		$c = 0;
148
		$sql = 'CREATE TABLE `' . $table . "` (\n";
149
		foreach ($data['columns'] as $column) {
150
			if (isset($column['name'])) {
151
				if ($c > 0)
152
					$sql .= ",\n";
153
				$sql .= '`' . $column['name'] . '`';
154
				if (isset($column['type']))
155
					$sql .= ' ' . $column['type'];
156
				if (isset($column['unsigned']))
157
					$sql .= ' unsigned';
158
				if (isset($column['NULL']) && $column['NULL'] == false)
159
					$sql .= ' NOT NULL';
160
				if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
161
					$sql .= ' default NULL';
162
				if (isset($column['default']))
163
					$sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
164
				if (isset($column['auto_increment']))
165
					$sql .= ' auto_increment';
166
				$c++;
167
			}
168
		}
169
170
		if (isset($data['primary'])) {
171
			$sql .= ",\n PRIMARY KEY (`" . $data['primary'] . '`)';
172
		}
173
174
		if (sizeof($data['keys'])) {
175
		foreach ($data['keys'] as $key) {
176
			if (isset($key['name'])) {
177
				$sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)';
178
			}
179
		}
180
		}
181
		$sql .= ') TYPE = ' . $data['type'];
182
183
		if (isset($data['comment'])) {
184
			$sql .= " COMMENT = '" . $data['comment'] . "'";
185
		}
186
		if (db_execute($sql)) {
187
			db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
188
		}
189
	} else {
190
		db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
191
	}
192
}
193
194
function api_plugin_db_changes_remove ($plugin) {
195
	// Example: api_plugin_db_changes_remove ('thold');
196
197
	$tables = db_fetch_assoc("SELECT `table` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='create'", false);
198
	if (count($tables)) {
199
		foreach ($tables as $table) {
200
			db_execute("DROP TABLE IF EXISTS `" . $table['table'] . "`;");
201
		}
202
		db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false);
203
	}
204
	$columns = db_fetch_assoc("SELECT `table`, `column` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='addcolumn'", false);
205
	if (count($columns)) {
206
		foreach ($columns as $column) {
207
			db_execute('ALTER TABLE `' . $column['table'] . '` DROP `' . $column['column'] . '`');
208
		}
209
		db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false);
210
	}
211
}
212
213
function api_plugin_db_add_column ($plugin, $table, $column) {
214
	// Example: api_plugin_db_add_column ('thold', 'plugin_config', array('name' => 'test' . rand(1, 200), 'type' => 'varchar (255)', 'NULL' => false));
215
216
	global $config, $database_default;
217
	include_once($config['library_path'] . '/database.php');
218
219
	$result = db_fetch_assoc('show columns from `' . $table . '`') or die (mysql_error());
220
	$columns = array();
221
	foreach($result as $index => $arr) {
222
		foreach ($arr as $t) {
223
			$columns[] = $t;
224
		}
225
	}
226
	if (isset($column['name']) && !in_array($column['name'], $columns)) {
227
		$sql = 'ALTER TABLE `' . $table . '` ADD `' . $column['name'] . '`';
228
		if (isset($column['type']))
229
			$sql .= ' ' . $column['type'];
230
		if (isset($column['unsigned']))
231
			$sql .= ' unsigned';
232
		if (isset($column['NULL']) && $column['NULL'] == false)
233
			$sql .= ' NOT NULL';
234
		if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
235
			$sql .= ' default NULL';
236
		if (isset($column['default']))
237
			$sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
238
		if (isset($column['auto_increment']))
239
			$sql .= ' auto_increment';
240
		if (isset($column['after']))
241
			$sql .= ' AFTER ' . $column['after'];
242
243
		if (db_execute($sql)) {
244
			db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')");
245
		}
246
	}
247
}
248
249
function api_plugin_install ($plugin) {
250
	global $config;
251
	include_once($config['base_path'] . "/plugins/$plugin/setup.php");
252
253
	$exists = db_fetch_assoc("SELECT id FROM plugin_config WHERE directory = '$plugin'", false);
254
	if (sizeof($exists)) {
255
		db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
256
	}
257
258
	$name = $author = $webpage = $version = '';
259
	$function = 'plugin_' . $plugin . '_version';
260
	if (function_exists($function)){
261
		$info = $function();
262
		$name = $info['longname'];
263
		if (isset($info['homepage'])) {
264
			$webpage = $info['homepage'];
265
		}elseif (isset($info['webpage'])) {
266
			$webpage = $info['webpage'];
267
		}else{
268
			$webpage = "Not Stated";
269
		}
270
		$author = $info['author'];
271
		$version = $info['version'];
272
	}
273
274
	db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')");
275
276
	$function = 'plugin_' . $plugin . '_install';
277
	if (function_exists($function)){
278
		$function();
279
		$ready = api_plugin_check_config ($plugin);
280
		if ($ready) {
281
			// Set the plugin as "disabled" so it can go live
282
			db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
283
		} else {
284
			// Set the plugin as "needs configuration"
285
			db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'");
286
		}
287
	}
288
}
289
290
function api_plugin_uninstall ($plugin) {
291
	global $config;
292
	include_once($config['base_path'] . "/plugins/$plugin/setup.php");
293
	// Run the Plugin's Uninstall Function first
294
	$function = 'plugin_' . $plugin . '_uninstall';
295
	if (function_exists($function)) {
296
		$function();
297
	}
298
	api_plugin_remove_hooks ($plugin);
299
	api_plugin_remove_realms ($plugin);
300
	db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
301
	api_plugin_db_changes_remove ($plugin);
302
}
303
304
function api_plugin_check_config ($plugin) {
305
	global $config;
306
	include_once($config['base_path'] . "/plugins/$plugin/setup.php");
307
	$function = 'plugin_' . $plugin . '_check_config';
308
	if (function_exists($function)) {
309
		return $function();
310
	}
311
	return TRUE;
312
}
313
314
function api_plugin_enable ($plugin) {
315
	$ready = api_plugin_check_config ($plugin);
316
	if ($ready) {
317
		api_plugin_enable_hooks ($plugin);
318
		db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'");
319
	}
320
}
321
322
function api_plugin_is_enabled ($plugin) {
323
	$status = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = '$plugin'", false);
324
	if ($status == '1')
325
		return true;
326
	return false;
327
}
328
329
function api_plugin_disable ($plugin) {
330
	api_plugin_disable_hooks ($plugin);
331
	db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
332
}
333
334
function api_plugin_moveup($plugin) {
335
	global $plugins_system;
336
337
	$sql_where = "";
338
	if (sizeof($plugins_system)) {
339
		foreach($plugins_system as $s) {
340
			$sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
341
		}
342
343
		$sql_where .= ")";
344
	}
345
346
	$id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:""));
347
	$temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1;
348
	$prior_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config WHERE id<$id" . (strlen($sql_where) ? " AND " . $sql_where:""));
349
350
	/* update the above plugin to the prior temp id */
351
	db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$prior_id");
352
	db_execute("UPDATE plugin_config SET id=$prior_id WHERE id=$id");
353
	db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id");
354
}
355
356
function api_plugin_movedown($plugin) {
357
	global $plugins_system;
358
359
	$sql_where = "";
360
	if (sizeof($plugins_system)) {
361
		foreach($plugins_system as $s) {
362
			$sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
363
		}
364
365
		$sql_where .= ")";
366
	}
367
368
	$id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:""));
369
	$temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1;
370
	$next_id = db_fetch_cell("SELECT MIN(id) FROM plugin_config WHERE id>$id" . (strlen($sql_where) ? " AND " . $sql_where:""));
371
372
	/* update the above plugin to the prior temp id */
373
	db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$next_id");
374
	db_execute("UPDATE plugin_config SET id=$next_id WHERE id=$id");
375
	db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id");
376
}
377
378
function api_plugin_register_hook ($plugin, $hook, $function, $file) {
379
	$exists = db_fetch_assoc("SELECT id FROM plugin_hooks WHERE name = '$plugin' AND hook = '$hook'", false);
380
	if (!count($exists)) {
381
		$settings = array('config_settings', 'config_arrays', 'config_form');
382
		if (!in_array($hook, $settings)) {
383
			db_execute("INSERT INTO plugin_hooks (name, hook, function, file) VALUES ('$plugin', '$hook', '$function', '$file')");
384
		} else {
385
			db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)");
386
		}
387
	}
388
}
389
390
function api_plugin_remove_hooks ($plugin) {
391
	db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'");
392
}
393
394
function api_plugin_enable_hooks ($plugin) {
395
	db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'");
396
}
397
398
function api_plugin_disable_hooks ($plugin) {
399
	db_execute("UPDATE plugin_hooks SET status = 0 WHERE name = '$plugin' AND hook != 'config_settings' AND hook != 'config_arrays' AND hook != 'config_form'");
400
}
401
402
function api_plugin_register_realm ($plugin, $file, $display, $admin = false) {
403
	$exists = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
404
	if (!count($exists)) {
405
		db_execute("INSERT INTO plugin_realms (plugin, file, display) VALUES ('$plugin', '$file', '$display')");
406
		if ($admin) {
407
			$realm_id = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
408
			$realm_id = $realm_id[0]['id'] + 100;
409
			$user_id = db_fetch_assoc("SELECT id FROM user_auth WHERE username = 'admin'", false);
410
			if (count($user_id)) {
411
				$user_id = $user_id[0]['id'];
412
				$exists = db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id = $user_id and realm_id = $realm_id", false);
413
				if (!count($exists)) {
414
					db_execute("INSERT INTO user_auth_realm (user_id, realm_id) VALUES ($user_id, $realm_id)");
415
				}
416
			}
417
		}
418
	}
419
}
420
421
function api_plugin_remove_realms ($plugin) {
422
	$realms = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin'", false);
423
	foreach ($realms as $realm) {
424
		$id = $realm['id'] + 100;
425
		db_execute("DELETE FROM user_auth_realm WHERE realm_id = '$id'");
426
	}
427
	db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'");
428
}
429
430
function api_plugin_load_realms () {
431
	global $user_auth_realms, $user_auth_realm_filenames;
432
	$plugin_realms = db_fetch_assoc("SELECT * FROM plugin_realms ORDER BY plugin, display", false);
433
	if (count($plugin_realms)) {
434
		foreach ($plugin_realms as $plugin_realm) {
435
			$plugin_files = explode(',', $plugin_realm['file']);
436
			foreach($plugin_files as $plugin_file) {
437
				$user_auth_realm_filenames[$plugin_file] = $plugin_realm['id'] + 100;
438
			}
439
			$user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display'];
440
		}
441
	}
442
}
443
444
function api_plugin_user_realm_auth ($filename = '') {
445
	global $user_realms, $user_auth_realms, $user_auth_realm_filenames;
446
	/* list all realms that this user has access to */
447
	if (!isset($user_realms)) {
448
		if (read_config_option('global_auth') == 'on' || read_config_option('auth_method') != 0) {
449
			$user_realms = db_fetch_assoc("select realm_id from user_auth_realm where user_id=" . $_SESSION["sess_user_id"], false);
450
			$user_realms = array_rekey($user_realms, "realm_id", "realm_id");
451
		}else{
452
			$user_realms = $user_auth_realms;
453
		}
454
	}
455
	if ($filename != '' && isset($user_auth_realm_filenames[basename($filename)])) {
456
		if (isset($user_realms[$user_auth_realm_filenames[basename($filename)]]))
457
			return TRUE;
458
	}
459
	return FALSE;
460
}
461
462
function plugin_config_arrays () {
463
	global $menu;
464
	$menu['Configuration']['plugins.php'] = 'Plugin Management';
465
	api_plugin_load_realms ();
466
}
467
468
function plugin_draw_navigation_text ($nav) {
469
	$nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1");
470
	return $nav;
471
}
472
473
474
475
476
477
478
(-)cacti-0.8.7g.orig//lib/poller.php (-1 / +4 lines)
Lines 344-351 Link Here
344
				}
344
				}
345
			}
345
			}
346
		}
346
		}
347
		api_plugin_hook_function('poller_output', $rrd_update_array);
347
348
348
		$rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
349
		if (api_plugin_hook_function('poller_on_demand', $results)) {
350
			$rrds_processed = rrdtool_function_update($rrd_update_array, $rrdtool_pipe);
351
		}
349
	}
352
	}
350
353
351
	return $rrds_processed;
354
	return $rrds_processed;
(-)cacti-0.8.7g.orig//lib/rrd.php (-1 / +21 lines)
Lines 419-424 Link Here
419
419
420
	$data_source_path = get_data_source_path($local_data_id, true);
420
	$data_source_path = get_data_source_path($local_data_id, true);
421
421
422
	/* update the rrdfile if performing a fetch */
423
	api_plugin_hook_function('rrdtool_function_fetch_cache_check', $local_data_id);
424
422
	/* build and run the rrdtool fetch command with all of our data */
425
	/* build and run the rrdtool fetch command with all of our data */
423
	$cmd_line = "fetch $data_source_path AVERAGE -s $start_time -e $end_time";
426
	$cmd_line = "fetch $data_source_path AVERAGE -s $start_time -e $end_time";
424
	if ($resolution > 0) {
427
	if ($resolution > 0) {
Lines 539-544 Link Here
539
		}
542
		}
540
	}
543
	}
541
544
545
	$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));
546
	if (isset($data['return']) && $data['return'] != false)
547
		return $data['return'];
548
542
	/* find the step and how often this graph is updated with new data */
549
	/* find the step and how often this graph is updated with new data */
543
	$ds_step = db_fetch_cell("select
550
	$ds_step = db_fetch_cell("select
544
		data_template_data.rrd_step
551
		data_template_data.rrd_step
Lines 1376-1381 Link Here
1376
	}
1383
	}
1377
	}
1384
	}
1378
1385
1386
	$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));
1387
	if (!empty($graph_array)) {
1388
		$graph_defs = $graph_array['graph_defs'];
1389
		$txt_graph_items = $graph_array['txt_graph_items'];
1390
		$graph_opts = $graph_array['graph_opts'];
1391
	}
1392
1379
	/* either print out the source or pass the source onto rrdtool to get us a nice PNG */
1393
	/* either print out the source or pass the source onto rrdtool to get us a nice PNG */
1380
	if (isset($graph_data_array["print_source"])) {
1394
	if (isset($graph_data_array["print_source"])) {
1381
		print "<PRE>" . htmlspecialchars(read_config_option("path_rrdtool") . " graph " . $graph_opts . $graph_defs . $txt_graph_items) . "</PRE>";
1395
		print "<PRE>" . htmlspecialchars(read_config_option("path_rrdtool") . " graph " . $graph_opts . $graph_defs . $txt_graph_items) . "</PRE>";
Lines 1384-1396 Link Here
1384
			@rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrdtool_pipe);
1398
			@rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_NULL, $rrdtool_pipe);
1385
			return 0;
1399
			return 0;
1386
		}else{
1400
		}else{
1401
			$graph_data_array = api_plugin_hook_function('prep_graph_array', $graph_data_array);
1402
1387
			if (isset($graph_data_array["output_flag"])) {
1403
			if (isset($graph_data_array["output_flag"])) {
1388
				$output_flag = $graph_data_array["output_flag"];
1404
				$output_flag = $graph_data_array["output_flag"];
1389
			}else{
1405
			}else{
1390
				$output_flag = RRDTOOL_OUTPUT_GRAPH_DATA;
1406
				$output_flag = RRDTOOL_OUTPUT_GRAPH_DATA;
1391
			}
1407
			}
1392
1408
1393
			return @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrdtool_pipe);
1409
			$output = @rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, $output_flag, $rrdtool_pipe);
1410
1411
			api_plugin_hook_function('rrdtool_function_graph_set_file', array('output' => $output, 'local_graph_id' => $local_graph_id, 'rra_id' => $rra_id));
1412
1413
			return $output;
1394
		}
1414
		}
1395
	}
1415
	}
1396
}
1416
}
(-)cacti-0.8.7g.orig//lib/template.php (+12 lines)
Lines 786-791 Link Here
786
		update_graph_data_query_cache($cache_array["local_graph_id"]);
786
		update_graph_data_query_cache($cache_array["local_graph_id"]);
787
	}
787
	}
788
788
789
	# now that we have the id of the new host, we may plugin postprocessing code
790
	$save["id"] = $cache_array["local_graph_id"];
791
	$save["graph_template_id"] = $graph_template_id;	// attention: unset!
792
	if (is_array($snmp_query_array)) {
793
		$save["snmp_query_id"] = $snmp_query_array["snmp_query_id"];
794
		$save["snmp_index"] = $snmp_query_array["snmp_index"];
795
	} else {
796
		$save["snmp_query_id"] = 0;
797
		$save["snmp_index"] = 0;
798
	}
799
	api_plugin_hook_function('create_complete_graph_from_template', $save);
800
789
	return $cache_array;
801
	return $cache_array;
790
}
802
}
791
803
(-)cacti-0.8.7g.orig//lib/variables.php (+3 lines)
Lines 183-188 Link Here
183
	$string = str_replace($l_escape_string . "host_max_oids" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["max_oids"], $string);
183
	$string = str_replace($l_escape_string . "host_max_oids" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["max_oids"], $string);
184
	$string = str_replace($l_escape_string . "host_id" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["id"], $string);
184
	$string = str_replace($l_escape_string . "host_id" . $r_escape_string, $_SESSION["sess_host_cache_array"][$host_id]["id"], $string);
185
185
186
	$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));
187
	$string = $temp['string'];
188
186
	return $string;
189
	return $string;
187
}
190
}
188
191
(-)cacti-0.8.7g.orig//plugins/index.php (+5 lines)
Line 0 Link Here
1
<?php
2
3
header("Location:../index.php");
4
5
?>
(-)cacti-0.8.7g.orig//plugins.php (+665 lines)
Line 0 Link Here
1
<?php
2
/*
3
 +-------------------------------------------------------------------------+
4
 | Copyright (C) 2004-2010 The Cacti Group                                 |
5
 |                                                                         |
6
 | This program is free software; you can redistribute it and/or           |
7
 | modify it under the terms of the GNU General Public License             |
8
 | as published by the Free Software Foundation; either version 2          |
9
 | of the License, or (at your option) any later version.                  |
10
 |                                                                         |
11
 | This program is distributed in the hope that it will be useful,         |
12
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
13
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
14
 | GNU General Public License for more details.                            |
15
 +-------------------------------------------------------------------------+
16
 | Cacti: The Complete RRDTool-based Graphing Solution                     |
17
 +-------------------------------------------------------------------------+
18
 | This code is designed, written, and maintained by the Cacti Group. See  |
19
 | about.php and/or the AUTHORS file for specific developer information.   |
20
 +-------------------------------------------------------------------------+
21
 | http://www.cacti.net/                                                   |
22
 +-------------------------------------------------------------------------+
23
*/
24
25
include("./include/auth.php");
26
27
define("MAX_DISPLAY_PAGES", 21);
28
29
$actions = array("install" => "Install",
30
	"enable" => "Enable",
31
	"disable" => "Disable",
32
	"uninstall" => "Uninstall",
33
//	"check" => "Check"
34
);
35
36
$status_names = array(
37
	-2 => 'Disabled',
38
	-1 => 'Active',
39
	0 => 'Not Installed',
40
	1 => 'Active',
41
	2 => 'Awaiting Configuration',
42
	3 => 'Awaiting Upgrade',
43
	4 => 'Installed'
44
);
45
46
/* get the comprehensive list of plugins */
47
$pluginslist = retrieve_plugin_list();
48
49
/* Check to see if we are installing, etc... */
50
$modes = array('installold', 'uninstallold', 'install', 'uninstall', 'disable', 'enable', 'check', 'moveup', 'movedown');
51
52
if (isset($_GET['mode']) && in_array($_GET['mode'], $modes)  && isset($_GET['id'])) {
53
	input_validate_input_regex(get_request_var("id"), "^([a-zA-Z0-9]+)$");
54
55
	$mode = $_GET['mode'];
56
	$id   = sanitize_search_string($_GET['id']);
57
58
	switch ($mode) {
59
		case 'installold':
60
			api_plugin_install_old($id);
61
			header("Location: plugins.php");
62
			exit;
63
			break;
64
		case 'uninstallold':
65
			api_plugin_uninstall_old($id);
66
			header("Location: plugins.php");
67
			exit;
68
			break;
69
		case 'install':
70
			api_plugin_install($id);
71
			header("Location: plugins.php");
72
			exit;
73
			break;
74
		case 'uninstall':
75
			if (!in_array($id, $pluginslist)) break;
76
			api_plugin_uninstall($id);
77
			header("Location: plugins.php");
78
			exit;
79
			break;
80
		case 'disable':
81
			if (!in_array($id, $pluginslist)) break;
82
			api_plugin_disable($id);
83
			header("Location: plugins.php");
84
			exit;
85
			break;
86
		case 'enable':
87
			if (!in_array($id, $pluginslist)) break;
88
			api_plugin_enable($id);
89
			header("Location: plugins.php");
90
			exit;
91
			break;
92
		case 'check':
93
			if (!in_array($id, $pluginslist)) break;
94
			break;
95
		case 'moveup':
96
			if (!in_array($id, $pluginslist)) break;
97
			if (is_system_plugin($id)) break;
98
			api_plugin_moveup($id);
99
			header("Location: plugins.php");
100
			exit;
101
			break;
102
		case 'movedown':
103
			if (!in_array($id, $pluginslist)) break;
104
			if (is_system_plugin($id)) break;
105
			api_plugin_movedown($id);
106
			header("Location: plugins.php");
107
			exit;
108
			break;
109
	}
110
}
111
112
function retrieve_plugin_list () {
113
	$pluginslist = array();
114
	$temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name');
115
	foreach ($temp as $t) {
116
		$pluginslist[] = $t['directory'];
117
	}
118
	return $pluginslist;
119
}
120
121
include("./include/top_header.php");
122
123
update_show_current();
124
125
include("./include/bottom_footer.php");
126
127
function api_plugin_install_old ($plugin) {
128
	global $config;
129
	if (!file_exists($config['base_path'] . "/plugins/$plugin/setup.php")) {
130
		return false;
131
	}
132
	$oldplugins = read_config_option('oldplugins');
133
	if (strlen(trim($oldplugins))) {
134
	$oldplugins = explode(',', $oldplugins);
135
	}else{
136
		$oldplugins = array();
137
	}
138
	if (!in_array($plugin, $oldplugins)) {
139
		include_once($config['base_path'] . "/plugins/$plugin/setup.php");
140
		$function = 'plugin_init_' . $plugin;
141
		if (function_exists($function)){
142
			$oldplugins[] = $plugin;
143
			$oldplugins   = implode(',', $oldplugins);
144
			set_config_option('oldplugins', $oldplugins);
145
			unset($_SESSION['sess_config_array']['oldplugins']);
146
			return true;
147
		} else {
148
			return false;
149
		}
150
	}
151
	return false;
152
}
153
154
function api_plugin_uninstall_old ($plugin) {
155
	global $config;
156
	$oldplugins = read_config_option('oldplugins');
157
	if (strlen(trim($oldplugins))) {
158
	$oldplugins = explode(',', $oldplugins);
159
	}else{
160
		$oldplugins = array();
161
	}
162
	if (!empty($oldplugins)) {
163
		if (in_array($plugin, $oldplugins)) {
164
			for ($a = 0; $a < count($oldplugins); $a++) {
165
				if ($oldplugins[$a] == $plugin) {
166
					unset($oldplugins[$a]);
167
					break;
168
				}
169
			}
170
			$oldplugins = implode(',', $oldplugins);
171
			set_config_option('oldplugins', $oldplugins);
172
			unset($_SESSION['sess_config_array']['oldplugins']);
173
			return true;
174
		}
175
	}
176
	return false;
177
}
178
179
function update_show_updates () {
180
	global $pluginslist, $colors, $config, $plugin_architecture;
181
182
	$cinfo = array();
183
	sort($pluginslist);
184
185
	$cinfo = update_get_plugin_info ();
186
187
	$x = 0;
188
189
	$info = update_get_cached_plugin_info();
190
191
	$cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ;
192
	if (isset($cinfo['cacti_plugin_arch']['version'])) {
193
		$archnew =  update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']);
194
	} else {
195
		$archnew = 0;
196
	}
197
198
	if ($cactinew) {
199
		$x++;
200
		print "<tr><td width='25%' valign=top><table width='100%'>";
201
		html_header(array("Cacti"), 2);
202
		form_alternate_row_color($colors["alternate"],$colors["light"], 0);
203
		print "<td width='25%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr>";
204
		form_alternate_row_color($colors["alternate"],$colors["light"], 0);
205
		print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti']['changes']) . "</td></tr></table>";
206
	}
207
	if (isset($plugin_architecture['version']) && $archnew) {
208
		$x++;
209
		print "<table width='100%'>";
210
		html_header(array("Plugin Architecture"), 2);
211
		form_alternate_row_color($colors["alternate"],$colors["light"], 0);
212
		print "<td width='25%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td>";
213
		form_alternate_row_color($colors["alternate"],$colors["light"], 0);
214
		print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti_plugin_arch']['changes']) . "</td></tr></table>";
215
	}
216
	print "<table width='100%' cellspacing=0 cellpadding=3>";
217
218
	foreach ($pluginslist as $plugin) {
219
		if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) {
220
			$x++;
221
			print "<table width='100%'>";
222
			html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2);
223
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
224
			print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
225
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
226
			print "<td><strong>Version:</strong></td><td>" . $info[$plugin]['version'] . "</td>";
227
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
228
			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>";
229
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
230
			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>";
231
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
232
			print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info[$plugin]['changes']) . "</td>";
233
234
			print "</tr></table>";
235
		}
236
	}
237
	if ($x == 0)
238
		print "<br><center><b>There are currently no Updates!</b></center><br>";
239
	print "</table>";
240
	html_end_box(TRUE);
241
}
242
243
function update_check_if_newer() {
244
	return false;
245
}
246
247
function plugins_temp_table_exists($table) {
248
	return sizeof(db_fetch_row("SHOW TABLES LIKE '$table'"));
249
}
250
251
function plugins_load_temp_table() {
252
	global $config, $plugins;
253
254
	$pluginslist = retrieve_plugin_list();
255
256
	if (isset($_SESSION["plugin_temp_table"])) {
257
		$table = $_SESSION["plugin_temp_table"];
258
	}else{
259
		$table = "plugin_temp_table_" . rand();
260
	}
261
262
	while (true) {
263
		if (!plugins_temp_table_exists($table)) {
264
			$_SESSION["plugin_temp_table"] = $table;
265
			db_execute("CREATE TEMPORARY TABLE $table LIKE plugin_config");
266
			db_execute("INSERT INTO $table SELECT * FROM plugin_config");
267
			break;
268
		}else{
269
			$table = "plugin_temp_table_" . rand();
270
		}
271
	}
272
273
	$path = $config['base_path'] . '/plugins/';
274
	$dh = opendir($path);
275
	while (($file = readdir($dh)) !== false) {
276
		if ((is_dir("$path/$file")) && (file_exists("$path/$file/setup.php")) && (!in_array($file, $pluginslist))) {
277
			include_once("$path/$file/setup.php");
278
			if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) {
279
				$function = $file . '_version';
280
				$cinfo[$file] = $function();
281
				if (!isset($cinfo[$file]['author']))   $cinfo[$file]['author']   = 'Unknown';
282
				if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
283
				if (isset($cinfo[$file]['webpage']))   $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
284
				if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['longname'] = ucfirst($file);
285
				$cinfo[$file]['status'] = -2;
286
				if (in_array($file, $plugins)) {
287
					$cinfo[$file]['status'] = -1;
288
				}
289
				db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
290
					VALUES ('" .
291
						$file . "', '" .
292
						$cinfo[$file]['longname'] . "', '" .
293
						$cinfo[$file]['status']   . "', '" .
294
						$cinfo[$file]['author']   . "', '" .
295
						$cinfo[$file]['homepage'] . "', '" .
296
						$cinfo[$file]['version']  . "')");
297
				$pluginslist[] = $file;
298
			} elseif (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
299
				$function               = $file . '_version';
300
				$cinfo[$file]           = $function();
301
				$cinfo[$file]['status'] = 0;
302
				if (!isset($cinfo[$file]['author']))   $cinfo[$file]['author']   = 'Unknown';
303
				if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
304
				if (isset($cinfo[$file]['webpage']))   $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
305
				if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['homepage'] = ucfirst($file);
306
307
				/* see if it's been installed as old, if so, remove from oldplugins array and session */
308
				$oldplugins = read_config_option("oldplugins");
309
				if (substr_count($oldplugins, $file)) {
310
					$oldplugins = str_replace($file, "", $oldplugins);
311
					$oldplugins = str_replace(",,", ",", $oldplugins);
312
					$oldplugins = trim($oldplugins, ",");
313
					set_config_option('oldplugins', $oldplugins);
314
					$_SESSION['sess_config_array']['oldplugins'] = $oldplugins;
315
				}
316
317
				db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
318
					VALUES ('" .
319
						$file . "', '" .
320
						$cinfo[$file]['longname'] . "', '" .
321
						$cinfo[$file]['status'] . "', '" .
322
						$cinfo[$file]['author'] . "', '" .
323
						$cinfo[$file]['homepage'] . "', '" .
324
						$cinfo[$file]['version'] . "')");
325
				$pluginslist[] = $file;
326
			}
327
		}
328
	}
329
	closedir($dh);
330
331
	return $table;
332
}
333
334
function update_show_current () {
335
	global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names, $actions;
336
337
	/* ================= input validation ================= */
338
	input_validate_input_number(get_request_var_request("page"));
339
	/* ==================================================== */
340
341
	/* clean up search string */
342
	if (isset($_REQUEST["filter"])) {
343
		$_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
344
	}
345
346
	/* clean up sort_column */
347
	if (isset($_REQUEST["sort_column"])) {
348
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
349
	}
350
351
	/* clean up search string */
352
	if (isset($_REQUEST["sort_direction"])) {
353
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
354
	}
355
356
	/* if the user pushed the 'clear' button */
357
	if (isset($_REQUEST["clear_x"])) {
358
		kill_session_var("sess_plugins_filter");
359
		kill_session_var("sess_plugins_sort_column");
360
		kill_session_var("sess_plugins_sort_direction");
361
362
		unset($_REQUEST["page"]);
363
		unset($_REQUEST["filter"]);
364
		unset($_REQUEST["sort_column"]);
365
		unset($_REQUEST["sort_direction"]);
366
		$_REQUEST["page"] = 1;
367
	}
368
369
	/* remember these search fields in session vars so we don't have to keep passing them around */
370
	load_current_session_value("filter", "sess_plugins_filter", "");
371
	load_current_session_value("sort_column", "sess_plugins_sort_column", "name");
372
	load_current_session_value("sort_direction", "sess_plugins_sort_direction", "ASC");
373
	load_current_session_value("page", "sess_plugins_current_page", "1");
374
375
	$table = plugins_load_temp_table();
376
377
	html_start_box("<strong>Plugin Management</strong> (Cacti Version: " . $config["cacti_version"] .
378
		(isset($plugin_architecture['version']) ? ", Plugin Architecture Version: " . $plugin_architecture['version']:"") .
379
		")", "100%", $colors["header"], "3", "center", "");
380
381
	?>
382
	<tr bgcolor="#<?php print $colors['panel'];?>">
383
		<td class="noprint">
384
		<form name="form_plugins" method="get" action="plugins.php">
385
			<table width="100%" cellpadding="0" cellspacing="0">
386
				<tr class="noprint">
387
					<td nowrap style='white-space: nowrap;' width="50">
388
						Search:&nbsp;
389
					</td>
390
					<td width="1">
391
						<input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>">
392
					</td>
393
					<td nowrap style='white-space: nowrap;'>
394
						&nbsp;<input type="submit" value="Go" title="Set/Refresh Filters">
395
						<input type="submit" name="clear_x" value="Clear" title="Clear Filters">
396
					</td>
397
				</tr>
398
			</table>
399
			<input type='hidden' name='page' value='1'>
400
		</form>
401
		</td>
402
	</tr>
403
	<?php
404
405
	html_end_box();
406
407
	/* print checkbox form for validation */
408
	print "<form name='chk' method='post' action='plugins.php'>\n";
409
410
	html_start_box("", "100%", $colors["header"], "3", "center", "");
411
412
	/* form the 'where' clause for our main sql query */
413
	$sql_where = "WHERE ($table.name LIKE '%%" . get_request_var_request("filter") . "%%')";
414
415
	if (get_request_var_request("sort_column") == "version") {
416
		$sortc = "version+0";
417
	}else{
418
		$sortc = get_request_var_request("sort_column");
419
	}
420
421
	if (get_request_var_request("sort_column") == "id") {
422
		$sortd = "ASC";
423
	}else{
424
		$sortd = get_request_var_request("sort_direction");
425
	}
426
427
	$total_rows = db_fetch_cell("SELECT
428
		count(*)
429
		FROM $table
430
		$sql_where");
431
432
	$plugins = db_fetch_assoc("SELECT *
433
		FROM $table
434
		$sql_where
435
		ORDER BY " . $sortc . " " . $sortd . "
436
		LIMIT " . (read_config_option("num_rows_device")*(get_request_var_request("page")-1)) . "," . read_config_option("num_rows_device"));
437
438
	db_execute("DROP TABLE $table");
439
440
	/* generate page list */
441
	$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"));
442
443
	if ($total_rows == 0) {
444
		$nav = "<tr bgcolor='#" . $colors["header"] . "'>
445
				<td colspan='9'>
446
					<table width='100%' cellspacing='0' cellpadding='0' border='0'>
447
						<tr>
448
							<td align='center' class='textHeaderDark'>
449
								No Plugins Found
450
							</td>\n
451
						</tr>
452
					</table>
453
				</td>
454
			</tr>\n";
455
	}elseif ($total_rows < read_config_option("num_rows_device")) {
456
		$nav = "<tr bgcolor='#" . $colors["header"] . "'>
457
				<td colspan='9'>
458
					<table width='100%' cellspacing='0' cellpadding='0' border='0'>
459
						<tr>
460
							<td align='center' class='textHeaderDark'>
461
								Showing All $total_rows Rows
462
							</td>\n
463
						</tr>
464
					</table>
465
				</td>
466
			</tr>\n";
467
	}else{
468
		$nav = "<tr bgcolor='#" . $colors["header"] . "'>
469
				<td colspan='9'>
470
					<table width='100%' cellspacing='0' cellpadding='0' border='0'>
471
						<tr>
472
							<td align='left' class='textHeaderDark'>
473
								<strong>&lt;&lt; "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("plugins.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page")-1)) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong>
474
							</td>\n
475
							<td align='center' class='textHeaderDark'>
476
								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]
477
							</td>\n
478
							<td align='right' class='textHeaderDark'>
479
								<strong>"; if ((get_request_var_request("page") * read_config_option("num_rows_device")) < $total_rows) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("plugins.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page")+1)) . "'>"; } $nav .= "Next"; if ((get_request_var_request("page") * read_config_option("num_rows_device")) < $total_rows) { $nav .= "</a>"; } $nav .= " &gt;&gt;</strong>
480
							</td>\n
481
						</tr>
482
					</table>
483
				</td>
484
			</tr>\n";
485
	}
486
487
	print $nav;
488
489
	$display_text = array(
490
		"nosort" => array("Actions", ""),
491
		"directory" => array("Name", "ASC"),
492
		"id" => array("Load Order", "ASC"),
493
		"name" => array("Description", "ASC"),
494
		"nosort1" => array("Type", "ASC"),
495
		"status" => array("Status", "ASC"),
496
		"author" => array("Author", "ASC"),
497
		"webpage" => array("Web Page", "ASC"),
498
		"version" => array("Version", "ASC"));
499
500
	html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), 1);
501
502
	$i = 0;
503
	if (sizeof($plugins)) {
504
		if (get_request_var_request("sort_column") == "id") {
505
			$inst_system_plugins = get_system_plugins($plugins);
506
			if (sizeof($inst_system_plugins)) {
507
				foreach($inst_system_plugins as $plugin) {
508
					form_alternate_row_color($colors["alternate"], $colors["light"], $i); $i++;
509
					print format_plugin_row($plugin, false, false, true);
510
				}
511
			}
512
		}
513
514
		$j = 0;
515
		foreach ($plugins as $plugin) {
516
			if ((isset($plugins[$j+1]) && $plugins[$j+1]['status'] < 0) || (!isset($plugins[$j+1]))) {
517
				$last_plugin = true;
518
			}else{
519
				$last_plugin = false;
520
			}
521
			if ($plugin['status'] <= 0 || is_system_plugin($plugin) || (get_request_var_request('sort_column') != 'id')) {
522
				$load_ordering = false;
523
			}else{
524
				$load_ordering = true;
525
			}
526
527
			if (get_request_var_request("sort_column") == "id") {
528
				if (!is_system_plugin($plugin)) {
529
					form_alternate_row_color($colors["alternate"], $colors["light"], $i);
530
					print format_plugin_row($plugin, $last_plugin, $load_ordering, false);
531
					$i++;
532
				}
533
			}else{
534
				form_alternate_row_color($colors["alternate"], $colors["light"], $i);
535
				print format_plugin_row($plugin, $last_plugin, $load_ordering, is_system_plugin($plugin));
536
				$i++;
537
			}
538
539
			$j++;
540
		}
541
542
		print $nav;
543
	}else{
544
		print "<tr><td><em>No Plugins Found</em></td></tr>";
545
	}
546
547
	html_end_box(false);
548
549
	html_start_box("", "100%", $colors["header"], "3", "center", "");
550
	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>";
551
	html_end_box();
552
553
	print "</form>\n";
554
}
555
556
function format_plugin_row($plugin, $last_plugin, $include_ordering, $system_plugin) {
557
	global $status_names;
558
	static $first_plugin = true;
559
560
	$row = plugin_actions($plugin);
561
	$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>";
562
	if ($include_ordering) {
563
		$row .= "<td style='white-space:nowrap;'>";
564
		if (!$first_plugin) {
565
			$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>";
566
		}else{
567
			$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>";
568
		}
569
		if (!$last_plugin) {
570
			$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>";
571
		}else{
572
			$row .= "<a href='#' title='Can Increase Load Order' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'></a>";
573
		}
574
		$row .= "</td>\n";
575
	}else{
576
		$row .= "<td></td>\n";
577
	}
578
579
	$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";
580
	$row .= "<td style='white-space:nowrap;'>" . ($system_plugin ? "System": ($plugin['status'] < 0 ? "Old PIA":"General")) . "</td>\n";
581
	$row .= "<td style='white-space:nowrap;'>" . $status_names[$plugin["status"]] . "</td>\n";
582
	$row .= "<td style='white-space:nowrap;'>" . $plugin["author"] . "</td>\n";
583
	$row .= "<td><a href='" . htmlspecialchars($plugin["webpage"]) . "'>" . htmlspecialchars($plugin["webpage"]) . "</a></td>\n";
584
	$row .= "<td>" . $plugin["version"] . "</td>\n";
585
	$row .= "</tr>\n";
586
587
	if ($include_ordering) {
588
		$first_plugin = false;
589
	}
590
591
	return $row;
592
}
593
594
function plugin_actions($plugin) {
595
	$link = "<td>";
596
	switch ($plugin['status']) {
597
		case "-2": // Old PA Not Installed
598
			$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>";
599
			$link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
600
			break;
601
		case "-1":	// Old PA Currently Active
602
			$oldplugins = read_config_option('oldplugins');
603
			if (strlen(trim($oldplugins))) {
604
				$oldplugins = explode(',', $oldplugins);
605
			}else{
606
				$oldplugins = array();
607
			}
608
			if (in_array($plugin['directory'], $oldplugins)) {
609
				$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>";
610
			} else {
611
				$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>";
612
			}
613
			$link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
614
			break;
615
		case "0": // Not Installed
616
			$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>";
617
			$link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
618
			break;
619
		case "1":	// Currently Active
620
			$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>";
621
			$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>";
622
			break;
623
		case "4":	// Installed but not active
624
			$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>";
625
			$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>";
626
			break;
627
		default: // Old PIA
628
			$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>";
629
			$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>";
630
			break;
631
	}
632
	$link .= "</td>";
633
634
	return $link;
635
}
636
637
function is_system_plugin($plugin) {
638
	global $plugins_system;
639
640
	if (is_array($plugin)) {
641
		$plugin = $plugin["directory"];
642
	}
643
644
	if (!in_array($plugin, $plugins_system)) {
645
		return false;
646
	}else{
647
		return true;
648
	}
649
}
650
651
function get_system_plugins($plugins) {
652
	$inst_system_plugins = array();
653
654
	if (sizeof($plugins)) {
655
		foreach($plugins as $plugin) {
656
			if (is_system_plugin($plugin)) {
657
				$inst_system_plugins[] = $plugin;
658
			}
659
		}
660
	}
661
662
	return $inst_system_plugins;
663
}
664
665
(-)cacti-0.8.7g.orig//poller.php (-1 / +9 lines)
Lines 108-113 Link Here
108
	pcntl_signal(SIGINT, "sig_handler");
108
	pcntl_signal(SIGINT, "sig_handler");
109
}
109
}
110
110
111
api_plugin_hook('poller_top');
112
111
/* record the start time */
113
/* record the start time */
112
list($micro,$seconds) = explode(" ", microtime());
114
list($micro,$seconds) = explode(" ", microtime());
113
$poller_start         = $seconds + $micro;
115
$poller_start         = $seconds + $micro;
Lines 303-308 Link Here
303
			$total_procs    = $concurrent_processes;
305
			$total_procs    = $concurrent_processes;
304
		}
306
		}
305
307
308
		$extra_args = api_plugin_hook_function ('poller_command_args', $extra_args);
309
306
		/* Populate each execution file with appropriate information */
310
		/* Populate each execution file with appropriate information */
307
		foreach ($polling_hosts as $item) {
311
		foreach ($polling_hosts as $item) {
308
			if ($host_count == 1) {
312
			if ($host_count == 1) {
Lines 427-433 Link Here
427
431
428
	/* record the start time for this loop */
432
	/* record the start time for this loop */
429
	list($micro,$seconds) = explode(" ", microtime());
433
	list($micro,$seconds) = explode(" ", microtime());
430
	$loop_end = $seconds + $micro;
434
	$loop_end  = $seconds + $micro;
431
	$loop_time = $loop_end - $loop_start;
435
	$loop_time = $loop_end - $loop_start;
432
436
433
	if ($loop_time < $poller_interval) {
437
	if ($loop_time < $poller_interval) {
Lines 446-452 Link Here
446
450
447
		/* sleep the appripriate amount of time */
451
		/* sleep the appripriate amount of time */
448
		if ($poller_runs_completed < $poller_runs) {
452
		if ($poller_runs_completed < $poller_runs) {
453
			api_plugin_hook('poller_bottom');
449
			usleep($sleep_time * 1000000);
454
			usleep($sleep_time * 1000000);
455
			api_plugin_hook('poller_top');
450
		}
456
		}
451
	}else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
457
	}else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
452
		cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER");
458
		cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER");
Lines 493-496 Link Here
493
	echo "    --debug|-d     Output debug information.  Similar to cacti's DEBUG logging level.\n\n";
499
	echo "    --debug|-d     Output debug information.  Similar to cacti's DEBUG logging level.\n\n";
494
}
500
}
495
501
502
api_plugin_hook('poller_bottom');
503
496
?>
504
?>
(-)cacti-0.8.7g.orig//user_admin.php (-3 / +10 lines)
Lines 57-65 Link Here
57
		break;
57
		break;
58
58
59
	default:
59
	default:
60
		include_once("include/top_header.php");
60
		if (!api_plugin_hook_function('user_admin_action', get_request_var_request("action"))) {
61
		user();
61
			include_once("include/top_header.php");
62
		include_once("include/bottom_footer.php");
62
			user();
63
			include_once("include/bottom_footer.php");
64
		}
63
		break;
65
		break;
64
}
66
}
65
67
Lines 402-407 Link Here
402
		$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);
404
		$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);
403
		$save["realm"] = get_request_var_post("realm", 0);
405
		$save["realm"] = get_request_var_post("realm", 0);
404
		$save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3);
406
		$save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3);
407
		$save = api_plugin_hook_function('user_admin_setup_sql_save', $save);
405
408
406
		if (!is_error_message()) {
409
		if (!is_error_message()) {
407
			$user_id = sql_save($save, "user_auth");
410
			$user_id = sql_save($save, "user_auth");
Lines 444-449 Link Here
444
					policy_hosts = " . get_request_var_post("policy_hosts") . ",
447
					policy_hosts = " . get_request_var_post("policy_hosts") . ",
445
					policy_graph_templates = " . get_request_var_post("policy_graph_templates") . "
448
					policy_graph_templates = " . get_request_var_post("policy_graph_templates") . "
446
					WHERE id = " . get_request_var_post("id"));
449
					WHERE id = " . get_request_var_post("id"));
450
			} else {
451
				api_plugin_hook('user_admin_user_save');
447
			}
452
			}
448
		}
453
		}
449
	}
454
	}
Lines 889-894 Link Here
889
		$header_label = "[new]";
894
		$header_label = "[new]";
890
	}
895
	}
891
896
897
	api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0));
898
892
	html_start_box("<strong>User Management</strong> $header_label", "100%", $colors["header"], "3", "center", "");
899
	html_start_box("<strong>User Management</strong> $header_label", "100%", $colors["header"], "3", "center", "");
893
900
894
	draw_edit_form(array(
901
	draw_edit_form(array(
(-)cacti-0.8.7g.orig//utilities.php (-3 / +8 lines)
Lines 123-133 Link Here
123
		include_once("./include/bottom_footer.php");
123
		include_once("./include/bottom_footer.php");
124
		break;
124
		break;
125
	default:
125
	default:
126
		include_once("./include/top_header.php");
127
126
128
		utilities();
127
		if (!api_plugin_hook_function('utilities_action', $_REQUEST['action'])) {
128
			include_once('./include/top_header.php');
129
129
130
		include_once("./include/bottom_footer.php");
130
			utilities();
131
132
			include_once('./include/bottom_footer.php');
133
		}
131
		break;
134
		break;
132
}
135
}
133
136
Lines 1644-1649 Link Here
1644
1647
1645
	<?php
1648
	<?php
1646
1649
1650
	api_plugin_hook('utilities_list');
1651
1647
	html_end_box();
1652
	html_end_box();
1648
}
1653
}
1649
1654

Return to bug 346741