Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 324457
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//data_sources.php (-1 / +15 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-1315 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 = 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 */
1327
			/* 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"]));
1328
			$data_template_name = ((empty($data_source["data_template_name"])) ? "<em>None</em>" : htmlspecialchars($data_source["data_template_name"]));
1315
			$data_input_name    = ((empty($data_source["data_input_name"])) ? "<em>External</em>" : htmlspecialchars($data_source["data_input_name"]));
1329
			$data_input_name    = ((empty($data_source["data_input_name"])) ? "<em>External</em>" : htmlspecialchars($data_source["data_input_name"]));
(-)cacti-0.8.7g.orig//data_sources.php.orig (+1342 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
include_once("./lib/utility.php");
27
include_once("./lib/api_graph.php");
28
include_once("./lib/api_data_source.php");
29
include_once("./lib/template.php");
30
include_once("./lib/html_form_template.php");
31
include_once("./lib/rrd.php");
32
include_once("./lib/data_query.php");
33
34
define("MAX_DISPLAY_PAGES", 21);
35
36
$ds_actions = array(
37
	1 => "Delete",
38
	2 => "Change Data Template",
39
	3 => "Change Host",
40
	8 => "Reapply Suggested Names",
41
	4 => "Duplicate",
42
	5 => "Convert to Data Template",
43
	6 => "Enable",
44
	7 => "Disable"
45
	);
46
47
/* set default action */
48
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
49
50
switch ($_REQUEST["action"]) {
51
	case 'save':
52
		form_save();
53
54
		break;
55
	case 'actions':
56
		form_actions();
57
58
		break;
59
	case 'rrd_add':
60
		ds_rrd_add();
61
62
		break;
63
	case 'rrd_remove':
64
		ds_rrd_remove();
65
66
		break;
67
	case 'data_edit':
68
		include_once("./include/top_header.php");
69
70
		data_edit();
71
72
		include_once("./include/bottom_footer.php");
73
		break;
74
	case 'ds_remove':
75
		ds_remove();
76
77
		header ("Location: data_sources.php");
78
		break;
79
	case 'ds_edit':
80
		ds_edit();
81
82
		break;
83
	default:
84
		include_once("./include/top_header.php");
85
86
		ds();
87
88
		include_once("./include/bottom_footer.php");
89
		break;
90
}
91
92
/* --------------------------
93
    The Save Function
94
   -------------------------- */
