CVE-2018-20723: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (CWE-79)
value: A cross-site scripting (XSS) vulnerability exists in color_templates.php in Cacti before 1.2.0 due to lack of escaping of unintended characters in the Name field for a Color.
CWE description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
CVSS v3 base score: 4.8
Published: 2019-01-16T16:29Z
Repository: https://github.com/Cacti/cacti
Language: PHP
Files changed: CHANGELOG, aggregate_graphs.php, aggregate_templates.php, automation_networks.php, automation_tree_rules.php, cdef.php, color_templates.php, data_debug.php, data_input.php, data_queries.php, data_source_profiles.php, data_sources.php, data_templates.php, gprint_presets.php, graph_templates.php, graph_view.php, graphs.php, host_templates.php, lib/html_reports.php, lib/html_utility.php, links.php, managers.php, sites.php, tree.php, user_admin.php, user_domains.php, user_group_admin.php, utilities.php, vdef.php
Commit date: 2018-12-16 09:54:11 -0600
Commit message: Resolving Issues #2213, #2214, #2215 and Additional

Multiple XSS vectors associated with un-escaped strings.  Introduce new
function, audit all calls, remove inline styles for classes, some i18n
missed.

Diff: diff --git a/CHANGELOG b/CHANGELOG
index 52558e8a52..880337d888 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,10 +4,13 @@ Cacti CHANGELOG
 -issue#2188: SNMP timeout errors are being duplicated
 -issue#2191: i18n_themes is not properly primed in global_arrays.php
 -issue#2202: Can't create more than one graph with add_graphs.php from one template
 -issue#2207: Removing Graph Template does not Remove Data Query Associations
 -issue#2212: Stored XSS in "Website Hostname" field
+-issue#2213: Stored XSS in "Website Hostname" field - Devices
+-issue#2214: Stored XSS in "Vertical Label" field - Graph
+-issue#2215: Stored XSS in "Name" field - Color 
 -feature: Update phpseclib to version 2.0.12
 
 1.2.0 Beta 4
 -issue#2186: Boost generates invalid SQL during on demand update
 -issue#2182: Graph View missing 'html_graph_template_multiselect()' function
diff --git a/aggregate_graphs.php b/aggregate_graphs.php
index 32fdad2f3c..3a1699c239 100644
--- a/aggregate_graphs.php
+++ b/aggregate_graphs.php
@@ -1197,16 +1197,16 @@ function aggregate_items() {
 			form_alternate_row('line' . $graph['local_graph_id'], true);
 
 			if (validate_is_regex(get_request_var('rfilter'))) {
 				form_selectable_cell(filter_value($graph['title_cache'], get_request_var('rfilter')), $graph['local_graph_id']);
 			} else {
-				form_selectable_cell(get_request_var('rfilter') != '' ? aggregate_format_text(html_escape($graph['title_cache']), get_request_var('rfilter')) : html_escape($graph['title_cache']), $graph['local_graph_id']);
+				form_selectable_ecell(get_request_var('rfilter') != '' ? aggregate_format_text($graph['title_cache'], get_request_var('rfilter')) : $graph['title_cache'], $graph['local_graph_id']);
 			}
 
 			form_selectable_cell($graph['local_graph_id'], $graph['local_graph_id'], '', 'right');
 			form_selectable_cell(($graph['agg_graph_id'] != '' ? "<span class='associated'>" . __('Yes') . '</span>':"<span class='notAssociated'>" . __('No') . "</span>"), $graph['local_graph_id']);
-			form_selectable_cell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
+			form_selectable_ecell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
 			form_checkbox_cell($graph['title_cache'], $graph['local_graph_id']);
 			form_end_row();
 		}
 	} else {
 		print '<tr><td><em>' . __('No Graphs Found') . '</em></td></tr>';
@@ -1526,11 +1526,11 @@ function aggregate_graph() {
 			$template_name = html_escape($graph['name']);
 			form_alternate_row('line' . $graph['local_graph_id'], true);
 			form_selectable_cell(filter_value(title_trim($graph['title_cache'], read_config_option('max_title_length')), get_request_var('filter'), 'aggregate_graphs.php?action=edit&id=' . $graph['local_graph_id']), $graph['local_graph_id']);
 			form_selectable_cell($graph['local_graph_id'], $graph['local_graph_id'], '', 'right');
 			form_selectable_cell((empty($graph['name']) ? '<em>' . __('None') . '</em>' : filter_value($template_name, get_request_var('filter'))), $graph['local_graph_id']);
-			form_selectable_cell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
+			form_selectable_ecell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
 			form_checkbox_cell($graph['title_cache'], $graph['local_graph_id']);
 			form_end_row();
 		}
 	} else {
 		print '<tr><td colspan="' . (cacti_sizeof($display_text)+1) . '"><em>' . __('No Aggregate Graphs Found') .'</em></td></tr>';
diff --git a/aggregate_templates.php b/aggregate_templates.php
index df1f2b389d..eecd891e2c 100644
--- a/aggregate_templates.php
+++ b/aggregate_templates.php
@@ -656,12 +656,12 @@ function aggregate_template() {
 				$disabled = false;
 			}
 
 			form_alternate_row('line' . $template['id'], true, $disabled);
 			form_selectable_cell(filter_value($template['name'], get_request_var('filter'), 'aggregate_templates.php?action=edit&id=' . $template['id'] . '&page=1'), $template['id']);
-			form_selectable_cell($disabled ? 'No':'Yes', $template['id'], '', 'text-align:right');
-			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('aggregate_graphs.php?reset=true&template_id=' . $template['id']) . '">' . number_format_i18n($template['graphs'], '-1') . '</a>', $template['id'], '', 'text-align:right;');
+			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'right');
+			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('aggregate_graphs.php?reset=true&template_id=' . $template['id']) . '">' . number_format_i18n($template['graphs'], '-1') . '</a>', $template['id'], '', 'right');
 			form_selectable_cell(filter_value($template['graph_template_name'], get_request_var('filter')), $template['id']);
 			form_checkbox_cell($template['graph_template_name'], $template['id'], $disabled);
 			form_end_row();
 		}
 	} else {
diff --git a/automation_networks.php b/automation_networks.php
index 984fa317d2..7c827d9153 100644
--- a/automation_networks.php
+++ b/automation_networks.php
@@ -1131,21 +1131,21 @@ function networks() {
 					$progress = "0/0/0";
 				}
 			}
 
 			form_alternate_row('line' . $network['id'], true);
-			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('automation_networks.php?action=edit&id=' . $network['id']) . '">' . $network['name'] . '</a>', $network['id']);
-			form_selectable_cell($network['data_collector'], $network['id']);
+			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('automation_networks.php?action=edit&id=' . $network['id']) . '">' . html_escape($network['name']) . '</a>', $network['id']);
+			form_selectable_ecell($network['data_collector'], $network['id']);
 			form_selectable_cell($sched_types[$network['sched_type']], $network['id']);
