Exemplo n.º 1
0
function api_poller_fields_validate(&$_fields_poller, $poller_field_name_format = "|field|") {
	require_once(CACTI_BASE_PATH . "/lib/poller/poller_info.php");

	if (sizeof($_fields_device) == 0) {
		return array();
	}

	/* array containing errored fields */
	$error_fields = array();

	/* get a complete field list */
	$fields_device = api_poller_form_list();

	/* base fields */
	while (list($_field_name, $_field_array) = each($fields_device)) {
		if ((isset($_fields_device[$_field_name])) && (isset($_field_array["validate_regexp"])) && (isset($_field_array["validate_empty"]))) {
			$form_field_name = str_replace("|field|", $_field_name, $device_field_name_format);

			if (!form_input_validate($_fields_device[$_field_name], $form_field_name, $_field_array["validate_regexp"], $_field_array["validate_empty"])) {
				$error_fields[] = $form_field_name;
			}
		}
	}

	return $error_fields;
}
Exemplo n.º 2
0
function api_poller_total_get($filter_array = "") {
	require_once(CACTI_BASE_PATH . "/lib/poller/poller_form.php");

	$sql_where = "";
	/* validation and setup for the WHERE clause */
	if ((is_array($filter_array)) && (sizeof($filter_array) > 0)) {
		/* validate each field against the known master field list */
		$field_errors = api_poller_fields_validate(sql_filter_array_to_field_array($filter_array), "|field|");

		/* if a field input error has occured, register the error in the session and return */
		if (sizeof($field_errors) > 0) {
			field_register_error($field_errors);
			return false;
		/* otherwise, form an SQL WHERE string using the filter fields */
		}else{
			$sql_where = sql_filter_array_to_where_string($filter_array, api_poller_form_list(), true);
		}
	}

	return db_fetch_cell("select count(*) from poller $sql_where");
}