95
96
function form_save() {
97
	if ((isset($_POST["save_component_data_source_new"])) && (!empty($_POST["data_template_id"]))) {
98
		/* ================= input validation ================= */
99
		input_validate_input_number(get_request_var_post("host_id"));
100
		input_validate_input_number(get_request_var_post("data_template_id"));
101
		/* ==================================================== */
102
103
		$save["id"] = $_POST["local_data_id"];
104
		$save["data_template_id"] = $_POST["data_template_id"];
105
		$save["host_id"] = $_POST["host_id"];
106
107
		$local_data_id = sql_save($save, "data_local");
108
109
		change_data_template($local_data_id, $_POST["data_template_id"]);
110
111
		/* update the title cache */
112
		update_data_source_title_cache($local_data_id);
113
114
		/* update host data */
115
		if (!empty($_POST["host_id"])) {
116
			push_out_host($_POST["host_id"], $local_data_id);
117
		}
118
	}
119
120
	if ((isset($_POST["save_component_data"])) && (!is_error_message())) {
121
		/* ================= input validation ================= */
122
		input_validate_input_number(get_request_var_post("data_template_data_id"));
123
		/* ==================================================== */
124
125
		/* ok, first pull out all 'input' values so we know how much to save */
126
		$input_fields = db_fetch_assoc("select
127
			data_template_data.data_input_id,
128
			data_local.host_id,
129
			data_input_fields.id,
130
			data_input_fields.input_output,
131
			data_input_fields.data_name,
132
			data_input_fields.regexp_match,
133
			data_input_fields.allow_nulls,
134
			data_input_fields.type_code
135
			from data_template_data
136
			left join data_input_fields on (data_input_fields.data_input_id=data_template_data.data_input_id)
137
			left join data_local on (data_template_data.local_data_id=data_local.id)
138
			where data_template_data.id=" . $_POST["data_template_data_id"] . "
139
			and data_input_fields.input_output='in'");
140
141
		if (sizeof($input_fields) > 0) {
142
		foreach ($input_fields as $input_field) {
143
			if (isset($_POST{"value_" . $input_field["id"]})) {
144
				/* save the data into the 'data_input_data' table */
145
				$form_value = $_POST{"value_" . $input_field["id"]};
146
147
				/* we shouldn't enforce rules on fields the user cannot see (ie. templated ones) */
148
				$is_templated = db_fetch_cell("select t_value from data_input_data where data_input_field_id=" . $input_field["id"] . " and data_template_data_id=" . db_fetch_cell("select local_data_template_data_id from data_template_data where id=" . $_POST["data_template_data_id"]));
149
150
				if ($is_templated == "") {
151
					$allow_nulls = true;
152
				}elseif ($input_field["allow_nulls"] == "on") {
153
					$allow_nulls = true;
154
				}elseif (empty($input_field["allow_nulls"])) {
155
					$allow_nulls = false;
156
				}
157
158
				/* run regexp match on input string */
159
				$form_value = form_input_validate($form_value, "value_" . $input_field["id"], $input_field["regexp_match"], $allow_nulls, 3);
160
161
				if (!is_error_message()) {
162
					db_execute("replace into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values
163
						(" . $input_field["id"] . "," . $_POST["data_template_data_id"] . ",'','$form_value')");
164
				}
165
			}
166
		}
167
		}
168
	}
169
170
	if ((isset($_POST["save_component_data_source"])) && (!is_error_message())) {
171
		/* ================= input validation ================= */
172
		input_validate_input_number(get_request_var_post("local_data_id"));
173
		input_validate_input_number(get_request_var_post("current_rrd"));
174
		input_validate_input_number(get_request_var_post("data_template_id"));
175
		input_validate_input_number(get_request_var_post("host_id"));
176
		/* ==================================================== */
177
178
		$save1["id"] = $_POST["local_data_id"];
179
		$save1["data_template_id"] = $_POST["data_template_id"];
180
		$save1["host_id"] = $_POST["host_id"];
181
182
		$save2["id"] = $_POST["data_template_data_id"];
183
		$save2["local_data_template_data_id"] = $_POST["local_data_template_data_id"];
184
		$save2["data_template_id"] = $_POST["data_template_id"];
185
		$save2["data_input_id"] = form_input_validate($_POST["data_input_id"], "data_input_id", "", true, 3);
186
		$save2["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
187
		$save2["data_source_path"] = form_input_validate($_POST["data_source_path"], "data_source_path", "", true, 3);
188
		$save2["active"] = form_input_validate((isset($_POST["active"]) ? $_POST["active"] : ""), "active", "", true, 3);
189
		$save2["rrd_step"] = form_input_validate($_POST["rrd_step"], "rrd_step", "^[0-9]+$", false, 3);
190
191
		if (!is_error_message()) {
192
			$local_data_id = sql_save($save1, "data_local");
193
194
			$save2["local_data_id"] = $local_data_id;
195
			$data_template_data_id = sql_save($save2, "data_template_data");
196
197
			if ($data_template_data_id) {
198
				raise_message(1);
199
			}else{
200
				raise_message(2);
201
			}
202
		}
203
204
		if (!is_error_message()) {
205
			/* if this is a new data source and a template has been selected, skip item creation this time
206
			otherwise it throws off the templatate creation because of the NULL data */
207
			if ((!empty($_POST["local_data_id"])) || (empty($_POST["data_template_id"]))) {
208
				/* if no template was set before the save, there will be only one data source item to save;
209
				otherwise there might be >1 */
210
				if (empty($_POST["_data_template_id"])) {
211
					$rrds[0]["id"] = $_POST["current_rrd"];
212
				}else{
213
					$rrds = db_fetch_assoc("select id from data_template_rrd where local_data_id=" . $_POST["local_data_id"]);
214
				}
215
216
				if (sizeof($rrds) > 0) {
217
				foreach ($rrds as $rrd) {
218
					if (empty($_POST["_data_template_id"])) {
219
						$name_modifier = "";
220
					}else{
221
						$name_modifier = "_" . $rrd["id"];
222
					}
223
224
					$save3["id"] = $rrd["id"];
225
					$save3["local_data_id"] = $local_data_id;
226
					$save3["local_data_template_rrd_id"] = db_fetch_cell("select local_data_template_rrd_id from data_template_rrd where id=" . $rrd["id"]);
227
					$save3["data_template_id"] = $_POST["data_template_id"];
228
					$save3["rrd_maximum"] = form_input_validate($_POST["rrd_maximum$name_modifier"], "rrd_maximum$name_modifier", "^(-?([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)([eE][+\-]?[0-9]+)?)|U$", false, 3);
229
					$save3["rrd_minimum"] = form_input_validate($_POST["rrd_minimum$name_modifier"], "rrd_minimum$name_modifier", "^(-?([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)([eE][+\-]?[0-9]+)?)|U$", false, 3);
230
					$save3["rrd_heartbeat"] = form_input_validate($_POST["rrd_heartbeat$name_modifier"], "rrd_heartbeat$name_modifier", "^[0-9]+$", false, 3);
231
					$save3["data_source_type_id"] = $_POST["data_source_type_id$name_modifier"];
232
					$save3["data_source_name"] = form_input_validate($_POST["data_source_name$name_modifier"], "data_source_name$name_modifier", "^[a-zA-Z0-9_-]{1,19}$", false, 3);
233
					$save3["data_input_field_id"] = form_input_validate((isset($_POST["data_input_field_id$name_modifier"]) ? $_POST["data_input_field_id$name_modifier"] : "0"), "data_input_field_id$name_modifier", "", true, 3);
234
235
					$data_template_rrd_id = sql_save($save3, "data_template_rrd");
236
237
					if ($data_template_rrd_id) {
238
						raise_message(1);
239
					}else{
240
						raise_message(2);
241
					}
242
				}
243
				}
244
			}
245
		}
246
247
		if (!is_error_message()) {
248
			if (!empty($_POST["rra_id"])) {
249
				/* save entries in 'selected rras' field */
250
				db_execute("delete from data_template_data_rra where data_template_data_id=$data_template_data_id");
251
252
				for ($i=0; ($i < count($_POST["rra_id"])); $i++) {
253
					/* ================= input validation ================= */
254
					input_validate_input_number($_POST["rra_id"][$i]);
255
					/* ==================================================== */
256
257
					db_execute("insert into data_template_data_rra (rra_id,data_template_data_id)
258
						values (" . $_POST["rra_id"][$i] . ",$data_template_data_id)");
259
				}
260
			}
261
262
			if ($_POST["data_template_id"] != $_POST["_data_template_id"]) {
263
				/* update all necessary template information */
264
				change_data_template($local_data_id, $_POST["data_template_id"]);
265
			}elseif (!empty($_POST["data_template_id"])) {
266
				update_data_source_data_query_cache($local_data_id);
267
			}
268
269
			if ($_POST["host_id"] != $_POST["_host_id"]) {
270
				/* push out all necessary host information */
271
				push_out_host($_POST["host_id"], $local_data_id);
272
273
				/* reset current host for display purposes */
274
				$_SESSION["sess_data_source_current_host_id"] = $_POST["host_id"];
275
			}
276
277
			/* if no data source path has been entered, generate one */
278
			if (empty($_POST["data_source_path"])) {
279
				generate_data_source_path($local_data_id);
280
			}
281
282
			/* update the title cache */
283
			update_data_source_title_cache($local_data_id);
284
		}
285
	}
286
287
	/* update the poller cache last to make sure everything is fresh */
288
	if ((!is_error_message()) && (!empty($local_data_id))) {
289
		update_poller_cache($local_data_id, false);
290
	}
291
292
	if ((isset($_POST["save_component_data_source_new"])) && (empty($_POST["data_template_id"]))) {
293
		header("Location: data_sources.php?action=ds_edit&host_id=" . $_POST["host_id"] . "&new=1");
294
	}elseif ((is_error_message()) || ($_POST["data_template_id"] != $_POST["_data_template_id"]) || ($_POST["data_input_id"] != $_POST["_data_input_id"]) || ($_POST["host_id"] != $_POST["_host_id"])) {
295
		header("Location: data_sources.php?action=ds_edit&id=" . (empty($local_data_id) ? $_POST["local_data_id"] : $local_data_id) . "&host_id=" . $_POST["host_id"] . "&view_rrd=" . (isset($_POST["current_rrd"]) ? $_POST["current_rrd"] : "0"));
296
	}else{
297
		header("Location: data_sources.php");
298
	}
299
}
300
301
/* ------------------------
302
    The "actions" function
303
   ------------------------ */
304
305
function form_actions() {
306
	global $colors, $ds_actions;
307
308
	/* if we are to save this form, instead of display it */
309
	if (isset($_POST["selected_items"])) {
310
		$selected_items = unserialize(stripslashes($_POST["selected_items"]));
311
312
		if ($_POST["drp_action"] == "1") { /* delete */
313
			if (!isset($_POST["delete_type"])) { $_POST["delete_type"] = 1; }
314
315
			switch ($_POST["delete_type"]) {
316
				case '2': /* delete all graph items tied to this data source */
317
					$data_template_rrds = db_fetch_assoc("select id from data_template_rrd where " . array_to_sql_or($selected_items, "local_data_id"));
318
319
					/* loop through each data source item */
320
					if (sizeof($data_template_rrds) > 0) {
321
						foreach ($data_template_rrds as $item) {
322
							db_execute("delete from graph_templates_item where task_item_id=" . $item["id"] . " and local_graph_id > 0");
323
						}
324
					}
325
326
					break;
327
				case '3': /* delete all graphs tied to this data source */
328
					$graphs = db_fetch_assoc("select
329
						graph_templates_graph.local_graph_id
330
						from (data_template_rrd,graph_templates_item,graph_templates_graph)
331
						where graph_templates_item.task_item_id=data_template_rrd.id
332
						and graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id
333
						and " . array_to_sql_or($selected_items, "data_template_rrd.local_data_id") . "
334
						and graph_templates_graph.local_graph_id > 0
335
						group by graph_templates_graph.local_graph_id");
336
337
					if (sizeof($graphs) > 0) {
338
						foreach ($graphs as $graph) {
339
							api_graph_remove($graph["local_graph_id"]);
340
						}
341
					}
342
343
					break;
344
				}
345
346
				for ($i=0;($i<count($selected_items));$i++) {
347
					/* ================= input validation ================= */
348
					input_validate_input_number($selected_items[$i]);
349
					/* ==================================================== */
350
351
					api_data_source_remove($selected_items[$i]);
352
				}
353
		}elseif ($_POST["drp_action"] == "2") { /* change graph template */
354
			for ($i=0;($i<count($selected_items));$i++) {
355
				/* ================= input validation ================= */
356
				input_validate_input_number($selected_items[$i]);
357
				input_validate_input_number(get_request_var_post("data_template_id"));
358
				/* ==================================================== */
359
360
				change_data_template($selected_items[$i], $_POST["data_template_id"]);
361
			}
362
		}elseif ($_POST["drp_action"] == "3") { /* change host */
363
			for ($i=0;($i<count($selected_items));$i++) {
364
				/* ================= input validation ================= */
365
				input_validate_input_number($selected_items[$i]);
366
				input_validate_input_number(get_request_var_post("host_id"));
367
				/* ==================================================== */
368
369
				db_execute("update data_local set host_id=" . $_POST["host_id"] . " where id=" . $selected_items[$i]);
370
				push_out_host($_POST["host_id"], $selected_items[$i]);
371
				update_data_source_title_cache($selected_items[$i]);
372
			}
373
		}elseif ($_POST["drp_action"] == "4") { /* duplicate */
374
			for ($i=0;($i<count($selected_items));$i++) {
375
				/* ================= input validation ================= */
376
				input_validate_input_number($selected_items[$i]);
377
				/* ==================================================== */
378
379
				duplicate_data_source($selected_items[$i], 0, $_POST["title_format"]);
380
			}
381
		}elseif ($_POST["drp_action"] == "5") { /* data source -> data template */
382
			for ($i=0;($i<count($selected_items));$i++) {
383
				/* ================= input validation ================= */
384
				input_validate_input_number($selected_items[$i]);
385
				/* ==================================================== */
386
387
				data_source_to_data_template($selected_items[$i], $_POST["title_format"]);
388
			}
389
		}elseif ($_POST["drp_action"] == "6") { /* data source enable */
390
			for ($i=0;($i<count($selected_items));$i++) {
391
				api_data_source_enable($selected_items[$i]);
392
			}
393
		}elseif ($_POST["drp_action"] == "7") { /* data source disable */
394
			for ($i=0;($i<count($selected_items));$i++) {
395
				api_data_source_disable($selected_items[$i]);
396
			}
397
		}elseif ($_POST["drp_action"] == "8") { /* reapply suggested data source naming */
398
			for ($i=0;($i<count($selected_items));$i++) {
399
				/* ================= input validation ================= */
400
				input_validate_input_number($selected_items[$i]);
401
				/* ==================================================== */
402
				api_reapply_suggested_data_source_title($selected_items[$i]);
403
				update_data_source_title_cache($selected_items[$i]);
404
			}
405
		}
406
		header("Location: data_sources.php");
407
		exit;
408
	}
409
410
	/* setup some variables */
411
	$ds_list = ""; $i = 0;
412
413
	/* loop through each of the graphs selected on the previous page and get more info about them */
414
	while (list($var,$val) = each($_POST)) {
415
		if (ereg("^chk_([0-9]+)$", $var, $matches)) {
416
			/* ================= input validation ================= */
417
			input_validate_input_number($matches[1]);
418
			/* ==================================================== */
419
420
			$ds_list .= "<li>" . get_data_source_title($matches[1]) . "<br>";
421
			$ds_array[$i] = $matches[1];
422
423
			$i++;
424
		}
425
	}
426
427
	include_once("./include/top_header.php");
428
429
	html_start_box("<strong>" . $ds_actions{$_POST["drp_action"]} . "</strong>", "60%", $colors["header_panel"], "3", "center", "");
430
431
	print "<form action='data_sources.php' method='post'>\n";
432
433
	if (isset($ds_array) && sizeof($ds_array)) {
434
		if ($_POST["drp_action"] == "1") { /* delete */
435
			$graphs = array();
436
437
			/* find out which (if any) graphs are using this data source, so we can tell the user */
438
			if (isset($ds_array)) {
439
				$graphs = db_fetch_assoc("select
440
					graph_templates_graph.local_graph_id,
441
					graph_templates_graph.title_cache
442
					from (data_template_rrd,graph_templates_item,graph_templates_graph)
443
					where graph_templates_item.task_item_id=data_template_rrd.id
444
					and graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id
445
					and " . array_to_sql_or($ds_array, "data_template_rrd.local_data_id") . "
446
					and graph_templates_graph.local_graph_id > 0
447
					group by graph_templates_graph.local_graph_id
448
					order by graph_templates_graph.title_cache");
449
			}
450
451
			print "	<tr>
452
					<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
453
						<p>When you click \"Continue\", the following Data Source(s) will be deleted.</p>
454
						<p><ul>$ds_list</ul></p>";
455
456
						if (sizeof($graphs) > 0) {
457
							print "<tr bgcolor='#" . $colors["form_alternate1"] . "'><td class='textArea'><p class='textArea'>The following graphs are using these data sources:</p>\n";
458
459
							print "<ul>";
460
							foreach ($graphs as $graph) {
461
								print "<li><strong>" . $graph["title_cache"] . "</strong></li>\n";
462
							}
463
							print "</ul>";
464
465
							print "<br>";
466
							form_radio_button("delete_type", "3", "1", "Leave the Graph(s) untouched.", "1"); print "<br>";
467
							form_radio_button("delete_type", "3", "2", "Delete all <strong>Graph Item(s)</strong> that reference these Data Source(s).", "1"); print "<br>";
468
							form_radio_button("delete_type", "3", "3", "Delete all <strong>Graph(s)</strong> that reference these Data Source(s).", "1"); print "<br>";
469
							print "</td></tr>";
470
						}
471
					print "
472
					</td>
473
				</tr>\n
474
				";
475
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete Data Source(s)'>";
476
		}elseif ($_POST["drp_action"] == "2") { /* change graph template */
477
			print "	<tr>
478
					<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
479
						<p>Choose a Data Template and click \"Continue\" to change the Data Template for
480
						the following Data Source(s). Be aware that all warnings will be suppressed during the
481
						conversion, so graph data loss is possible.</p>
482
						<p><ul>$ds_list</ul></p>
483
						<p><strong>New Data Template:</strong><br>"; form_dropdown("data_template_id",db_fetch_assoc("select data_template.id,data_template.name from data_template order by data_template.name"),"name","id","","","0"); print "</p>
484
					</td>
485
				</tr>\n
486
				";
487
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Change Graph Template for Data Source(s)'>";
488
		}elseif ($_POST["drp_action"] == "3") { /* change host */
489
			print "	<tr>
490
					<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
491
						<p>Choose a new Device for these Data Source(s) and click \"Continue\"</p>
492
						<p><ul>$ds_list</ul></p>
493
						<p><strong>New Host:</strong><br>"; form_dropdown("host_id",db_fetch_assoc("select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"),"name","id","","","0"); print "</p>
494
					</td>
495
				</tr>\n
496
				";
497
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Change Device'>";
498
		}elseif ($_POST["drp_action"] == "4") { /* duplicate */
499
			print "	<tr>
500
					<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
501
						<p>When you click \"Continue\", the following Data Source(s) will be duplicated. You can
502
						optionally change the title format for the new Data Source(s).</p>
503
						<p><ul>$ds_list</ul></p>
504
						<p><strong>Title Format:</strong><br>"; form_text_box("title_format", "<ds_title> (1)", "", "255", "30", "text"); print "</p>
505
					</td>
506
				</tr>\n
507
				";
508
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Duplicate Data Source(s)'>";
509
		}elseif ($_POST["drp_action"] == "5") { /* data source -> data template */
510
			print "	<tr>
511
					<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
512
						<p>When you click \"Continue\", the following Data Source(s) will be converted into Data Template(s).
513
						You can optionally change the title format for the new Data Template(s).</p>
514
						<p><ul>$ds_list</ul></p>
515
						<p><strong>Title Format:</strong><br>"; form_text_box("title_format", "<ds_title> Template", "", "255", "30", "text"); print "</p>
516
					</td>
517
				</tr>\n
518
				";
519
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Convert Data Source(s) to Data Template(s)'>";
520
		}elseif ($_POST["drp_action"] == "6") { /* data source enable */
521
			print "	<tr>
522
					<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
523
						<p>When you click \"Continue\", the following Data Source(s) will be enabled.</p>
524
						<p><ul>$ds_list</ul></p>
525
					</td>
526
				</tr>\n
527
				";
528
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Enable Data Source(s)'>";
529
		}elseif ($_POST["drp_action"] == "7") { /* data source disable */
530
			print "	<tr>
531
					<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
532
						<p>When you click \"Continue\", the following Data Source(s) will be disabled.</p>
533
						<p><ul>$ds_list</ul></p>
534
					</td>
535
				</tr>\n
536
				";
537
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Disable Data Source(s)'>";
538
		}elseif ($_POST["drp_action"] == "8") { /* reapply suggested data source naming */
539
			print "	<tr>
540
					<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
541
						<p>When you click \"Continue\", the following Data Source(s) will will have their suggested naming conventions
542
						recalculated.</p>
543
						<p><ul>$ds_list</ul></p>
544
					</td>
545
				</tr>\n
546
				";
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)'>";
548
		}
549
	}else{
550
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one data source.</span></td></tr>\n";
551
		$save_html = "<input type='button' value='Return' onClick='window.history.back()'>";
552
	}
553
554
	print "	<tr>
555
			<td align='right' bgcolor='#eaeaea'>
556
				<input type='hidden' name='action' value='actions'>
557
				<input type='hidden' name='selected_items' value='" . (isset($ds_array) ? serialize($ds_array) : '') . "'>
558
				<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>
559
				$save_html
560
			</td>
561
		</tr>
562
		";
563
564
	html_end_box();
565
566
	include_once("./include/bottom_footer.php");
567
}
568
569
/* ----------------------------
570
    data - Custom Data
571
   ---------------------------- */
572
573
function data_edit() {
574
	/* ================= input validation ================= */
575
	input_validate_input_number(get_request_var("id"));
576
	/* ==================================================== */
577
578
	global $config, $colors;
579
580
	if (!empty($_GET["id"])) {
581
		$data = db_fetch_row("select id,data_input_id,data_template_id,name,local_data_id from data_template_data where local_data_id=" . $_GET["id"]);
582
		$template_data = db_fetch_row("select id,data_input_id from data_template_data where data_template_id=" . $data["data_template_id"] . " and local_data_id=0");
583
584
		$host = db_fetch_row("select host.id,host.hostname from (data_local,host) where data_local.host_id=host.id and data_local.id=" . $_GET["id"]);
585
586
		$header_label = "[edit: " . htmlspecialchars($data["name"]) . "]";
587
	}else{
588
		$header_label = "[new]";
589
	}
590
591
	print "<form method='post' action='data_sources.php'>\n";
592
593
	$i = 0;
594
	if (!empty($data["data_input_id"])) {
595
		/* get each INPUT field for this data input source */
596
		$fields = db_fetch_assoc("select * from data_input_fields where data_input_id=" . $data["data_input_id"] . " and input_output='in' order by name");
597
598
		html_start_box("<strong>Custom Data</strong> [data input: " . htmlspecialchars(db_fetch_cell("select name from data_input where id=" . $data["data_input_id"])) . "]", "100%", $colors["header"], "3", "center", "");
599
600
		/* loop through each field found */
601
		if (sizeof($fields) > 0) {
602
		foreach ($fields as $field) {
603
			$data_input_data = db_fetch_row("select * from data_input_data where data_template_data_id=" . $data["id"] . " and data_input_field_id=" . $field["id"]);
604
605
			if (sizeof($data_input_data) > 0) {
606
				$old_value = $data_input_data["value"];
607
			}else{
608
				$old_value = "";
609
			}
610
611
			/* if data template then get t_value from template, else always allow user input */
612
			if (empty($data["data_template_id"])) {
613
				$can_template = "on";
614
			}else{
615
				$can_template = db_fetch_cell("select t_value from data_input_data where data_template_data_id=" . $template_data["id"] . " and data_input_field_id=" . $field["id"]);
616
			}
617
618
			form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
619
620
			if ((!empty($host["id"])) && (eregi('^' . VALID_HOST_FIELDS . '$', $field["type_code"]))) {
621
				print "<td width='50%'><strong>" . $field["name"] . "</strong> (From Host: " . $host["hostname"] . ")</td>\n";
622
				print "<td><em>$old_value</em></td>\n";
623
			}elseif (empty($can_template)) {
624
				print "<td width='50%'><strong>" . $field["name"] . "</strong> (From Data Template)</td>\n";
625
				print "<td><em>" . (empty($old_value) ? "Nothing Entered" : $old_value) . "</em></td>\n";
626
			}else{
627
				print "<td width='50%'><strong>" . $field["name"] . "</strong></td>\n";
628
				print "<td>";
629
630
				draw_custom_data_row("value_" . $field["id"], $field["id"], $data["id"], $old_value);
631
632
				print "</td>";
633
			}
634
635
			print "</tr>\n";
636
637
			$i++;
638
		}
639
		}else{
640
			print "<tr><td><em>No Input Fields for the Selected Data Input Source</em></td></tr>";
641
		}
642
643
		html_end_box();
644
	}
645
646
	form_hidden_box("local_data_id", (isset($data) ? $data["local_data_id"] : "0"), "");
647
	form_hidden_box("data_template_data_id", (isset($data) ? $data["id"] : "0"), "");
648
	form_hidden_box("save_component_data", "1", "");
649
}
650
651
/* ------------------------
652
    Data Source Functions
653
   ------------------------ */
654
655
function ds_rrd_remove() {
656
	/* ================= input validation ================= */
657
	input_validate_input_number(get_request_var("id"));
658
	/* ==================================================== */
659
660
	db_execute("delete from data_template_rrd where id=" . $_GET["id"]);
661
	db_execute("update graph_templates_item set task_item_id=0 where task_item_id=" . $_GET["id"]);
662
663
	header("Location: data_sources.php?action=ds_edit&id=" . $_GET["local_data_id"]);
664
}
665
666
function ds_rrd_add() {
667
	/* ================= input validation ================= */
668
	input_validate_input_number(get_request_var("id"));
669
	/* ==================================================== */
670
671
	db_execute("insert into data_template_rrd (local_data_id,rrd_maximum,rrd_minimum,rrd_heartbeat,data_source_type_id,
672
		data_source_name) values (" . $_GET["id"] . ",100,0,600,1,'ds')");
673
	$data_template_rrd_id = db_fetch_insert_id();
674
675
	header("Location: data_sources.php?action=ds_edit&id=" . $_GET["id"] . "&view_rrd=$data_template_rrd_id");
676
}
677
678
function ds_edit() {
679
	global $colors, $struct_data_source, $struct_data_source_item, $data_source_types;
680
681
	/* ================= input validation ================= */
682
	input_validate_input_number(get_request_var("id"));
683
	input_validate_input_number(get_request_var("host_id"));
684
	/* ==================================================== */
685
686
	$use_data_template = true;
687
	$host_id = 0;
688
689
	if (!empty($_GET["id"])) {
690
		$data_local = db_fetch_row("select host_id,data_template_id from data_local where id='" . $_GET["id"] . "'");
691
		$data       = db_fetch_row("select * from data_template_data where local_data_id='" . $_GET["id"] . "'");
692
693
		if (isset($data_local["data_template_id"]) && $data_local["data_template_id"] >= 0) {
694
			$data_template      = db_fetch_row("select id,name from data_template where id='" . $data_local["data_template_id"] . "'");
695
			$data_template_data = db_fetch_row("select * from data_template_data where data_template_id='" . $data_local["data_template_id"] . "' and local_data_id=0");
696
		} else {
697
			$_SESSION["sess_messages"] = 'Data Source "' . $_GET["id"] . '" does not exist.';
698
			header ("Location: data_sources.php");
699
			exit;
700
		}
701
702
		$header_label = "[edit: " . htmlspecialchars(get_data_source_title($_GET["id"])) . "]";
703
704
		if (empty($data_local["data_template_id"])) {
705
			$use_data_template = false;
706
		}
707
	}else{
708
		$header_label = "[new]";
709
710
		$use_data_template = false;
711
	}
712
713
	/* handle debug mode */
714
	if (isset($_GET["debug"])) {
715
		if ($_GET["debug"] == "0") {
716
			kill_session_var("ds_debug_mode");
717
		}elseif ($_GET["debug"] == "1") {
718
			$_SESSION["ds_debug_mode"] = true;
719
		}
720
	}
721
722
	include_once("./include/top_header.php");
723
724
	if (!empty($_GET["id"])) {
725
		?>
726
		<table width="100%" align="center">
727
			<tr>
728
				<td class="textInfo" colspan="2" valign="top">
729
					<?php print htmlspecialchars(get_data_source_title($_GET["id"]));?>
730
				</td>
731
				<td class="textInfo" align="right" valign="top">
732
					<span style="color: #c16921;">*<a href='<?php print htmlspecialchars("data_sources.php?action=ds_edit&id=" . (isset($_GET["id"]) ? $_GET["id"] : "0"));?>&debug=<?php print (isset($_SESSION["ds_debug_mode"]) ? "0" : "1");?>'>Turn <strong><?php print (isset($_SESSION["ds_debug_mode"]) ? "Off" : "On");?></strong> Data Source Debug Mode.</a><br>
733
					<?php
734
						if (!empty($data_template["id"])) {
735
							?><span style="color: #c16921;">*<a href='<?php print htmlspecialchars("data_templates.php?action=template_edit&id=" . (isset($data_template["id"]) ? $data_template["id"] : "0"));?>'>Edit Data Template.</a><br><?php
736
						}
737
						if (!empty($_GET["host_id"]) || !empty($data_local["host_id"])) {
738
							?><span style="color: #c16921;">*<a href='<?php print htmlspecialchars("host.php?action=edit&id=" . (isset($_GET["host_id"]) ? $_GET["host_id"] : $data_local["host_id"]));?>'>Edit Host.</a><br><?php
739
						}
740
					?>
741
				</td>
742
			</tr>
743
		</table>
744
		<br>
745
		<?php
746
	}
747
748
	html_start_box("<strong>Data Template Selection</strong> $header_label", "100%", $colors["header"], "3", "center", "");
749
750
	$form_array = array(
751
		"data_template_id" => array(
752
			"method" => "drop_sql",
753
			"friendly_name" => "Selected Data Template",
754
			"description" => "The name given to this data template.",
755
			"value" => (isset($data_template) ? $data_template["id"] : "0"),
756
			"none_value" => "None",
757
			"sql" => "select id,name from data_template order by name"
758
			),
759
		"host_id" => array(
760
			"method" => "drop_sql",
761
			"friendly_name" => "Host",
762
			"description" => "Choose the host that this graph belongs to.",
763
			"value" => (isset($_GET["host_id"]) ? $_GET["host_id"] : $data_local["host_id"]),
764
			"none_value" => "None",
765
			"sql" => "select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"
766
			),
767
		"_data_template_id" => array(
768
			"method" => "hidden",
769
			"value" => (isset($data_template) ? $data_template["id"] : "0")
770
			),
771
		"_host_id" => array(
772
			"method" => "hidden",
773
			"value" => (empty($data_local["host_id"]) ? (isset($_GET["host_id"]) ? $_GET["host_id"] : "0") : $data_local["host_id"])
774
			),
775
		"_data_input_id" => array(
776
			"method" => "hidden",
777
			"value" => (isset($data["data_input_id"]) ? $data["data_input_id"] : "0")
778
			),
779
		"data_template_data_id" => array(
780
			"method" => "hidden",
781
			"value" => (isset($data) ? $data["id"] : "0")
782
			),
783
		"local_data_template_data_id" => array(
784
			"method" => "hidden",
785
			"value" => (isset($data) ? $data["local_data_template_data_id"] : "0")
786
			),
787
		"local_data_id" => array(
788
			"method" => "hidden",
789
			"value" => (isset($data) ? $data["local_data_id"] : "0")
790
			),
791
		);
792
793
	draw_edit_form(
794
		array(
795
			"config" => array(),
796
			"fields" => $form_array
797
			)
798
		);
799
800
	html_end_box();
801
802
	/* only display the "inputs" area if we are using a data template for this data source */
803
	if (!empty($data["data_template_id"])) {
804
		$template_data_rrds = db_fetch_assoc("select * from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
805
806
		html_start_box("<strong>Supplemental Data Template Data</strong>", "100%", $colors["header"], "3", "center", "");
807
808
		draw_nontemplated_fields_data_source($data["data_template_id"], $data["local_data_id"], $data, "|field|", "<strong>Data Source Fields</strong>", true, true, 0);
809
		draw_nontemplated_fields_data_source_item($data["data_template_id"], $template_data_rrds, "|field|_|id|", "<strong>Data Source Item Fields</strong>", true, true, true, 0);
810
		draw_nontemplated_fields_custom_data($data["id"], "value_|id|", "<strong>Custom Data</strong>", true, true, 0);
811
812
		form_hidden_box("save_component_data","1","");
813
814
		html_end_box();
815
	}
816
817
	if (((isset($_GET["id"])) || (isset($_GET["new"]))) && (empty($data["data_template_id"]))) {
818
		html_start_box("<strong>Data Source</strong>", "100%", $colors["header"], "3", "center", "");
819
820
		$form_array = array();
821
822
		while (list($field_name, $field_array) = each($struct_data_source)) {
823
			$form_array += array($field_name => $struct_data_source[$field_name]);
824
825
			if (!(($use_data_template == false) || (!empty($data_template_data{"t_" . $field_name})) || ($field_array["flags"] == "NOTEMPLATE"))) {
826
				$form_array[$field_name]["description"] = "";
827
			}
828
829
			$form_array[$field_name]["value"] = (isset($data[$field_name]) ? $data[$field_name] : "");
830
			$form_array[$field_name]["form_id"] = (empty($data["id"]) ? "0" : $data["id"]);
831
832
			if (!(($use_data_template == false) || (!empty($data_template_data{"t_" . $field_name})) || ($field_array["flags"] == "NOTEMPLATE"))) {
833
				$form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
834
			}
835
		}
836
837
		draw_edit_form(
838
			array(
839
				"config" => array(
840
					"no_form_tag" => true
841
					),
842
				"fields" => inject_form_variables($form_array, (isset($data) ? $data : array()))
843
				)
844
			);
845
846
		html_end_box();
847
848
		/* fetch ALL rrd's for this data source */
849
		if (!empty($_GET["id"])) {
850
			$template_data_rrds = db_fetch_assoc("select id,data_source_name from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
851
		}
852
853
		/* select the first "rrd" of this data source by default */
854
		if (empty($_GET["view_rrd"])) {
855
			$_GET["view_rrd"] = (isset($template_data_rrds[0]["id"]) ? $template_data_rrds[0]["id"] : "0");
856
		}
857
858
		/* get more information about the rrd we chose */
859
		if (!empty($_GET["view_rrd"])) {
860
			$local_data_template_rrd_id = db_fetch_cell("select local_data_template_rrd_id from data_template_rrd where id=" . $_GET["view_rrd"]);
861
862
			$rrd = db_fetch_row("select * from data_template_rrd where id=" . $_GET["view_rrd"]);
863
			$rrd_template = db_fetch_row("select * from data_template_rrd where id=$local_data_template_rrd_id");
864
865
			$header_label = "[edit: " . $rrd["data_source_name"] . "]";
866
		}else{
867
			$header_label = "";
868
		}
869
870
		$i = 0;
871
		if (isset($template_data_rrds)) {
872
			if (sizeof($template_data_rrds) > 1) {
873
874
			/* draw the data source tabs on the top of the page */
875
			print "	<table class='tabs' width='100%' cellspacing='0' cellpadding='3' align='center'>
876
					<tr>\n";
877
878
					foreach ($template_data_rrds as $template_data_rrd) {
879
						$i++;
880
						print "	<td " . (($template_data_rrd["id"] == $_GET["view_rrd"]) ? "bgcolor='silver'" : "bgcolor='#DFDFDF'") . " nowrap='nowrap' width='" . ((strlen($template_data_rrd["data_source_name"]) * 9) + 50) . "' align='center' class='tab'>
881
								<span class='textHeader'><a href='" . htmlspecialchars("data_sources.php?action=ds_edit&id=" . $_GET["id"] . "&view_rrd=" . $template_data_rrd["id"]) . "'>$i: " . htmlspecialchars($template_data_rrd["data_source_name"]) . "</a>" . (($use_data_template == false) ? " <a href='" . htmlspecialchars("data_sources.php?action=rrd_remove&id=" . $template_data_rrd["id"] . "&local_data_id=" . $_GET["id"]) . "'><img src='images/delete_icon.gif' border='0' alt='Delete'></a>" : "") . "</span>
882
							</td>\n
883
							<td width='1'></td>\n";
884
					}
885
886
					print "
887
					<td></td>\n
888
					</tr>
889
				</table>\n";
890
891
			}elseif (sizeof($template_data_rrds) == 1) {
892
				$_GET["view_rrd"] = $template_data_rrds[0]["id"];
893
			}
894
		}
895
896
		html_start_box("", "100%", $colors["header"], "3", "center", "");
897
898
		print "	<tr>
899
				<td bgcolor='#" . $colors["header"] . "' class='textHeaderDark'>
900
					<strong>Data Source Item</strong> $header_label
901
				</td>
902
				<td class='textHeaderDark' align='right' bgcolor='#" . $colors["header"] . "'>
903
					" . ((!empty($_GET["id"]) && (empty($data_template["id"]))) ? "<strong><a class='linkOverDark' href='" . htmlspecialchars("data_sources.php?action=rrd_add&id=" . $_GET["id"]) . "'>New</a>&nbsp;</strong>" : "") . "
904
				</td>
905
			</tr>\n";
906
907
		/* data input fields list */
908
		if ((empty($data["data_input_id"])) || (db_fetch_cell("select type_id from data_input where id=" . $data["data_input_id"]) > "1")) {
909
			unset($struct_data_source_item["data_input_field_id"]);
910
		}else{
911
			$struct_data_source_item["data_input_field_id"]["sql"] = "select id,CONCAT(data_name,' - ',name) as name from data_input_fields where data_input_id=" . $data["data_input_id"] . " and input_output='out' and update_rra='on' order by data_name,name";
912
		}
913
914
		$form_array = array();
915
916
		while (list($field_name, $field_array) = each($struct_data_source_item)) {
917
			$form_array += array($field_name => $struct_data_source_item[$field_name]);
918
919
			if (!(($use_data_template == false) || ($rrd_template{"t_" . $field_name} == "on"))) {
920
				$form_array[$field_name]["description"] = "";
921
			}
922
923
			$form_array[$field_name]["value"] = (isset($rrd) ? $rrd[$field_name] : "");
924
925
			if (!(($use_data_template == false) || ($rrd_template{"t_" . $field_name} == "on"))) {
926
				$form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
927
			}
928
		}
929
930
		draw_edit_form(
931
			array(
932
				"config" => array(
933
					"no_form_tag" => true
934
					),
935
				"fields" => array(
936
					"data_template_rrd_id" => array(
937
						"method" => "hidden",
938
						"value" => (isset($rrd) ? $rrd["id"] : "0")
939
					),
940
					"local_data_template_rrd_id" => array(
941
						"method" => "hidden",
942
						"value" => (isset($rrd) ? $rrd["local_data_template_rrd_id"] : "0")
943
					)
944
				) + $form_array
945
			)
946
			);
947
948
		html_end_box();
949
950
		/* data source data goes here */
951
		data_edit();
952
953
		form_hidden_box("current_rrd", $_GET["view_rrd"], "0");
954
	}
955
956
	/* display the debug mode box if the user wants it */
957
	if ((isset($_SESSION["ds_debug_mode"])) && (isset($_GET["id"]))) {
958
		?>
959
		<table width="100%" align="center">
960
			<tr>
961
				<td>
962
					<span class="textInfo">Data Source Debug</span><br>
963
					<pre><?php print @rrdtool_function_create($_GET["id"], true);?></pre>
964
				</td>
965
			</tr>
966
		</table>
967
		<?php
968
	}
969
970
	if ((isset($_GET["id"])) || (isset($_GET["new"]))) {
971
		form_hidden_box("save_component_data_source","1","");
972
	}else{
973
		form_hidden_box("save_component_data_source_new","1","");
974
	}
975
976
	form_save_button("data_sources.php");
977
978
	include_once("./include/bottom_footer.php");
979
980
}
981
982
function get_poller_interval($seconds) {
983
	if ($seconds == 0) {
984
		return "<em>External</em>";
985
	}else if ($seconds < 60) {
986
		return "<em>" . $seconds . " Seconds</em>";
987
	}else if ($seconds == 60) {
988
		return "1 Minute";
989
	}else{
990
		return "<em>" . ($seconds / 60) . " Minutes</em>";
991
	}
992
}
993
994
function ds() {
995
	global $colors, $ds_actions, $item_rows;
996
997
	/* ================= input validation ================= */
998
	input_validate_input_number(get_request_var_request("ds_rows"));
999
	input_validate_input_number(get_request_var_request("host_id"));
1000
	input_validate_input_number(get_request_var_request("template_id"));
1001
	input_validate_input_number(get_request_var_request("method_id"));
1002
	input_validate_input_number(get_request_var_request("page"));
1003
	/* ==================================================== */
1004
1005
	/* clean up search string */
1006
	if (isset($_REQUEST["filter"])) {
1007
		$_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
1008
	}
1009
1010
	/* clean up sort_column string */
1011
	if (isset($_REQUEST["sort_column"])) {
1012
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
1013
	}
1014
1015
	/* clean up sort_direction string */
1016
	if (isset($_REQUEST["sort_direction"])) {
1017
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
1018
	}
1019
1020
	/* if the user pushed the 'clear' button */
1021
	if (isset($_REQUEST["clear_x"])) {
1022
		kill_session_var("sess_ds_current_page");
1023
		kill_session_var("sess_ds_filter");
1024
		kill_session_var("sess_ds_sort_column");
1025
		kill_session_var("sess_ds_sort_direction");
1026
		kill_session_var("sess_ds_rows");
1027
		kill_session_var("sess_ds_host_id");
1028
		kill_session_var("sess_ds_template_id");
1029
		kill_session_var("sess_ds_method_id");
1030
1031
		unset($_REQUEST["page"]);
1032
		unset($_REQUEST["filter"]);
1033
		unset($_REQUEST["sort_column"]);
1034
		unset($_REQUEST["sort_direction"]);
1035
		unset($_REQUEST["ds_rows"]);
1036
		unset($_REQUEST["host_id"]);
1037
		unset($_REQUEST["template_id"]);
1038
		unset($_REQUEST["method_id"]);
1039
	}
1040
1041
	/* remember these search fields in session vars so we don't have to keep passing them around */
1042
	load_current_session_value("page", "sess_ds_current_page", "1");
1043
	load_current_session_value("filter", "sess_ds_filter", "");
1044
	load_current_session_value("sort_column", "sess_ds_sort_column", "name_cache");
1045
	load_current_session_value("sort_direction", "sess_ds_sort_direction", "ASC");
1046
	load_current_session_value("ds_rows", "sess_ds_rows", read_config_option("num_rows_data_source"));
1047
	load_current_session_value("host_id", "sess_ds_host_id", "-1");
1048
	load_current_session_value("template_id", "sess_ds_template_id", "-1");
1049
	load_current_session_value("method_id", "sess_ds_method_id", "-1");
1050
1051
	$host = db_fetch_row("select hostname from host where id=" . get_request_var_request("host_id"));
1052
1053
	/* if the number of rows is -1, set it to the default */
1054
	if (get_request_var_request("ds_rows") == -1) {
1055
		$_REQUEST["ds_rows"] = read_config_option("num_rows_data_source");
1056
	}
1057
1058
	?>
1059
	<script type="text/javascript">
1060
	<!--
1061
1062
	function applyDSFilterChange(objForm) {
1063
		strURL = '?host_id=' + objForm.host_id.value;
1064
		strURL = strURL + '&filter=' + objForm.filter.value;
1065
		strURL = strURL + '&ds_rows=' + objForm.ds_rows.value;
1066
		strURL = strURL + '&template_id=' + objForm.template_id.value;
1067
		strURL = strURL + '&method_id=' + objForm.method_id.value;
1068
		document.location = strURL;
1069
	}
1070
1071
	-->
1072
	</script>
1073
	<?php
1074
1075
	html_start_box("<strong>Data Sources</strong> [host: " . (empty($host["hostname"]) ? "No Host" : htmlspecialchars($host["hostname"])) . "]", "100%", $colors["header"], "3", "center", "data_sources.php?action=ds_edit&host_id=" . get_request_var_request("host_id"));
1076
1077
	?>
1078
	<tr bgcolor="#<?php print $colors["panel"];?>">
1079
		<td>
1080
		<form name="form_data_sources" action="data_sources.php">
1081
			<table cellpadding="1" cellspacing="0">
1082
				<tr>
1083
					<td width="50">
1084
						Host:&nbsp;
1085
					</td>
1086
					<td>
1087
						<select name="host_id" onChange="applyDSFilterChange(document.form_data_sources)">
1088
							<option value="-1"<?php if (get_request_var_request("host_id") == "-1") {?> selected<?php }?>>Any</option>
1089
							<option value="0"<?php if (get_request_var_request("host_id") == "0") {?> selected<?php }?>>None</option>
1090
							<?php
1091
							$hosts = db_fetch_assoc("select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname");
1092
1093
							if (sizeof($hosts) > 0) {
1094
								foreach ($hosts as $host) {
1095
									print "<option value='" . $host["id"] . "'"; if (get_request_var_request("host_id") == $host["id"]) { print " selected"; } print ">" . title_trim(htmlspecialchars($host["name"]), 40) . "</option>\n";
1096
								}
1097
							}
1098
							?>
1099
1100
						</select>
1101
					</td>
1102
					<td width="50">
1103
						&nbsp;Template:&nbsp;
1104
					</td>
1105
					<td width="1">
1106
						<select name="template_id" onChange="applyDSFilterChange(document.form_data_sources)">
1107
							<option value="-1"<?php if (get_request_var_request("template_id") == "-1") {?> selected<?php }?>>Any</option>
1108
							<option value="0"<?php if (get_request_var_request("template_id") == "0") {?> selected<?php }?>>None</option>
1109
							<?php
1110
1111
							$templates = db_fetch_assoc("SELECT DISTINCT data_template.id, data_template.name
1112
								FROM data_template
1113
								INNER JOIN data_template_data
1114
								ON data_template.id=data_template_data.data_template_id
1115
								WHERE data_template_data.local_data_id>0
1116
								ORDER BY data_template.name");
1117
1118
							if (sizeof($templates) > 0) {
1119
								foreach ($templates as $template) {
1120
									print "<option value='" . $template["id"] . "'"; if (get_request_var_request("template_id") == $template["id"]) { print " selected"; } print ">" . title_trim(htmlspecialchars($template["name"]), 40) . "</option>\n";
1121
								}
1122
							}
1123
							?>
1124
1125
						</select>
1126
					</td>
1127
					<td nowrap style='white-space: nowrap;'>
1128
						&nbsp;<input type="submit" value="Go" title="Set/Refresh Filters">
1129
						<input type="submit" name="clear_x" value="Clear" title="Clear Filters">
1130
					</td>
1131
				</tr>
1132
				<tr>
1133
					<td width="50">
1134
						Method:&nbsp;
1135
					</td>
1136
					<td width="1">
1137
						<select name="method_id" onChange="applyDSFilterChange(document.form_data_sources)">
1138
							<option value="-1"<?php if (get_request_var_request("method_id") == "-1") {?> selected<?php }?>>Any</option>
1139
							<option value="0"<?php if (get_request_var_request("method_id") == "0") {?> selected<?php }?>>None</option>
1140
							<?php
1141
1142
							$methods = db_fetch_assoc("SELECT DISTINCT data_input.id, data_input.name
1143
								FROM data_input
1144
								INNER JOIN data_template_data
1145
								ON data_input.id=data_template_data.data_input_id
1146
								WHERE data_template_data.local_data_id>0
1147
								ORDER BY data_input.name");
1148
1149
							if (sizeof($methods) > 0) {
1150
								foreach ($methods as $method) {
1151
									print "<option value='" . $method["id"] . "'"; if (get_request_var_request("method_id") == $method["id"]) { print " selected"; } print ">" . title_trim(htmlspecialchars($method["name"]), 40) . "</option>\n";
1152
								}
1153
							}
1154
							?>
1155
						</select>
1156
					</td>
1157
					<td nowrap style='white-space: nowrap;' width="50">
1158
						&nbsp;Rows per Page:&nbsp;
1159
					</td>
1160
					<td width="1">
1161
						<select name="ds_rows" onChange="applyDSFilterChange(document.form_data_sources)">
1162
							<option value="-1"<?php if (get_request_var_request("ds_rows") == "-1") {?> selected<?php }?>>Default</option>
1163
							<?php
1164
							if (sizeof($item_rows) > 0) {
1165
								foreach ($item_rows as $key => $value) {
1166
									print "<option value='" . $key . "'"; if (get_request_var_request("ds_rows") == $key) { print " selected"; } print ">" . htmlspecialchars($value) . "</option>\n";
1167
								}
1168
							}
1169
							?>
1170
						</select>
1171
					</td>
1172
				</tr>
1173
			</table>
1174
			<table cellpadding="1" cellspacing="0">
1175
				<tr>
1176
					<td width="50">
1177
						Search:&nbsp;
1178
					</td>
1179
					<td width="1">
1180
						<input type="text" name="filter" size="40" value="<?php print htmlspecialchars(get_request_var_request("filter"));?>">
1181
					</td>
1182
				</tr>
1183
			</table>
1184
			<input type='hidden' name='page' value='1'>
1185
		</form>
1186
		</td>
1187
	</tr>
1188
	<?php
1189
1190
	html_end_box();
1191
1192
	/* form the 'where' clause for our main sql query */
1193
	if (strlen(get_request_var_request("filter"))) {
1194
		$sql_where1 = "AND (data_template_data.name_cache like '%%" . get_request_var_request("filter") . "%%'" .
1195
			" OR data_template_data.local_data_id like '%%" . get_request_var_request("filter") . "%%'" .
1196
			" OR data_template.name like '%%" . get_request_var_request("filter") . "%%'" .
1197
			" OR data_input.name like '%%" . get_request_var_request("filter") . "%%')";
1198
1199
		$sql_where2 = "AND (data_template_data.name_cache like '%%" . get_request_var_request("filter") . "%%'" .
1200
			" OR data_template.name like '%%" . get_request_var_request("filter") . "%%')";
1201
	}else{
1202
		$sql_where1 = "";
1203
		$sql_where2 = "";
1204
	}
1205
1206
	if (get_request_var_request("host_id") == "-1") {
1207
		/* Show all items */
1208
	}elseif (get_request_var_request("host_id") == "0") {
1209
		$sql_where1 .= " AND data_local.host_id=0";
1210
		$sql_where2 .= " AND data_local.host_id=0";
1211
	}elseif (!empty($_REQUEST["host_id"])) {
1212
		$sql_where1 .= " AND data_local.host_id=" . get_request_var_request("host_id");
1213
		$sql_where2 .= " AND data_local.host_id=" . get_request_var_request("host_id");
1214
	}
1215
1216
	if (get_request_var_request("template_id") == "-1") {
1217
		/* Show all items */
1218
	}elseif (get_request_var_request("template_id") == "0") {
1219
		$sql_where1 .= " AND data_template_data.data_template_id=0";
1220
		$sql_where2 .= " AND data_template_data.data_template_id=0";
1221
	}elseif (!empty($_REQUEST["host_id"])) {
1222
		$sql_where1 .= " AND data_template_data.data_template_id=" . get_request_var_request("template_id");
1223
		$sql_where2 .= " AND data_template_data.data_template_id=" . get_request_var_request("template_id");
1224
	}
1225
1226
	if (get_request_var_request("method_id") == "-1") {
1227
		/* Show all items */
1228
	}elseif (get_request_var_request("method_id") == "0") {
1229
		$sql_where1 .= " AND data_template_data.data_input_id=0";
1230
		$sql_where2 .= " AND data_template_data.data_input_id=0";
1231
	}elseif (!empty($_REQUEST["method_id"])) {
1232
		$sql_where1 .= " AND data_template_data.data_input_id=" . get_request_var_request("method_id");
1233
		$sql_where2 .= " AND data_template_data.data_input_id=" . get_request_var_request("method_id");
1234
	}
1235
1236
	$total_rows = sizeof(db_fetch_assoc("SELECT
1237
		data_local.id
1238
		FROM (data_local,data_template_data)
1239
		LEFT JOIN data_input
1240
		ON (data_input.id=data_template_data.data_input_id)
1241
		LEFT JOIN data_template
1242
		ON (data_local.data_template_id=data_template.id)
1243
		WHERE data_local.id=data_template_data.local_data_id
1244
		$sql_where1"));
1245
1246
	$poller_intervals = array_rekey(db_fetch_assoc("SELECT data_template_data.local_data_id AS id,
1247
		Min(data_template_data.rrd_step*rra.steps) AS poller_interval
1248
		FROM data_template
1249
		INNER JOIN (data_local
1250
		INNER JOIN ((data_template_data_rra
1251
		INNER JOIN data_template_data ON data_template_data_rra.data_template_data_id=data_template_data.id)
1252
		INNER JOIN rra ON data_template_data_rra.rra_id = rra.id) ON data_local.id = data_template_data.local_data_id) ON data_template.id = data_template_data.data_template_id
1253
		$sql_where2
1254
		GROUP BY data_template_data.local_data_id"), "id", "poller_interval");
1255
1256
	$data_sources = db_fetch_assoc("SELECT
1257
		data_template_data.local_data_id,
1258
		data_template_data.name_cache,
1259
		data_template_data.active,
1260
		data_input.name as data_input_name,
1261
		data_template.name as data_template_name,
1262
		data_local.host_id
1263
		FROM (data_local,data_template_data)
1264
		LEFT JOIN data_input
1265
		ON (data_input.id=data_template_data.data_input_id)
1266
		LEFT JOIN data_template
1267
		ON (data_local.data_template_id=data_template.id)
1268
		WHERE data_local.id=data_template_data.local_data_id
1269
		$sql_where1
1270
		ORDER BY ". get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") .
1271
		" LIMIT " . (get_request_var_request("ds_rows")*(get_request_var_request("page")-1)) . "," . get_request_var_request("ds_rows"));
1272
1273
	print "<form name='chk' method='post' action='data_sources.php'>\n";
1274
1275
	html_start_box("", "100%", $colors["header"], "3", "center", "");
1276
1277
	/* generate page list */
1278
	$url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, get_request_var_request("ds_rows"), $total_rows, "data_sources.php?filter=" . get_request_var_request("filter") . "&host_id=" . get_request_var_request("host_id"));
1279
1280
	$nav = "<tr bgcolor='#" . $colors["header"] . "'>
1281
			<td colspan='7'>
1282
				<table width='100%' cellspacing='0' cellpadding='0' border='0'>
1283
					<tr>
1284
						<td align='left' class='textHeaderDark'>
1285
							<strong>&lt;&lt; "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("data_sources.php?filter=" . get_request_var_request("filter") . "&host_id=" . get_request_var_request("host_id") . "&page=" . (get_request_var_request("page")-1)) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong>
1286
						</td>\n
1287
						<td align='center' class='textHeaderDark'>
1288
							Showing Rows " . ((get_request_var_request("ds_rows")*(get_request_var_request("page")-1))+1) . " to " . ((($total_rows < get_request_var_request("ds_rows")) || ($total_rows < (get_request_var_request("ds_rows")*get_request_var_request("page")))) ? $total_rows : (get_request_var_request("ds_rows")*get_request_var_request("page"))) . " of $total_rows [$url_page_select]
1289
						</td>\n
1290
						<td align='right' class='textHeaderDark'>
1291
							<strong>"; if ((get_request_var_request("page") * get_request_var_request("ds_rows")) < $total_rows) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("data_sources.php?filter=" . get_request_var_request("filter") . "&host_id=" . get_request_var_request("host_id") . "&page=" . (get_request_var_request("page")+1)) . "'>"; } $nav .= "Next"; if ((get_request_var_request("page") * get_request_var_request("ds_rows")) < $total_rows) { $nav .= "</a>"; } $nav .= " &gt;&gt;</strong>
1292
						</td>\n
1293
					</tr>
1294
				</table>
1295
			</td>
1296
		</tr>\n";
1297
1298
	print $nav;
1299
1300
	$display_text = array(
1301
		"name_cache" => array("Name", "ASC"),
1302
		"local_data_id" => array("ID","ASC"),
1303
		"data_input_name" => array("Data Input Method", "ASC"),
1304
		"nosort" => array("Poller Interval", "ASC"),
1305
		"active" => array("Active", "ASC"),
1306
		"data_template_name" => array("Template Name", "ASC"));
1307
1308
	html_header_sort_checkbox($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), false);
1309
1310
	$i = 0;
1311
	if (sizeof($data_sources) > 0) {
1312
		foreach ($data_sources as $data_source) {
1313
			/* 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"]));
1315
			$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);
1317
			form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $data_source["local_data_id"]); $i++;
1318
			form_selectable_cell("<a class='linkEditMain' href='" . htmlspecialchars("data_sources.php?action=ds_edit&id=" . $data_source["local_data_id"]) . "' title='" . $data_source["name_cache"] . "'>" . ((get_request_var_request("filter") != "") ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim(htmlspecialchars($data_source["name_cache"]), read_config_option("max_title_data_source"))) : title_trim(htmlspecialchars($data_source["name_cache"]), read_config_option("max_title_data_source"))) . "</a>", $data_source["local_data_id"]);
1319
			form_selectable_cell($data_source['local_data_id'], $data_source['local_data_id']);
1320
			form_selectable_cell(((get_request_var_request("filter") != "") ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $data_input_name) : $data_input_name), $data_source["local_data_id"]);
1321
			form_selectable_cell(get_poller_interval($poller_interval), $data_source["local_data_id"]);
1322
			form_selectable_cell(($data_source['active'] == "on" ? "Yes" : "No"), $data_source["local_data_id"]);
1323
			form_selectable_cell(((get_request_var_request("filter") != "") ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $data_template_name) : $data_template_name), $data_source["local_data_id"]);
1324
			form_checkbox_cell($data_source["name_cache"], $data_source["local_data_id"]);
1325
			form_end_row();
1326
		}
1327
1328
		/* put the nav bar on the bottom as well */
1329
		print $nav;
1330
	}else{
1331
		print "<tr><td><em>No Data Sources</em></td></tr>";
1332
	}
1333
1334
	html_end_box(false);
1335
1336
	/* draw the dropdown containing a list of available actions for this form */
1337
	draw_actions_dropdown($ds_actions);
1338
1339
	print "</form>\n";
1340
}
1341
?>
1342
(-)cacti-0.8.7g.orig//graph.php (-2 / +7 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 94-110 Link Here
94
					<table width='1' cellpadding='0'>
96
					<table width='1' cellpadding='0'>
95
						<tr>
97
						<tr>
96
							<td>
98
							<td>
97
								<img class='graphimage' id='graph_<?php print $_GET["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?action=view&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"]);?>' border='0' alt='<?php print htmlspecialchars($graph_title);?>'>
99
									<img class='graphimage' id='graph_<?php print $_GET["local_graph_id"] ?>' src='<?php print htmlspecialchars("graph_image.php?action=view&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $rra["id"]);?>' border='0' alt='<?php print htmlspecialchars($graph_title);?>'>
98
							</td>
100
							</td>
99
							<td valign='top' style='padding: 3px;' class='noprint'>
101
							<td valign='top' style='padding: 3px;' class='noprint'>
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>
102
								<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>
103
								<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>
104
								<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>
105
								<?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>
106
							</td>
104
						</tr>
107
						</tr>
105
						<tr>
108
						<tr>
106
							<td colspan='2' align='center'>
109
							<td colspan='2' align='center'>
107
								<strong><?php print htmlspecialchars($rra["name"]);?></strong>
110
									<strong><?php print htmlspecialchars($rra["name"]);?></strong>
108
							</td>
111
							</td>
109
						</tr>
112
						</tr>
110
					</table>
113
					</table>
Lines 215-220 Link Here
215
					<td valign='top' style='padding: 3px;' class='noprint'>
218
					<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>
219
						<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>
220
						<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>
221
						<?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>
222
					</td>
219
				</tr>
223
				</tr>
220
				<tr>
224
				<tr>
Lines 247-252 Link Here
247
					<td valign='top' style='padding: 3px;'>
251
					<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>
252
						<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>
253
						<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>
254
						<?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>
255
					</td>
251
				</tr>
256
				</tr>
252
				<tr>
257
				<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 (+15 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 305-310 Link Here
305
307
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);
308
				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
			}
309
			}
310
		} else {
311
			api_plugin_hook_function('device_action_execute', $_POST['drp_action']); 
308
		}
312
		}
309
313
310
		header("Location: host.php");
314
		header("Location: host.php");
Lines 450-455 Link Here
450
				<input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
454
				<input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n
451
				";
455
				";
452
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Place Device(s) on Tree'>";
456
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Place Device(s) on Tree'>";
457
		} else {
458
			$save['drp_action'] = $_POST['drp_action'];
459
			$save['host_list'] = $host_list;
460
			$save['host_array'] = (isset($host_array)? $host_array : array());
461
			api_plugin_hook_function('device_action_prepare', $save);
462
			$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
453
		}
463
		}
454
	}else{
464
	}else{
455
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one device.</span></td></tr>\n";
465
		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"));
542
	input_validate_input_number(get_request_var("id"));
533
	/* ==================================================== */
543
	/* ==================================================== */
534
544
545
	api_plugin_hook('host_edit_top');
546
535
	if (!empty($_GET["id"])) {
547
	if (!empty($_GET["id"])) {
536
		$host = db_fetch_row("select * from host where id=" . $_GET["id"]);
548
		$host = db_fetch_row("select * from host where id=" . $_GET["id"]);
537
		$header_label = "[edit: " . htmlspecialchars($host["description"]) . "]";
549
		$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>
655
					<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>
656
					<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>
657
					<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
					<?php api_plugin_hook('device_edit_top_links'); ?>
646
				</td>
659
				</td>
647
			</tr>
660
			</tr>
648
		</table>
661
		</table>
Lines 1107-1112 Link Here
1107
	}
1120
	}
1108
1121
1109
	form_save_button("host.php", "return");
1122
	form_save_button("host.php", "return");
1123
1124
	api_plugin_hook('host_edit_bottom');
1110
}
1125
}
1111
1126
1112
function host() {
1127
function host() {
(-)cacti-0.8.7g.orig//include/auth.php (-4 / +7 lines)
Lines 31-36 Link Here
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: auth_changepassword.php?ref=" . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php"));
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.8'
661
	);
662
663
api_plugin_hook('config_arrays');
664
657
?>
665
?>
(-)cacti-0.8.7g.orig//include/global_constants.php (-1 / +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
?>
176
define('OPER_MODE_NATIVE', 0);
177
define('OPER_MODE_RESKIN', 1);
178
define('OPER_MODE_IFRAME_NONAV', 2);
179
180
?>
(-)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 (+38 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;
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
29
$oldplugins = read_config_option('oldplugins');
30
$oldplugins = explode(',', $oldplugins);
31
$plugins = array_merge($plugins, $oldplugins);
32
33
/* On startup, register all plugins configured for use. */
34
if (isset($plugins) && is_array($plugins)) {
35
	foreach ($plugins as $name) {
36
		use_plugin($name);
37
	}
38
}
(-)cacti-0.8.7g.orig//include/top_graph_header.php (-19 / +38 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
if ($oper_mode == OPER_MODE_RESKIN) {
30
	return;
31
}
32
28
/* ================= input validation ================= */
33
/* ================= input validation ================= */
29
input_validate_input_number(get_request_var_request("local_graph_id"));
34
input_validate_input_number(get_request_var_request("local_graph_id"));
30
input_validate_input_number(get_request_var_request("graph_start"));
35
input_validate_input_number(get_request_var_request("graph_start"));
Lines 52-92 Link Here
52
	$_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all";
57
	$_SESSION["sess_nav_level_cache"][2]["url"] = "graph.php?local_graph_id=" . $_REQUEST["local_graph_id"] . "&rra_id=all";
53
}
58
}
54
59
60
$page_title = api_plugin_hook_function('page_title', draw_navigation_text("title"));
61
55
?>
62
?>
56
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
63
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
57
<html>
64
<html>
58
<head>
65
<head>
59
	<title><?php echo draw_navigation_text("title");?></title>
66
	<title><?php echo $page_title; ?></title>
60
	<?php
67
	<?php
61
	if (isset($_SESSION["custom"]) && $_SESSION["custom"] == true) {
68
	if (isset($_SESSION["custom"]) && $_SESSION["custom"] == true) {
62
		print "<meta http-equiv=refresh content='99999'>\r\n";
69
		print "<meta http-equiv=refresh content='99999'>\r\n";
63
	}else{
70
	}else{
64
		print "<meta http-equiv=refresh content='" . htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES) . "'>\r\n";
71
		$refresh = api_plugin_hook_function('top_graph_refresh', htmlspecialchars(read_graph_config_option("page_refresh"),ENT_QUOTES));
72
		print "<meta http-equiv=refresh content='" . $refresh . "'>\r\n";
65
	}
73
	}
