当前位置: 首页>>代码示例>>PHP>>正文


PHP log_save函数代码示例

本文整理汇总了PHP中log_save函数的典型用法代码示例。如果您正苦于以下问题:PHP log_save函数的具体用法?PHP log_save怎么用?PHP log_save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log_save函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: form_input_validate

function form_input_validate($field_value, $field_name, $regexp_match, $allow_empty, $custom_message = 0) {
	if (($allow_empty == true) && ($field_value == "")) {
		if ($custom_message == 3) {
			return $field_value;
		}else{
			return true;
		}
	}

	/* php 4.2+ complains about empty regexps */
	if (empty($regexp_match)) { $regexp_match = ".*"; }

	if ((!ereg($regexp_match, $field_value) || (($allow_empty == false) && ($field_value == "")))) {
		if ($custom_message == 3) {
			return $field_value;
		}else{
			log_save("Field validation error occured for field '$field_name' value '$field_value' pattern '$regexp_match' allow empty '" . ($allow_empty == false ? "no" : "yes") . "' in ". __FUNCTION__ . "()", SEV_NOTICE);

			return false;
		}
	}else{
		if ($custom_message == 3) {
			return $field_value;
		}else{
			return true;
		}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:28,代码来源:form.php

示例2: api_poller_get

function api_poller_get($poller_id) {
	/* sanity check for $poller_id */
	if ((!is_numeric($poller_id)) || (empty($poller_id))) {
		log_save("Invalid input '$poller_id' for 'poller_id' in " . __FUNCTION__ . "()", SEV_ERROR);
		return false;
	}

	return db_fetch_row("select * from poller where poller_id = " . sql_sanitize($poller_id));
}
开发者ID:songchin,项目名称:Cacti,代码行数:9,代码来源:poller_info.php

示例3: db_order_direction_validate

function db_order_direction_validate($direction, $log_errors = true) {
	if (($direction == "asc") || ($direction == "desc")) {
		return true;
	}else{
		if ($log_errors == true) {
			log_save("Invalid order direction '$direction' in " . log_get_last_function() . "()", SEV_WARNING);
		}

		return false;
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:11,代码来源:validate.php

示例4: save

 /**
  * 日志保存
  * @static
  * @access public
  * @param integer $type 日志记录方式
  * @param string $destination  写入目标
  * @param string $extra 额外参数
  * @return void
  */
 static function save($type = '', $destination = '', $extra = '')
 {
     if (empty(self::$log)) {
         return;
     }
     //[cluster] 保存日志
     $now = date(self::$format);
     log_save(self::$log, $now . ' ' . get_client_ip() . ' ' . $_SERVER['REQUEST_URI']);
     // 保存后清空日志缓存
     self::$log = array();
     //clearstatcache();
 }
开发者ID:lxp521125,项目名称:TP-Admin,代码行数:21,代码来源:Log.class.php

示例5: api_graph_template_get

function api_graph_template_get($graph_template_id) {
	/* sanity checks */
	validate_id_die($graph_template_id, "graph_template_id");

	$graph_template = db_fetch_row("select * from graph_template where id = " . sql_sanitize($graph_template_id));

	if (sizeof($graph_template) == 0) {
		log_save("Invalid graph template [ID#$graph_template_id] specified in api_graph_template_get()", SEV_ERROR);
		return false;
	}else{
		return $graph_template;
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:13,代码来源:graph_template_info.php

示例6: event_get

/**
 * Retreive an event and all associated parameters
 *
 * Given an event id, return all name => value pairs containing all the data for an event
 *
 * @param int $event_id Event ID
 * @return array event parameters
 */
function event_get ($event_id) {
	/* sanity check for $event_id */
	if ((!is_numeric($event_id)) || (empty($event_id))) {
		log_save("Invalid input '$event_id' for 'event_id' in " . __FUNCTION__ . "()", SEV_ERROR);
		return false;
	}
	$event = db_fetch_row("select * from event_queue_control where id = " . sql_sanitize($event_id));
	$params = db_fetch_assoc("select * from event_queue_param where control_id = " . sql_sanitize($event_id));

	foreach($params as $param) {
		$event[$param['name']] = $param['value'];
	}	

	return $event;
}
开发者ID:songchin,项目名称:Cacti,代码行数:23,代码来源:event_info.php

示例7: change_password

function change_password() {
	global $colors;

	$change_result = 1;

	$user_realms = api_user_realms_list($_SESSION["sess_user_id"]);

	/* check if authorized */
	if ($user_realms["18"]["value"] == "1") {
		/* check passwords */
		if ((!empty($_POST["password_old"])) && (!empty($_POST["password_new"])) && (!empty($_POST["password_new_confirm"]))) {
			if ($_POST["password_new"] != $_POST["password_new_confirm"]) {
				/* New passwords do not match */
				raise_message(4);
			}else{
				$change_result = api_user_changepassword($_SESSION["sess_user_id"],$_POST["password_new"],$_POST["password_old"]);
				if ($change_result == "0") {
					/* Password changed successfully */
					raise_message(11);
					/* Log password change */
					$username = db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);
					log_save(_("CHANGEPASSWORD: Password change successful"), SEV_INFO, FACIL_AUTH);
				}elseif ($change_result == "2") {
					/* Authentication failure for old password */
					raise_message(8);
					log_save(_("CHANGEPASSWORD: Authenication failure on old password"), SEV_WARNING, FACIL_AUTH);
				}else{
					/* General error changing password */
					raise_message(9);
					log_save(_("CHANGEPASSWORD: General Error unable to change password"), SEV_ERROR, FACIL_AUTH);
				}
			}
		}else{
			/* error empty fields */
			raise_message(10);
		}
	}

	require_once(CACTI_BASE_PATH . "/include/top_header.php");
	if ($user_realms["18"]["value"] != "1") {
		/* Access Denied */
		display_custom_error_message("Access Denied.");
	}
	require_once(CACTI_BASE_PATH . "/include/bottom_footer.php");

}
开发者ID:songchin,项目名称:Cacti,代码行数:46,代码来源:user_changepassword.php

示例8: api_package_metadata_save

function api_package_metadata_save($package_metadata_id, &$_fields_package_metadata) {
	require_once(CACTI_BASE_PATH . "/lib/package/package_info.php");

	/* sanity checks */
	validate_id_die($package_metadata_id, "package_metadata_id", true);

	/* sanity check for $package_id */
	if ((empty($package_metadata_id)) && (empty($_fields_package_metadata["package_id"]))) {
		log_save("Required package_id when package_metadata_id = 0", SEV_ERROR);
		return false;
	} else if ((isset($_fields_package_metadata["package_id"])) && (!is_numeric($_fields_package_metadata["package_id"]))) {
		return false;
	}

	/* field: id */
	$_fields["id"] = array("type" => DB_TYPE_INTEGER, "value" => $package_metadata_id);

	/* field: package_id */
	if (!empty($_fields_package_metadata["package_id"])) {
		$_fields["package_id"] = array("type" => DB_TYPE_INTEGER, "value" => $_fields_package_metadata["package_id"]);
	}

	/* convert the input array into something that is compatible with db_replace() */
	$_fields += sql_get_database_field_array($_fields_package_metadata, api_package_metadata_form_list());

	/* check for an empty field list */
	if (sizeof($_fields) == 1) {
		return true;
	}

	if (db_replace("package_metadata", $_fields, array("id"))) {
		if (empty($package_metadata_id)) {
			return db_fetch_insert_id();
		}else{
			return $package_metadata_id;
		}
	}else{
		return false;
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:40,代码来源:package_update.php

示例9: api_script_field_save

function api_script_field_save($script_field_id, $_fields_script_field) {
	require_once(CACTI_BASE_PATH . "/lib/script/script_info.php");

	/* sanity checks */
	validate_id_die($script_field_id, "script_field_id", true);

	/* make sure that there is at least one field to save */
	if (sizeof($_fields_script_field) == 0) {
		return false;
	}

	/* sanity check for $script_id */
	if ((empty($script_field_id)) && (empty($_fields_script_field["data_input_id"]))) {
		log_save("Required script_id when script_field_id = 0", SEV_ERROR);
		return false;
	} else if ((isset($_fields_script_field["data_input_id"])) && (!db_integer_validate($_fields_script_field["data_input_id"]))) {
		return false;
	}

	/* field: id */
	$_fields["id"] = array("type" => DB_TYPE_INTEGER, "value" => $script_field_id);

	/* field: graph_tree_id */
	if (isset($_fields_script_field["data_input_id"])) {
		$_fields["data_input_id"] = array("type" => DB_TYPE_INTEGER, "value" => $_fields_script_field["data_input_id"]);
	}

	/* convert the input array into something that is compatible with db_replace() */
	$_fields += sql_get_database_field_array($_fields_script_field, api_script_field_form_list());

	if (db_replace("data_input_fields", $_fields, array("id"))) {
		if (empty($script_field_id)) {
			$script_field_id = db_fetch_insert_id();
		}

		return $script_field_id;
	}else{
		return false;
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:40,代码来源:script_update.php

示例10: form_save

function form_save()
{
    if ($_POST["action_post"] == "graph_edit") {
        /* fetch some cache variables */
        if (empty($_POST["id"])) {
            $_graph_template_id = 0;
        } else {
            $_graph_template_id = db_fetch_cell("select graph_template_id from graph where id=" . $_POST["id"]);
        }
        /* cache all post field values */
        init_post_field_cache();
        $form_graph_fields = array();
        $form_graph_item_fields = array();
        /* parse out form values that we care about */
        reset($_POST);
        while (list($name, $value) = each($_POST)) {
            if (substr($name, 0, 2) == "g|") {
                $matches = explode("|", $name);
                $form_graph_fields[$matches[1]] = $value;
            } else {
                if (substr($name, 0, 4) == "gip|") {
                    $matches = explode("|", $name);
                    $form_graph_item_fields[$matches[2]] = $value;
                }
            }
        }
        /* make a list of fields to save */
        while (list($_field_name, $_field_value) = each($form_graph_fields)) {
            /* make sure that we know about this field */
            if (isset($fields_graph[$_field_name])) {
                $save_graph[$_field_name] = $_field_value;
            }
        }
        /* add any unchecked checkbox fields */
        $form_graph_fields += field_register_html_checkboxes(api_graph_form_list(), "g||field|");
        $form_graph_fields["host_id"] = $_POST["host_id"];
        $form_graph_fields["graph_template_id"] = $_POST["graph_template_id"];
        /* step #2: field validation */
        $suggested_value_fields = array();
        /* placeholder */
        field_register_error(api_graph_fields_validate($form_graph_fields, $suggested_value_fields, "g||field|", ""));
        /* step #3: field save */
        if (is_error_message()) {
            log_save("User input validation error for graph [ID#" . $_POST["id"] . "]", SEV_DEBUG);
        } else {
            /* save graph data */
            if (!api_graph_save($_POST["id"], $form_graph_fields)) {
                log_save("Save error for graph [ID#" . $_POST["id"] . "]", SEV_ERROR);
            }
            /* save graph item data for templated graphs */
            if (!empty($_graph_template_id)) {
                if (sizeof($form_graph_item_fields) > 0) {
                    foreach ($form_graph_item_fields as $graph_template_item_input_id => $value) {
                        if (!api_graph_template_item_input_propagate($graph_template_item_input_id, $value)) {
                            log_save("Save error when propagating graph item input [ID#{$graph_template_item_input_id}] to graph [ID#" . $_POST["id"] . "]", SEV_ERROR);
                        }
                    }
                }
            }
        }
        if (is_error_message() || $_POST["graph_template_id"] != $_graph_template_id) {
            header("Location: graphs.php?action=edit&id=" . $_POST["id"] . (!isset($_POST["host_id"]) ? "" : "&host_id=" . $_POST["host_id"]) . (!isset($_POST["graph_template_id"]) ? "" : "&graph_template_id=" . $_POST["graph_template_id"]));
        } else {
            header("Location: graphs.php");
        }
        /* submit button on the actions area page */
    } else {
        if ($_POST["action_post"] == "box-1") {
            $selected_rows = explode(":", $_POST["box-1-action-area-selected-rows"]);
            if ($_POST["box-1-action-area-type"] == "search") {
                $get_string = "";
                if ($_POST["box-1-search_device"] != "-1") {
                    $get_string .= ($get_string == "" ? "?" : "&") . "search_device=" . urlencode($_POST["box-1-search_device"]);
                }
                if (trim($_POST["box-1-search_filter"]) != "") {
                    $get_string .= ($get_string == "" ? "?" : "&") . "search_filter=" . urlencode($_POST["box-1-search_filter"]);
                }
                header("Location: graphs.php{$get_string}");
            } else {
                if ($_POST["box-1-action-area-type"] == "remove") {
                    foreach ($selected_rows as $graph_id) {
                        api_graph_remove($graph_id);
                    }
                } else {
                    if ($_POST["box-1-action-area-type"] == "duplicate") {
                        // not yet coded
                    } else {
                        if ($_POST["box-1-action-area-type"] == "change_graph_template") {
                            // note yet coded
                        } else {
                            if ($_POST["box-1-action-area-type"] == "change_host") {
                                foreach ($selected_rows as $graph_id) {
                                    api_graph_host_update($graph_id, $_POST["box-1-change_device"]);
                                }
                            } else {
                                if ($_POST["box-1-action-area-type"] == "convert_graph_template") {
                                    // note yet coded
                                } else {
                                    if ($_POST["box-1-action-area-type"] == "place_tree") {
                                        // note yet coded
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:graphs.php

示例11: sql_get_quoted_string

function sql_get_quoted_string($field_type, $field_value) {
	if ($field_type == DB_TYPE_STRING) {
		return "'" . sql_sanitize($field_value) . "'";
	}else if ($field_type == DB_TYPE_INTEGER){
		if (is_numeric($field_value)) {
			return $field_value;
		}else{
			log_message("Invalid numeric column value '" . $field_value . "' in " . __FUNCTION__ . "()", LOG_LEVEL_WARNING, "lib-db");
			die("Invalid numeric column value '" . $field_value . "' in " . __FUNCTION__ . "()");
		}
	}else if ($field_type == DB_TYPE_INTEGER) {
		if (db_integer_validate($field_value, true, true)) {
			return $field_value;
		}else{
			log_message("Invalid numeric column value '" . $field_value . "' in " . __FUNCTION__ . "()", LOG_LEVEL_WARNING, "lib-db");
			die("Invalid numeric column value '" . $field_value . "' in " . __FUNCTION__ . "()");
		}
	}else if ($field_type == DB_TYPE_NULL) {
		return "NULL";
	}else if ($field_type == DB_TYPE_BLOB) {
		// i think the addslashes() may cause problems for non-mysql dbs, but it wasn't working for me otherwise
		return "'" . addslashes($field_value) . "'";
	}else if ($field_type == DB_TYPE_HTML_CHECKBOX) {
		if ($field_value == "on") {
			return 1;
		}else if ($field_value == "") {
			return 0;
		}else if ($field_value == "0") {
			return 0;
		}else if ($field_value == "1") {
			return 1;
		}else{
			return 0;
		}
	}else if ($field_type == DB_TYPE_FUNC_NOW) {
		return "NOW()";
	}else if ($field_type == DB_TYPE_FUNC_MD5) {
		return "'" . md5($field_value) . "'";
	}else{
		log_save("Invalid column type '" . $field_type . "' value '" . $field_value . "' in " . __FUNCTION__ . "()", SEV_WARNING);
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:42,代码来源:database_utility.php

示例12: update_host_status


//.........这里部分代码省略.........
		if ($ping_time < $hosts[$host_id]["min_time"])
			$hosts[$host_id]["min_time"] = $ping_time;

		/* average time */
		$hosts[$host_id]["avg_time"] = (($hosts[$host_id]["total_polls"]-1-$hosts[$host_id]["failed_polls"])
			* $hosts[$host_id]["avg_time"] + $ping_time) / ($hosts[$host_id]["total_polls"]-$hosts[$host_id]["failed_polls"]);

		/* the host was down, now it's recovering */
		if (($hosts[$host_id]["status"] == HOST_DOWN) || ($hosts[$host_id]["status"] == HOST_RECOVERING )) {
			/* just up, change to recovering */
			if ($hosts[$host_id]["status"] == HOST_DOWN) {
				$hosts[$host_id]["status"] = HOST_RECOVERING;
				$hosts[$host_id]["status_event_count"] = 1;
			} else {
				$hosts[$host_id]["status_event_count"]++;
			}

			/* if it's time to issue a recovery message, indicate so */
			if ($hosts[$host_id]["status_event_count"] >= $ping_recovery_count) {
				/* host is up, flag it that way */
				$hosts[$host_id]["status"] = HOST_UP;

				$issue_log_message = true;

				/* update the recovery date only if the recovery count is 1 */
				if ($ping_recovery_count == 1) {
					$hosts[$host_id]["status_rec_date"] = date("Y-m-d h:i:s");
				}

				/* reset the event counter */
				$hosts[$host_id]["status_event_count"] = 0;
			/* host is recovering, but not ready to issue log message */
			} else {
				/* host recovering for the first time, set event date */
				if ($hosts[$host_id]["status_event_count"] == 1) {
					$hosts[$host_id]["status_rec_date"] = date("Y-m-d h:i:s");
				}
			}
		} else {
		/* host was unknown and now is up */
			$hosts[$host_id]["status"] = HOST_UP;
			$hosts[$host_id]["status_event_count"] = 0;
		}
	}
	/* if the user wants a flood of information then flood them */
	if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_HIGH) {
		if (($hosts[$host_id]["status"] == HOST_UP) || ($hosts[$host_id]["status"] == HOST_RECOVERING)) {
			/* log ping result if we are to use a ping for reachability testing */
			if ($ping_availability == AVAIL_SNMP_AND_PING) {
				log_save(_("PING: ") . $ping->ping_response, SEV_INFO, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
				log_save(_("SNMP: ") . $ping->snmp_response, SEV_INFO, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
			} elseif ($ping_availability == AVAIL_SNMP) {
				if ($hosts[$host_id]["snmp_community"] == "") {
					log_save(_("SNMP: Device does not require SNMP"), SEV_INFO, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
				}else{
					log_save(_("SNMP: ") . $ping->snmp_response, SEV_INFO, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
				}
			} elseif ($ping_availability == AVAIL_NONE) {
				log_save(_("AVAIL: Availability checking disabled for host"), SEV_INFO, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
			} else {
				log_save(_("PING: ") . $ping->ping_response, SEV_INFO, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
			}
		} else {
			if ($ping_availability == AVAIL_SNMP_AND_PING) {
				log_save(_("PING: ") . $ping->ping_response, SEV_INFO, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
				log_save(_("SNMP: ") . $ping->snmp_response, SEV_INFO, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
			} elseif ($ping_availability == AVAIL_SNMP) {
				log_save(_("SNMP: ") . $ping->snmp_response, SEV_INFO, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
			} elseif ($ping_availability == AVAIL_NONE) {
				log_save(_("AVAIL: Availability cheking disabled for host"), SEV_INFO,  FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
			} else {
				log_save(_("PING: ") . $ping->ping_response, SEV_INFO,  FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
			}
		}
	}

	/* if there is supposed to be an event generated, do it */
	if ($issue_log_message) {
		if ($hosts[$host_id]["status"] == HOST_DOWN) {
			log_save(_("DEVICE EVENT: Device is DOWN Message: ") . $hosts[$host_id]["status_last_error"], SEV_ERROR, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
		} else {
			log_save(_("DEVICE EVENT: Device Returned from DOWN State"), SEV_NOTICE, FACIL_POLLER, "", $poller_id, $host_id, $print_data_to_stdout);
		}
	}

	db_execute("update host set
		status = '" . $hosts[$host_id]["status"] . "',
		status_event_count = '" . $hosts[$host_id]["status_event_count"] . "',
		status_fail_date = '" . $hosts[$host_id]["status_fail_date"] . "',
		status_rec_date = '" . $hosts[$host_id]["status_rec_date"] . "',
		status_last_error = '" . $hosts[$host_id]["status_last_error"] . "',
		min_time = '" . $hosts[$host_id]["min_time"] . "',
		max_time = '" . $hosts[$host_id]["max_time"] . "',
		cur_time = '" . $hosts[$host_id]["cur_time"] . "',
		avg_time = '" . $hosts[$host_id]["avg_time"] . "',
		total_polls = '" . $hosts[$host_id]["total_polls"] . "',
		failed_polls = '" . $hosts[$host_id]["failed_polls"] . "',
		availability = '" . $hosts[$host_id]["availability"] . "'
		where hostname = '" . $hosts[$host_id]["hostname"] . "'");
}
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:poller.php

示例13: api_graph_template_item_save

function api_graph_template_item_save($graph_template_item_id, $_fields_graph_item) {
	require_once(CACTI_BASE_PATH . "/lib/sys/sequence.php");
	require_once(CACTI_BASE_PATH . "/lib/graph_template/graph_template_info.php");

	/* sanity checks */
	validate_id_die($graph_template_item_id, "graph_template_item_id", true);

	/* make sure that there is at least one field to save */
	if (sizeof($_fields_graph_item) == 0) {
		return false;
	}

	/* sanity check for $graph_template_id */
	if ((empty($graph_template_item_id)) && (empty($_fields_graph_item["graph_template_id"]))) {
		log_save("Required graph_template_id when graph_template_item_id = 0", SEV_ERROR);
		return false;
	} else if ((isset($_fields_graph_item["graph_template_id"])) && (!db_integer_validate($_fields_graph_item["graph_template_id"]))) {
		return false;
	}

	/* field: id */
	$_fields["id"] = array("type" => DB_TYPE_INTEGER, "value" => $graph_template_item_id);

	/* field: graph_template_id */
	if (!empty($_fields_graph_item["graph_template_id"])) {
		$_fields["graph_template_id"] = array("type" => DB_TYPE_INTEGER, "value" => $_fields_graph_item["graph_template_id"]);
	}

	/* field: sequence */
	if (empty($graph_template_item_id)) {
		$_fields["sequence"] = array("type" => DB_TYPE_INTEGER, "value" => seq_get_current($graph_template_item_id, "sequence", "graph_template_item", "graph_template_id = " . sql_sanitize($_fields_graph_item["graph_template_id"])));
	}

	/* convert the input array into something that is compatible with db_replace() */
	$_fields += sql_get_database_field_array($_fields_graph_item, api_graph_template_item_form_list());

	if (db_replace("graph_template_item", $_fields, array("id"))) {
		if (empty($graph_template_item_id)) {
			$graph_template_item_id = db_fetch_insert_id();
		}

		return $graph_template_item_id;
	}else{
		return false;
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:46,代码来源:graph_template_update.php

示例14: api_data_template_item_get

function api_data_template_item_get($data_template_item_id) {
	/* sanity check for $data_template_item_id */
	if ((!is_numeric($data_template_item_id)) || (empty($data_template_item_id))) {
		return false;
	}

	$data_template_item = db_fetch_row("select * from data_template_item where id = " . sql_sanitize($data_template_item_id));

	if (sizeof($data_template_item) == 0) {
		log_save("Invalid data template item [ID#$data_template_item_id] specified in api_data_template_item_get()", SEV_ERROR);
		return false;
	}else{
		return $data_template_item;
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:15,代码来源:data_template_info.php

示例15: api_graph_tree_item_save

function api_graph_tree_item_save($graph_tree_item_id, &$_fields_graph_tree_item) {
	require_once(CACTI_BASE_PATH . "/include/graph_tree/graph_tree_constants.php");
	require_once(CACTI_BASE_PATH . "/lib/graph_tree/graph_tree_utility.php");
	require_once(CACTI_BASE_PATH . "/lib/graph_tree/graph_tree_info.php");

	/* sanity checks */
	validate_id_die($graph_tree_item_id, "graph_tree_item_id", true);

	/* sanity check for $graph_tree_id */
	if ((empty($graph_tree_item_id)) && (empty($_fields_graph_tree_item["graph_tree_id"]))) {
		log_save("Required graph_tree_id when graph_tree_item_id = 0", SEV_ERROR);
		return false;
	}else if ((isset($_fields_graph_tree_item["graph_tree_id"])) && (!db_integer_validate($_fields_graph_tree_item["graph_tree_id"]))) {
		return false;
	}

	/* sanity check for $item_type */
	if ((!isset($_fields_graph_tree_item["item_type"])) || (!db_integer_validate($_fields_graph_tree_item["item_type"]))) {
		log_save("Missing required item_type", SEV_ERROR);
		return false;
	}

	/* sanity check for $item_value */
	if ((empty($graph_tree_item_id)) && (empty($_fields_graph_tree_item["item_value"]))) {
		log_save("Required item_value when graph_tree_item_id = 0", SEV_ERROR);
		return false;
	}else if ((isset($_fields_graph_tree_item["item_value"])) && ( (($_fields_graph_tree_item["item_type"] == TREE_ITEM_TYPE_GRAPH) || ($_fields_graph_tree_item["item_type"] == TREE_ITEM_TYPE_HOST)) && (!db_integer_validate($_fields_graph_tree_item["item_value"])) )) {
		return false;
	}

	/* sanity check for $parent_item_id */
	if ((!isset($_fields_graph_tree_item["parent_item_id"])) || (!db_integer_validate($_fields_graph_tree_item["parent_item_id"], true))) {
		log_save("Missing required parent_item_id", SEV_ERROR);
		return false;
	}

	/* field: id */
	$_fields["id"] = array("type" => DB_TYPE_INTEGER, "value" => $graph_tree_item_id);

	/* field: graph_tree_id */
	if (isset($_fields_graph_tree_item["graph_tree_id"])) {
		$_fields["graph_tree_id"] = array("type" => DB_TYPE_INTEGER, "value" => $_fields_graph_tree_item["graph_tree_id"]);
	}

	/* get a copy of the parent tree item id */
	if ($_fields_graph_tree_item["parent_item_id"] == "0") {
		$parent_order_key = "";
		$parent_sort_type = TREE_ORDERING_NONE;
	}else{
		$parent_graph_tree_item = api_graph_tree_item_get($_fields_graph_tree_item["parent_item_id"]);
		$parent_order_key = $parent_graph_tree_item["order_key"];
		$parent_sort_type = $parent_graph_tree_item["sort_children_type"];
	}

	/* generate a new order key if this is a new graph tree item */
	if (empty($graph_tree_item_id)) {
		$_fields["order_key"] = array("type" => DB_TYPE_STRING, "value" => api_graph_tree_item_available_order_key_get($_fields_graph_tree_item["graph_tree_id"], $parent_order_key));
	}else{
		$graph_tree_item = api_graph_tree_item_get($graph_tree_item_id);
		$_fields["order_key"] = array("type" => DB_TYPE_STRING, "value" => $graph_tree_item["order_key"]);
	}

	/* if this item is a graph, make sure it is not being added to the same branch twice */
	$search_key = substr($parent_order_key, 0, (api_graph_tree_item_depth_get($parent_order_key) * CHARS_PER_TIER));
	if (($_fields_graph_tree_item["item_type"] == TREE_ITEM_TYPE_GRAPH) && (sizeof(db_fetch_assoc("select id from graph_tree_items where item_value = " . $_fields_graph_tree_item["item_value"] . " and item_type = " . TREE_ITEM_TYPE_GRAPH . " and graph_tree_id = " . $_fields_graph_tree_item["graph_tree_id"] . " and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) {
		return true;
	}

	/* convert the input array into something that is compatible with db_replace() */
	$_fields += sql_get_database_field_array($_fields_graph_tree_item, api_graph_tree_item_form_list());

	/* check for an empty field list */
	if (sizeof($_fields) == 1) {
		return true;
	}

	if (db_replace("graph_tree_items", $_fields, array("id"))) {
		if (empty($graph_tree_item_id)) {
			$graph_tree_item_id = db_fetch_insert_id();
		}

		/* re-parent the branch if the parent item has changed */
		if ($_fields_graph_tree_item["parent_item_id"] != api_graph_tree_item_parent_get_bykey($_fields["order_key"]["value"], $_fields_graph_tree_item["graph_tree_id"])) {
			api_graph_tree_item_reparent($graph_tree_item_id, $_fields_graph_tree_item["parent_item_id"]);
		}

		$parent_tree = api_graph_tree_get($_fields_graph_tree_item["graph_tree_id"]);

		/* tree item ordering */
		if ($parent_tree["sort_type"] == TREE_ORDERING_NONE) {
			/* resort our parent */
			if ($parent_sort_type != TREE_ORDERING_NONE) {
				echo $parent_sort_type;
				api_graph_tree_item_sort(SORT_TYPE_TREE_ITEM, $_fields_graph_tree_item["parent_item_id"], $parent_sort_type);
			}

			/* if this is a header, sort direct children */
			if (($_fields_graph_tree_item["item_type"] == TREE_ITEM_TYPE_HEADER) && ($parent_sort_type != TREE_ORDERING_NONE)) {
				api_graph_tree_item_sort(SORT_TYPE_TREE_ITEM, $graph_tree_item_id, $parent_sort_type);
			}
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:graph_tree_update.php


注:本文中的log_save函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。