-			form_selectable_cell(number_format_i18n($network['total_ips']), $network['id'], '', 'text-align:right;');
-			form_selectable_cell($mystat, $network['id'], '', 'text-align:right;');
-			form_selectable_cell($progress, $network['id'], '', 'text-align:right;');
-			form_selectable_cell(number_format_i18n($updown['up']) . '/' . number_format_i18n($updown['snmp']), $network['id'], '', 'text-align:right;');
-			form_selectable_cell(number_format_i18n($network['threads']), $network['id'], '', 'text-align:right;');
-			form_selectable_cell(round($network['last_runtime'],2), $network['id'], '', 'text-align:right;');
-			form_selectable_cell($network['enabled'] == '' || $network['sched_type'] == '1' ? __('N/A'):($network['next_start'] == '0000-00-00 00:00:00' ? substr($network['start_at'],0,16):substr($network['next_start'],0,16)), $network['id'], '', 'text-align:right;');
-			form_selectable_cell($network['last_started'] == '0000-00-00 00:00:00' ? 'Never':substr($network['last_started'],0,16), $network['id'], '', 'text-align:right;');
+			form_selectable_cell(number_format_i18n($network['total_ips']), $network['id'], '', 'right');
+			form_selectable_cell($mystat, $network['id'], '', 'right');
+			form_selectable_cell($progress, $network['id'], '', 'right');
+			form_selectable_cell(number_format_i18n($updown['up']) . '/' . number_format_i18n($updown['snmp']), $network['id'], '', 'right');
+			form_selectable_cell(number_format_i18n($network['threads']), $network['id'], '', 'right');
+			form_selectable_cell(round($network['last_runtime'],2), $network['id'], '', 'right');
+			form_selectable_cell($network['enabled'] == '' || $network['sched_type'] == '1' ? __('N/A'):($network['next_start'] == '0000-00-00 00:00:00' ? substr($network['start_at'],0,16):substr($network['next_start'],0,16)), $network['id'], '', 'right');
+			form_selectable_cell($network['last_started'] == '0000-00-00 00:00:00' ? __('Never'):substr($network['last_started'],0,16), $network['id'], '', 'right');
 			form_checkbox_cell($network['name'], $network['id']);
 			form_end_row();
 		}
 	} else {
 		print "<tr><td colspan='10'><em>" . __('No Networks Found') . "</em></td></tr>";
diff --git a/automation_tree_rules.php b/automation_tree_rules.php
index 1139c7e33c..4588b2d44a 100644
--- a/automation_tree_rules.php
+++ b/automation_tree_rules.php
@@ -945,17 +945,17 @@ function automation_tree_rules() {
 	html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false);
 
 	if (cacti_sizeof($automation_tree_rules)) {
 		foreach ($automation_tree_rules as 	$automation_tree_rule) {
 			$tree_item_type_name = ((empty($automation_tree_rule['leaf_type'])) ? '<em>' . __('None') . '</em>' : $automation_tree_item_types[$automation_tree_rule['leaf_type']]);
-			$subtree_name = ((empty($automation_tree_rule['subtree_name'])) ? '<em>' . __('ROOT') . '</em>' : $automation_tree_rule['subtree_name']);
+			$subtree_name = ((empty($automation_tree_rule['subtree_name'])) ? '<em>' . __('ROOT') . '</em>' : html_escape($automation_tree_rule['subtree_name']));
 			$tree_host_grouping_type = ((empty($host_group_types[$automation_tree_rule['host_grouping_type']])) ? '' : $host_group_types[$automation_tree_rule['host_grouping_type']]);
 			form_alternate_row('line' .  $automation_tree_rule['id'], true);
 
 			form_selectable_cell(filter_value($automation_tree_rule['name'], get_request_var('filter'), 'automation_tree_rules.php?action=edit&id=' . $automation_tree_rule['id'] . '&page=1'), $automation_tree_rule['id']);
 			form_selectable_cell($automation_tree_rule['id'], $automation_tree_rule['id'], '', 'text-align:right');
-			form_selectable_cell($automation_tree_rule['tree_name'], $automation_tree_rule['id']);
+			form_selectable_ecell($automation_tree_rule['tree_name'], $automation_tree_rule['id']);
 			form_selectable_cell($subtree_name, $automation_tree_rule['id']);
 			form_selectable_cell($tree_item_type_name, $automation_tree_rule['id']);
 			form_selectable_cell($tree_host_grouping_type, $automation_tree_rule['id']);
 			form_selectable_cell($automation_tree_rule['enabled'] ? __('Enabled'):__('Disabled'), $automation_tree_rule['id'], '', 'text-align:right');
 			form_checkbox_cell($automation_tree_rule['name'], $automation_tree_rule['id']);
diff --git a/cdef.php b/cdef.php
index 2e7666ebb7..485f070755 100644
--- a/cdef.php
+++ b/cdef.php
@@ -104,11 +104,11 @@ switch (get_request_var('action')) {
 
 function draw_cdef_preview($cdef_id) {
 	?>
 	<tr class='even'>
 		<td style='padding:4px'>
-			<pre>cdef=<?php print get_cdef($cdef_id, true);?></pre>
+			<pre>cdef=<?php print html_escape(get_cdef($cdef_id, true));?></pre>
 		</td>
 	</tr>
 	<?php
 }
 
@@ -431,11 +431,11 @@ function item_edit() {
 
 	html_start_box(__('CDEF Preview'), '100%', '', '3', 'center', '');
 	draw_cdef_preview(get_request_var('cdef_id'));
 	html_end_box();
 
-	form_start('cdef.php', 'form_cdef');
+	form_start('cdef.php', 'chk');
 
 	$cdef_name = db_fetch_cell_prepared('SELECT name
 		FROM cdef
 		WHERE id = ?',
 		array(get_request_var('cdef_id')));
@@ -895,13 +895,13 @@ function cdef() {
 				$disabled = true;
 			}
 
 			form_alternate_row('line' . $cdef['id'], false, $disabled);
 			form_selectable_cell(filter_value($cdef['name'], get_request_var('filter'), 'cdef.php?action=edit&id=' . $cdef['id']), $cdef['id']);
-			form_selectable_cell($disabled ? __('No') : __('Yes'), $cdef['id'], '', 'text-align:right');
-			form_selectable_cell(number_format_i18n($cdef['graphs'], '-1'), $cdef['id'], '', 'text-align:right');
-			form_selectable_cell(number_format_i18n($cdef['templates'], '-1'), $cdef['id'], '', 'text-align:right');
+			form_selectable_cell($disabled ? __('No'):__('Yes'), $cdef['id'], '', 'right');
+			form_selectable_cell(number_format_i18n($cdef['graphs'], '-1'), $cdef['id'], '', 'right');
+			form_selectable_cell(number_format_i18n($cdef['templates'], '-1'), $cdef['id'], '', 'right');
 			form_checkbox_cell($cdef['name'], $cdef['id'], $disabled);
 			form_end_row();
 		}
 	} else {
 		print "<tr class='tableRow'><td colspan='4'><em>" . __('No CDEFs') . "</em></td></tr>\n";
diff --git a/color_templates.php b/color_templates.php
index 91a8392386..fb0ffd6101 100644
--- a/color_templates.php
+++ b/color_templates.php
@@ -573,13 +573,13 @@ function aggregate_color_template() {
 			}
 
 			form_alternate_row('line' . $template['color_template_id'], true);
 
 			form_selectable_cell(filter_value($template['name'], get_request_var('filter'), 'color_templates.php?action=template_edit&color_template_id=' . $template['color_template_id'] . '&page=1'), $template['color_template_id']);
-			form_selectable_cell($disabled ? __('No') : __('Yes'), $template['color_template_id'], '', 'text-align:right');
-            form_selectable_cell(number_format_i18n($template['graphs']), $template['color_template_id'], '', 'text-align:right;');
-            form_selectable_cell(number_format_i18n($template['templates']), $template['color_template_id'], '', 'text-align:right;');
+			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['color_template_id'], '', 'right');
+			form_selectable_cell(number_format_i18n($template['graphs']), $template['color_template_id'], '', 'right');
+			form_selectable_cell(number_format_i18n($template['templates']), $template['color_template_id'], '', 'right');
 			form_checkbox_cell($template['name'], $template['color_template_id'], $disabled);
 			form_end_row();
 		}
 	} else {
 		print "<tr><td colspan='" . (cacti_sizeof($display_text)+1) . "'><em>" . __('No Color Templates Found') ."</em></td></tr>\n";
diff --git a/data_debug.php b/data_debug.php
index 20c62358cb..29cc67c452 100644
--- a/data_debug.php
+++ b/data_debug.php
@@ -257,22 +257,22 @@ function debug_wizard() {
 			$name = get_data_source_title($check['datasource']);
 			$title = $name;
 			if (strlen($name) > 50) {
 				$name = substr($name, 0, 50);
 			}
-			form_selectable_cell('<a class="linkEditMain" title="' . $title .'" href="' . htmlspecialchars('data_debug.php?action=view&id=' . $check['id']) . '">' . $name . '</a>', $check['id']);
-			form_selectable_cell($user, $check['id']);
+			form_selectable_cell('<a class="linkEditMain" title="' . $title .'" href="' . html_escape('data_debug.php?action=view&id=' . $check['id']) . '">' . html_escape($name) . '</a>', $check['id']);
+			form_selectable_ecell($user, $check['id']);
 			form_selectable_cell(date('F j, Y, G:i', $check['started']), $check['id']);
-			form_selectable_cell($check['datasource'], $check['id']);
-			form_selectable_cell(debug_icon(($check['done'] ? (strlen($issue_line) ? 'off' : 'on' ) : '')), $check['id'], '', 'text-align: center;');
-			form_selectable_cell(debug_icon($info['rrd_writable']), $check['id'], '', 'text-align: center;');
-			form_selectable_cell(debug_icon($info['rrd_exists']), $check['id'], '', 'text-align: center;');
-			form_selectable_cell(debug_icon($info['active']), $check['id'], '', 'text-align: center;');
-			form_selectable_cell(debug_icon($info['rrd_match']), $check['id'], '', 'text-align: center;');
-			form_selectable_cell(debug_icon($info['valid_data']), $check['id'], '', 'text-align: center;');
-			form_selectable_cell(debug_icon(($info['rra_timestamp2'] != '' ? 1 : '')), $check['id'], '', 'text-align: center;');
-			form_selectable_cell('<a class=\'linkEditMain\' href=\'#\' title="' . html_escape($issue_title) . '">' . html_escape(strlen(trim($issue_line)) ? $issue_line : '<none>') . '</a>', $check['id']);
+			form_selectable_ecell($check['datasource'], $check['id']);
+			form_selectable_cell(debug_icon(($check['done'] ? (strlen($issue_line) ? 'off' : 'on' ) : '')), $check['id'], '', 'center');
+			form_selectable_cell(debug_icon($info['rrd_writable']), $check['id'], '', 'center');
+			form_selectable_cell(debug_icon($info['rrd_exists']), $check['id'], '', 'center');
+			form_selectable_cell(debug_icon($info['active']), $check['id'], '', 'center');
+			form_selectable_cell(debug_icon($info['rrd_match']), $check['id'], '', 'center');
+			form_selectable_cell(debug_icon($info['valid_data']), $check['id'], '', 'center');
+			form_selectable_cell(debug_icon(($info['rra_timestamp2'] != '' ? 1 : '')), $check['id'], '', 'center');
+			form_selectable_cell('<a class=\'linkEditMain\' href=\'#\' title="' . html_escape($issue_title) . '">' . html_escape(strlen(trim($issue_line)) ? $issue_line : __('<none>')) . '</a>', $check['id']);
 			form_checkbox_cell($check['id'], $check['id']);
 			form_end_row();
 		}
 	}else{
 		print "<tr><td colspan='5'><em>" . __('No Checks') . "</em></td></tr>\n";
@@ -343,13 +343,13 @@ function debug_view() {
 	$i = 1;
 	foreach ($fields as $field) {
 		$field_name = $field['name'];
 
 		form_alternate_row('line' . $i);
-		form_selectable_cell($field['title'], $i);
+		form_selectable_ecell($field['title'], $i);
 
-		$value = '<not set>';
+		$value = __('<not set>');
 		$icon  = '';
 
 		if (array_key_exists($field_name, $check['info'])) {
 			$value = $check['info'][$field_name];
 			$icon  = debug_icon($check['info'][$field_name]);
@@ -366,28 +366,19 @@ function debug_view() {
 		$value_title = $value;
 		if (strlen($value) > 100) {
 			$value = substr($value, 0, 100);
 		}
 
-		form_selectable_cell($value, $i, '', '', $value_title);
+		form_selectable_ecell($value, $i, '', '', $value_title);
 		form_selectable_cell($icon, $i);
 
 		form_end_row();
 		$i++;
 	}
 
 
 	html_end_box(false);
-
-/*
-	print "<pre>";
-	if (isset($check) && is_array($check)) {
-		print_r($check);
-	}
-	print "</pre>";
-*/
-
 }
 
 function debug_icon($result) {
 	if ($result === '' || $result === false) {
 			return '<i class="fa fa-spinner fa-pulse fa-fw"></i>';
diff --git a/data_input.php b/data_input.php
index ce6415a636..26b3dcb16d 100644
--- a/data_input.php
+++ b/data_input.php
@@ -920,13 +920,13 @@ function data() {
 			} else {
 				$disabled = false;
 			}
 			form_alternate_row('line' . $data_input['id'], true, $disabled);
 			form_selectable_cell(filter_value($data_input['name'], get_request_var('filter'), 'data_input.php?action=edit&id=' . $data_input['id']), $data_input['id']);
-			form_selectable_cell($disabled ? __('No'): __('Yes'), $data_input['id'],'', 'text-align:right');
-			form_selectable_cell(number_format_i18n($data_input['data_sources'], '-1'), $data_input['id'],'', 'text-align:right');
-			form_selectable_cell(number_format_i18n($data_input['templates'], '-1'), $data_input['id'],'', 'text-align:right');
+			form_selectable_cell($disabled ? __('No'):__('Yes'), $data_input['id'],'', 'right');
+			form_selectable_cell(number_format_i18n($data_input['data_sources'], '-1'), $data_input['id'],'', 'right');
+			form_selectable_cell(number_format_i18n($data_input['templates'], '-1'), $data_input['id'],'', 'right');
 			form_selectable_cell($input_types[$data_input['type_id']], $data_input['id']);
 			form_checkbox_cell($data_input['name'], $data_input['id'], $disabled);
 			form_end_row();
 		}
 	} else {
diff --git a/data_queries.php b/data_queries.php
index 09150de867..11f6b17e65 100644
--- a/data_queries.php
+++ b/data_queries.php
@@ -1377,14 +1377,14 @@ function data_query() {
 				$disabled = true;
 			}
 
 			form_alternate_row('line' . $snmp_query['id'], true, $disabled);
 			form_selectable_cell(filter_value($snmp_query['name'], get_request_var('filter'), 'data_queries.php?action=edit&id=' . $snmp_query['id']), $snmp_query['id']);
-			form_selectable_cell($snmp_query['id'], $snmp_query['id'], '', 'text-align:right;');
-			form_selectable_cell($disabled ? __('No') : __('Yes'), $snmp_query['id'], '', 'text-align:right');
-			form_selectable_cell(number_format_i18n($snmp_query['graphs'], '-1'), $snmp_query['id'], '', 'text-align:right');
-			form_selectable_cell(number_format_i18n($snmp_query['templates'], '-1'), $snmp_query['id'], '', 'text-align:right');
+			form_selectable_cell($snmp_query['id'], $snmp_query['id'], '', 'right');
+			form_selectable_cell($disabled ? __('No'):__('Yes'), $snmp_query['id'], '', 'right');
+			form_selectable_cell(number_format_i18n($snmp_query['graphs'], '-1'), $snmp_query['id'], '', 'right');
+			form_selectable_cell(number_format_i18n($snmp_query['templates'], '-1'), $snmp_query['id'], '', 'right');
 			form_selectable_cell(filter_value($snmp_query['data_input_method'], get_request_var('filter')), $snmp_query['id']);
 			form_checkbox_cell($snmp_query['name'], $snmp_query['id'], $disabled);
 			form_end_row();
 		}
 	} else {
diff --git a/data_source_profiles.php b/data_source_profiles.php
index 410913c80b..ba001841c7 100644
--- a/data_source_profiles.php
+++ b/data_source_profiles.php
@@ -999,17 +999,17 @@ function profile() {
 				$dt = number_format_i18n($profile['templates'], '-1');
 			}
 
 			form_alternate_row('line' . $profile['id'], false, $disabled);
 			form_selectable_cell(filter_value($profile['name'], get_request_var('filter'), 'data_source_profiles.php?action=edit&id=' . $profile['id']), $profile['id']);
-			form_selectable_cell($profile['default'] == 'on' ? __('Yes'):'', $profile['id'], '', 'text-align:right');
-			form_selectable_cell($disabled ? __('No') : __('Yes'), $profile['id'], '', 'text-align:right');
-			form_selectable_cell($readonly ? __('Yes') : __('No'), $profile['id'], '', 'text-align:right');
-			form_selectable_cell($sampling_intervals[$profile['step']], $profile['id'], '', 'text-align:right');
-			form_selectable_cell($heartbeats[$profile['heartbeat']], $profile['id'], '', 'text-align:right');
-			form_selectable_cell($ds, $profile['id'], '', 'text-align:right');
-			form_selectable_cell($dt, $profile['id'], '', 'text-align:right');
+			form_selectable_cell($profile['default'] == 'on' ? __('Yes'):'', $profile['id'], '', 'right');
+			form_selectable_cell($disabled ? __('No'):__('Yes'), $profile['id'], '', 'right');
+			form_selectable_cell($readonly ? __('Yes'):__('No'), $profile['id'], '', 'right');
+			form_selectable_cell($sampling_intervals[$profile['step']], $profile['id'], '', 'right');
+			form_selectable_cell($heartbeats[$profile['heartbeat']], $profile['id'], '', 'right');
+			form_selectable_cell($ds, $profile['id'], '', 'right');
+			form_selectable_cell($dt, $profile['id'], '', 'right');
 			form_checkbox_cell($profile['name'], $profile['id'], $disabled);
 			form_end_row();
 		}
 	} else {
 		print "<tr class='tableRow'><td colspan='4'><em>" . __('No Data Source Profiles Found') . "</em></td></tr>\n";
diff --git a/data_sources.php b/data_sources.php
index 5ec67b213c..2243bb4d62 100644
--- a/data_sources.php
+++ b/data_sources.php
@@ -1558,14 +1558,14 @@ function ds() {
 				$data_template_name = html_escape($data_source['data_template_name']);
 			}
 
 			form_alternate_row('line' . $data_source['local_data_id'], true, $disabled);
 			form_selectable_cell(filter_value(title_trim($data_source['name_cache'], read_config_option('max_title_length')), get_request_var('rfilter'), 'data_sources.php?action=ds_edit&id=' . $data_source['local_data_id']), $data_source['local_data_id']);
-			form_selectable_cell($data_source['local_data_id'], $data_source['local_data_id'], '', 'text-align:right');
+			form_selectable_cell($data_source['local_data_id'], $data_source['local_data_id'], '', 'right');
 			form_selectable_cell(get_poller_interval($data_source['rrd_step'], $data_source['data_source_profile_id']), $data_source['local_data_id']);
 			form_selectable_cell(api_data_source_deletable($data_source['local_data_id']) ? __('Yes') : __('No'), $data_source['local_data_id']);
-			form_selectable_cell(($data_source['active'] == 'on' ? __('Yes') : __('No')), $data_source['local_data_id']);
+			form_selectable_cell(($data_source['active'] == 'on' ? __('Yes'):__('No')), $data_source['local_data_id']);
 			form_selectable_cell($data_template_name, $data_source['local_data_id']);
 			form_checkbox_cell($data_source['name_cache'], $data_source['local_data_id'], $disabled);
 			form_end_row();
 		}
 	} else {
diff --git a/data_templates.php b/data_templates.php
index 0a5f82f112..8d45bcc62d 100644
--- a/data_templates.php
+++ b/data_templates.php
@@ -1014,13 +1014,13 @@ function template() {
 				$disabled = false;
 			}
 
 			form_alternate_row('line' . $template['id'], true, $disabled);
 			form_selectable_cell(filter_value($template['name'], get_request_var('filter'), 'data_templates.php?action=template_edit&id=' . $template['id']), $template['id']);
-			form_selectable_cell($template['id'], $template['id'], '', 'text-align:right');
-			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'text-align:right');
-			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('data_sources.php?reset=true&template_id=' . $template['id']) . '">' . number_format_i18n($template['data_sources']) . '</a>', $template['id'], '', 'text-align:right');
+			form_selectable_cell($template['id'], $template['id'], '', 'right');
+			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'right');
+			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('data_sources.php?reset=true&template_id=' . $template['id']) . '">' . number_format_i18n($template['data_sources']) . '</a>', $template['id'], '', 'right');
 			form_selectable_cell((empty($template['data_input_method']) ? '<em>' . __('None') .'</em>': html_escape($template['data_input_method'])), $template['id']);
 			form_selectable_cell((empty($template['profile_name']) ? __('External'):html_escape($template['profile_name'])), $template['id']);
 			form_selectable_cell((($template['active'] == 'on') ? __('Active'):__('Disabled')), $template['id']);
 			form_checkbox_cell($template['name'], $template['id'], $disabled);
 			form_end_row();