66
	?>
74
	?>
67
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
75
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
68
	<link href="include/main.css" type="text/css" rel="stylesheet">
76
	<link href="<?php echo $config['url_path']; ?>include/main.css" type="text/css" rel="stylesheet">
69
	<link href="images/favicon.ico" rel="shortcut icon"/>
77
	<link href="<?php echo $config['url_path']; ?>images/favicon.ico" rel="shortcut icon"/>
70
	<script type="text/javascript" src="include/layout.js"></script>
78
	<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>
79
	<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>
80
	<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>
81
	<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>
82
	<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>
83
	<script type="text/javascript" src="<?php echo $config['url_path']; ?>include/jscalendar/calendar-setup.js"></script>
84
	<?php api_plugin_hook('page_head'); ?>
76
</head>
85
</head>
77
86
78
<body>
87
<?php if ($oper_mode == OPER_MODE_NATIVE) {?>
88
<body <?php print api_plugin_hook_function("body_style", "");?>>
79
<a name='page_top'></a>
89
<a name='page_top'></a>
90
<?php }else{?>
91
<body <?php print api_plugin_hook_function("body_style", "");?>>
92
<?php }?>
93
80
<table style="width:100%;height:100%;" cellspacing="0" cellpadding="0">
94
<table style="width:100%;height:100%;" cellspacing="0" cellpadding="0">
95
<?php if ($oper_mode == OPER_MODE_NATIVE) { ;?>
81
	<tr style="height:25px;" bgcolor="#a9a9a9" class="noprint">
96
	<tr style="height:25px;" bgcolor="#a9a9a9" class="noprint">
82
		<td colspan="2" valign="bottom" nowrap>
97
		<td colspan="2" valign="bottom" nowrap>
83
			<table width="100%" cellspacing="0" cellpadding="0">
98
			<table width="100%" cellspacing="0" cellpadding="0">
84
				<tr style="background: transparent url('images/cacti_backdrop2.gif') no-repeat center right;">
99
				<tr style="background: transparent url('<?php echo $config['url_path']; ?>images/cacti_backdrop2.gif') no-repeat center right;">
85
					<td id="tabs" nowrap>
100
					<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;
101
						&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
102
						api_plugin_hook('top_graph_header_tabs');
103
						?>
87
					</td>
104
					</td>
88
					<td id="gtabs" align="right" nowrap>
105
					<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>
106
						<?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>
107
					</td>
91
				</tr>
108
				</tr>
92
			</table>
109
			</table>
Lines 94-100 Link Here
94
	</tr>
111
	</tr>
95
	<tr style="height:2px;" bgcolor="#183c8f" class="noprint">
112
	<tr style="height:2px;" bgcolor="#183c8f" class="noprint">
96
		<td colspan="2">
113
		<td colspan="2">
97
			<img src="images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br>
114
			<img src="<?php echo $config['url_path']; ?>images/transparent_line.gif" style="height:2px;width:170px;" border="0"><br>
98
		</td>
115
		</td>
99
	</tr>
116
	</tr>
100
	<tr style="height:5px;" bgcolor="#e9e9e9" class="noprint">
117
	<tr style="height:5px;" bgcolor="#e9e9e9" class="noprint">
Lines 106-112 Link Here
106
					</td>
123
					</td>
107
					<td align="right">
124
					<td align="right">
108
						<?php if ((isset($_SESSION["sess_user_id"])) && ($using_guest_account == false)) { ?>
125
						<?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;
126
						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 } ?>
127
						<?php } ?>
