Пример #1
0
function update_show_current()
{
    global $plugins, $pluginslist, $plugin_architecture, $config, $status_names, $actions, $item_rows;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("page"));
    input_validate_input_number(get_request_var_request("rows"));
    /* ==================================================== */
    /* clean up search string */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
    }
    /* clean up sort_column */
    if (isset($_REQUEST["sort_column"])) {
        $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
    }
    /* clean up search string */
    if (isset($_REQUEST["sort_direction"])) {
        $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear_x"])) {
        kill_session_var("sess_plugins_filter");
        kill_session_var("sess_plugins_rows");
        kill_session_var("sess_plugins_sort_column");
        kill_session_var("sess_plugins_sort_direction");
        unset($_REQUEST["page"]);
        unset($_REQUEST["rows"]);
        unset($_REQUEST["filter"]);
        unset($_REQUEST["sort_column"]);
        unset($_REQUEST["sort_direction"]);
        $_REQUEST["page"] = 1;
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("filter", "sess_plugins_filter", "");
    load_current_session_value("rows", "sess_plugins_rows", "-1");
    load_current_session_value("sort_column", "sess_plugins_sort_column", "name");
    load_current_session_value("sort_direction", "sess_plugins_sort_direction", "ASC");
    load_current_session_value("page", "sess_plugins_current_page", "1");
    $table = plugins_load_temp_table();
    ?>
	<script type="text/javascript">
	<!--
	function applyFilterChange(objForm) {
		strURL = '?rows=' + objForm.rows.value;
		strURL = strURL + '&filter=' + objForm.filter.value;
		document.location = strURL;
	}
	-->
	</script>
	<?php 
    html_start_box("<strong>Plugin Management</strong> (Cacti Version: " . $config["cacti_version"] . (isset($plugin_architecture['version']) ? ", Plugin Architecture Version: " . $plugin_architecture['version'] : "") . ")", "100%", "", "3", "center", "");
    ?>
	<tr class='even noprint'>
		<td class="noprint">
		<form name="form_plugins" method="get" action="plugins.php">
			<table cellpadding="0" cellspacing="0">
				<tr class="noprint">
					<td nowrap style='white-space: nowrap;' width="50">
						Search:&nbsp;
					</td>
					<td width="1">
						<input type="text" name="filter" size="40" value="<?php 
    print get_request_var_request("filter");
    ?>
">
					</td>
					<td nowrap style='white-space: nowrap;' width="50">
						&nbsp;Rows:&nbsp;
					</td>
					<td width="1">
						<select name="rows" onChange="applyFilterChange(document.form_plugins)">
							<option value="-1"<?php 
    if (get_request_var_request("rows") == "-1") {
        ?>
 selected<?php 
    }
    ?>
>Default</option>
							<?php 
    if (sizeof($item_rows) > 0) {
        foreach ($item_rows as $key => $value) {
            print "<option value='" . $key . "'";
            if (get_request_var_request("rows") == $key) {
                print " selected";
            }
            print ">" . htmlspecialchars($value) . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td nowrap style='white-space: nowrap;'>
						&nbsp;<input type="submit" value="Go" title="Set/Refresh Filters">
					</td>
					<td nowrap style='white-space: nowrap;'>
						&nbsp;<input type="submit" name="clear_x" value="Clear" title="Clear Filters">
					</td>
				</tr>
			</table>
			<input type='hidden' name='page' value='1'>
		</form>
		</td>
	</tr>
	<?php 
    html_end_box();
    /* print checkbox form for validation */
    print "<form name='chk' method='post' action='plugins.php'>\n";
    html_start_box("", "100%", "", "3", "center", "");
    /* form the 'where' clause for our main sql query */
    $sql_where = "WHERE ({$table}.name LIKE '%%" . get_request_var_request("filter") . "%%')";
    if (get_request_var_request("sort_column") == "version") {
        $sortc = "version+0";
    } else {
        $sortc = get_request_var_request("sort_column");
    }
    if (get_request_var_request("sort_column") == "id") {
        $sortd = "ASC";
    } else {
        $sortd = get_request_var_request("sort_direction");
    }
    if ($_REQUEST['rows'] == '-1') {
        $rows = read_config_option('num_rows_device');
    } else {
        $rows = get_request_var_request('rows');
    }
    $total_rows = db_fetch_cell("SELECT\n\t\tcount(*)\n\t\tFROM {$table}\n\t\t{$sql_where}");
    $plugins = db_fetch_assoc("SELECT *\n\t\tFROM {$table}\n\t\t{$sql_where}\n\t\tORDER BY " . $sortc . " " . $sortd . "\n\t\tLIMIT " . $rows * (get_request_var_request("page") - 1) . "," . $rows);
    db_execute("DROP TABLE {$table}");
    $nav = html_nav_bar("plugins.php?filter=" . get_request_var_request("filter"), MAX_DISPLAY_PAGES, get_request_var_request("page"), $rows, $total_rows, 8);
    print $nav;
    $display_text = array("nosort" => array("Actions", ""), "directory" => array("Name", "ASC"), "version" => array("Version", "ASC"), "id" => array("Load Order", "ASC"), "name" => array("Description", "ASC"), "nosort1" => array("Type", "ASC"), "status" => array("Status", "ASC"), "author" => array("Author", "ASC"));
    html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), 1);
    $i = 0;
    if (sizeof($plugins)) {
        if (get_request_var_request("sort_column") == "id") {
            $inst_system_plugins = get_system_plugins($plugins);
            if (sizeof($inst_system_plugins)) {
                foreach ($inst_system_plugins as $plugin) {
                    form_alternate_row('', true);
                    print format_plugin_row($plugin, false, false, true);
                }
            }
        }
        $j = 0;
        foreach ($plugins as $plugin) {
            if (isset($plugins[$j + 1]) && $plugins[$j + 1]['status'] < 0 || !isset($plugins[$j + 1])) {
                $last_plugin = true;
            } else {
                $last_plugin = false;
            }
            if ($plugin['status'] <= 0 || is_system_plugin($plugin) || get_request_var_request('sort_column') != 'id') {
                $load_ordering = false;
            } else {
                $load_ordering = true;
            }
            if (get_request_var_request("sort_column") == "id") {
                if (!is_system_plugin($plugin)) {
                    form_alternate_row('', true);
                    print format_plugin_row($plugin, $last_plugin, $load_ordering, false);
                    $i++;
                }
            } else {
                form_alternate_row('', true);
                print format_plugin_row($plugin, $last_plugin, $load_ordering, is_system_plugin($plugin));
                $i++;
            }
            $j++;
        }
        print $nav;
    } else {
        print "<tr><td><em>No Plugins Found</em></td></tr>";
    }
    html_end_box(false);
    html_start_box("", "100%", "", "3", "center", "");
    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>";
    html_end_box();
    print "</form>\n";
}
Пример #2
0
function update_show_current()
{
    global $plugins, $pluginslist, $config, $status_names, $actions, $item_rows;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('page'));
    input_validate_input_number(get_request_var_request('rows'));
    input_validate_input_number(get_request_var_request('state'));
    /* ==================================================== */
    /* clean up search string */
    if (isset($_REQUEST['filter'])) {
        $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter'));
    }
    /* clean up sort_column */
    if (isset($_REQUEST['sort_column'])) {
        $_REQUEST['sort_column'] = sanitize_search_string(get_request_var_request('sort_column'));
    }
    /* clean up search string */
    if (isset($_REQUEST['sort_direction'])) {
        $_REQUEST['sort_direction'] = sanitize_search_string(get_request_var_request('sort_direction'));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST['clear_x'])) {
        kill_session_var('sess_plugins_filter');
        kill_session_var('sess_default_rows');
        kill_session_var('sess_plugins_state');
        kill_session_var('sess_plugins_sort_column');
        kill_session_var('sess_plugins_sort_direction');
        unset($_REQUEST['page']);
        unset($_REQUEST['rows']);
        unset($_REQUEST['state']);
        unset($_REQUEST['filter']);
        unset($_REQUEST['sort_column']);
        unset($_REQUEST['sort_direction']);
        $_REQUEST['page'] = 1;
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value('filter', 'sess_plugins_filter', '');
    load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table'));
    load_current_session_value('state', 'sess_plugins_state', '5');
    load_current_session_value('sort_column', 'sess_plugins_sort_column', 'name');
    load_current_session_value('sort_direction', 'sess_plugins_sort_direction', 'ASC');
    load_current_session_value('page', 'sess_plugins_current_page', '1');
    $table = plugins_load_temp_table();
    ?>
	<script type="text/javascript">
	function applyFilter() {
		strURL = 'plugins.php?filter='+$('#filter').val()+'&rows='+$('#rows').val()+'&page='+$('#page').val()+'&state='+$('#state').val()+'&header=false';
		$.get(strURL, function(data) {
			$('#main').html(data);
			applySkin();
		});
	}

	function clearFilter() {
		strURL = 'plugins.php?clear_x=1&header=false';
		$.get(strURL, function(data) {
			$('#main').html(data);
			applySkin();
		});
	}

	$(function() {
		$('#refresh').click(function() {
			applyFilter();
		});

		$('#clear').click(function() {
			clearFilter();
		});

		$('#form_plugins').submit(function(event) {
			event.preventDefault();
			applyFilter();
		});
	});
	</script>
	<?php 
    html_start_box('<strong>Plugin Management</strong> (Cacti Version: ' . $config['cacti_version'] . ')', '100%', '', '3', 'center', '');
    ?>
	<tr class='even noprint'>
		<td class="noprint">
		<form id="form_plugins" method="get" action="plugins.php">
			<table cellpadding="2" cellspacing="0">
				<tr class="noprint">
					<td width="50">
						Search
					</td>
					<td>
						<input id='filter' type="text" name="filter" size="25" value="<?php 
    print get_request_var_request('filter');
    ?>
">
					</td>
					<td>
						Status
					</td>
					<td>
						<select id='state' name="state" onChange="applyFilter()">
							<option value="-3"<?php 
    if (get_request_var_request('state') == '-3') {
        ?>
 selected<?php 
    }
    ?>
>All</option>
							<option value="1"<?php 
    if (get_request_var_request('state') == '1') {
        ?>
 selected<?php 
    }
    ?>
>Active</option>
							<option value="4"<?php 
    if (get_request_var_request('state') == '4') {
        ?>
 selected<?php 
    }
    ?>
>Installed</option>
							<option value="5"<?php 
    if (get_request_var_request('state') == '5') {
        ?>
 selected<?php 
    }
    ?>
>Active/Installed</option>
							<option value="0"<?php 
    if (get_request_var_request('state') == '0') {
        ?>
 selected<?php 
    }
    ?>
>Not Installed</option>
							<option value="-1"<?php 
    if (get_request_var_request('state') == '-1') {
        ?>
 selected<?php 
    }
    ?>
>Legacy Installed</option>
							<option value="-2"<?php 
    if (get_request_var_request('state') == '-2') {
        ?>
 selected<?php 
    }
    ?>
>Legacy Not Intalled</option>
						</select>
					</td>
					<td>
						Plugins
					</td>
					<td>
						<select id='rows' name="rows" onChange="applyFilter()">
							<?php 
    if (sizeof($item_rows) > 0) {
        foreach ($item_rows as $key => $value) {
            print "<option value='" . $key . "'";
            if (get_request_var_request('rows') == $key) {
                print ' selected';
            }
            print '>' . htmlspecialchars($value) . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td>
						<input type="button" id='refresh' value="Go" title="Set/Refresh Filters">
					</td>
					<td>
						<input type="button" id='clear' name="clear_x" value="Clear" title="Clear Filters">
					</td>
				</tr>
			</table>
			<input type='hidden' id='page' name='page' value='<?php 
    print $_REQUEST['page'];
    ?>
'>
		</form>
		</td>
	</tr>
	<?php 
    html_end_box();
    /* print checkbox form for validation */
    print "<form name='chk' method='post' action='plugins.php'>\n";
    html_start_box('', '100%', '', '3', 'center', '');
    $sql_where = '';
    /* form the 'where' clause for our main sql query */
    if (strlen($_REQUEST['filter'])) {
        $sql_where = "WHERE ({$table}.name LIKE '%%" . get_request_var_request('filter') . "%%')";
    }
    if ($_REQUEST['state'] > -3) {
        if ($_REQUEST['state'] == 5) {
            $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' status IN(1,4)';
        } else {
            $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' status=' . $_REQUEST['state'];
        }
    }
    if (get_request_var_request('sort_column') == 'version') {
        $sortc = 'version+0';
    } else {
        $sortc = get_request_var_request('sort_column');
    }
    if (get_request_var_request('sort_column') == 'id') {
        $sortd = 'ASC';
    } else {
        $sortd = get_request_var_request('sort_direction');
    }
    if ($_REQUEST['rows'] == '-1') {
        $rows = read_config_option('num_rows_table');
    } else {
        $rows = get_request_var_request('rows');
    }
    $total_rows = db_fetch_cell("SELECT\n\t\tcount(*)\n\t\tFROM {$table}\n\t\t{$sql_where}");
    $plugins = db_fetch_assoc("SELECT *\n\t\tFROM {$table}\n\t\t{$sql_where}\n\t\tORDER BY " . $sortc . ' ' . $sortd . '
		LIMIT ' . $rows * (get_request_var_request('page') - 1) . ',' . $rows);
    db_execute("DROP TABLE {$table}");
    $nav = html_nav_bar('plugins.php?filter=' . get_request_var_request('filter'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 8, 'Plugins', 'page', 'main');
    print $nav;
    $display_text = array('nosort' => array('display' => 'Actions', 'align' => 'left', 'sort' => '', 'tip' => 'Actions available include "Install", "Activate", "Disable", "Enable", "Uninstall".'), 'directory' => array('display' => 'Plugin Name', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The name for this Plugin.  The name is controlled by the direcotry it resides in.'), 'id' => array('display' => 'Load Order', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The load order of the Plugin.  You can change the load order by first sorting by it, then moving a Plugin either up or down.'), 'name' => array('display' => 'Plugin Description', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'A description that the Plugins author has given to the Plugin.'), 'version' => array('display' => 'Version', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The version of this Plugin.'), 'status' => array('display' => 'Status', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The status of this Plugin.'), 'author' => array('display' => 'Author', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The author of this Plugin.'));
    html_header_sort($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), 1);
    $i = 0;
    if (sizeof($plugins)) {
        $j = 0;
        foreach ($plugins as $plugin) {
            if (isset($plugins[$j + 1]) && $plugins[$j + 1]['status'] < 0 || !isset($plugins[$j + 1])) {
                $last_plugin = true;
            } else {
                $last_plugin = false;
            }
            if ($plugin['status'] <= 0 || get_request_var_request('sort_column') != 'id') {
                $load_ordering = false;
            } else {
                $load_ordering = true;
            }
            form_alternate_row('', true);
            print format_plugin_row($plugin, $last_plugin, $load_ordering);
            $i++;
            $j++;
        }
        print $nav;
    } else {
        print '<tr><td><em>No Plugins Found</em></td></tr>';
    }
    html_end_box(false);
    print "</form>\n";
}