diff --git a/gprint_presets.php b/gprint_presets.php
index d8ab3d62e7..cd3a22bcd6 100644
--- a/gprint_presets.php
+++ b/gprint_presets.php
@@ -408,14 +408,14 @@ function gprint_presets() {
 				$disabled = true;
 			}
 
             form_alternate_row('line' . $gp['id'], false, $disabled);
 			form_selectable_cell(filter_value($gp['name'], get_request_var('filter'), 'gprint_presets.php?action=edit&id=' . $gp['id']), $gp['id']);
-            form_selectable_cell($gp['gprint_text'], $gp['id'], '', 'text-align:right');
-            form_selectable_cell($disabled ? __('No'):__('Yes'), $gp['id'], '', 'text-align:right');
-            form_selectable_cell(number_format_i18n($gp['graphs'], '-1'), $gp['id'], '', 'text-align:right');
-            form_selectable_cell(number_format_i18n($gp['templates'], '-1'), $gp['id'], '', 'text-align:right');
+            form_selectable_cell($gp['gprint_text'], $gp['id'], '', 'right');
+            form_selectable_cell($disabled ? __('No'):__('Yes'), $gp['id'], '', 'right');
+            form_selectable_cell(number_format_i18n($gp['graphs'], '-1'), $gp['id'], '', 'right');
+            form_selectable_cell(number_format_i18n($gp['templates'], '-1'), $gp['id'], '', 'right');
             form_checkbox_cell($gp['name'], $gp['id'], $disabled);
             form_end_row();
 		}
 	} else {
 		print "<tr class='tableRow'><td colspan='6'><em>" . __('No GPRINT Presets') . "</em></td></tr>\n";
diff --git a/graph_templates.php b/graph_templates.php
index c09e1a2805..3e26dc840c 100644
--- a/graph_templates.php
+++ b/graph_templates.php
@@ -806,16 +806,16 @@ function template() {
 			} else {
 				$disabled = false;
 			}
 			form_alternate_row('line' . $template['id'], true, $disabled);
 			form_selectable_cell(filter_value($template['name'], get_request_var('filter'), 'graph_templates.php?action=template_edit&id=' . $template['id']), $template['id']);
-			form_selectable_cell($template['id'], $template['id'], '', 'text-align:right');
-			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'text-align:right');
-			form_selectable_cell(number_format_i18n($template['graphs'], '-1'), $template['id'], '', 'text-align:right');
-			form_selectable_cell($template['size'], $template['id'], '', 'text-align:right');
-			form_selectable_cell($image_types[$template['image_format_id']], $template['id'], '', 'text-align:right');
-			form_selectable_cell($template['vertical_label'], $template['id'], '', 'text-align:right');
+			form_selectable_cell($template['id'], $template['id'], '', 'right');
+			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'right');
+			form_selectable_cell(number_format_i18n($template['graphs'], '-1'), $template['id'], '', 'right');
+			form_selectable_ecell($template['size'], $template['id'], '', 'right');
+			form_selectable_cell($image_types[$template['image_format_id']], $template['id'], '', 'right');
+			form_selectable_ecell($template['vertical_label'], $template['id'], '', 'right');
 			form_checkbox_cell($template['name'], $template['id'], $disabled);
 			form_end_row();
 		}
 	} else {
 		print "<tr class='tableRow'><td colspan='4'><em>" . __('No Graph Templates Found') . "</em></td></tr>\n";
diff --git a/graph_view.php b/graph_view.php
index 77e8e8aa80..48743d8f17 100644
--- a/graph_view.php
+++ b/graph_view.php
@@ -719,13 +719,13 @@ case 'list':
 				}
 			}
 
 			form_alternate_row('line' . $graph['local_graph_id'], true);
 			form_selectable_cell(filter_value($graph['title_cache'], get_request_var('rfilter'), 'graph.php?local_graph_id=' . $graph['local_graph_id'] . '&rra_id=0'), $graph['local_graph_id']);