111
					</td>
128
					</td>
112
				</tr>
129
				</tr>
Lines 114-123 Link Here
114
		</td>
131
		</td>
115
	</tr>
132
	</tr>
116
	<tr class="noprint">
133
	<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;">
134
		<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>
135
			<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>
136
		</td>
120
		<td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(images/shadow.gif); background-repeat: repeat-x;">
137
		<td bgcolor="#ffffff" colspan="1" style="height:8px;background-image: url(<?php echo $config['url_path']; ?>images/shadow.gif); background-repeat: repeat-x;">
121
138
122
		</td>
139
		</td>
123
	</tr>
140
	</tr>
Lines 143-148 Link Here
143
		</td>
160
		</td>
144
	</tr>
161
	</tr>
145
	<?php }
162
	<?php }
163
	}
164
	global $graph_views;
146
	load_current_session_value("action", "sess_cacti_graph_action", $graph_views[read_graph_config_option("default_tree_view_mode")]);
165
	load_current_session_value("action", "sess_cacti_graph_action", $graph_views[read_graph_config_option("default_tree_view_mode")]);
147
	?>
166
	?>
148
	<tr>
167
	<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) {
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_device.php (+2 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()) {
(-)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/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 / +5 lines)
Lines 722-732 Link Here
722
     on a confirmation form
722
     on a confirmation form
723
   @arg $cancel_url - the url to go to when the user clicks 'cancel'
723
   @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' */
724
   @arg $action_url - the url to go to when the user clicks 'delete' */
725
function form_confirm_buttons($action_url, $cancel_url) { ?>
725
function form_confirm_buttons($action_url, $cancel_url) {
726
	global $config;
727
	?>
726
	<tr>
728
	<tr>
727
		<td bgcolor="#E1E1E1">
729
		<td bgcolor="#E1E1E1">
728
			<input type='button' onClick='cactiReturnTo("<?php print $cancel_url;?>")' value='Cancel'>
730
			<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'>
731
			<input type='submit' onClick='cactiReturnTo("<?php print $config['url_path'] . $action_url;?>&confirm=true")' value='Delete'>
730
		</td>
732
		</td>
731
	</tr>
733
	</tr>
732
<?php }
734
<?php }
(-)cacti-0.8.7g.orig//lib/plugins.php (+476 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
		foreach ($data['keys'] as $key) {
175
			if (isset($key['name'])) {
176
				$sql .= ",\n KEY `" . $key['name'] . '` (`' . $key['columns'] . '`)';
177
			}
178
		}
179
		$sql .= ') TYPE = ' . $data['type'];
180
181
		if (isset($data['comment'])) {
182
			$sql .= " COMMENT = '" . $data['comment'] . "'";
183
		}
184
		if (db_execute($sql)) {
185
			db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
186
		}
187
	} else {
188
		db_execute("INSERT INTO plugin_db_changes (plugin, `table`, method) VALUES ('$plugin', '$table', 'create')");
189
	}
