Exemplo n.º 1
0
function template()
{
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate");
    $filter_array = array();
    /* search field: filter (searches template name) */
    if (isset_get_var("search_filter")) {
        $filter_array["template_name"] = get_get_var("search_filter");
    }
    /* get a list of all data templates on this page */
    $data_templates = api_data_template_list($filter_array);
    /* get a list of data input types for display in the data sources list */
    $data_input_types = api_data_source_input_type_list();
    form_start("data_templates.php");
    $box_id = "1";
    html_start_box("<strong>" . _("Data Templates") . "</strong>", "data_templates.php?action=edit");
    html_header_checkbox(array(_("Template Name"), _("Data Input Type"), _("Status")), $box_id);
    $i = 0;
    if (sizeof($data_templates) > 0) {
        foreach ($data_templates as $data_template) {
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_template["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
')">
				<td class="title">
					<a onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
')" href="data_templates.php?action=edit&id=<?php 
            echo $data_template["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $data_template["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $data_template["template_name"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo $data_input_types[$data_template["data_input_type"]];
            ?>
				</td>
				<td>
					<?php 
            if ($data_template["active"] == "1") {
                echo _("Active");
            } else {
                echo _("Disabled");
            }
            ?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_template["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_template["id"];
            ?>
' title="<?php 
            echo $data_template["template_name"];
            ?>
">
				</td>
			</tr>
			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No data templates found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "3", HTML_BOX_SEARCH_NO_ICON);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "data_template_list");
    form_end();
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Data Template');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Data Templates');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php 
}
Exemplo n.º 2
0
 * @copyright This source is distributed under the GPL
 * @file included login page
 * @modifications Cyril Maguire
 */
/* Gutama plugin package
 * @version 1.6
 * @date	01/10/2013
 * @author	Cyril MAGUIRE
*/
gu_theme_messages();
?>

<p>&nbsp;</p>
<div style="text-align: center">
	<form name="login_form" method="post" action="login.php?action=login<?php 
echo is_get_var('ref') ? '&amp;ref=' . urlencode(get_get_var('ref')) : '';
?>
" onsubmit="return loginSubmit(this);">
		<p><?php 
echo t('Username');
?>
<br/><input name="u" type="text" class="textfield" id="u" value="<?php 
echo $name;
?>
" /><br/>
		<?php 
echo t('Password');
?>
<br/><input type="hidden" id="p" name="p" /><input name="dummy_p" type="password" class="textfield" id="dummy_p" />
		</p>
		<p>
Exemplo n.º 3
0
function build_get_url_string($name_list) {
	$url_string = "";

	if (sizeof($name_list) > 0) {
		foreach ($name_list as $get_field_name) {
			if (isset_get_var($get_field_name)) {
				$url_string .= ($url_string == "" ? "?" : "&") . "$get_field_name=" . urlencode(get_get_var($get_field_name));
			}
		}
	}

	return $url_string;
}
Exemplo n.º 4
0
function graph()
{
    $current_page = get_get_var_number("page", "1");
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate", "change_graph_template" => "Change Graph Template", "change_host" => "Change Host", "convert_graph_template" => "Convert to Graph Template", "place_tree" => "Place on Tree");
    $filter_array = array();
    /* search field: device template */
    if (isset_get_var("search_device")) {
        $filter_array["host_id"] = get_get_var("search_device");
    }
    /* search field: filter (searches data source name) */
    if (isset_get_var("search_filter")) {
        $filter_array["filter"] = array("title_cache|title" => get_get_var("search_filter"));
    }
    /* get a list of all graphs on this page */
    $graphs = api_graph_list($filter_array, $current_page, read_config_option("num_rows_data_source"));
    /* get the total number of graphs on all pages */
    $total_rows = api_graph_total_get($filter_array);
    /* generate page list */
    $url_string = build_get_url_string(array("search_device", "search_filter"));
    $url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_graph"), $total_rows, "graphs.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");
    form_start("graphs.php");
    $box_id = "1";
    html_start_box("<strong>" . _("Graphs") . "</strong>", "graphs.php?action=edit", $url_page_select);
    html_header_checkbox(array(_("Graph Title"), _("Template Name"), _("Size")), $box_id);
    $i = 0;
    if (sizeof($graphs) > 0) {
        foreach ($graphs as $graph) {
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $graph["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
')">
				<td class="title">
					<a onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
')" href="graphs.php?action=edit&id=<?php 
            echo $graph["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $graph["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $graph["title_cache"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo empty($graph["template_name"]) ? "<em>" . _("None") . "</em>" : $graph["template_name"];
            ?>
				</td>
				<td>
					<?php 
            echo $graph["height"];
            ?>
x<?php 
            echo $graph["width"];
            ?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $graph["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $graph["id"];
            ?>
' title="<?php 
            echo $graph["title_cache"];
            ?>
">
				</td>
			</tr>
			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No graphs found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "3", sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE, $url_page_select);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "graph_list");
    form_end();
    /* pre-cache the device list since we need it in more than one place below */
    $device_list = array_rekey(api_device_list(), "id", "description");
    /* fill in the list of available devices for the search dropdown */
    $search_devices = array();
    $search_devices["-1"] = "Any";
    $search_devices["0"] = "None";
    $search_devices += $device_list;
    /* fill in the list of available devices for the change host dropdown */
    $change_host_list = array();
    $change_host_list["0"] = "None";
    $change_host_list += $device_list;
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these graphs?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Graph');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these graphs?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Graph');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'search') {
			_elm_dt_input = action_area_generate_select('box-' + box_id + '-search_device');
			<?php 
    echo get_js_dropdown_code('_elm_dt_input', $search_devices, isset_get_var("search_device") ? get_get_var("search_device") : "-1");
    ?>

			_elm_ht_input = action_area_generate_input('text', 'box-' + box_id + '-search_filter', '<?php 
    echo get_get_var("search_filter");
    ?>
');
			_elm_ht_input.size = '30';

			parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'Device', true, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_ht_input, 'Filter', false, true));

			action_area_update_header_caption(box_id, 'Search');
			action_area_update_submit_caption(box_id, 'Search');
		}else if (type == 'change_host') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to change the host for these graphs?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			_elm_dt_input = action_area_generate_select('box-' + box_id + '-change_device');
			<?php 
    echo get_js_dropdown_code('_elm_dt_input', $change_host_list, "0");
    ?>

			parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'New Device', true, true));

			action_area_update_header_caption(box_id, 'Change Host');
			action_area_update_submit_caption(box_id, 'Change');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php 
}
Exemplo n.º 5
0
function host()
{
    $current_page = get_get_var_number("page", "1");
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate", "enable" => "Enable", "disable" => "Disable", "clear_stats" => "Clear Statistics", "change_snmp_opts" => "Change SNMP Options", "change_avail_opts" => "Change Availability Options", "change_poller" => "Change Poller");
    $filter_array = array();
    /* search field: device template */
    if (isset_get_var("search_device_template")) {
        $filter_array["=host_template_id"] = get_get_var("search_device_template");
    }
    /* search field: device status */
    if (isset_get_var("search_status")) {
        $filter_array["=status"] = get_get_var("search_status");
    }
    /* search field: filter (searches device description and hostname) */
    if (isset_get_var("search_filter")) {
        $filter_array["%filter"] = array("hostname" => get_get_var("search_filter"), "description" => get_get_var("search_filter"));
    }
    /* get a list of all devices on this page */
    $devices = api_device_list($filter_array, "description", "asc", read_config_option("num_rows_device") * ($current_page - 1), read_config_option("num_rows_device"));
    /* get the total number of devices on all pages */
    $total_rows = api_device_total_get($filter_array);
    /* generate page list */
    $url_string = build_get_url_string(array("search_device_template", "search_status", "search_filter"));
    $url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "devices.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");
    form_start("devices.php");
    $box_id = "1";
    html_start_box("<strong>" . _("Devices") . "</strong>", "devices.php?action=edit", $url_page_select);
    html_header_checkbox(array(_("Description"), _("Status"), _("Hostname"), _("Current (ms)"), _("Average (ms)"), _("Availability")), $box_id);
    $i = 0;
    if (sizeof($devices) > 0) {
        foreach ($devices as $host) {
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $host["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
')">
				<td class="title">
					<a onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
')" href="devices.php?action=edit&id=<?php 
            echo $host["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $host["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $host["description"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo get_colored_device_status($host["disabled"] == "on" ? true : false, $host["status"]);
            ?>
				</td>
				<td>
					<?php 
            echo html_highlight_words(get_get_var("search_filter"), $host["hostname"]);
            ?>
				</td>
				<td>
					<?php 
            echo round($host["cur_time"], 2);
            ?>
				</td>
				<td>
					<?php 
            echo round($host["avg_time"], 2);
            ?>
				</td>
				<td>
					<?php 
            echo round($host["availability"], 2);
            ?>
%
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $host["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $host["id"];
            ?>
' title="<?php 
            echo $host["description"];
            ?>
">
				</td>
			</tr>
			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No devices found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "6", sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE, $url_page_select);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "device_list");
    form_end();
    /* fill in the list of available device templates for the search dropdown */
    $search_device_templates = array();
    $search_device_templates["-1"] = "Any";
    $search_device_templates["0"] = "None";
    $search_device_templates += array_rekey(api_device_template_list(), "id", "name");
    /* fill in the list of available host status types for the search dropdown */
    $search_host_status_types = array();
    $search_host_status_types["-1"] = "Any";
    $search_host_status_types["-2"] = "Disabled";
    $search_host_status_types += api_device_status_type_list();
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			parent_div.appendChild(action_area_generate_input('radio', 'box-' + box_id + '-remove_type', '1'));
			parent_div.appendChild(document.createTextNode('Leave all graphs and data sources untouched. Data sources will be disabled however.'));
			parent_div.appendChild(action_area_generate_break());

			_elm_rt_input = action_area_generate_input('radio', 'box-' + box_id + '-remove_type', '2');
			_elm_rt_input.checked = true;
			parent_div.appendChild(_elm_rt_input);
			parent_div.appendChild(document.createTextNode("Delete all associated graphs and data sources."));

			action_area_update_header_caption(box_id, 'Remove Device');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Devices');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'enable') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to enable these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Enable Devices');
			action_area_update_submit_caption(box_id, 'Enable');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'disable') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to disable these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Disable Devices');
			action_area_update_submit_caption(box_id, 'Disable');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'clear_stats') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to clear polling statistics for these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Clear Polling Statistics');
			action_area_update_submit_caption(box_id, 'Clear');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'search') {
			_elm_dt_input = action_area_generate_select('box-' + box_id + '-search_device_template');
			<?php 
    echo get_js_dropdown_code('_elm_dt_input', $search_device_templates, isset_get_var("search_device_template") ? get_get_var("search_device_template") : "-1");
    ?>

			_elm_ds_input = action_area_generate_select('box-' + box_id + '-search_status');
			<?php 
    echo get_js_dropdown_code('_elm_ds_input', $search_host_status_types, isset_get_var("search_status") ? get_get_var("search_status") : "-1");
    ?>

			_elm_ht_input = action_area_generate_input('text', 'box-' + box_id + '-search_filter', '<?php 
    echo get_get_var("search_filter");
    ?>
');
			_elm_ht_input.size = '30';

			parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'Device Template', true, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_ds_input, 'Device Status', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_ht_input, 'Filter', false, true));

			action_area_update_header_caption(box_id, 'Search');
			action_area_update_submit_caption(box_id, 'Search');
		}
	}
	-->
	</script>

	<?php 
}
Exemplo n.º 6
0
function data_query_field_edit()
{
    $_data_query_field_id = get_get_var_number("id");
    $_data_query_id = get_get_var_number("data_query_id");
    if (empty($_data_query_field_id)) {
        $header_label = "[new]";
        $_field_type = get_get_var("field_type");
    } else {
        $data_query_field = api_data_query_field_get($_data_query_field_id);
        $_field_type = $data_query_field["type"];
        $header_label = "[edit: " . $data_query_field["name"] . "]";
    }
    $data_query = api_data_query_get($_data_query_id);
    form_start("data_queries.php", "form_data_query");
    html_start_box("<strong>" . _("Data Query Fields") . "</strong> {$header_label}");
    _data_query_field_field__name("name", isset($data_query_field["name"]) ? $data_query_field["name"] : "", isset($data_query_field["id"]) ? $data_query_field["id"] : "0");
    _data_query_field_field__name_desc("name_desc", isset($data_query_field["name_desc"]) ? $data_query_field["name_desc"] : "", isset($data_query_field["id"]) ? $data_query_field["id"] : "0");
    if ($data_query["input_type"] == DATA_QUERY_INPUT_TYPE_SNMP_QUERY) {
        _data_query_field_field__source_snmp("source", isset($data_query_field["source"]) ? $data_query_field["source"] : "", isset($data_query_field["id"]) ? $data_query_field["id"] : "0");
    } else {
        if ($data_query["input_type"] == DATA_QUERY_INPUT_TYPE_SCRIPT_QUERY || $data_query["input_type"] == DATA_QUERY_INPUT_TYPE_PHP_SCRIPT_SERVER_QUERY) {
            _data_query_field_field__source_script("source", isset($data_query_field["source"]) ? $data_query_field["source"] : "", isset($data_query_field["id"]) ? $data_query_field["id"] : "0");
        }
    }
    if ($data_query["input_type"] == DATA_QUERY_INPUT_TYPE_SNMP_QUERY) {
        _data_query_field_field__method(isset($data_query_field["method_type"]) ? $data_query_field["method_type"] : "", isset($data_query_field["method_value"]) ? $data_query_field["method_value"] : "", isset($data_query_field["id"]) ? $data_query_field["id"] : "0");
    }
    html_end_box();
    form_hidden_box("data_query_field_id", $_data_query_field_id);
    form_hidden_box("data_query_id", $_data_query_id);
    form_hidden_box("field_type", $_field_type);
    form_save_button("data_queries.php?action=edit&id={$_data_query_id}", "save_data_query_field");
}
Exemplo n.º 7
0
function view_users()
{
    $current_page = get_get_var_number("page", "1");
    /* setup action menu */
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate", "enable" => "Enable", "disable" => "Disable", "passwdexpire" => "Password Expire");
    /* search field: filter (searchs device description and hostname) */
    $filter_array = array();
    $filter_url = "";
    if (isset_get_var("search_filter")) {
        $filter_array["name"] = get_get_var("search_filter");
        $filter_url .= ($filter_url == "" ? "" : "&") . "search_filter=" . urlencode(get_get_var("search_filter"));
    }
    if (isset_get_var("search_name")) {
        $filter_array["name"] = get_get_var("search_name");
        $filter_url .= ($filter_url == "" ? "" : "&") . "search_name=" . urlencode(get_get_var("search_name"));
    }
    if (isset_get_var("search_description")) {
        $filter_array["description"] = get_get_var("search_description");
        $filter_url .= ($filter_url == "" ? "" : "&") . "search_description=" . urlencode(get_get_var("search_description"));
    }
    if (isset_get_var("search_enabled")) {
        $filter_array["enabled"] = get_get_var("search_enabled");
        $filter_url .= ($filter_url == "" ? "" : "&") . "search_enabled=" . urlencode(get_get_var("search_enabled"));
    }
    /* get log entires */
    $users = api_auth_control_list(AUTH_CONTROL_OBJECT_TYPE_USER, $filter_array, read_config_option("num_rows_page"), read_config_option("num_rows_page") * ($current_page - 1));
    $total_rows = api_auth_control_total_get($filter_array);
    /* generate page list */
    $url_string = build_get_url_string(array("search_filter", "search_name", "search_description"));
    $url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_page"), $total_rows, "auth_user.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");
    /* Output html */
    $box_id = 1;
    form_start("auth_user.php");
    html_start_box("<strong>" . _("Users") . "</strong>", "auth_user.php?action=add", $url_page_select);
    html_header_checkbox(array(_("Username"), _("Full Name"), _("Enabled"), _("Last Login"), _("Last Login IP")), $box_id);
    $i = 0;
    if (is_array($users) && sizeof($users) > 0) {
        foreach ($users as $user) {
            $user_info = api_auth_control_get(AUTH_CONTROL_OBJECT_TYPE_USER, $user["id"]);
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $user["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
')">
				<td class="title">
					<a  onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
')" href="auth_user.php?action=edit&id=<?php 
            echo $user["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $user["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $user["name"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo $user["description"];
            ?>
				</td>
				<td>
					<?php 
            if ($user_info["enabled"] == 1) {
                echo "Yes";
            } else {
                echo "No";
            }
            ?>
				</td>
				<td>
					<?php 
            if ($user_info["last_login"] == "0000-00-00 00:00:00" || $user_info["last_login"] == "") {
                echo "N/A";
            } else {
                echo $user["last_login"];
            }
            ?>
				</td>
				<td>
					<?php 
            if ($user_info["last_login_ip"] == "") {
                echo "N/A";
            } else {
                echo $user_info["last_login_ip"];
            }
            ?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $user["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $user["id"];
            ?>
' title="<?php 
            echo $user["name"];
            ?>
">
				</td>
			</tr>

			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No Users Found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "5", sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE, $url_page_select, 1);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items, 250);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "auth_user_list");
    form_end();
    /* fill in the list of available host status types for the search dropdown */
    $search_auth_enabled = array();
    $search_auth_enabled["-1"] = "Any";
    $search_auth_enabled["1"] = "Enabled";
    $search_auth_enabled["0"] = "Disabled";
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			parent_div.appendChild(action_area_generate_break());

			action_area_update_header_caption(box_id, 'Remove User');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate User');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'enable') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to enable these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Enable Users');
			action_area_update_submit_caption(box_id, 'Enable');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'disable') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to disable these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Disable Users');
			action_area_update_submit_caption(box_id, 'Disable');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'passwdexpire') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to set the password expire interval for these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));




			action_area_update_header_caption(box_id, 'Set');
			action_area_update_submit_caption(box_id, 'Clear');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'search') {

                        _elm_ds_input = action_area_generate_select('box-' + box_id + '-search_status');
                        <?php 
    echo get_js_dropdown_code('_elm_ds_input', $search_auth_enabled, isset_get_var("search_enabled") ? get_get_var("search_enabled") : "-1");
    ?>

                        _elm_ht_input = action_area_generate_input('text', 'box-' + box_id + '-search_filter', '<?php 
    echo get_get_var("search_filter");
    ?>
');
                        _elm_ht_input.size = '30';

                        parent_div.appendChild(action_area_generate_search_field(_elm_ds_input, 'Enabled', false, false));
                        parent_div.appendChild(action_area_generate_search_field(_elm_ht_input, 'Filter', false, true));

                        action_area_update_header_caption(box_id, 'Search');
                        action_area_update_submit_caption(box_id, 'Search');

		}

	}
	-->
	</script>

	<?php 
}
Exemplo n.º 8
0
function pollers() {
	$current_page = get_get_var_number("page", "1");

	global $colors, $poller_actions, $input_types;

	$menu_items = array(
		"enable" => _("Enable"),
		"disable" => _("Disable"),
		"delete" => _("Delete")
		);

	$filter_array = array();

	/* search field: filter (searches device description and hostname) */
	if (isset_get_var("search_filter")) {
		$filter_array["filter"] = array("name" => get_get_var("search_filter"), "hostname" => get_get_var("search_filter"));
	}

	/* clean up sort_column string */
	if (isset_get_var("sort_column")) {
		$filter_array["sort_column"] = get_get_var("sort_column");
	}else{
		$filter_array["sort_column"] = "name";
	}

	/* clean up sort_direction string */
	if (isset_get_var("sort_direction")) {
		$filter_array["sort_direction"] = get_get_var("sort_direction");
	}else{
		$filter_array["sort_direction"] = "ASC";
	}

	/* get a list of all devices on this page */
	$pollers = api_poller_list($filter_array, $current_page, read_config_option("num_rows_device"));

	/* get the total number of devices on all pages */
	$total_rows = api_poller_total_get($filter_array);

	/* generate page list */
	$url_string = build_get_url_string(array("search_filter"));
	$url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "pollers.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");

	form_start("pollers.php");

	$box_id = "1";
	html_start_box("<strong>" . _("Pollers") . "</strong>", "pollers.php?action=edit", $url_page_select);

	$display_text = array(
		"name"        => array(_("Name"),          "ASC"),
		"hostname"    => array(_("Hostname"),      "ASC"),
		"run_state"   => array(_("Status"),        "ASC"),
		"cur_time"    => array(_("Last Time"),     "DESC"),
		"min_time"    => array(_("Min Time"),      "DESC"),
		"max_time"    => array(_("Max Time"),      "DESC"),
		"avg_time"    => array(_("Avg Time"),      "DESC"),
		"active"      => array(_("Enabled"),       "ASC"),
		"last_update" => array(_("Last Run Date"), "ASC"));

	html_header_sort_checkbox($display_text, $filter_array["sort_column"], $filter_array["sort_direction"], $box_id);

	$i = 0;

	if (sizeof($pollers) > 0) {
	foreach ($pollers as $poller) {
		?>
		<tr class="item" id="box-<?php echo $box_id;?>-row-<?php echo $poller["poller_id"];?>" onClick="display_row_select('<?php echo $box_id;?>',document.forms[0],'box-<?php echo $box_id;?>-row-<?php echo $poller["poller_id"];?>', 'box-<?php echo $box_id;?>-chk-<?php echo $poller["poller_id"];?>')" onMouseOver="display_row_hover('box-<?php echo $box_id;?>-row-<?php echo $poller["poller_id"];?>')" onMouseOut="display_row_clear('box-<?php echo $box_id;?>-row-<?php echo $poller["poller_id"];?>')">
			<td class="title">
				<a href="pollers.php?action=edit&poller_id=<?php print $poller["id"];?>"><?php print $poller["name"];?></a>
			</td>
			<td>
				<?php echo $poller["hostname"];?>
			</td>
			<td>
				<?php echo $poller["run_state"];?>
			</td>
			<td>
				<?php echo $poller["cur_time"];?>
			</td>
			<td>
				<?php echo $poller["min_time"];?>
			</td>
			<td>
				<?php echo $poller["max_time"];?>
			</td>
			<td>
				<?php echo $poller["avg_time"];?>
			</td>
			<td>
				<?php echo ($poller["active"] == "on" ? _("Yes") : _("No"));?>
			</td>
			<td>
				<?php echo $poller["last_update"];?>
			</td>
			<td class="checkbox" align="center">
				<input type='checkbox' name='box-<?php echo $box_id;?>-chk-<?php echo $poller["poller_id"];?>' id='box-<?php echo $box_id;?>-chk-<?php echo $poller["poller_id"];?>' title="<?php echo $poller["name"];?>">
			</td>
		</tr>
		<?php
	}
	}else{
		?>
		<tr class="empty">
			<td colspan="6">
				<?php echo _("No Pollers Found.");?>
			</td>
		</tr>
		<?php
	}

	html_box_toolbar_draw($box_id, "0", "9", (sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE), $url_page_select);
	html_end_box(false);

	html_box_actions_menu_draw($box_id, "0", $menu_items);
	html_box_actions_area_create($box_id);

	form_hidden_box("action_post", "poller_list");
	form_end();
}
Exemplo n.º 9
0
    } elseif (strpos($var, 'subscribe_list') !== FALSE) {
        $posted_lists = is_array($val) ? $val : ((int) $val != 0 ? array((int) $val) : array());
    } elseif (strpos($var, 'unsubscribe_submit') !== FALSE) {
        $posted_action = 'unsubscribe';
    } elseif (strpos($var, 'subscribe_submit') !== FALSE) {
        $posted_action = 'subscribe';
    }
}
// Check if we've got what we need to do a posted (un)subscription
if ($posted_action != '' && $posted_address != '' && count($posted_lists) > 0) {
    gu_subscription_process($posted_address, $posted_lists, $posted_action == 'subscribe');
}
// Get querystring variables
$list_id = is_get_var('list') ? (int) get_get_var('list') : 0;
$address = is_get_var('addr') ? get_get_var('addr') : '';
$action = is_get_var('action') ? get_get_var('action') : '';
// Check if we've got what we need to do a querystring (un)subscription
if ($list_id > 0 && $address != '' && $action != '') {
    $list_ids = array($list_id);
    gu_subscription_process($address, $list_ids, $subscribe == 'subscribe');
}
// Check to see if a single valid list was specified
if ($list_id > 0 || count($posted_lists) == 1) {
    if ($list_id == 0) {
        $list_id = $posted_lists[0];
    }
    $list = gu_list::get($list_id, FALSE);
} else {
    // Load all non-private lists
    $lists = gu_list::get_all(FALSE, FALSE);
}
Exemplo n.º 10
0
        $name = '';
        gu_error(t('Incorrect username or password'));
    }
} elseif (is_get_var('action') && get_get_var('action') == 'login') {
    $username = is_post_var('u') ? get_post_var('u') : '';
    $password = is_post_var('p') ? get_post_var('p') : '';
    $remember = is_post_var('login_remember');
    if (gu_session_authenticate($username, $password, $remember)) {
        // Redirect to page that referred here - or to the home page
        $redirect = is_get_var('ref') ? urldecode(get_get_var('ref')) : absolute_url('index.php');
        header('Location: ' . $redirect);
        exit;
    } else {
        gu_error(t('Incorrect username or password'));
    }
} elseif (is_get_var('action') && get_get_var('action') == 'logout') {
    // Invalidate session flag
    gu_session_set_valid(FALSE);
}
gu_theme_start();
?>