-			form_selectable_cell($graph['description'], $graph['local_graph_id']);
-			form_selectable_cell($graph['template_name'], $graph['local_graph_id']);
-			form_selectable_cell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id']);
+			form_selectable_ecell($graph['description'], $graph['local_graph_id']);
+			form_selectable_ecell($graph['template_name'], $graph['local_graph_id']);
+			form_selectable_ecell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id']);
 			form_checkbox_cell($graph['title_cache'], $graph['local_graph_id']);
 			form_end_row();
 		}
 	}
 
diff --git a/graphs.php b/graphs.php
index 8be44f7b05..6e751dd132 100644
--- a/graphs.php
+++ b/graphs.php
@@ -2041,14 +2041,14 @@ function graph_management() {
 				$url = '';
 			}
 
 			form_alternate_row('line' . $graph['local_graph_id'], true);
 			form_selectable_cell(filter_value(title_trim($graph['title_cache'], read_config_option('max_title_length')), get_request_var('rfilter'), 'graphs.php?action=graph_edit&id=' . $graph['local_graph_id']), $graph['local_graph_id']);
-			form_selectable_cell($graph['local_graph_id'], $graph['local_graph_id'], '', 'text-align:right');
+			form_selectable_cell($graph['local_graph_id'], $graph['local_graph_id'], '', 'right');
 			form_selectable_cell(filter_value($sources[$graph['source']], get_request_var('rfilter')), $graph['local_graph_id'], '', 'right');
 			form_selectable_cell(filter_value($template_details['name'], get_request_var('rfilter'), $url), $graph['local_graph_id'], '', 'right');
-			form_selectable_cell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
+			form_selectable_ecell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
 			form_checkbox_cell($graph['title_cache'], $graph['local_graph_id']);
 			form_end_row();
 		}
 	} else {
 		print "<tr class='tableRow'><td colspan='5'><em>" . __('No Graphs Found') . "</em></td></tr>";
diff --git a/host_templates.php b/host_templates.php
index b671fce585..316b25dd86 100644
--- a/host_templates.php
+++ b/host_templates.php
@@ -849,13 +849,13 @@ function template() {
 				$disabled = false;
 			}
 
 			form_alternate_row('line' . $template['id'], true, $disabled);
 			form_selectable_cell(filter_value($template['name'], get_request_var('filter'), 'host_templates.php?action=edit&id=' . $template['id']), $template['id']);
-			form_selectable_cell($template['id'], $template['id'], '', 'text-align:right');
-			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'text-align:right');
-			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('host.php?reset=true&host_template_id=' . $template['id']) . '">' . number_format_i18n($template['hosts'], '-1') . '</a>', $template['id'], '', 'text-align:right');
+			form_selectable_cell($template['id'], $template['id'], '', 'right');
+			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'right');
+			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('host.php?reset=true&host_template_id=' . $template['id']) . '">' . number_format_i18n($template['hosts'], '-1') . '</a>', $template['id'], '', 'right');
 			form_checkbox_cell($template['name'], $template['id'], $disabled);
 			form_end_row();
 		}
 	} else {
 		print "<tr class='tableRow'><td colspan='4'><em>" . __('No Device Templates Found') . "</em></td></tr>\n";
diff --git a/lib/html_reports.php b/lib/html_reports.php
index 57dfe3d0ac..963369a314 100644
--- a/lib/html_reports.php
+++ b/lib/html_reports.php
@@ -1620,25 +1620,25 @@ function reports() {
 
 			form_selectable_cell(filter_value($report['name'], get_request_var('filter'), get_reports_page() . '?action=edit&tab=details&id=' . $report['id'] . '&page=1'), $report['id']);
 
 			if (is_reports_admin()) {
 				if (reports_html_account_exists($report['user_id'])) {
-					form_selectable_cell($report['full_name'], $report['id']);
+					form_selectable_ecell($report['full_name'], $report['id']);
 				} else {
 					form_selectable_cell(__('Report Disabled - No Owner'), $report['id']);
 				}
 			}
 
 			$interval = __('Every') . ' ' . $report['count'] . ' ' . $reports_interval[$report['intrvl']];
 
 			form_selectable_cell($interval, $report['id']);
 			form_selectable_cell(($report['lastsent'] == 0) ? __('Never') : date($date_format, $report['lastsent']), $report['lastsent']);
 			form_selectable_cell(date($date_format, $report['mailtime']), $report['id']);
-			form_selectable_cell($report['from_name'], $report['id']);
-			form_selectable_cell((substr_count($report['email'], ',') ? __('Multiple'): $report['email']), $report['id']);
+			form_selectable_ecell($report['from_name'], $report['id']);
+			form_selectable_ecell((substr_count($report['email'], ',') ? __('Multiple'): $report['email']), $report['id']);
 			form_selectable_cell((isset($attach_types[$report['attachment_type']])) ? $attach_types[$report['attachment_type']] : __('Invalid'), $report['id']);
-			form_selectable_cell($report['enabled'] ? __('Enabled'): __('Disabled'), $report['id']);
+			form_selectable_cell($report['enabled'] ? __('Enabled'):__('Disabled'), $report['id']);
 			form_checkbox_cell($report['name'], $report['id']);
 
 			form_end_row();
 		}
 	} else {
diff --git a/lib/html_utility.php b/lib/html_utility.php
index 37a23ffeed..6ea0997095 100644
--- a/lib/html_utility.php
+++ b/lib/html_utility.php
@@ -147,10 +147,20 @@ function form_alternate_row($row_id = '', $light = false, $disabled = false) {
 	} else {
 		print "<tr class='$class tableRow'>\n";
 	}
 }
 