190
}
191
192
function api_plugin_db_changes_remove ($plugin) {
193
	// Example: api_plugin_db_changes_remove ('thold');
194
195
	$tables = db_fetch_assoc("SELECT `table` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='create'", false);
196
	if (count($tables)) {
197
		foreach ($tables as $table) {
198
			db_execute("DROP TABLE IF EXISTS `" . $table['table'] . "`;");
199
		}
200
		db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method ='create'", false);
201
	}
202
	$columns = db_fetch_assoc("SELECT `table`, `column` FROM plugin_db_changes WHERE plugin = '$plugin' AND method ='addcolumn'", false);
203
	if (count($columns)) {
204
		foreach ($columns as $column) {
205
			db_execute('ALTER TABLE `' . $column['table'] . '` DROP `' . $column['column'] . '`');
206
		}
207
		db_execute("DELETE FROM plugin_db_changes where plugin = '$plugin' AND method = 'addcolumn'", false);
208
	}
209
}
210
211
function api_plugin_db_add_column ($plugin, $table, $column) {
212
	// Example: api_plugin_db_add_column ('thold', 'plugin_config', array('name' => 'test' . rand(1, 200), 'type' => 'varchar (255)', 'NULL' => false));
213
214
	global $config, $database_default;
215
	include_once($config['library_path'] . '/database.php');
216
217
	$result = db_fetch_assoc('show columns from `' . $table . '`') or die (mysql_error());
218
	$columns = array();
219
	foreach($result as $index => $arr) {
220
		foreach ($arr as $t) {
221
			$columns[] = $t;
222
		}
223
	}
224
	if (isset($column['name']) && !in_array($column['name'], $columns)) {
225
		$sql = 'ALTER TABLE `' . $table . '` ADD `' . $column['name'] . '`';
226
		if (isset($column['type']))
227
			$sql .= ' ' . $column['type'];
228
		if (isset($column['unsigned']))
229
			$sql .= ' unsigned';
230
		if (isset($column['NULL']) && $column['NULL'] == false)
231
			$sql .= ' NOT NULL';
232
		if (isset($column['NULL']) && $column['NULL'] == true && !isset($column['default']))
233
			$sql .= ' default NULL';
234
		if (isset($column['default']))
235
			$sql .= ' default ' . (is_numeric($column['default']) ? $column['default'] : "'" . $column['default'] . "'");
236
		if (isset($column['auto_increment']))
237
			$sql .= ' auto_increment';
238
		if (isset($column['after']))
239
			$sql .= ' AFTER ' . $column['after'];
240
241
		if (db_execute($sql)) {
242
			db_execute("INSERT INTO plugin_db_changes (plugin, `table`, `column`, `method`) VALUES ('$plugin', '$table', '" . $column['name'] . "', 'addcolumn')");
243
		}
244
	}
245
}
246
247
function api_plugin_install ($plugin) {
248
	global $config;
249
	include_once($config['base_path'] . "/plugins/$plugin/setup.php");
250
251
	$exists = db_fetch_assoc("SELECT id FROM plugin_config WHERE directory = '$plugin'", false);
252
	if (sizeof($exists)) {
253
		db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
254
	}
255
256
	$name = $author = $webpage = $version = '';
257
	$function = 'plugin_' . $plugin . '_version';
258
	if (function_exists($function)){
259
		$info = $function();
260
		$name = $info['longname'];
261
		if (isset($info['homepage'])) {
262
			$webpage = $info['homepage'];
263
		}elseif (isset($info['webpage'])) {
264
			$webpage = $info['webpage'];
265
		}else{
266
			$webpage = "Not Stated";
267
		}
268
		$author = $info['author'];
269
		$version = $info['version'];
270
	}
271
272
	db_execute("INSERT INTO plugin_config (directory, name, author, webpage, version) VALUES ('$plugin', '$name', '$author', '$webpage', '$version')");
273
274
	$function = 'plugin_' . $plugin . '_install';
275
	if (function_exists($function)){
276
		$function();
277
		$ready = api_plugin_check_config ($plugin);
278
		if ($ready) {
279
			// Set the plugin as "disabled" so it can go live
280
			db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
281
		} else {
282
			// Set the plugin as "needs configuration"
283
			db_execute("UPDATE plugin_config SET status = 2 WHERE directory = '$plugin'");
284
		}
285
	}
286
}
287
288
function api_plugin_uninstall ($plugin) {
289
	global $config;
290
	include_once($config['base_path'] . "/plugins/$plugin/setup.php");
291
	// Run the Plugin's Uninstall Function first
292
	$function = 'plugin_' . $plugin . '_uninstall';
293
	if (function_exists($function)) {
294
		$function();
295
	}
296
	api_plugin_remove_hooks ($plugin);
297
	api_plugin_remove_realms ($plugin);
298
	db_execute("DELETE FROM plugin_config WHERE directory = '$plugin'");
299
	api_plugin_db_changes_remove ($plugin);
300
}
301
302
function api_plugin_check_config ($plugin) {
303
	global $config;
304
	include_once($config['base_path'] . "/plugins/$plugin/setup.php");
305
	$function = 'plugin_' . $plugin . '_check_config';
306
	if (function_exists($function)) {
307
		return $function();
308
	}
309
	return TRUE;
310
}
311
312
function api_plugin_enable ($plugin) {
313
	$ready = api_plugin_check_config ($plugin);
314
	if ($ready) {
315
		api_plugin_enable_hooks ($plugin);
316
		db_execute("UPDATE plugin_config SET status = 1 WHERE directory = '$plugin'");
317
	}
318
}
319
320
function api_plugin_is_enabled ($plugin) {
321
	$status = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = '$plugin'", false);
322
	if ($status == '1')
323
		return true;
324
	return false;
325
}
326
327
function api_plugin_disable ($plugin) {
328
	api_plugin_disable_hooks ($plugin);
329
	db_execute("UPDATE plugin_config SET status = 4 WHERE directory = '$plugin'");
330
}
331
332
function api_plugin_moveup($plugin) {
333
	global $plugins_system;
334
335
	$sql_where = "";
336
	if (sizeof($plugins_system)) {
337
		foreach($plugins_system as $s) {
338
			$sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
339
		}
340
341
		$sql_where .= ")";
342
	}
343
344
	$id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:""));