<script type="text/javascript">
/* <![CDATA[ */
function loginSubmit(form)
{
	// MD5 encrypt the password and store in hidden field
    form.p.value = hex_md5(form.dummy_p.value);
	
	// Replace the visible password field with Xs
	var mask = 'X';
Exemplo n.º 11
0
 * @copyright This source is distributed under the GPL
 * @file The list editing page
 * @modifications Cyril Maguire
 */
/* Gutama plugin package
 * @version 1.6
 * @date	01/10/2013
 * @author	Cyril MAGUIRE
*/
include_once 'inc/gutuma.php';
gu_init();
gu_theme_start();
// Get id of list to edit from querystring
$list_id = is_get_var('list') ? (int) get_get_var('list') : 0;
$start = is_get_var('start') ? (int) get_get_var('start') : 0;
$filter = is_get_var('filter') ? get_get_var('filter') : '';
// Load list data
$list = gu_list::get($list_id, TRUE);
// Make updates
if (is_post_var('list_update')) {
    $list->set_name(get_post_var('list_name'));
    $list->set_private(is_post_var('list_private'));
    if ($list->update()) {
        gu_success(t('List updated'));
    }
} elseif (is_post_var('new_address')) {
    $address = trim(get_post_var('new_address'));
    if ($list->add($address, TRUE)) {
        gu_success(t('Address <b><i>%</i></b> added to list', array($address)));
    }
}
Exemplo n.º 12
0
function export_logs() {

	/* search field: filter (searchs device description and hostname) */
	$filter_array = array();
	if (isset_get_var("search_filter")) {
		$filter_array["message"] = get_get_var("search_filter");
	}
	if (isset_get_var("search_facility")) {
		$filter_array["facility"] = get_get_var("search_facility");
	}
	if (isset_get_var("search_severity")) {
		$filter_array["severity"] = get_get_var("search_severity");
	}
	if (isset_get_var("search_poller")) {
		$filter_array["poller_id"] = get_get_var("search_poller");
	}
	if (isset_get_var("search_host")) {
		$filter_array["host_id"] = get_get_var("search_host");
	}
	if (isset_get_var("search_plugin")) {
		$filter_array["plugin"] = get_get_var("search_plugin");
	}
	if (isset_get_var("search_username")) {
		$filter_array["username"] = get_get_var("search_username");
	}
	if (isset_get_var("search_source")) {
		$filter_array["source"] = get_get_var("search_source");
	}

	/* Search and Replace chars */
	$search = array("\"","\t","\n","\r");
	$replace = array(""," "," "," ");

	/* get log entires */
	$logs = log_list($filter_array);

	/* Output CSV */
	header("Content-type: text/plain");
	header("Content-Disposition: attachment; filename=cacti_system_log." . date("Ymd.Hms") . ".csv");

	print "\"" . _("Date") . "\",";
	print "\"" . _("Facility") . "\",";
	print "\"" . _("Severity") . "\",";
	print "\"" . _("Poller") . "\",";
	print "\"" . _("Host") . "\",";
	print "\"" . _("Plugin") . "\",";
	print "\"" . _("User") . "\",";
	print "\"" . _("Source") . "\",";
	print "\"" . _("Message") . "\"\n";

	$i = 0;
	if ((is_array($logs)) && (sizeof($logs) > 0)) {
		foreach ($logs as $log) {
			print "\"" . $log["logdate"] . "\",";
			print "\"" . log_get_facility($log["facility"]) . "\",";
			print "\"" . log_get_severity($log["severity"]) . "\",";
			print "\"";
			if ($log["poller_name"] == "") {
				print "SYSTEM";
			}else{
				print $log["poller_name"];
			}
			print "\",\"";
			if ($log["host"] == "") {
				print "SYSTEM";
			}else{
				print $log["host"];
			}
			print "\",\"";
			if ($log["plugin"] == "") {
				print "N/A";
			}else{
				print $log["plugin"];
			}
			print "\",\"";
			if ($log["username"] == "") {
				print "SYSTEM";
			}else{
				print $log["username"];
			}
			print "\",\"";
			if ($log["source"] == "") {
				print "SYSTEM";
			}else{
				print $log["source"];
			}

			print "\",\"" . str_replace($search,$replace,$log["message"]) . "\"\n";
		}
	}

}
Exemplo n.º 13
0
 * @file The settings page
 * @modifications Cyril Maguire
 */
/* Gutama plugin package
 * @version 1.6
 * @date	01/10/2013
 * @author	Cyril MAGUIRE
*/
include_once 'inc/gutuma.php';
include_once 'inc/mailer.php';
if ($_SESSION['profil'] != PROFIL_ADMIN) {
    header('Location:compose.php');
    exit;
}
gu_init();
$section = is_get_var('section') ? get_get_var('section') : 'general';
$section_titles['general'] = t("General settings");
$section_titles['transport'] = t("Transport settings");
$section_titles['messages'] = t("Message settings");
// Save settings
if (is_post_var('save_settings')) {
    if ($section == 'general') {
        gu_config::set('collective_name', get_post_var('collective_name'));
        gu_config::set('application_name', get_post_var('application_name'));
        gu_config::set('admin_name', get_post_var('admin_name'));
        gu_config::set('admin_email', get_post_var('admin_email'));
        gu_config::set('theme_name', get_post_var('theme_name'));
        /*gu_config::set('admin_username', get_post_var('admin_username'));
        		$pass1 = get_post_var('admin_password');
        		$pass2 = get_post_var('admin_password_retype');
        		if ($pass1 != '') {
Exemplo n.º 14
0
 function Create($image, $text, $align, $font, $fontsize = 15, $resize_width = 0, $padding = 5, $text_color = -1, $shadow_color = -1)
 {
     $this->img = false;
     set_error_handler(array($this, "ErrorHandler"));
     // second, make sure its an image
     if (!(list($width, $height, $this->imgtype, $attr) = @getimagesize($image))) {
         return $this->ShowError("Error: Cannot get parameters of specified image");
     }
     // ensure position is correct
     if (!in_array($align, array('tl', 'tr', 'bl', 'br'))) {
         $align = 'tl';
     }
     // fix up the font size
     $fontsize = str_replace('px', '', trim($fontsize));
     if ($fontsize == '' || !is_int($fontsize)) {
         $fontsize = 15;
     }
     // verify the font
     if (!($font = realpath($font))) {
         return $this->ShowError("Error: Invalid font specified!");
     }
     switch ($this->imgtype) {
         case 1:
             // gif
             $this->img = @imagecreatefromgif($image);
             break;
         case 2:
             // jpg
             $this->img = @imagecreatefromjpeg($image);
             break;
         case 3:
             // png
             $this->img = @imagecreatefrompng($image);
             break;
         default:
             // i don't care about other formats
             return false;
     }
     if (!$this->img) {
         return $this->ShowError("Error: Cannot use specified image");
     }
     // see if we need to resize the image first
     if ($resize_width != 0) {
         // todo: Add a 'max-width, max-height' parameter...
         $ratio = $width / $resize_width;
         $resize_height = intval($height / $ratio);
         $thumb_img = imagecreatetruecolor($resize_width, $resize_height);
         if (!imagecopyresampled($thumb_img, $this->img, 0, 0, 0, 0, $resize_width, $resize_height, $width, $height)) {
             return $this->ShowError("Error: Could not resize image!");
         }
         // fix these
         $height = $resize_height;
         $width = $resize_width;
         // destroy original object
         imagedestroy($this->img);
         $this->img = $thumb_img;
     }
     // allocate colors for text
     if ($text_color === -1) {
         $text_color = imagecolorallocate($this->img, 255, 255, 255);
     } else {
         $text_color = imagecolorallocate($this->img, $text_color[0], $text_color[1], $text_color[2]);
     }
     // allocate colors for text shadow
     if ($shadow_color === -1) {
         $shadow_color = imagecolorallocate($this->img, 0, 0, 0);
     } else {
         $shadow_color = imagecolorallocate($this->img, $shadow_color[0], $shadow_color[1], $shadow_color[2]);
     }
     // next, we should try to create the text.. hopefully it wraps nicely
     putenv('GDFONTPATH=' . realpath('.'));
     // hack, just in case
     // grab the font height, M is supposed to be big, with any random chars lying around
     $font_height = $this->img_height(imagettfbbox($fontsize, 0, $font, 'Mjg'));
     $row_spacing = intval($font_height * 0.2);
     // purely arbitrary value
     $space_width = $this->img_width(imagettfbbox($fontsize, 0, $font, ' '));
     // try and do our best imitation of wordwrapping
     $text_elements = explode(' ', str_replace("\n", '', str_replace("\r\n", '', $text)));
     // adjust this depending on alignment
     $top = $padding + $font_height;
     $left = $padding;
     // initialize
     $line_width = 0;
     $line_beginning = 0;
     // index of beginning of line
     $inc = 1;
     $c = count($text_elements);
     $i = 0;
     if ($align[0] == 'b') {
         $top = $height - $padding;
         $font_height = $font_height * -1;
         $row_spacing = $row_spacing * -1;
         $inc = -1;
         $i = $c - 1;
     }
     $dbg = get_get_var('dbg');
     $line_beginning = $i;
     // draw text elements starting from alignment position..
     for (; $i >= 0 && $i < $c; $i += $inc) {
         $lf_width = $this->img_width(imagettfbbox($fontsize, 0, $font, $text_elements[$i]));
         // add a space
         if ($i != $line_beginning) {
             $lf_width += $space_width;
         }
         // see if we've exceeded the max width
         if ($lf_width + $line_width + $padding * 2 > $width) {
             // draw it out then!
             if ($align[1] == 'r') {
                 $left = $width - $padding - $line_width;
             }
             if ($align[0] == 'b') {
                 $text = implode(' ', array_slice($text_elements, $i + 1, $line_beginning - $i));
             } else {
                 $text = implode(' ', array_slice($text_elements, $line_beginning, $i - $line_beginning));
             }
             // draw the text
             imagettftext($this->img, $fontsize, 0, $left - 1, $top + 1, $shadow_color, $font, $text);
             imagettftext($this->img, $fontsize, 0, $left, $top, $text_color, $font, $text);
             // keep moving, reset params
             $top += $font_height + $row_spacing;
             $line_beginning = $i;
             $line_width = $lf_width;
         } else {
             // keep trucking
             $line_width += $lf_width;
         }
     }
     // get the last line too
     if ($line_width != 0) {
         if ($align[1] == 'r') {
             $left = $width - $padding - $line_width;
         }
         if ($align[0] == 'b') {
             $text = implode(' ', array_slice($text_elements, $i + 1, $line_beginning - $i));
         } else {
             $text = implode(' ', array_slice($text_elements, $line_beginning, $i - $line_beginning));
         }
         imagettftext($this->img, $fontsize, 0, $left - 1, $top + 1, $shadow_color, $font, $text);
         imagettftext($this->img, $fontsize, 0, $left, $top, $text_color, $font, $text);
     }
     imagecolordeallocate($this->img, $shadow_color);
     imagecolordeallocate($this->img, $text_color);
     restore_error_handler();
     return true;
 }
Exemplo n.º 15
0
    if (is_post_var('msg_subject')) {
        $newsletter->set_subject(get_post_var('msg_subject'));
    }
    if (is_post_var('msg_html')) {
        $newsletter->set_html(get_post_var('msg_html'));
    }
    if (is_post_var('msg_text')) {
        $newsletter->set_text(get_post_var('msg_text'));
    } else {
        $newsletter->generate_text();
    }
}
// Take recipient list from querystring if none specified thus far
if ($newsletter->get_recipients() == '' && is_get_var('list')) {
    foreach ($lists as $list) {
        $list_id = (int) get_get_var('list');
        if ($list->get_id() == $list_id) {
            $newsletter->set_recipients($list->get_name());
            break;
        }
    }
}
// Preview the newsletter
$preview_mode = is_post_var('preview_submit');
// Send the newsletter
if (is_post_var('send_submit')) {
    // Saves newsletter to outbox
    if ($newsletter->send_prepare()) {
        $mailer = new gu_mailer();
        if ($mailer->init()) {
            if ($newsletter->send_batch($mailer)) {
Exemplo n.º 16
0
function package() {
	$menu_items = array(
		"remove" => "Remove",
		"duplicate" => "Duplicate"
		);

	$filter_array = array();

	/* search field: filter (searches package name) */
	if (isset_get_var("search_filter")) {
		$filter_array["name"] = get_get_var("search_filter");
	}

	/* get a list of all packages on this page */
	$packages = api_package_list($filter_array);

	form_start("packages.php");

	$box_id = "1";
	html_start_box("<strong>" . _("Template Packages") . "</strong>", "packages.php?action=new");
	html_header_checkbox(array(_("Name"), _("Author"), _("Category")), $box_id);

	$i = 0;
	if (sizeof($packages) > 0) {
		foreach ($packages as $package) {
			?>
			<tr class="item" id="box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>" onClick="display_row_select('<?php echo $box_id;?>',document.forms[0],'box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>', 'box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>')" onMouseOver="display_row_hover('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')" onMouseOut="display_row_clear('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')">
				<td class="title">
					<a onClick="display_row_block('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')" href="packages.php?action=view&id=<?php echo $package["id"];?>"><span id="box-<?php echo $box_id;?>-text-<?php echo $package["id"];?>"><?php echo html_highlight_words(get_get_var("search_filter"), $package["name"]);?></span></a>
				</td>
				<td>
					Ian Berry
				</td>
				<td>
					<?php echo $package["category"];?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>' id='box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>' title="<?php echo $package["name"];?>">
				</td>
			</tr>
			<?php
		}
	}else{
		?>
		<tr class="empty">
			<td colspan="6">
				No template packages found.
			</td>
		</tr>
		<?php
	}
	html_box_toolbar_draw($box_id, "0", "3", HTML_BOX_SEARCH_NONE);
	html_end_box(false);

	//html_box_actions_menu_draw($box_id, "0", $menu_items);
	html_box_actions_area_create($box_id);

	form_hidden_box("action_post", "package_list");
	form_end();

	echo "<br />\n";

	form_start("packages.php", "import_package", true);

	html_start_box("<strong>" . _("Import Package") . "</strong>");

	_package_import_field__file("import_package_file");
	_package_import_field__text("import_package_text");

	?>
	<tr>
		<td style="border-top: 1px solid #b5b5b5; padding: 1px;" colspan="2">
			<table width="100%" cellpadding="2" cellspacing="0">
				<tr>
					<td align="right">
						&nbsp;<input type="image" src="<?php echo html_get_theme_images_path('button_import.gif');?>" alt="<?php echo _('Import');?>" name="package_import" align="absmiddle">
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php

	html_end_box();

	form_hidden_box("action", "save");
	form_hidden_box("action_post", "package_import");
	form_end();

	//print_a(htmlspecialchars(package_export("1")));

	?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Data Template');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Data Templates');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php
}
Exemplo n.º 17
0
 * @author	Cyril MAGUIRE
*/
include_once 'inc/gutuma.php';
include_once 'inc/newsletter.php';
include_once 'inc/mailer.php';
gu_init();
if (is_get_var('send')) {
    $newsletter = gu_newsletter::get((int) get_get_var('send'));
    if ($newsletter !== FALSE) {
        $mailer = new gu_mailer();
        if ($mailer->init()) {
            $newsletter->send_batch($mailer);
        }
    }
}
$box = is_get_var('box') ? get_get_var('box') : 'drafts';
$mailbox = gu_newsletter::get_mailbox();
$newsletters = $mailbox[$box];
gu_theme_start();
?>
<script type="text/javascript">
/* <![CDATA[ */
	function gu_newsletter_draft_menu(id)
	{
		return '<a href="compose.php?msg=' + id + '" class="imglink" title="<?php 
echo t('Edit and send');
?>
"><img src="themes/<?php 
echo gu_config::get('theme_name');
?>
/images/icon_mail.png" /></a>&nbsp;&nbsp;'