+/* form_selectable_ecell - a wrapper to form_selectable_cell that escapes the contents
+   @arg $contents - the readable portion of the
+   @arg $id - the id of the object that will be highlighted
+   @arg $width - the width of the table element
+   @arg $style_or_class - the style or class to apply to the table element
+   @arg $title - optional title for the column */
+function form_selectable_ecell($contents, $id, $width = '', $style_or_class = '', $title = '') {
+	form_selectable_cell(html_escape($contents), $id, $width, $style_or_class, $title);
+}
+
 /* form_selectable_cell - format's a table row such that it can be highlighted using cacti's js actions
    @arg $contents - the readable portion of the
    @arg $id - the id of the object that will be highlighted
    @arg $width - the width of the table element
    @arg $style_or_class - the style or class to apply to the table element
diff --git a/links.php b/links.php
index ee2b80ae49..bdfc8abffe 100644
--- a/links.php
+++ b/links.php
@@ -395,14 +395,14 @@ function pages() {
 			if ($page['enabled'] == 'on') {
 				$actions .= '<a class="pic" href="' . html_escape('link.php?id=' . $page['id']) . '" title="' . __esc('View Page') . '"><img src="' . $config['url_path'] . 'images/view_page.png" alt=""></a>';
 			}
 
 			form_selectable_cell($actions, $page['id'], '50');
-			form_selectable_cell(html_escape($page['contentfile']), $page['id']);
-			form_selectable_cell(html_escape($page['title']), $page['id']);
-			form_selectable_cell(html_escape($style_translate[$page['style']]) . ($page['style'] == 'CONSOLE' ? ' ( ' . ($page['extendedstyle'] == '' ? 'External Links':$page['extendedstyle']) . ' )':''), $page['id']);
-			form_selectable_cell(($page['enabled'] == 'on' ? 'Yes':'No'), $page['id']);
+			form_selectable_ecell($page['contentfile'], $page['id']);
+			form_selectable_ecell($page['title'], $page['id']);
+			form_selectable_ecell($style_translate[$page['style']] . ($page['style'] == 'CONSOLE' ? ' ( ' . ($page['extendedstyle'] == '' ? __('External Links'):$page['extendedstyle']) . ' )':''), $page['id']);
+			form_selectable_cell(($page['enabled'] == 'on' ? __('Yes'):__('No')), $page['id']);
 
 			if (get_request_var('sort_column') == 'sortorder') {
 				if ($i != 0) {
 					$sort = '<a class="pic fa fa-caret-up moveArrow" href="' . html_escape('links.php?action=move_page_up&order=' . $page['sortorder'] . '&id='.$page['id']) . '"></a>';
 				} else {
diff --git a/managers.php b/managers.php
index cb7e0658e4..9046932007 100644
--- a/managers.php
+++ b/managers.php
@@ -64,11 +64,11 @@ switch (get_request_var('action')) {
 		bottom_footer();
 	break;
 }
 
 function manager(){
-	global $manager_actions, $item_rows;
+	global $config, $manager_actions, $item_rows;
 
 	/* ================= input validation and session storage ================= */
 	$filters = array(
 		'rows' => array(
 			'filter' => FILTER_VALIDATE_INT,
@@ -236,16 +236,16 @@ function manager(){
 	if (cacti_sizeof($managers)) {
 		foreach ($managers as $item) {
 			$description = filter_value($item['description'], get_request_var('filter'));
 			$hostname    = filter_value($item['hostname'], get_request_var('filter'));
 			form_alternate_row('line' . $item['id'], false);
-			form_selectable_cell('<a class="linkEditMain" href="managers.php?action=edit&id=' . $item['id'] . '">' . $description . '</a>', $item['id']);
+			form_selectable_cell('<a class="linkEditMain" href="' . html_escape($config['url_path'] . 'managers.php?action=edit&id=' . $item['id']) . '">' . html_escape($description) . '</a>', $item['id']);
 			form_selectable_cell($item['id'], $item['id']);
 			form_selectable_cell($item['disabled'] ? '<span class="deviceDown">' . __('Disabled') . '</span>' : '<span class="deviceUp">' . __('Enabled') . '</span>', $item['id']);
-			form_selectable_cell($hostname, $item['id']);
-			form_selectable_cell('<a class="linkEditMain" href="managers.php?action=edit&tab=notifications&id=' . $item['id'] . '">' . ($item['count_notify'] ? $item['count_notify'] : 0) . '</a>' , $item['id']);
-			form_selectable_cell('<a class="linkEditMain" href="managers.php?action=edit&tab=logs&id=' . $item['id'] . '">' . ($item['count_log'] ? $item['count_log'] : 0 ) . '</a>', $item['id']);
+			form_selectable_ecell($hostname, $item['id']);
+			form_selectable_cell('<a class="linkEditMain" href="' . html_escape($config['url_path'] . 'managers.php?action=edit&tab=notifications&id=' . $item['id']) . '">' . ($item['count_notify'] ? $item['count_notify'] : 0) . '</a>' , $item['id']);
+			form_selectable_cell('<a class="linkEditMain" href="' . html_escape($config['url_path'] . 'managers.php?action=edit&tab=logs&id=' . $item['id']) . '">' . ($item['count_log'] ? $item['count_log'] : 0 ) . '</a>', $item['id']);
 			form_checkbox_cell($item['description'], $item['id']);
 			form_end_row();
 		}
 	} else {
 		print '<tr><td><em>' . __('No SNMP Notification Receivers') . '</em></td></tr>';
@@ -593,11 +593,11 @@ function manager_notifications($id, $header_label) {
 
 			form_selectable_cell($oid, $row_id);
 			form_selectable_cell($mib, $row_id);
 			form_selectable_cell($item['kind'], $row_id);
 			form_selectable_cell($item['max-access'],$row_id);
-			form_selectable_cell(((isset($notifications[$item['mib']]) && isset($notifications[$item['mib']][$item['name']])) ? '<span class="deviceUp">' .__('Enabled') : '<span class="deviceDown">' .  __('Disabled')) . '</span>', $row_id);
+			form_selectable_cell(((isset($notifications[$item['mib']]) && isset($notifications[$item['mib']][$item['name']])) ? '<span class="deviceUp">' . __('Enabled'):'<span class="deviceDown">' . __('Disabled')) . '</span>', $row_id);
 			form_checkbox_cell($item['oid'], $row_id);
 			form_end_row();
 		}
 	} else {
 		print '<tr><td><em>' . __('No SNMP Notifications') . '</em></td></tr>';
diff --git a/sites.php b/sites.php
index e3a80df105..6f0f41bab7 100644
--- a/sites.php
+++ b/sites.php
@@ -527,18 +527,18 @@ function sites() {
 	html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false);
 
 	$i = 0;
 	if (cacti_sizeof($site_list)) {
 		foreach ($site_list as $site) {
-			$devices_url = $config['url_path'] . 'host.php?reset=1&site_id=' . $site['id'];
+			$devices_url = html_escape($config['url_path'] . 'host.php?reset=1&site_id=' . $site['id']);
 			form_alternate_row('line' . $site['id'], true);
 			form_selectable_cell(filter_value($site['name'], get_request_var('filter'), 'sites.php?action=edit&id=' . $site['id']), $site['id']);
 			form_selectable_cell($site['id'], $site['id'], '', 'right');
 			form_selectable_cell('<a class="linkEditMain" href="' . $devices_url . '">' . number_format_i18n($site['hosts'], '-1') . '</a>', $site['id'], '', 'right');
-			form_selectable_cell($site['city'], $site['id'], '', 'left');
-			form_selectable_cell($site['state'], $site['id'], '', 'left');
-			form_selectable_cell($site['country'], $site['id'], '', 'left');
+			form_selectable_ecell($site['city'], $site['id'], '', 'left');
+			form_selectable_ecell($site['state'], $site['id'], '', 'left');
+			form_selectable_ecell($site['country'], $site['id'], '', 'left');
 			form_checkbox_cell($site['name'], $site['id']);
 			form_end_row();
 		}
 	} else {
 		print "<tr class='tableRow'><td colspan='4'><em>" . __('No Sites Found') . "</em></td></tr>\n";
diff --git a/tree.php b/tree.php
index 92e2dadaa3..7077680dcc 100644
--- a/tree.php
+++ b/tree.php
@@ -2007,21 +2007,21 @@ function tree() {
 				}
 			}
 
 			form_alternate_row('line' . $tree['id'], true);
 			form_selectable_cell(filter_value($tree['name'], get_request_var('filter'), 'tree.php?action=edit&id=' . $tree['id']), $tree['id']);
-			form_selectable_cell($tree['id'], $tree['id'], '', 'text-align:right');
+			form_selectable_cell($tree['id'], $tree['id'], '', 'right');
 			form_selectable_cell($tree['enabled'] == 'on' ? __('Yes'):__('No'), $tree['id']);
 			form_selectable_cell($tree['locked'] == '1' ? __('Yes'):__('No'), $tree['id']);
 			form_selectable_cell(get_username($tree['user_id']), $tree['id']);
 			form_selectable_cell($sequence, $tree['id'], '', 'nowrap center');
-			form_selectable_cell(substr($tree['last_modified'],0,16), $tree['id'], '', 'text-align:right');
-			form_selectable_cell(get_username($tree['modified_by']), $tree['id'], '', 'text-align:right');
-			form_selectable_cell($tree['sites'] > 0 ? number_format_i18n($tree['sites'], '-1'):'-', $tree['id'], '', 'text-align:right');
-			form_selectable_cell($tree['branches'] > 0 ? number_format_i18n($tree['branches'], '-1'):'-', $tree['id'], '', 'text-align:right');
-			form_selectable_cell($tree['hosts'] > 0 ? number_format_i18n($tree['hosts'], '-1'):'-', $tree['id'], '', 'text-align:right');
-			form_selectable_cell($tree['graphs'] > 0 ? number_format_i18n($tree['graphs'], '-1'):'-', $tree['id'], '', 'text-align:right');
+			form_selectable_cell(substr($tree['last_modified'],0,16), $tree['id'], '', 'right');
+			form_selectable_cell(get_username($tree['modified_by']), $tree['id'], '', 'right');
+			form_selectable_cell($tree['sites'] > 0 ? number_format_i18n($tree['sites'], '-1'):'-', $tree['id'], '', 'right');
+			form_selectable_cell($tree['branches'] > 0 ? number_format_i18n($tree['branches'], '-1'):'-', $tree['id'], '', 'right');
+			form_selectable_cell($tree['hosts'] > 0 ? number_format_i18n($tree['hosts'], '-1'):'-', $tree['id'], '', 'right');
+			form_selectable_cell($tree['graphs'] > 0 ? number_format_i18n($tree['graphs'], '-1'):'-', $tree['id'], '', 'right');
 			form_checkbox_cell($tree['name'], $tree['id']);
 			form_end_row();
 
 			$i++;
 		}
diff --git a/user_admin.php b/user_admin.php
index 602d4c05ff..3cd348ed9e 100644
--- a/user_admin.php
+++ b/user_admin.php
@@ -1239,11 +1239,11 @@ function graph_perms_edit($tab, $header_label) {
 
 		if (cacti_sizeof($hosts)) {
 			foreach ($hosts as $host) {
 				form_alternate_row('line' . $host['id'], true);
 				form_selectable_cell(filter_value($host['description'], get_request_var('filter')), $host['id']);
-				form_selectable_cell(round(($host['id']), 2), $host['id']);
+				form_selectable_cell($host['id'], $host['id']);
 				if (empty($host['user_id']) || $host['user_id'] == NULL) {
 					if ($policy['policy_hosts'] == 1) {
 						form_selectable_cell('<span class="accessGranted">' . __('Access Granted') . '</span>', $host['id']);
 					} else {
 						form_selectable_cell('<span class="accessRestricted">' . __('Access Restricted') . '</span>', $host['id']);
diff --git a/user_domains.php b/user_domains.php
index 212b4c56cb..e269fb1c74 100644
--- a/user_domains.php
+++ b/user_domains.php
@@ -758,13 +758,13 @@ function domains() {
 			/* hide system types */
 			form_alternate_row('line' . $domain['domain_id'], true);
 			form_selectable_cell(filter_value($domain['domain_name'], get_request_var('filter'), 'user_domains.php?action=edit&domain_id=' . $domain['domain_id']), $domain['domain_id']);
 			form_selectable_cell($domain_types[$domain['type']], $domain['domain_id']);
 			form_selectable_cell(($domain['defdomain'] == '0' ? '--': __('Yes') ), $domain['domain_id']);
-			form_selectable_cell(($domain['user_id'] == '0' ? __('None Selected') : db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($domain['user_id']))), $domain['domain_id']);
-			form_selectable_cell(db_fetch_cell_prepared('SELECT cn_full_name FROM user_domains_ldap WHERE domain_id = ?', array($domain['domain_id'])), $domain['domain_id']);
-			form_selectable_cell(db_fetch_cell_prepared('SELECT cn_email FROM user_domains_ldap WHERE domain_id = ?', array($domain['domain_id'])), $domain['domain_id']);
+			form_selectable_ecell(($domain['user_id'] == '0' ? __('None Selected') : db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($domain['user_id']))), $domain['domain_id']);
+			form_selectable_ecell(db_fetch_cell_prepared('SELECT cn_full_name FROM user_domains_ldap WHERE domain_id = ?', array($domain['domain_id'])), $domain['domain_id']);
+			form_selectable_ecell(db_fetch_cell_prepared('SELECT cn_email FROM user_domains_ldap WHERE domain_id = ?', array($domain['domain_id'])), $domain['domain_id']);
 			form_selectable_cell($domain['enabled'] == 'on' ? __('Yes'):__('No'), $domain['domain_id']);
 			form_checkbox_cell($domain['domain_name'], $domain['domain_id']);
 			form_end_row();
 		}
 	} else {
diff --git a/user_group_admin.php b/user_group_admin.php
index 5510effaf6..931e819f50 100644
--- a/user_group_admin.php
+++ b/user_group_admin.php
@@ -686,11 +686,11 @@ function user_group_members_edit($header_label) {
 			if (user_group_is_member($g['id'], get_request_var('id'))) {
 				form_selectable_cell('<span class="accessGranted">' . __('Group Member') . '</span>', $g['id']);
 			} else {
 				form_selectable_cell('<span class="accessRestricted">' . __('Non Member') . '</span>', $g['id']);
 			}
-			form_selectable_cell(($g['enabled'] == 'on' ? __('Enabled'): __('Disabled') ), $g['id']);
+			form_selectable_cell(($g['enabled'] == 'on' ? __('Enabled'):__('Disabled') ), $g['id']);
 			form_selectable_cell((isset($auth_realms[$g['realm']]) ? $auth_realms[$g['realm']]:'Unknown'), $g['id']);
 			form_checkbox_cell($g['full_name'], $g['id']);
 			form_end_row();
 		}
 	} else {
@@ -973,11 +973,11 @@ function user_group_graph_perms_edit($tab, $header_label) {
 
 		if (cacti_sizeof($hosts)) {
 			foreach ($hosts as $host) {
 				form_alternate_row('line' . $host['id'], true);
 				form_selectable_cell(filter_value($host['description'], get_request_var('filter')), $host['id']);
-				form_selectable_cell(round(($host['id']), 2), $host['id']);
+				form_selectable_cell($host['id'], $host['id']);
 				if (empty($host['group_id']) || $host['group_id'] == NULL) {
 					if ($policy['policy_hosts'] == 1) {
 						form_selectable_cell('<span class="accessGranted">' . __('Access Granted') . '</span>', $host['id']);
 					} else {
 						form_selectable_cell('<span class="accessRestricted">' . __('Access Restricted') . '</span>', $host['id']);
diff --git a/utilities.php b/utilities.php
index 215786e2b0..12628666d3 100644
--- a/utilities.php
+++ b/utilities.php
@@ -2479,20 +2479,20 @@ function snmpagent_utilities_run_cache() {
 			$name       = filter_value($item['name'], get_request_var('filter'));
 			$mib        = filter_value($item['mib'], get_request_var('filter'));
 			$max_access = filter_value($item['max-access'], get_request_var('filter'));
 
 			form_alternate_row('line' . $item['oid'], false);
-			form_selectable_cell( $oid, $item['oid']);
+			form_selectable_cell($oid, $item['oid']);
 			if($item['description']) {
 				print '<td><a href="#" title="<div class=\'header\'>' . $name . '</div><div class=\'content preformatted\'>' . html_escape($item['description']) . '</div>" class="tooltip">' . $name . '</a></td>';
 			}else {
 				print "<td>$name</td>";
 			}
 			form_selectable_cell($mib, $item['oid']);
 			form_selectable_cell($item['kind'], $item['oid']);
 			form_selectable_cell($max_access, $item['oid']);
-			form_selectable_cell((in_array($item['kind'], array(__('Scalar'), __('Column Data'))) ? $item['value'] : __('N/A')), $item['oid']);
+			form_selectable_ecell((in_array($item['kind'], array(__('Scalar'), __('Column Data'))) ? $item['value'] : __('N/A')), $item['oid']);
 			form_end_row();
 		}
 	}
 
 	html_end_box();
diff --git a/vdef.php b/vdef.php
index 6fa3a969c7..b745317f58 100644
--- a/vdef.php
+++ b/vdef.php
@@ -97,11 +97,11 @@ switch (get_request_var('action')) {
 
 function draw_vdef_preview($vdef_id) {
 	?>
 	<tr class='even'>
 		<td style='padding:4px'>
-			<pre>vdef=<?php print get_vdef($vdef_id, true);?></pre>
+			<pre>vdef=<?php print html_escape(get_vdef($vdef_id, true));?></pre>
 		</td>
 	</tr>
 	<?php
 }
 
@@ -402,11 +402,11 @@ function vdef_item_edit() {
 		$header_label = __('VDEF Items [edit: %s]', html_escape($name));
 	}else {
 		$header_label = __('VDEF Items [new]');
 	}
 
-	form_start('vdef.php', 'form_vdef');
+	form_start('vdef.php', 'chk');
 
 	html_start_box($header_label, '100%', '', '3', 'center', '');
 
 	if (isset_request_var('type_select')) {
 		$current_type = get_request_var('type_select');
@@ -895,13 +895,13 @@ function vdef($refresh = true) {
                 $disabled = true;
             }
 
             form_alternate_row('line' . $vdef['id'], false, $disabled);
 			form_selectable_cell(filter_value($vdef['name'], get_request_var('filter'), 'vdef.php?action=edit&id=' . $vdef['id']), $vdef['id']);
-            form_selectable_cell($disabled ? __('No'):__('Yes'), $vdef['id'], '', 'text-align:right');
-            form_selectable_cell(number_format_i18n($vdef['graphs'], '-1'), $vdef['id'], '', 'text-align:right');
-            form_selectable_cell(number_format_i18n($vdef['templates'], '-1'), $vdef['id'], '', 'text-align:right');
+            form_selectable_cell($disabled ? __('No'):__('Yes'), $vdef['id'], '', 'right');
+            form_selectable_cell(number_format_i18n($vdef['graphs'], '-1'), $vdef['id'], '', 'right');
+            form_selectable_cell(number_format_i18n($vdef['templates'], '-1'), $vdef['id'], '', 'right');
             form_checkbox_cell($vdef['name'], $vdef['id'], $disabled);
             form_end_row();
         }
     } else {
         print "<tr class='tableRow'><td colspan='4'><em>" . __('No VDEFs') . "</em></td></tr>\n";

Vulnerable code: 				form_selectable_cell(get_request_var('rfilter') != '' ? aggregate_format_text(html_escape($graph['title_cache']), get_request_var('rfilter')) : html_escape($graph['title_cache']), $graph['local_graph_id']);
			form_selectable_cell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
			form_selectable_cell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
			form_selectable_cell($disabled ? 'No':'Yes', $template['id'], '', 'text-align:right');
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('aggregate_graphs.php?reset=true&template_id=' . $template['id']) . '">' . number_format_i18n($template['graphs'], '-1') . '</a>', $template['id'], '', 'text-align:right;');
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('automation_networks.php?action=edit&id=' . $network['id']) . '">' . $network['name'] . '</a>', $network['id']);
			form_selectable_cell($network['data_collector'], $network['id']);
			form_selectable_cell(number_format_i18n($network['total_ips']), $network['id'], '', 'text-align:right;');
			form_selectable_cell($mystat, $network['id'], '', 'text-align:right;');
			form_selectable_cell($progress, $network['id'], '', 'text-align:right;');
			form_selectable_cell(number_format_i18n($updown['up']) . '/' . number_format_i18n($updown['snmp']), $network['id'], '', 'text-align:right;');
			form_selectable_cell(number_format_i18n($network['threads']), $network['id'], '', 'text-align:right;');
			form_selectable_cell(round($network['last_runtime'],2), $network['id'], '', 'text-align:right;');
			form_selectable_cell($network['enabled'] == '' || $network['sched_type'] == '1' ? __('N/A'):($network['next_start'] == '0000-00-00 00:00:00' ? substr($network['start_at'],0,16):substr($network['next_start'],0,16)), $network['id'], '', 'text-align:right;');
			form_selectable_cell($network['last_started'] == '0000-00-00 00:00:00' ? 'Never':substr($network['last_started'],0,16), $network['id'], '', 'text-align:right;');
			$subtree_name = ((empty($automation_tree_rule['subtree_name'])) ? '<em>' . __('ROOT') . '</em>' : $automation_tree_rule['subtree_name']);
			form_selectable_cell($automation_tree_rule['tree_name'], $automation_tree_rule['id']);
			<pre>cdef=<?php print get_cdef($cdef_id, true);?></pre>
	form_start('cdef.php', 'form_cdef');
			form_selectable_cell($disabled ? __('No') : __('Yes'), $cdef['id'], '', 'text-align:right');
			form_selectable_cell(number_format_i18n($cdef['graphs'], '-1'), $cdef['id'], '', 'text-align:right');
			form_selectable_cell(number_format_i18n($cdef['templates'], '-1'), $cdef['id'], '', 'text-align:right');
			form_selectable_cell($disabled ? __('No') : __('Yes'), $template['color_template_id'], '', 'text-align:right');
            form_selectable_cell(number_format_i18n($template['graphs']), $template['color_template_id'], '', 'text-align:right;');
            form_selectable_cell(number_format_i18n($template['templates']), $template['color_template_id'], '', 'text-align:right;');
			form_selectable_cell('<a class="linkEditMain" title="' . $title .'" href="' . htmlspecialchars('data_debug.php?action=view&id=' . $check['id']) . '">' . $name . '</a>', $check['id']);
			form_selectable_cell($user, $check['id']);
			form_selectable_cell($check['datasource'], $check['id']);
			form_selectable_cell(debug_icon(($check['done'] ? (strlen($issue_line) ? 'off' : 'on' ) : '')), $check['id'], '', 'text-align: center;');
			form_selectable_cell(debug_icon($info['rrd_writable']), $check['id'], '', 'text-align: center;');
			form_selectable_cell(debug_icon($info['rrd_exists']), $check['id'], '', 'text-align: center;');
			form_selectable_cell(debug_icon($info['active']), $check['id'], '', 'text-align: center;');
			form_selectable_cell(debug_icon($info['rrd_match']), $check['id'], '', 'text-align: center;');
			form_selectable_cell(debug_icon($info['valid_data']), $check['id'], '', 'text-align: center;');
			form_selectable_cell(debug_icon(($info['rra_timestamp2'] != '' ? 1 : '')), $check['id'], '', 'text-align: center;');
			form_selectable_cell('<a class=\'linkEditMain\' href=\'#\' title="' . html_escape($issue_title) . '">' . html_escape(strlen(trim($issue_line)) ? $issue_line : '<none>') . '</a>', $check['id']);
		form_selectable_cell($field['title'], $i);
		$value = '<not set>';
		form_selectable_cell($value, $i, '', '', $value_title);

/*
	print "<pre>";
	if (isset($check) && is_array($check)) {
		print_r($check);
	}
	print "</pre>";
*/

			form_selectable_cell($disabled ? __('No'): __('Yes'), $data_input['id'],'', 'text-align:right');
			form_selectable_cell(number_format_i18n($data_input['data_sources'], '-1'), $data_input['id'],'', 'text-align:right');
			form_selectable_cell(number_format_i18n($data_input['templates'], '-1'), $data_input['id'],'', 'text-align:right');
			form_selectable_cell($snmp_query['id'], $snmp_query['id'], '', 'text-align:right;');
			form_selectable_cell($disabled ? __('No') : __('Yes'), $snmp_query['id'], '', 'text-align:right');
			form_selectable_cell(number_format_i18n($snmp_query['graphs'], '-1'), $snmp_query['id'], '', 'text-align:right');
			form_selectable_cell(number_format_i18n($snmp_query['templates'], '-1'), $snmp_query['id'], '', 'text-align:right');
			form_selectable_cell($profile['default'] == 'on' ? __('Yes'):'', $profile['id'], '', 'text-align:right');
			form_selectable_cell($disabled ? __('No') : __('Yes'), $profile['id'], '', 'text-align:right');
			form_selectable_cell($readonly ? __('Yes') : __('No'), $profile['id'], '', 'text-align:right');
			form_selectable_cell($sampling_intervals[$profile['step']], $profile['id'], '', 'text-align:right');
			form_selectable_cell($heartbeats[$profile['heartbeat']], $profile['id'], '', 'text-align:right');
			form_selectable_cell($ds, $profile['id'], '', 'text-align:right');
			form_selectable_cell($dt, $profile['id'], '', 'text-align:right');
			form_selectable_cell($data_source['local_data_id'], $data_source['local_data_id'], '', 'text-align:right');
			form_selectable_cell(($data_source['active'] == 'on' ? __('Yes') : __('No')), $data_source['local_data_id']);
			form_selectable_cell($template['id'], $template['id'], '', 'text-align:right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'text-align:right');
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('data_sources.php?reset=true&template_id=' . $template['id']) . '">' . number_format_i18n($template['data_sources']) . '</a>', $template['id'], '', 'text-align:right');
            form_selectable_cell($gp['gprint_text'], $gp['id'], '', 'text-align:right');
            form_selectable_cell($disabled ? __('No'):__('Yes'), $gp['id'], '', 'text-align:right');
            form_selectable_cell(number_format_i18n($gp['graphs'], '-1'), $gp['id'], '', 'text-align:right');
            form_selectable_cell(number_format_i18n($gp['templates'], '-1'), $gp['id'], '', 'text-align:right');
			form_selectable_cell($template['id'], $template['id'], '', 'text-align:right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'text-align:right');
			form_selectable_cell(number_format_i18n($template['graphs'], '-1'), $template['id'], '', 'text-align:right');
			form_selectable_cell($template['size'], $template['id'], '', 'text-align:right');
			form_selectable_cell($image_types[$template['image_format_id']], $template['id'], '', 'text-align:right');
			form_selectable_cell($template['vertical_label'], $template['id'], '', 'text-align:right');
			form_selectable_cell($graph['description'], $graph['local_graph_id']);
			form_selectable_cell($graph['template_name'], $graph['local_graph_id']);
			form_selectable_cell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id']);
			form_selectable_cell($graph['local_graph_id'], $graph['local_graph_id'], '', 'text-align:right');
			form_selectable_cell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
			form_selectable_cell($template['id'], $template['id'], '', 'text-align:right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'text-align:right');
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('host.php?reset=true&host_template_id=' . $template['id']) . '">' . number_format_i18n($template['hosts'], '-1') . '</a>', $template['id'], '', 'text-align:right');
					form_selectable_cell($report['full_name'], $report['id']);
			form_selectable_cell($report['from_name'], $report['id']);
			form_selectable_cell((substr_count($report['email'], ',') ? __('Multiple'): $report['email']), $report['id']);
			form_selectable_cell($report['enabled'] ? __('Enabled'): __('Disabled'), $report['id']);
			form_selectable_cell(html_escape($page['contentfile']), $page['id']);
			form_selectable_cell(html_escape($page['title']), $page['id']);
			form_selectable_cell(html_escape($style_translate[$page['style']]) . ($page['style'] == 'CONSOLE' ? ' ( ' . ($page['extendedstyle'] == '' ? 'External Links':$page['extendedstyle']) . ' )':''), $page['id']);
			form_selectable_cell(($page['enabled'] == 'on' ? 'Yes':'No'), $page['id']);
	global $manager_actions, $item_rows;
			form_selectable_cell('<a class="linkEditMain" href="managers.php?action=edit&id=' . $item['id'] . '">' . $description . '</a>', $item['id']);
			form_selectable_cell($hostname, $item['id']);
			form_selectable_cell('<a class="linkEditMain" href="managers.php?action=edit&tab=notifications&id=' . $item['id'] . '">' . ($item['count_notify'] ? $item['count_notify'] : 0) . '</a>' , $item['id']);
			form_selectable_cell('<a class="linkEditMain" href="managers.php?action=edit&tab=logs&id=' . $item['id'] . '">' . ($item['count_log'] ? $item['count_log'] : 0 ) . '</a>', $item['id']);
			form_selectable_cell(((isset($notifications[$item['mib']]) && isset($notifications[$item['mib']][$item['name']])) ? '<span class="deviceUp">' .__('Enabled') : '<span class="deviceDown">' .  __('Disabled')) . '</span>', $row_id);
			$devices_url = $config['url_path'] . 'host.php?reset=1&site_id=' . $site['id'];
			form_selectable_cell($site['city'], $site['id'], '', 'left');
			form_selectable_cell($site['state'], $site['id'], '', 'left');
			form_selectable_cell($site['country'], $site['id'], '', 'left');
			form_selectable_cell($tree['id'], $tree['id'], '', 'text-align:right');
			form_selectable_cell(substr($tree['last_modified'],0,16), $tree['id'], '', 'text-align:right');
			form_selectable_cell(get_username($tree['modified_by']), $tree['id'], '', 'text-align:right');
			form_selectable_cell($tree['sites'] > 0 ? number_format_i18n($tree['sites'], '-1'):'-', $tree['id'], '', 'text-align:right');
			form_selectable_cell($tree['branches'] > 0 ? number_format_i18n($tree['branches'], '-1'):'-', $tree['id'], '', 'text-align:right');
			form_selectable_cell($tree['hosts'] > 0 ? number_format_i18n($tree['hosts'], '-1'):'-', $tree['id'], '', 'text-align:right');
			form_selectable_cell($tree['graphs'] > 0 ? number_format_i18n($tree['graphs'], '-1'):'-', $tree['id'], '', 'text-align:right');
				form_selectable_cell(round(($host['id']), 2), $host['id']);
			form_selectable_cell(($domain['user_id'] == '0' ? __('None Selected') : db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($domain['user_id']))), $domain['domain_id']);
			form_selectable_cell(db_fetch_cell_prepared('SELECT cn_full_name FROM user_domains_ldap WHERE domain_id = ?', array($domain['domain_id'])), $domain['domain_id']);
			form_selectable_cell(db_fetch_cell_prepared('SELECT cn_email FROM user_domains_ldap WHERE domain_id = ?', array($domain['domain_id'])), $domain['domain_id']);
			form_selectable_cell(($g['enabled'] == 'on' ? __('Enabled'): __('Disabled') ), $g['id']);
				form_selectable_cell(round(($host['id']), 2), $host['id']);
			form_selectable_cell( $oid, $item['oid']);
			form_selectable_cell((in_array($item['kind'], array(__('Scalar'), __('Column Data'))) ? $item['value'] : __('N/A')), $item['oid']);
			<pre>vdef=<?php print get_vdef($vdef_id, true);?></pre>
	form_start('vdef.php', 'form_vdef');
            form_selectable_cell($disabled ? __('No'):__('Yes'), $vdef['id'], '', 'text-align:right');
            form_selectable_cell(number_format_i18n($vdef['graphs'], '-1'), $vdef['id'], '', 'text-align:right');
            form_selectable_cell(number_format_i18n($vdef['templates'], '-1'), $vdef['id'], '', 'text-align:right');
Fixed code: -issue#2213: Stored XSS in "Website Hostname" field - Devices
-issue#2214: Stored XSS in "Vertical Label" field - Graph
-issue#2215: Stored XSS in "Name" field - Color 
				form_selectable_ecell(get_request_var('rfilter') != '' ? aggregate_format_text($graph['title_cache'], get_request_var('rfilter')) : $graph['title_cache'], $graph['local_graph_id']);
			form_selectable_ecell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
			form_selectable_ecell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'right');
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('aggregate_graphs.php?reset=true&template_id=' . $template['id']) . '">' . number_format_i18n($template['graphs'], '-1') . '</a>', $template['id'], '', 'right');
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('automation_networks.php?action=edit&id=' . $network['id']) . '">' . html_escape($network['name']) . '</a>', $network['id']);
			form_selectable_ecell($network['data_collector'], $network['id']);
			form_selectable_cell(number_format_i18n($network['total_ips']), $network['id'], '', 'right');
			form_selectable_cell($mystat, $network['id'], '', 'right');
			form_selectable_cell($progress, $network['id'], '', 'right');
			form_selectable_cell(number_format_i18n($updown['up']) . '/' . number_format_i18n($updown['snmp']), $network['id'], '', 'right');
			form_selectable_cell(number_format_i18n($network['threads']), $network['id'], '', 'right');
			form_selectable_cell(round($network['last_runtime'],2), $network['id'], '', 'right');
			form_selectable_cell($network['enabled'] == '' || $network['sched_type'] == '1' ? __('N/A'):($network['next_start'] == '0000-00-00 00:00:00' ? substr($network['start_at'],0,16):substr($network['next_start'],0,16)), $network['id'], '', 'right');
			form_selectable_cell($network['last_started'] == '0000-00-00 00:00:00' ? __('Never'):substr($network['last_started'],0,16), $network['id'], '', 'right');
			$subtree_name = ((empty($automation_tree_rule['subtree_name'])) ? '<em>' . __('ROOT') . '</em>' : html_escape($automation_tree_rule['subtree_name']));
			form_selectable_ecell($automation_tree_rule['tree_name'], $automation_tree_rule['id']);
			<pre>cdef=<?php print html_escape(get_cdef($cdef_id, true));?></pre>
	form_start('cdef.php', 'chk');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $cdef['id'], '', 'right');
			form_selectable_cell(number_format_i18n($cdef['graphs'], '-1'), $cdef['id'], '', 'right');
			form_selectable_cell(number_format_i18n($cdef['templates'], '-1'), $cdef['id'], '', 'right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['color_template_id'], '', 'right');
			form_selectable_cell(number_format_i18n($template['graphs']), $template['color_template_id'], '', 'right');
			form_selectable_cell(number_format_i18n($template['templates']), $template['color_template_id'], '', 'right');
			form_selectable_cell('<a class="linkEditMain" title="' . $title .'" href="' . html_escape('data_debug.php?action=view&id=' . $check['id']) . '">' . html_escape($name) . '</a>', $check['id']);
			form_selectable_ecell($user, $check['id']);
			form_selectable_ecell($check['datasource'], $check['id']);
			form_selectable_cell(debug_icon(($check['done'] ? (strlen($issue_line) ? 'off' : 'on' ) : '')), $check['id'], '', 'center');
			form_selectable_cell(debug_icon($info['rrd_writable']), $check['id'], '', 'center');
			form_selectable_cell(debug_icon($info['rrd_exists']), $check['id'], '', 'center');
			form_selectable_cell(debug_icon($info['active']), $check['id'], '', 'center');
			form_selectable_cell(debug_icon($info['rrd_match']), $check['id'], '', 'center');
			form_selectable_cell(debug_icon($info['valid_data']), $check['id'], '', 'center');
			form_selectable_cell(debug_icon(($info['rra_timestamp2'] != '' ? 1 : '')), $check['id'], '', 'center');
			form_selectable_cell('<a class=\'linkEditMain\' href=\'#\' title="' . html_escape($issue_title) . '">' . html_escape(strlen(trim($issue_line)) ? $issue_line : __('<none>')) . '</a>', $check['id']);
		form_selectable_ecell($field['title'], $i);
		$value = __('<not set>');
		form_selectable_ecell($value, $i, '', '', $value_title);
			form_selectable_cell($disabled ? __('No'):__('Yes'), $data_input['id'],'', 'right');
			form_selectable_cell(number_format_i18n($data_input['data_sources'], '-1'), $data_input['id'],'', 'right');
			form_selectable_cell(number_format_i18n($data_input['templates'], '-1'), $data_input['id'],'', 'right');
			form_selectable_cell($snmp_query['id'], $snmp_query['id'], '', 'right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $snmp_query['id'], '', 'right');
			form_selectable_cell(number_format_i18n($snmp_query['graphs'], '-1'), $snmp_query['id'], '', 'right');
			form_selectable_cell(number_format_i18n($snmp_query['templates'], '-1'), $snmp_query['id'], '', 'right');
			form_selectable_cell($profile['default'] == 'on' ? __('Yes'):'', $profile['id'], '', 'right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $profile['id'], '', 'right');
			form_selectable_cell($readonly ? __('Yes'):__('No'), $profile['id'], '', 'right');
			form_selectable_cell($sampling_intervals[$profile['step']], $profile['id'], '', 'right');
			form_selectable_cell($heartbeats[$profile['heartbeat']], $profile['id'], '', 'right');
			form_selectable_cell($ds, $profile['id'], '', 'right');
			form_selectable_cell($dt, $profile['id'], '', 'right');
			form_selectable_cell($data_source['local_data_id'], $data_source['local_data_id'], '', 'right');
			form_selectable_cell(($data_source['active'] == 'on' ? __('Yes'):__('No')), $data_source['local_data_id']);
			form_selectable_cell($template['id'], $template['id'], '', 'right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'right');
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('data_sources.php?reset=true&template_id=' . $template['id']) . '">' . number_format_i18n($template['data_sources']) . '</a>', $template['id'], '', 'right');
            form_selectable_cell($gp['gprint_text'], $gp['id'], '', 'right');
            form_selectable_cell($disabled ? __('No'):__('Yes'), $gp['id'], '', 'right');
            form_selectable_cell(number_format_i18n($gp['graphs'], '-1'), $gp['id'], '', 'right');
            form_selectable_cell(number_format_i18n($gp['templates'], '-1'), $gp['id'], '', 'right');
			form_selectable_cell($template['id'], $template['id'], '', 'right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'right');
			form_selectable_cell(number_format_i18n($template['graphs'], '-1'), $template['id'], '', 'right');
			form_selectable_ecell($template['size'], $template['id'], '', 'right');
			form_selectable_cell($image_types[$template['image_format_id']], $template['id'], '', 'right');
			form_selectable_ecell($template['vertical_label'], $template['id'], '', 'right');
			form_selectable_ecell($graph['description'], $graph['local_graph_id']);
			form_selectable_ecell($graph['template_name'], $graph['local_graph_id']);
			form_selectable_ecell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id']);
			form_selectable_cell($graph['local_graph_id'], $graph['local_graph_id'], '', 'right');
			form_selectable_ecell($graph['height'] . 'x' . $graph['width'], $graph['local_graph_id'], '', 'right');
			form_selectable_cell($template['id'], $template['id'], '', 'right');
			form_selectable_cell($disabled ? __('No'):__('Yes'), $template['id'], '', 'right');
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape('host.php?reset=true&host_template_id=' . $template['id']) . '">' . number_format_i18n($template['hosts'], '-1') . '</a>', $template['id'], '', 'right');
					form_selectable_ecell($report['full_name'], $report['id']);
			form_selectable_ecell($report['from_name'], $report['id']);
			form_selectable_ecell((substr_count($report['email'], ',') ? __('Multiple'): $report['email']), $report['id']);
			form_selectable_cell($report['enabled'] ? __('Enabled'):__('Disabled'), $report['id']);
/* form_selectable_ecell - a wrapper to form_selectable_cell that escapes the contents
   @arg $contents - the readable portion of the
   @arg $id - the id of the object that will be highlighted
   @arg $width - the width of the table element
   @arg $style_or_class - the style or class to apply to the table element
   @arg $title - optional title for the column */
function form_selectable_ecell($contents, $id, $width = '', $style_or_class = '', $title = '') {
	form_selectable_cell(html_escape($contents), $id, $width, $style_or_class, $title);
}

			form_selectable_ecell($page['contentfile'], $page['id']);
			form_selectable_ecell($page['title'], $page['id']);
			form_selectable_ecell($style_translate[$page['style']] . ($page['style'] == 'CONSOLE' ? ' ( ' . ($page['extendedstyle'] == '' ? __('External Links'):$page['extendedstyle']) . ' )':''), $page['id']);
			form_selectable_cell(($page['enabled'] == 'on' ? __('Yes'):__('No')), $page['id']);
	global $config, $manager_actions, $item_rows;
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape($config['url_path'] . 'managers.php?action=edit&id=' . $item['id']) . '">' . html_escape($description) . '</a>', $item['id']);
			form_selectable_ecell($hostname, $item['id']);
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape($config['url_path'] . 'managers.php?action=edit&tab=notifications&id=' . $item['id']) . '">' . ($item['count_notify'] ? $item['count_notify'] : 0) . '</a>' , $item['id']);
			form_selectable_cell('<a class="linkEditMain" href="' . html_escape($config['url_path'] . 'managers.php?action=edit&tab=logs&id=' . $item['id']) . '">' . ($item['count_log'] ? $item['count_log'] : 0 ) . '</a>', $item['id']);
			form_selectable_cell(((isset($notifications[$item['mib']]) && isset($notifications[$item['mib']][$item['name']])) ? '<span class="deviceUp">' . __('Enabled'):'<span class="deviceDown">' . __('Disabled')) . '</span>', $row_id);
			$devices_url = html_escape($config['url_path'] . 'host.php?reset=1&site_id=' . $site['id']);
			form_selectable_ecell($site['city'], $site['id'], '', 'left');
			form_selectable_ecell($site['state'], $site['id'], '', 'left');
			form_selectable_ecell($site['country'], $site['id'], '', 'left');
			form_selectable_cell($tree['id'], $tree['id'], '', 'right');
			form_selectable_cell(substr($tree['last_modified'],0,16), $tree['id'], '', 'right');
			form_selectable_cell(get_username($tree['modified_by']), $tree['id'], '', 'right');
			form_selectable_cell($tree['sites'] > 0 ? number_format_i18n($tree['sites'], '-1'):'-', $tree['id'], '', 'right');
			form_selectable_cell($tree['branches'] > 0 ? number_format_i18n($tree['branches'], '-1'):'-', $tree['id'], '', 'right');
			form_selectable_cell($tree['hosts'] > 0 ? number_format_i18n($tree['hosts'], '-1'):'-', $tree['id'], '', 'right');
			form_selectable_cell($tree['graphs'] > 0 ? number_format_i18n($tree['graphs'], '-1'):'-', $tree['id'], '', 'right');
				form_selectable_cell($host['id'], $host['id']);
			form_selectable_ecell(($domain['user_id'] == '0' ? __('None Selected') : db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($domain['user_id']))), $domain['domain_id']);
			form_selectable_ecell(db_fetch_cell_prepared('SELECT cn_full_name FROM user_domains_ldap WHERE domain_id = ?', array($domain['domain_id'])), $domain['domain_id']);
			form_selectable_ecell(db_fetch_cell_prepared('SELECT cn_email FROM user_domains_ldap WHERE domain_id = ?', array($domain['domain_id'])), $domain['domain_id']);
			form_selectable_cell(($g['enabled'] == 'on' ? __('Enabled'):__('Disabled') ), $g['id']);
				form_selectable_cell($host['id'], $host['id']);
			form_selectable_cell($oid, $item['oid']);
			form_selectable_ecell((in_array($item['kind'], array(__('Scalar'), __('Column Data'))) ? $item['value'] : __('N/A')), $item['oid']);
			<pre>vdef=<?php print html_escape(get_vdef($vdef_id, true));?></pre>
	form_start('vdef.php', 'chk');
            form_selectable_cell($disabled ? __('No'):__('Yes'), $vdef['id'], '', 'right');
            form_selectable_cell(number_format_i18n($vdef['graphs'], '-1'), $vdef['id'], '', 'right');
            form_selectable_cell(number_format_i18n($vdef['templates'], '-1'), $vdef['id'], '', 'right');