345
	$temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1;
346
	$prior_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config WHERE id<$id" . (strlen($sql_where) ? " AND " . $sql_where:""));
347
348
	/* update the above plugin to the prior temp id */
349
	db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$prior_id");
350
	db_execute("UPDATE plugin_config SET id=$prior_id WHERE id=$id");
351
	db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id");
352
}
353
354
function api_plugin_movedown($plugin) {
355
	global $plugins_system;
356
357
	$sql_where = "";
358
	if (sizeof($plugins_system)) {
359
		foreach($plugins_system as $s) {
360
			$sql_where .= (strlen($sql_where) ? " AND ":"(") . " directory!='$s'";
361
		}
362
363
		$sql_where .= ")";
364
	}
365
366
	$id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='$plugin'" . (strlen($sql_where) ? " AND " . $sql_where:""));
367
	$temp_id = db_fetch_cell("SELECT MAX(id) FROM plugin_config")+1;
368
	$next_id = db_fetch_cell("SELECT MIN(id) FROM plugin_config WHERE id>$id" . (strlen($sql_where) ? " AND " . $sql_where:""));
369
370
	/* update the above plugin to the prior temp id */
371
	db_execute("UPDATE plugin_config SET id=$temp_id WHERE id=$next_id");
372
	db_execute("UPDATE plugin_config SET id=$next_id WHERE id=$id");
373
	db_execute("UPDATE plugin_config SET id=$id WHERE id=$temp_id");
374
}
375
376
function api_plugin_register_hook ($plugin, $hook, $function, $file) {
377
	$exists = db_fetch_assoc("SELECT id FROM plugin_hooks WHERE name = '$plugin' AND hook = '$hook'", false);
378
	if (!count($exists)) {
379
		$settings = array('config_settings', 'config_arrays', 'config_form');
380
		if (!in_array($hook, $settings)) {
381
			db_execute("INSERT INTO plugin_hooks (name, hook, function, file) VALUES ('$plugin', '$hook', '$function', '$file')");
382
		} else {
383
			db_execute("INSERT INTO plugin_hooks (name, hook, function, file, status) VALUES ('$plugin', '$hook', '$function', '$file', 1)");
384
		}
385
	}
386
}
387
388
function api_plugin_remove_hooks ($plugin) {
389
	db_execute("DELETE FROM plugin_hooks WHERE name = '$plugin'");
390
}
391
392
function api_plugin_enable_hooks ($plugin) {
393
	db_execute("UPDATE plugin_hooks SET status = 1 WHERE name = '$plugin'");
394
}
395
396
function api_plugin_disable_hooks ($plugin) {
397
	db_execute("UPDATE plugin_hooks SET status = 0 WHERE name = '$plugin' AND hook != 'config_settings' AND hook != 'config_arrays' AND hook != 'config_form'");
398
}
399
400
function api_plugin_register_realm ($plugin, $file, $display, $admin = false) {
401
	$exists = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
402
	if (!count($exists)) {
403
		db_execute("INSERT INTO plugin_realms (plugin, file, display) VALUES ('$plugin', '$file', '$display')");
404
		if ($admin) {
405
			$realm_id = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin' AND file = '$file'", false);
406
			$realm_id = $realm_id[0]['id'] + 100;
407
			$user_id = db_fetch_assoc("SELECT id FROM user_auth WHERE username = 'admin'", false);
408
			if (count($user_id)) {
409
				$user_id = $user_id[0]['id'];
410
				$exists = db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id = $user_id and realm_id = $realm_id", false);
411
				if (!count($exists)) {
412
					db_execute("INSERT INTO user_auth_realm (user_id, realm_id) VALUES ($user_id, $realm_id)");
413
				}
414
			}
415
		}
416
	}
417
}
418
419
function api_plugin_remove_realms ($plugin) {
420
	$realms = db_fetch_assoc("SELECT id FROM plugin_realms WHERE plugin = '$plugin'", false);
421
	foreach ($realms as $realm) {
422
		$id = $realm['id'] + 100;
423
		db_execute("DELETE FROM user_auth_realm WHERE realm_id = '$id'");
424
	}
425
	db_execute("DELETE FROM plugin_realms WHERE plugin = '$plugin'");
426
}
427
428
function api_plugin_load_realms () {
429
	global $user_auth_realms, $user_auth_realm_filenames;
430
	$plugin_realms = db_fetch_assoc("SELECT * FROM plugin_realms ORDER BY plugin, display", false);
431
	if (count($plugin_realms)) {
432
		foreach ($plugin_realms as $plugin_realm) {
433
			$plugin_files = explode(',', $plugin_realm['file']);
434
			foreach($plugin_files as $plugin_file) {
435
				$user_auth_realm_filenames[$plugin_file] = $plugin_realm['id'] + 100;
436
			}
437
			$user_auth_realms[$plugin_realm['id'] + 100] = $plugin_realm['display'];
438
		}
439
	}
440
}
441
442
function api_plugin_user_realm_auth ($filename = '') {
443
	global $user_realms, $user_auth_realms, $user_auth_realm_filenames;
444
	/* list all realms that this user has access to */
445
	if (!isset($user_realms)) {
446
		if (read_config_option('global_auth') == 'on' || read_config_option('auth_method') != 0) {
447
			$user_realms = db_fetch_assoc("select realm_id from user_auth_realm where user_id=" . $_SESSION["sess_user_id"], false);
448
			$user_realms = array_rekey($user_realms, "realm_id", "realm_id");
449
		}else{
450
			$user_realms = $user_auth_realms;
451
		}
452
	}
453
	if ($filename != '') {
454
		if (isset($user_realms[$user_auth_realm_filenames{basename($filename)}]))
455
			return TRUE;
456
	}
457
	return FALSE;
458
}
459
460
function plugin_config_arrays () {
461
	global $menu;
462
	$menu['Configuration']['plugins.php'] = 'Plugin Management';
463
	api_plugin_load_realms ();
464
}
465
466
function plugin_draw_navigation_text ($nav) {
467
	$nav["plugins.php:"] = array("title" => "Plugin Management", "mapping" => "index.php:", "url" => "plugins.php", "level" => "1");
468
	return $nav;
469
}
470
471
472
473
474
475
476
(-)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/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 (+647 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
128
function api_plugin_install_old ($plugin) {
129
	global $config;
130
	if (!file_exists($config['base_path'] . "/plugins/$plugin/setup.php")) {
131
		return false;
132
	}
133
	$oldplugins = read_config_option('oldplugins');
134
	$oldplugins = explode(',', $oldplugins);
135
	if (!in_array($plugin, $oldplugins)) {
136
		include_once($config['base_path'] . "/plugins/$plugin/setup.php");
137
		$function = 'plugin_init_' . $plugin;
138
		if (function_exists($function)){
139
			$oldplugins[] = $plugin;
140
			$oldplugins = implode(',', $oldplugins);
141
			set_config_option('oldplugins', $oldplugins);
142
			unset($_SESSION['sess_config_array']['oldplugins']);
143
			return true;
144
		} else {
145
			return false;
146
		}
147
	}
148
	return false;
149
}
150
151
function api_plugin_uninstall_old ($plugin) {
152
	global $config;
153
	$oldplugins = read_config_option('oldplugins');
154
	$oldplugins = explode(',', $oldplugins);
155
	if (!empty($oldplugins)) {
156
		if (in_array($plugin, $oldplugins)) {
157
			for ($a = 0; $a < count($oldplugins); $a++) {
158
				if ($oldplugins[$a] == $plugin) {
159
					unset($oldplugins[$a]);
160
					break;
161
				}
162
			}
163
			$oldplugins = implode(',', $oldplugins);
164
			set_config_option('oldplugins', $oldplugins);
165
			unset($_SESSION['sess_config_array']['oldplugins']);
166
			return true;
167
		}
168
	}
169
	return false;
170
}
171
172
function update_show_updates () {
173
	global $pluginslist, $colors, $config, $plugin_architecture;
174
175
	$cinfo = array();
176
	sort($pluginslist);
177
178
	$cinfo = update_get_plugin_info ();
179
180
	$x = 0;
181
182
	$info = update_get_cached_plugin_info();
183
184
	$cactinew = update_check_if_newer($cinfo['cacti']['version'], $info['cacti']['version']) ;
185
	if (isset($cinfo['cacti_plugin_arch']['version'])) {
186
		$archnew =  update_check_if_newer($cinfo['cacti_plugin_arch']['version'], $info['cacti_plugin_arch']['version']);
187
	} else {
188
		$archnew = 0;
189
	}
190
191
	if ($cactinew) {
192
		$x++;
193
		print "<tr><td width='25%' valign=top><table width='100%'>";
194
		html_header(array("Cacti"), 2);
195
		form_alternate_row_color($colors["alternate"],$colors["light"], 0);
196
		print "<td width='25%'><strong>Version:</strong></td><td>" . $config["cacti_version"] . "</td></tr>";
197
		form_alternate_row_color($colors["alternate"],$colors["light"], 0);
198
		print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti']['changes']) . "</td></tr></table>";
199
	}
200
	if (isset($plugin_architecture['version']) && $archnew) {
201
		$x++;
202
		print "<table width='100%'>";
203
		html_header(array("Plugin Architecture"), 2);
204
		form_alternate_row_color($colors["alternate"],$colors["light"], 0);
205
		print "<td width='25%'><strong>Version:</strong></td><td>" . $plugin_architecture['version'] . "</td>";
206
		form_alternate_row_color($colors["alternate"],$colors["light"], 0);
207
		print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info['cacti_plugin_arch']['changes']) . "</td></tr></table>";
208
	}
209
	print "<table width='100%' cellspacing=0 cellpadding=3>";
210
211
	foreach ($pluginslist as $plugin) {
212
		if (isset($cinfo[$plugin]) && update_check_if_newer($cinfo[$plugin]['version'], $info[$plugin]['version'])) {
213
			$x++;
214
			print "<table width='100%'>";
215
			html_header(array((isset($cinfo[$plugin]['longname']) ? $cinfo[$plugin]['longname'] : $plugin)), 2);
216
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
217
			print "<td width='50%'><strong>Directory:</strong></td><td>$plugin</td>";
218
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
219
			print "<td><strong>Version:</strong></td><td>" . $info[$plugin]['version'] . "</td>";
220
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
221
			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>";
222
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
223
			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>";
224
			form_alternate_row_color($colors["alternate"],$colors["light"], 0);
225
			print "<td valign=top><strong>Changes:</strong></td><td>" . str_replace("\n", '<br>', $info[$plugin]['changes']) . "</td>";
226
227
			print "</tr></table>";
228
		}
229
	}
230
	if ($x == 0)
231
		print "<br><center><b>There are currently no Updates!</b></center><br>";
232
	print "</table>";
233
	html_end_box(TRUE);
234
}
235
236
function update_check_if_newer() {
237
	return false;
238
}
239
240
function plugins_temp_table_exists($table) {
241
	return sizeof(db_fetch_row("SHOW TABLES LIKE '$table'"));
242
}
243
244
function plugins_load_temp_table() {
245
	global $config, $plugins;
246
247
	$pluginslist = retrieve_plugin_list();
248
249
	if (isset($_SESSION["plugin_temp_table"])) {
250
		$table = $_SESSION["plugin_temp_table"];
251
	}else{
252
		$table = "plugin_temp_table_" . rand();
253
	}
254
255
	while (true) {
256
		if (!plugins_temp_table_exists($table)) {
257
			$_SESSION["plugin_temp_table"] = $table;
258
			db_execute("CREATE TEMPORARY TABLE $table LIKE plugin_config");
259
			db_execute("INSERT INTO $table SELECT * FROM plugin_config");
260
			break;
261
		}else{
262
			$table = "plugin_temp_table_" . rand();
263
		}
264
	}
265
266
	$path = $config['base_path'] . '/plugins/';
267
	$dh = opendir($path);
268
	while (($file = readdir($dh)) !== false) {
269
		if ((is_dir("$path/$file")) && (file_exists("$path/$file/setup.php")) && (!in_array($file, $pluginslist))) {
270
			if (!function_exists('plugin_' . $file . '_install')) {
271
				include_once("$path/$file/setup.php");
272
				if (!function_exists('plugin_' . $file . '_install') && function_exists($file . '_version')) {
273
					$function = $file . '_version';
274
					$cinfo[$file] = $function();
275
					if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown';
276
					if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
277
					if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
278
					if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['longname'] = ucfirst($file);
279
					$cinfo[$file]['status'] = -2;
280
					if (in_array($file, $plugins)) {
281
						$cinfo[$file]['status'] = -1;
282
					}
283
					db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
284
						VALUES ('" .
285
							$file . "', '" .
286
							$cinfo[$file]['longname'] . "', '" .
287
							$cinfo[$file]['status'] . "', '" .
288
							$cinfo[$file]['author'] . "', '" .
289
							$cinfo[$file]['homepage'] . "', '" .
290
							$cinfo[$file]['version'] . "')");
291
					$pluginslist[] = $file;
292
				} else if (function_exists('plugin_' . $file . '_install') && function_exists('plugin_' . $file . '_version')) {
293
					$function = $file . '_version';
294
					$cinfo[$file] = $function();
295
					$cinfo[$file]['status'] = 0;
296
					if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = 'Unknown';
297
					if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = 'Not Stated';
298
					if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage'];
299
					if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['homepage'] = ucfirst($file);
300
					db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version)
301
						VALUES ('" .
302
							$file . "', '" .
303
							$cinfo[$file]['longname'] . "', '" .
304
							$cinfo[$file]['status'] . "', '" .
305
							$cinfo[$file]['author'] . "', '" .
306
							$cinfo[$file]['homepage'] . "', '" .
307
							$cinfo[$file]['version'] . "')");
308
					$pluginslist[] = $file;
309
				}
310
			}else{
311
				cacti_log("WARNING: Install function already exists for plugin directory '$file'", false);
312
			}
313
		}
314
	}
315
	closedir($dh);
316
317
	return $table;
318
}
319
320
function update_show_current () {
321
	global $plugins, $pluginslist, $colors, $plugin_architecture, $config, $status_names, $actions;
322
323
	/* ================= input validation ================= */
324
	input_validate_input_number(get_request_var_request("page"));
325
	/* ==================================================== */
326
327
	/* clean up search string */
328
	if (isset($_REQUEST["filter"])) {
329
		$_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
330
	}
331
332
	/* clean up sort_column */
333
	if (isset($_REQUEST["sort_column"])) {
334
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
335
	}
336
337
	/* clean up search string */
338
	if (isset($_REQUEST["sort_direction"])) {
339
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
340
	}
341
342
	/* if the user pushed the 'clear' button */
343
	if (isset($_REQUEST["clear_x"])) {
344
		kill_session_var("sess_plugins_filter");
345
		kill_session_var("sess_plugins_sort_column");
346
		kill_session_var("sess_plugins_sort_direction");
347
348
		unset($_REQUEST["page"]);
349
		unset($_REQUEST["filter"]);
350
		unset($_REQUEST["sort_column"]);
351
		unset($_REQUEST["sort_direction"]);
352
		$_REQUEST["page"] = 1;
353
	}
354
355
	/* remember these search fields in session vars so we don't have to keep passing them around */
356
	load_current_session_value("filter", "sess_plugins_filter", "");
357
	load_current_session_value("sort_column", "sess_plugins_sort_column", "name");
358
	load_current_session_value("sort_direction", "sess_plugins_sort_direction", "ASC");
359
	load_current_session_value("page", "sess_plugins_current_page", "1");
360
361
	$table = plugins_load_temp_table();
362
363
	html_start_box("<strong>Plugin Management</strong> (Cacti Version: " . $config["cacti_version"] .
364
		(isset($plugin_architecture['version']) ? ", Plugin Architecture Version: " . $plugin_architecture['version']:"") .
365
		")", "100%", $colors["header"], "3", "center", "");
366
367
	?>
368
	<tr bgcolor="#<?php print $colors['panel'];?>">
369
		<td class="noprint">
370
		<form name="form_plugins" method="get" action="plugins.php">
371
			<table width="100%" cellpadding="0" cellspacing="0">
372
				<tr class="noprint">
373
					<td nowrap style='white-space: nowrap;' width="50">
374
						Search:&nbsp;
375
					</td>
376
					<td width="1">
377
						<input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>">
378
					</td>
379
					<td nowrap style='white-space: nowrap;'>
380
						&nbsp;<input type="submit" value="Go" title="Set/Refresh Filters">
381
						<input type="submit" name="clear_x" value="Clear" title="Clear Filters">
382
					</td>
383
				</tr>
384
			</table>
385
			<input type='hidden' name='page' value='1'>
386
		</form>
387
		</td>
388
	</tr>
389
	<?php
390
391
	html_end_box();
392
393
	/* print checkbox form for validation */
394
	print "<form name='chk' method='post' action='plugins.php'>\n";
395
396
	html_start_box("", "100%", $colors["header"], "3", "center", "");
397
398
	/* form the 'where' clause for our main sql query */
399
	$sql_where = "WHERE ($table.name LIKE '%%" . get_request_var_request("filter") . "%%')";
400
401
	if (get_request_var_request("sort_column") == "version") {
402
		$sortc = "version+0";
403
	}else{
404
		$sortc = get_request_var_request("sort_column");
405
	}
406
407
	if (get_request_var_request("sort_column") == "id") {
408
		$sortd = "ASC";
409
	}else{
410
		$sortd = get_request_var_request("sort_direction");
411
	}
412
413
	$total_rows = db_fetch_cell("SELECT
414
		count(*)
415
		FROM $table
416
		$sql_where");
417
418
	$plugins = db_fetch_assoc("SELECT *
419
		FROM $table
420
		$sql_where
421
		ORDER BY " . $sortc . " " . $sortd . "
422
		LIMIT " . (read_config_option("num_rows_device")*(get_request_var_request("page")-1)) . "," . read_config_option("num_rows_device"));
423
424
	db_execute("DROP TABLE $table");
425
426
	/* generate page list */
427
	$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"));
428
429
	if ($total_rows == 0) {
430
		$nav = "<tr bgcolor='#" . $colors["header"] . "'>
431
				<td colspan='9'>
432
					<table width='100%' cellspacing='0' cellpadding='0' border='0'>
433
						<tr>
434
							<td align='center' class='textHeaderDark'>
435
								No Plugins Found
436
							</td>\n
437
						</tr>
438
					</table>
439
				</td>
440
			</tr>\n";
441
	}elseif ($total_rows < read_config_option("num_rows_device")) {
442
		$nav = "<tr bgcolor='#" . $colors["header"] . "'>
443
				<td colspan='9'>
444
					<table width='100%' cellspacing='0' cellpadding='0' border='0'>
445
						<tr>
446
							<td align='center' class='textHeaderDark'>
447
								Showing All $total_rows Rows
448
							</td>\n
449
						</tr>
450
					</table>
451
				</td>
452
			</tr>\n";
453
	}else{
454
		$nav = "<tr bgcolor='#" . $colors["header"] . "'>
455
				<td colspan='9'>
456
					<table width='100%' cellspacing='0' cellpadding='0' border='0'>
457
						<tr>
458
							<td align='left' class='textHeaderDark'>
459
								<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>
460
							</td>\n
461
							<td align='center' class='textHeaderDark'>
462
								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]
463
							</td>\n
464
							<td align='right' class='textHeaderDark'>
465
								<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>
466
							</td>\n
467
						</tr>
468
					</table>
469
				</td>
470
			</tr>\n";
471
	}
472
473
	print $nav;
474
475
	$display_text = array(
476
		"nosort" => array("Actions", ""),
477
		"directory" => array("Name", "ASC"),
478
		"id" => array("Load Order", "ASC"),
479
		"name" => array("Description", "ASC"),
480
		"nosort1" => array("Type", "ASC"),
481
		"status" => array("Status", "ASC"),
482
		"author" => array("Author", "ASC"),
483
		"webpage" => array("Web Page", "ASC"),
484
		"version" => array("Version", "ASC"));
485
486
	html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), 1);
487
488
	$i = 0;
489
	if (sizeof($plugins)) {
490
		if (get_request_var_request("sort_column") == "id") {
491
			$inst_system_plugins = get_system_plugins($plugins);
492
			if (sizeof($inst_system_plugins)) {
493
				foreach($inst_system_plugins as $plugin) {
494
					form_alternate_row_color($colors["alternate"], $colors["light"], $i); $i++;
495
					print format_plugin_row($plugin, false, false, true);
496
				}
497
			}
498
		}
499
500
		$j = 0;
501
		foreach ($plugins as $plugin) {
502
			if ((isset($plugins[$j+1]) && $plugins[$j+1]['status'] < 0) || (!isset($plugins[$j+1]))) {
503
				$last_plugin = true;
504
			}else{
505
				$last_plugin = false;
506
			}
507
			if ($plugin['status'] <= 0 || is_system_plugin($plugin) || (get_request_var_request('sort_column') != 'id')) {
508
				$load_ordering = false;
509
			}else{
510
				$load_ordering = true;
511
			}
512
513
			if (get_request_var_request("sort_column") == "id") {
514
				if (!is_system_plugin($plugin)) {
515
					form_alternate_row_color($colors["alternate"], $colors["light"], $i);
516
					print format_plugin_row($plugin, $last_plugin, $load_ordering, false);
517
					$i++;
518
				}
519
			}else{
520
				form_alternate_row_color($colors["alternate"], $colors["light"], $i);
521
				print format_plugin_row($plugin, $last_plugin, $load_ordering, is_system_plugin($plugin));
522
				$i++;
523
			}
524
525
			$j++;
526
		}
527
528
		print $nav;
529
	}else{
530
		print "<tr><td><em>No Plugins Found</em></td></tr>";
531
	}
532
533
	html_end_box(false);
534
535
	html_start_box("", "100%", $colors["header"], "3", "center", "");
536
	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>";
537
	html_end_box();
538
539
	print "</form>\n";
540
}
541
542
function format_plugin_row($plugin, $last_plugin, $include_ordering, $system_plugin) {
543
	global $status_names;
544
	static $first_plugin = true;
545
546
	$row = plugin_actions($plugin);
547
	$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>";
548
	if ($include_ordering) {
549
		$row .= "<td style='white-space:nowrap;'>";
550
		if (!$first_plugin) {
551
			$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>";
552
		}else{
553
			$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>";
554
		}
555
		if (!$last_plugin) {
556
			$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>";
557
		}else{
558
			$row .= "<a href='#' title='Can Increase Load Order' class='linkEditMain'><img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'></a>";
559
		}
560
		$row .= "</td>\n";
561
	}else{
562
		$row .= "<td></td>\n";
563
	}
564
565
	$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";
566
	$row .= "<td style='white-space:nowrap;'>" . ($system_plugin ? "System": ($plugin['status'] < 0 ? "Old PIA":"General")) . "</td>\n";
567
	$row .= "<td style='white-space:nowrap;'>" . $status_names[$plugin["status"]] . "</td>\n";
568
	$row .= "<td style='white-space:nowrap;'>" . $plugin["author"] . "</td>\n";
569
	$row .= "<td><a href='" . htmlspecialchars($plugin["webpage"]) . "'>" . htmlspecialchars($plugin["webpage"]) . "</a></td>\n";
570
	$row .= "<td>" . $plugin["version"] . "</td>\n";
571
	$row .= "</tr>\n";
572
573
	if ($include_ordering) {
574
		$first_plugin = false;
575
	}
576
577
	return $row;
578
}
579
580
function plugin_actions($plugin) {
581
	$link = "<td>";
582
	switch ($plugin['status']) {
583
		case "-2": // Old PA Not Installed
584
			$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>";
585
			$link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
586
			break;
587
		case "-1":	// Old PA Currently Active
588
			$oldplugins = read_config_option('oldplugins');
589
			$oldplugins = explode(',', $oldplugins);
590
			if (in_array($plugin['directory'], $oldplugins)) {
591
				$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>";
592
			} else {
593
				$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>";
594
			}
595
			$link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
596
			break;
597
		case "0": // Not Installed
598
			$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>";
599
			$link .= "<img style='padding:1px;' border='0' align='absmiddle' src='images/view_none.gif'>";
600
			break;
601
		case "1":	// Currently Active
602
			$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>";
603
			$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>";
604
			break;
605
		case "4":	// Installed but not active
606
			$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>";
607
			$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>";
608
			break;
609
		default: // Old PIA
610
			$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>";
611
			$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>";
612
			break;
613
	}
614
	$link .= "</td>";
615
616
	return $link;
617
}
618
619
function is_system_plugin($plugin) {
620
	global $plugins_system;
621
622
	if (is_array($plugin)) {
623
		$plugin = $plugin["directory"];
624
	}
625
626
	if (!in_array($plugin, $plugins_system)) {
627
		return false;
628
	}else{
629
		return true;
630
	}
631
}
632
633
function get_system_plugins($plugins) {
634
	$inst_system_plugins = array();
635
636
	if (sizeof($plugins)) {
637
		foreach($plugins as $plugin) {
638
			if (is_system_plugin($plugin)) {
639
				$inst_system_plugins[] = $plugin;
640
			}
641
		}
642
	}
643
644
	return $inst_system_plugins;
645
}
646
647
(-)cacti-0.8.7g.orig//poller.php (+8 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 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//poller.php.orig (+496 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
/* tick use required as of PHP 4.3.0 to accomodate signal handling */
26
declare(ticks = 1);
27
28
function sig_handler($signo) {
29
	switch ($signo) {
30
		case SIGTERM:
31
		case SIGINT:
32
			cacti_log("WARNING: Cacti Master Poller process terminated by user", TRUE);
33
34
			$running_processes = db_fetch_assoc("SELECT * FROM poller_time WHERE end_time='0000-00-00 00:00:00'");
35
36
			if (sizeof($running_processes)) {
37
			foreach($running_processes as $process) {
38
				if (function_exists("posix_kill")) {
39
					cacti_log("WARNING: Termination poller process with pid '" . $process["pid"] . "'", TRUE, "POLLER");
40
					posix_kill($process["pid"], SIG_TERM);
41
				}
42
			}
43
			}
44
45
			db_execute("TRUNCATE TABLE poller_time");
46
47
			exit;
48
			break;
49
		default:
50
			/* ignore all other signals */
51
	}
52
}
53
54
/* do NOT run this script through a web browser */
55
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD'])  || isset($_SERVER['REMOTE_ADDR'])) {
56
	die("<br><strong>This script is only meant to run at the command line.</strong>");
57
}
58
59
/* we are not talking to the browser */
60
$no_http_headers = true;
61
62
/* start initialization section */
63
include(dirname(__FILE__) . "/include/global.php");
64
include_once($config["base_path"] . "/lib/poller.php");
65
include_once($config["base_path"] . "/lib/data_query.php");
66
include_once($config["base_path"] . "/lib/graph_export.php");
67
include_once($config["base_path"] . "/lib/rrd.php");
68
69
/* initialize some variables */
70
$force = FALSE;
71
$debug = FALSE;
72
73
/* process calling arguments */
74
$parms = $_SERVER["argv"];
75
array_shift($parms);
76
77
if (sizeof($parms)) {
78
foreach($parms as $parameter) {
79
	@list($arg, $value) = @explode("=", $parameter);
80
81
	switch ($arg) {
82
	case "-d":
83
	case "--debug":
84
		$debug = TRUE;
85
86
		break;
87
	case "--force":
88
		$force = TRUE;
89
90
		break;
91
	case "--version":
92
	case "-V":
93
	case "-H":
94
	case "--help":
95
		display_help();
96
		exit(0);
97
	default:
98
		echo "ERROR: Invalid Argument: ($arg)\n\n";
99
		display_help();
100
		exit(1);
101
	}
102
}
103
}
104
105
/* install signal handlers for UNIX only */
106
if (function_exists("pcntl_signal")) {
107
	pcntl_signal(SIGTERM, "sig_handler");
108
	pcntl_signal(SIGINT, "sig_handler");
109
}
110
111
/* record the start time */
112
list($micro,$seconds) = explode(" ", microtime());
113
$poller_start         = $seconds + $micro;
114
$overhead_time = 0;
115
116
/* get number of polling items from the database */
117
$poller_interval = read_config_option("poller_interval");
118
119
/* retreive the last time the poller ran */
120
$poller_lastrun = read_config_option('poller_lastrun');
121
122
/* get the current cron interval from the database */
123
$cron_interval = read_config_option("cron_interval");
124
125
if ($cron_interval != 60) {
126
	$cron_interval = 300;
127
}
128
129
/* see if the user wishes to use process leveling */
130
$process_leveling = read_config_option("process_leveling");
131
132
/* retreive the number of concurrent process settings */
133
$concurrent_processes = read_config_option("concurrent_processes");
134
135
/* assume a scheduled task of either 60 or 300 seconds */
136
if (isset($poller_interval)) {
137
	$num_polling_items = db_fetch_cell("SELECT COUNT(*) FROM poller_item WHERE rrd_next_step<=0");
138
	$items_perhost     = array_rekey(db_fetch_assoc("SELECT host_id, COUNT(*) AS data_sources
139
							FROM poller_item
140
							WHERE rrd_next_step<=0
141
							GROUP BY host_id
142
							ORDER BY host_id"), "host_id", "data_sources");
143
	$poller_runs       = intval($cron_interval / $poller_interval);
144
145
	define("MAX_POLLER_RUNTIME", $poller_runs * $poller_interval - 2);
146
}else{
147
	$num_polling_items = db_fetch_cell("SELECT COUNT(*) FROM poller_item");
148
	$items_perhost     = array_rekey(db_fetch_assoc("SELECT host_id, COUNT(*) AS data_sources
149
							FROM poller_item
150
							GROUP BY host_id
151
							ORDER BY host_id"), "host_id", "data_sources");
152
	$poller_runs       = 1;
153
154
	define("MAX_POLLER_RUNTIME", 298);
155
}
156
157
if (sizeof($items_perhost)) {
158
	$items_per_process   = floor($num_polling_items / $concurrent_processes);
159
160
	if ($items_per_process == 0) {
161
		$process_leveling = "off";
162
	}
163
}else{
164
	$process_leveling    = "off";
165
}
166
167
/* some text formatting for platform specific vocabulary */
168
if ($config["cacti_server_os"] == "unix") {
169
	$task_type = "Cron";
170
}else{
171
	$task_type = "Scheduled Task";
172
}
173
174
if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
175
	$poller_seconds_sincerun = "never";
176
	if (isset($poller_lastrun)) {
177
		$poller_seconds_sincerun = $seconds - $poller_lastrun;
178
	}
179
180
	cacti_log("NOTE: Poller Int: '$poller_interval', $task_type Int: '$cron_interval', Time Since Last: '$poller_seconds_sincerun', Max Runtime '" . MAX_POLLER_RUNTIME. "', Poller Runs: '$poller_runs'", TRUE, "POLLER");;
181
}
182
183
/* our cron can run at either 1 or 5 minute intervals */
184
if ($poller_interval <= 60) {
185
	$min_period = "60";
186
}else{
187
	$min_period = "300";
188
}
189
190
/* get to see if we are polling faster than reported by the settings, if so, exit */
191
if ((isset($poller_lastrun) && isset($poller_interval) && $poller_lastrun > 0) && (!$force)) {
192
	/* give the user some flexibility to run a little moe often */
193
	if ((($seconds - $poller_lastrun)*1.3) < MAX_POLLER_RUNTIME) {
194
		if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
195
			cacti_log("NOTE: $task_type is configured to run too often!  The Poller Interval is '$poller_interval' seconds, with a minimum $task_type period of '$min_period' seconds, but only " . ($seconds - $poller_lastrun) . ' seconds have passed since the poller last ran.', true, 'POLLER');
196
		}
197
		exit;
198
	}
199
}
200
201
/* check to see whether we have the poller interval set lower than the poller is actually ran, if so, issue a warning */
202
if ((($seconds - $poller_lastrun - 5) > MAX_POLLER_RUNTIME) && ($poller_lastrun > 0)) {
203
	cacti_log("WARNING: $task_type is out of sync with the Poller Interval!  The Poller Interval is '$poller_interval' seconds, with a maximum of a '300' second $task_type, but " . ($seconds - $poller_lastrun) . ' seconds have passed since the last poll!', true, 'POLLER');
204
}
205
206
db_execute("REPLACE INTO settings (name,value) VALUES ('poller_lastrun'," . $seconds . ')');
207
208
/* let PHP only run 1 second longer than the max runtime, plus the poller needs lot's of memory */
209
ini_set("max_execution_time", MAX_POLLER_RUNTIME + 1);
210
ini_set("memory_limit", "512M");
211
212
$poller_runs_completed = 0;
213
$poller_items_total    = 0;
214
$polling_hosts         = array_merge(array(0 => array("id" => "0")), db_fetch_assoc("SELECT id FROM host WHERE disabled='' ORDER BY id"));
215
216
while ($poller_runs_completed < $poller_runs) {
217
	/* record the start time for this loop */
218
	list($micro,$seconds) = explode(" ", microtime());
219
	$loop_start = $seconds + $micro;
220
221
	/* calculate overhead time */
222
	if ($overhead_time == 0) {
223
		$overhead_time = $loop_start - $poller_start;
224
	}
225
226
	/* initialize counters for script file handling */
227
	$host_count = 1;
228
229
	/* initialize file creation flags */
230
	$change_proc = false;
231
232
	/* initialize file and host count pointers */
233
	$started_processes = 0;
234
	$first_host        = 0;
235
	$last_host         = 0;
236
237
	/* update web paths for the poller */
238
	db_execute("REPLACE INTO settings (name,value) VALUES ('path_webroot','" . addslashes(($config["cacti_server_os"] == "win32") ? strtr(strtolower(substr(dirname(__FILE__), 0, 1)) . substr(dirname(__FILE__), 1),"\\", "/") : dirname(__FILE__)) . "')");
239
240
	/* obtain some defaults from the database */
241
	$poller      = read_config_option("poller_type");
242
	$max_threads = read_config_option("max_threads");
243
244
	/* initialize poller_time and poller_output tables, check poller_output for issues */
245
	$running_processes = db_fetch_cell("SELECT count(*) FROM poller_time WHERE end_time='0000-00-00 00:00:00'");
246
	if ($running_processes) {
247
		cacti_log("WARNING: There are '$running_processes' detected as overrunning a polling process, please investigate", TRUE, "POLLER");
248
	}
249
	db_execute("TRUNCATE TABLE poller_time");
250
251
	$issues = db_fetch_assoc("SELECT local_data_id, rrd_name FROM poller_output");
252
	if (sizeof($issues)) {
253
		$issue_list = "";
254
		$count = 0;
255
		foreach($issues as $issue) {
256
			if ($count <= 20) {
257
				if ($count == 0) {
258
					$issue_list .= $issue["rrd_name"] . "(DS[" . $issue["local_data_id"] . "])";
259
				}else{
260
					$issue_list .= ", " . $issue["rrd_name"] . "(DS[" . $issue["local_data_id"] . "])";
261
				}
262
			}
263
			$count++;
264
		}
265
266
		if ($count > 20) {
267
			$issue_list .= ", Additional Issues Remain.  Only showing first 20";
268
		}
269
270
		cacti_log("WARNING: Poller Output Table not Empty.  Issues Found: $count, Data Sources: $issue_list", TRUE, "POLLER");
271
		db_execute("TRUNCATE TABLE poller_output");
272
	}
273
274
	/* mainline */
275
	if (read_config_option("poller_enabled") == "on") {
276
		/* determine the number of hosts to process per file */
277
		$hosts_per_process = ceil(sizeof($polling_hosts) / $concurrent_processes );
278
279
		$items_launched    = 0;
280
281
		/* exit poller if spine is selected and file does not exist */
282
		if (($poller == "2") && (!file_exists(read_config_option("path_spine")))) {
283
			cacti_log("ERROR: The path: " . read_config_option("path_spine") . " is invalid.  Can not continue", true, "POLLER");
284
			exit;
285
		}
286
287
		/* Determine Command Name */
288
		if ($poller == "2") {
289
			$command_string = read_config_option("path_spine");
290
			$extra_args     = "";
291
			$method         = "spine";
292
			$total_procs    = $concurrent_processes * $max_threads;
293
			chdir(dirname(read_config_option("path_spine")));
294
		}else if ($config["cacti_server_os"] == "unix") {
295
			$command_string = read_config_option("path_php_binary");
296
			$extra_args     = "-q \"" . $config["base_path"] . "/cmd.php\"";
297
			$method         = "cmd.php";
298
			$total_procs    = $concurrent_processes;
299
		}else{
300
			$command_string = read_config_option("path_php_binary");
301
			$extra_args     = "-q \"" . strtolower($config["base_path"] . "/cmd.php\"");
302
			$method         = "cmd.php";
303
			$total_procs    = $concurrent_processes;
304
		}
305
306
		/* Populate each execution file with appropriate information */
307
		foreach ($polling_hosts as $item) {
308
			if ($host_count == 1) {
309
				$first_host = $item["id"];
310
			}
311
312
			if ($process_leveling != "on") {
313
				if ($host_count == $hosts_per_process) {
314
					$last_host    = $item["id"];
315
					$change_proc  = true;
316
				}
317
			}else{
318
				if (isset($items_perhost[$item["id"]])) {
319
					$items_launched += $items_perhost[$item["id"]];
320
				}
321
322
				if (($items_launched >= $items_per_process) ||
323
					(sizeof($items_perhost) == $concurrent_processes)) {
324
					$last_host      = $item["id"];
325
					$change_proc    = true;
326
					$items_launched = 0;
327
				}
328
			}
329
330
			$host_count ++;
331
332
			if ($change_proc) {
333
				exec_background($command_string, "$extra_args $first_host $last_host");
334
				usleep(100000);
335
336
				$host_count   = 1;
337
				$change_proc  = false;
338
				$first_host   = 0;
339
				$last_host    = 0;
340
341
				$started_processes++;
342
			} /* end change_process */
343
		} /* end for each */
344
345
		/* launch the last process */
346
		if ($host_count > 1) {
347
			$last_host = $item["id"];
348
349
			exec_background($command_string, "$extra_args $first_host $last_host");
350
			usleep(100000);
351
352
			$started_processes++;
353
		}
354
355
		/* insert the current date/time for graphs */
356
		db_execute("REPLACE INTO settings (name,value) VALUES ('date',NOW())");
357
358
		if ($poller == "1") {
359
			$max_threads = "N/A";
360
		}
361
362
		/* open a pipe to rrdtool for writing */
363
		$rrdtool_pipe = rrd_init();
364
365
		$rrds_processed = 0;
366
		while (1) {
367
			$finished_processes = db_fetch_cell("SELECT count(*) FROM poller_time WHERE poller_id=0 AND end_time>'0000-00-00 00:00:00'");
368
369
			if ($finished_processes >= $started_processes) {
370
				$rrds_processed = $rrds_processed + process_poller_output($rrdtool_pipe, TRUE);
371
372
				log_cacti_stats($loop_start, $method, $concurrent_processes, $max_threads,
373
					sizeof($polling_hosts), $hosts_per_process, $num_polling_items, $rrds_processed);
374
375
				break;
376
			}else {
377
				if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_MEDIUM || $debug) {
378
					print "Waiting on " . ($started_processes - $finished_processes) . " of " . $started_processes . " pollers.\n";
379
				}
380
381
				$rrds_processed = $rrds_processed + process_poller_output($rrdtool_pipe);
382
383
				/* end the process if the runtime exceeds MAX_POLLER_RUNTIME */
384
				if (($poller_start + MAX_POLLER_RUNTIME) < time()) {
385
					cacti_log("Maximum runtime of " . MAX_POLLER_RUNTIME . " seconds exceeded. Exiting.", true, "POLLER");
386
387
					log_cacti_stats($loop_start, $method, $concurrent_processes, $max_threads,
388
						sizeof($polling_hosts), $hosts_per_process, $num_polling_items, $rrds_processed);
389
390
					break;
391
				}else{
392
					usleep(500);
393
				}
394
			}
395
		}
396
397
		rrd_close($rrdtool_pipe);
398
399
		/* process poller commands */
400
		if (db_fetch_cell("SELECT COUNT(*) FROM poller_command") > 0) {
401
			$command_string = read_config_option("path_php_binary");
402
			$extra_args = "-q \"" . $config["base_path"] . "/poller_commands.php\"";
403
			exec_background($command_string, "$extra_args");
404
		} else {
405
			/* no re-index or Rechache present on this run
406
			 * in case, we have more PCOMMANDS than recaching, this has to be moved to poller_commands.php
407
			 * but then we'll have to call it each time to make sure, stats are updated */
408
			db_execute("REPLACE INTO settings (name,value) VALUES ('stats_recache','RecacheTime:0.0 HostsRecached:0')");
409
		}
410
411
		/* graph export */
412
		if ((read_config_option("export_type") != "disabled") &&
413
			(read_config_option("export_timing") != "disabled")) {
414
			$command_string = read_config_option("path_php_binary");
415
			$extra_args = "-q \"" . $config["base_path"] . "/poller_export.php\"";
416
			exec_background($command_string, "$extra_args");
417
		}
418
419
		if ($method == "spine") {
420
			chdir(read_config_option("path_webroot"));
421
		}
422
	}else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
423
		cacti_log("NOTE: There are no items in your poller for this polling cycle!", TRUE, "POLLER");
424
	}
425
426
	$poller_runs_completed++;
427
428
	/* record the start time for this loop */
429
	list($micro,$seconds) = explode(" ", microtime());
430
	$loop_end = $seconds + $micro;
431
	$loop_time = $loop_end - $loop_start;
432
433
	if ($loop_time < $poller_interval) {
434
		if ($poller_runs_completed == 1) {
435
			$sleep_time = $poller_interval - $loop_time - $overhead_time;
436
		} else {
437
			$sleep_time = $poller_interval - $loop_time;
438
		}
439
440
		/* log some nice debug information */
441
		if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG || $debug) {
442
			echo "Loop  Time is: " . round($loop_time, 2) . "\n";
443
			echo "Sleep Time is: " . round($sleep_time, 2) . "\n";
444
			echo "Total Time is: " . round($loop_end - $poller_start, 2) . "\n";
445
 		}
446
447
		/* sleep the appripriate amount of time */
448
		if ($poller_runs_completed < $poller_runs) {
449
			usleep($sleep_time * 1000000);
450
		}
451
	}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");
453
	}
454
}
455
456
function log_cacti_stats($loop_start, $method, $concurrent_processes, $max_threads, $num_hosts,
457
	$hosts_per_process, $num_polling_items, $rrds_processed) {
458
459
	/* take time and log performance data */
460
	list($micro,$seconds) = explode(" ", microtime());
461
	$loop_end = $seconds + $micro;
462
463
	$cacti_stats = sprintf(
464
		"Time:%01.4f " .
465
		"Method:%s " .
466
		"Processes:%s " .
467
		"Threads:%s " .
468
		"Hosts:%s " .
469
		"HostsPerProcess:%s " .
470
		"DataSources:%s " .
471
		"RRDsProcessed:%s",
472
		round($loop_end-$loop_start,4),
473
		$method,
474
		$concurrent_processes,
475
		$max_threads,
476
		$num_hosts,
477
		$hosts_per_process,
478
		$num_polling_items,
479
		$rrds_processed);
480
481
	cacti_log("STATS: " . $cacti_stats , true, "SYSTEM");
482
483
	/* insert poller stats into the settings table */
484
	db_execute("REPLACE INTO settings (name,value) VALUES ('stats_poller','$cacti_stats')");
485
}
486
487
function display_help() {
488
	echo "Cacti Poller Version " . db_fetch_cell("SELECT cacti FROM version") . ", Copyright 2004-2010 - The Cacti Group\n\n";
489
	echo "A simple command line utility to run the Cacti Poller.\n\n";
490
	echo "usage: poller.php [--force] [--debug|-d]\n\n";
491
	echo "Options:\n";
492
	echo "    --force        Override poller overrun detection and force a poller run\n";
493
	echo "    --debug|-d     Output debug information.  Similar to cacti's DEBUG logging level.\n\n";
494
}
495
496
?>
(-)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 324457