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


PHP db_replace函数代码示例

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


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

示例1: api_device_save

function api_device_save($device_id, &$_fields_device) {
	require_once(CACTI_BASE_PATH . "/lib/device/device_info.php");

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

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

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

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

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

示例2: api_data_preset_gprint_save

function api_data_preset_gprint_save($data_preset_gprint_id, $_fields_data_preset_gprint) {
	require_once(CACTI_BASE_PATH . "/lib/data_preset/data_preset_gprint_info.php");

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

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

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

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

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

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

示例3: form_save

function form_save() {
	global $settings_graphs;

	while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
		while (list($field_name, $field_array) = each($tab_fields)) {
			if ((isset($field_array["items"])) && (is_array($field_array["items"]))) {
				while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
					db_replace("settings_graphs",array("user_id"=>$_SESSION["sess_user_id"],"name"=>$sub_field_name,"value"=>(isset($_POST[$sub_field_name]) ? $_POST[$sub_field_name] : "")),array("user_id","name"),true);
				}
			}else{
				db_replace("settings_graphs",array("user_id"=>$_SESSION["sess_user_id"],"name"=>$field_name,"value"=>(isset($_POST[$field_name]) ? $_POST[$field_name] : "")),array("user_id","name"),true);
			}
		}
	}

	/* reset local settings cache so the user sees the new settings */
	kill_session_var("sess_graph_config_array");

	header("Location: " . $_POST["referer"]);
}
开发者ID:songchin,项目名称:Cacti,代码行数:20,代码来源:graph_settings.php

示例4: api_user_save

function api_user_save($array) {

	if (db_replace("user_auth", $array)) {

		/* logging */
		if (empty($array["id"])) {
			/* New user */
			$user_id = db_fetch_insert_id();
			log_save(sprintf(_("USER_ADMIN: User id '%s' added"), $user_id), SEV_NOTICE, FACIL_AUTH);
		}else{
			/* existing user */
			$user_id = $array["id"]["value"];
			log_save(sprintf(_("USER_ADMIN: User id '%s' updated"), $user_id), SEV_NOTICE, FACIL_AUTH);
		}
		return $user_id;
	} else {
		log_save(sprintf(_("USER_ADMIN: Error saving user id '%s' "), $user_id), SEV_ERROR, FACIL_AUTH);
		return 0;
	}

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

示例5: 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

示例6: api_data_preset_rra_item_save

function api_data_preset_rra_item_save($data_preset_rra_item_id, $_fields_data_preset_rra_item) {
	require_once(CACTI_BASE_PATH . "/lib/data_preset/data_preset_rra_info.php");

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

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

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

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

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

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

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

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

示例7: sql_save

function sql_save($fields, $table_name, $keys = "") {
	global $cnn_id;

	/* default primary key */
	if (!is_array($keys)) {
		$keys = array("id");
	}

	if (sizeof($fields) > 0) {
		foreach ($fields as $db_field_name => $db_field_value) {
			$new_fields[$db_field_name] = array("type" => DB_TYPE_STRING, "value" => $db_field_value);
		}
	}

	if (db_replace($table_name, $new_fields, $keys)) {
		if (empty($fields["id"])) {
			return $cnn_id->Insert_ID();
		}else{
			return $fields["id"];
		}
	}else{
		return false;
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:24,代码来源:database.php

示例8: sesskey

    echo $OUTPUT->notification(get_string('notimplemented', 'tool_replace'));
    echo $OUTPUT->footer();
    die;
}
if (!data_submitted() or !$search or !$replace or !confirm_sesskey() or !$sure) {
    /// Print a form
    echo $OUTPUT->notification(get_string('notsupported', 'tool_replace'));
    echo $OUTPUT->notification(get_string('excludedtables', 'tool_replace'));
    echo $OUTPUT->box_start();
    echo '<div class="mdl-align">';
    echo '<form action="index.php" method="post"><div>';
    echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
    echo '<div><label for="search">' . get_string('searchwholedb', 'tool_replace') . ' </label><input id="search" type="text" name="search" size="40" /> (' . get_string('searchwholedbhelp', 'tool_replace') . ')</div>';
    echo '<div><label for="replace">' . get_string('replacewith', 'tool_replace') . ' </label><input type="text" id="replace" name="replace" size="40" /> (' . get_string('replacewithhelp', 'tool_replace') . ')</div>';
    echo '<div><label for="sure">' . get_string('disclaimer', 'tool_replace') . ' </label><input type="checkbox" id="sure" name="sure" value="1" /></div>';
    echo '<div class="buttons"><input type="submit" class="singlebutton" value="Yes, do it now" /></div>';
    echo '</div></form>';
    echo '</div>';
    echo $OUTPUT->box_end();
    echo $OUTPUT->footer();
    die;
}
echo $OUTPUT->box_start();
db_replace($search, $replace);
echo $OUTPUT->box_end();
/// Rebuild course cache which might be incorrect now
echo $OUTPUT->notification(get_string('notifyrebuilding', 'tool_replace'), 'notifysuccess');
rebuild_course_cache();
echo $OUTPUT->notification(get_string('notifyfinished', 'tool_replace'), 'notifysuccess');
echo $OUTPUT->continue_button(new moodle_url('/admin/index.php'));
echo $OUTPUT->footer();
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:index.php

示例9: each

		$_REQUEST["step"] = "3";
	}elseif ($_REQUEST["step"] == "3") {
		$_REQUEST["step"] = "4";
	}
}

if ($_REQUEST["step"] == "4") {
	include_once("../lib/data_query.php");
	include_once("../lib/utility.php");

	$i = 0;

	/* get all items on the form and write values for them  */
	while (list($name, $array) = each($input)) {
		if (isset($_POST[$name])) {
			db_replace("settings", array("name"=>"$name","value"=>"$_POST[$name]"), "name", true);
		}
	}

	setcookie(session_name(),"",time() - 3600,"/");

	kill_session_var("sess_config_array");
	kill_session_var("sess_host_cache_array");

	/* just in case we have hard drive graphs to deal with */
	$host_id = db_fetch_cell("select id from host where hostname='127.0.0.1'");

	if (!empty($host_id)) {
		run_data_query($host_id, 6);
	}
开发者ID:songchin,项目名称:Cacti,代码行数:30,代码来源:index.php

示例10: optional_param

$search = optional_param('search', '', PARAM_RAW);
$replace = optional_param('replace', '', PARAM_RAW);
###################################################################
admin_externalpage_print_header();
print_heading('Search and replace text throughout the whole database');
if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) {
    /// Print a form
    print_simple_box_start('center');
    echo '<div align="center">';
    echo '<form action="replace.php" method="post">';
    echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
    echo 'Search whole database for: <input type="text" name="search" /><br />';
    echo 'Replace with this string: <input type="text" name="replace" /><br />';
    echo '<input type="submit" value="Yes, do it now" /><br />';
    echo '</form>';
    echo '</div>';
    print_simple_box_end();
    admin_externalpage_print_footer();
    die;
}
print_simple_box_start('center');
if (!db_replace($search, $replace)) {
    error('An error has occured during this process');
}
print_simple_box_end();
/// Rebuild course cache which might be incorrect now
notify('Rebuilding course cache...');
rebuild_course_cache();
notify('...finished');
print_continue('index.php');
admin_externalpage_print_footer();
开发者ID:r007,项目名称:PMoodle,代码行数:31,代码来源:replace.php

示例11: api_device_save

function api_device_save($id, $host_template_id, $description, $hostname, $snmp_community, $snmp_version,
	$snmp_username, $snmp_password, $snmp_port, $snmp_timeout, $disabled,
	$availability_method, $ping_method, $ping_port, $ping_timeout, $ping_retries,
	$notes, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context) {

	/* fetch some cache variables */
	if (empty($id)) {
		$_host_template_id = 0;
	}else{
		$_host_template_id = db_fetch_cell("select host_template_id from host where id=$id");
	}

	$save["id"] = $id;
	$save["host_template_id"]     = form_input_validate($host_template_id, "host_template_id", "^[0-9]+$", false, 3);
	$save["description"]          = form_input_validate($description, "description", "", false, 3);
	$save["hostname"]             = form_input_validate($hostname, "hostname", "", false, 3);
	$save["notes"]                = form_input_validate($notes, "notes", "", true, 3);

	$save["snmp_version"]         = form_input_validate($snmp_version, "snmp_version", "", true, 3);
	$save["snmp_community"]       = form_input_validate($snmp_community, "snmp_community", "", true, 3);

	$save["snmp_username"]        = form_input_validate($snmp_username, "snmp_username", "", true, 3);
	$save["snmp_password"]        = form_input_validate($snmp_password, "snmp_password", "", true, 3);
	$save["snmp_auth_protocol"]   = form_input_validate($snmp_auth_protocol, "snmp_auth_protocol", "", true, 3);
	$save["snmp_priv_passphrase"] = form_input_validate($snmp_priv_passphrase, "snmp_priv_passphrase", "", true, 3);
	$save["snmp_priv_protocol"]   = form_input_validate($snmp_priv_protocol, "snmp_priv_protocol", "", true, 3);
	$save["snmp_context"]         = form_input_validate($snmp_context, "snmp_context", "", true, 3);

	$save["snmp_port"]            = form_input_validate($snmp_port, "snmp_port", "^[0-9]+$", false, 3);
	$save["snmp_timeout"]         = form_input_validate($snmp_timeout, "snmp_timeout", "^[0-9]+$", false, 3);

	$save["disabled"]             = form_input_validate($disabled, "disabled", "", true, 3);

	$save["availability_method"]  = form_input_validate($availability_method, "availability_method", "^[0-9]+$", false, 3);
	$save["ping_method"]          = form_input_validate($ping_method, "ping_method", "^[0-9]+$", false, 3);
	$save["ping_port"]            = form_input_validate($ping_port, "ping_port", "^[0-9]+$", true, 3);
	$save["ping_timeout"]         = form_input_validate($ping_timeout, "ping_timeout", "^[0-9]+$", true, 3);
	$save["ping_retries"]         = form_input_validate($ping_retries, "ping_retries", "^[0-9]+$", true, 3);

	$host_id = 0;

	if (!is_error_message()) {
		$host_id = sql_save($save, "host");

		if ($host_id) {
			raise_message(1);

			/* push out relavant fields to data sources using this host */
			push_out_host($host_id, 0);

			/* the host substitution cache is now stale; purge it */
			kill_session_var("sess_host_cache_array");

			/* update title cache for graph and data source */
			update_data_source_title_cache_from_host($host_id);
			update_graph_title_cache_from_host($host_id);
		}else{
			raise_message(2);
		}

		/* if the user changes the host template, add each snmp query associated with it */
		if (($host_template_id != $_host_template_id) && (!empty($host_template_id))) {
			$snmp_queries = db_fetch_assoc("select snmp_query_id from host_template_snmp_query where host_template_id=$host_template_id");

			if (sizeof($snmp_queries) > 0) {
			foreach ($snmp_queries as $snmp_query) {
				db_replace("host_snmp_query",array("host_id"=>$host_id,"snmp_query_id"=>$snmp_query["snmp_query_id"],"reindex_method"=>DATA_QUERY_AUTOINDEX_BACKWARDS_UPTIME),array("host_id","snmp_query_id"),true);

				/* recache snmp data */
				run_data_query($host_id, $snmp_query["snmp_query_id"]);
			}
			}

			$graph_templates = db_fetch_assoc("select graph_template_id from host_template_graph where host_template_id=$host_template_id");

			if (sizeof($graph_templates) > 0) {
			foreach ($graph_templates as $graph_template) {
				db_replace("host_graph",array("host_id"=>$host_id,"graph_template_id"=>$graph_template["graph_template_id"]),array("host_id","graph_template_id"),true);
			}
			}
		}
	}

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

示例12: define

 */
define('NO_OUTPUT_BUFFERING', true);
require_once '../../../config.php';
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->libdir . '/adminlib.php';
admin_externalpage_setup('toolreplace');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('pageheader', 'tool_replace'));
if (!$DB->replace_all_text_supported()) {
    echo $OUTPUT->notification(get_string('notimplemented', 'tool_replace'));
    echo $OUTPUT->footer();
    die;
}
echo $OUTPUT->box_start();
echo $OUTPUT->notification(get_string('notsupported', 'tool_replace'));
echo $OUTPUT->notification(get_string('excludedtables', 'tool_replace'));
echo $OUTPUT->box_end();
$form = new tool_replace_form();
if (!($data = $form->get_data())) {
    $form->display();
    echo $OUTPUT->footer();
    die;
}
// Scroll to the end when finished.
$PAGE->requires->js_init_code("window.scrollTo(0, 5000000);");
echo $OUTPUT->box_start();
db_replace($data->search, $data->replace);
echo $OUTPUT->box_end();
// Course caches are now rebuilt on the fly.
echo $OUTPUT->continue_button(new moodle_url('/admin/index.php'));
echo $OUTPUT->footer();
开发者ID:pzhu2004,项目名称:moodle,代码行数:31,代码来源:index.php

示例13: 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

示例14: form_save

function form_save() {
	if (isset($_POST["save_component_item"])) {
		/* ================= input validation ================= */
		input_validate_input_number(get_request_var_post("graph_template_id"));
		input_validate_input_number(get_request_var_post("task_item_id"));
		/* ==================================================== */

		global $graph_item_types;

		$items[0] = array();

		if ($graph_item_types{$_POST["graph_type_id"]} == "LEGEND") {
			/* this can be a major time saver when creating lots of graphs with the typical
			GPRINT LAST/AVERAGE/MAX legends */
			$items = array(
				0 => array(
					"color_id" => "0",
					"graph_type_id" => "9",
					"consolidation_function_id" => "4",
					"text_format" => "Current:",
					"hard_return" => ""
					),
				1 => array(
					"color_id" => "0",
					"graph_type_id" => "9",
					"consolidation_function_id" => "1",
					"text_format" => "Average:",
					"hard_return" => ""
					),
				2 => array(
					"color_id" => "0",
					"graph_type_id" => "9",
					"consolidation_function_id" => "3",
					"text_format" => "Maximum:",
					"hard_return" => "on"
					));
		}

		foreach ($items as $item) {
			/* generate a new sequence if needed */
			if (empty($_POST["sequence"])) {
				$_POST["sequence"] = get_sequence($_POST["sequence"], "sequence", "graph_templates_item", "graph_template_id=" . $_POST["graph_template_id"] . " and local_graph_id=0");
			}

			$save["id"] = $_POST["graph_template_item_id"];
			$save["hash"] = get_hash_graph_template($_POST["graph_template_item_id"], "graph_template_item");
			$save["graph_template_id"] = $_POST["graph_template_id"];
			$save["local_graph_id"] = 0;
			$save["task_item_id"] = form_input_validate($_POST["task_item_id"], "task_item_id", "", true, 3);
			$save["color_id"] = form_input_validate((isset($item["color_id"]) ? $item["color_id"] : $_POST["color_id"]), "color_id", "", true, 3);
			$save["graph_type_id"] = form_input_validate((isset($item["graph_type_id"]) ? $item["graph_type_id"] : $_POST["graph_type_id"]), "graph_type_id", "", true, 3);
			$save["cdef_id"] = form_input_validate($_POST["cdef_id"], "cdef_id", "", true, 3);
			$save["consolidation_function_id"] = form_input_validate((isset($item["consolidation_function_id"]) ? $item["consolidation_function_id"] : $_POST["consolidation_function_id"]), "consolidation_function_id", "", true, 3);
			$save["text_format"] = form_input_validate((isset($item["text_format"]) ? $item["text_format"] : $_POST["text_format"]), "text_format", "", true, 3);
			$save["value"] = form_input_validate($_POST["value"], "value", "", true, 3);
			$save["hard_return"] = form_input_validate(((isset($item["hard_return"]) ? $item["hard_return"] : (isset($_POST["hard_return"]) ? $_POST["hard_return"] : ""))), "hard_return", "", true, 3);
			$save["gprint_id"] = form_input_validate($_POST["gprint_id"], "gprint_id", "", true, 3);
			$save["sequence"] = $_POST["sequence"];

			if (!is_error_message()) {
				/* Before we save the item, let's get a look at task_item_id <-> input associations */
				$orig_data_source_graph_inputs = db_fetch_assoc("select
					graph_template_input.id,
					graph_template_input.name,
					graph_templates_item.task_item_id
					from graph_template_input, graph_template_input_defs, graph_templates_item
					where graph_template_input.id=graph_template_input_defs.graph_template_input_id
					and graph_template_input_defs.graph_template_item_id=graph_templates_item.id
					and graph_template_input.graph_template_id=" . $save["graph_template_id"] . "
					and graph_template_input.column_name='task_item_id'
					group by graph_templates_item.task_item_id,graph_template_input.id,graph_template_input.name");

				$orig_data_source_to_input = array_rekey($orig_data_source_graph_inputs, "task_item_id", "id");

				$graph_template_item_id = sql_save($save, "graph_templates_item");

				if ($graph_template_item_id) {
					raise_message(1);

					if (!empty($save["task_item_id"])) {
						/* old item clean-up.  Don't delete anything if the item <-> task_item_id association remains the same. */
						if ($_POST["_task_item_id"] != $_POST["task_item_id"]) {
							/* It changed.  Delete any old associations */
							db_execute("delete from graph_template_input_defs where graph_template_item_id=$graph_template_item_id");

							/* Input for current data source exists and has changed.  Update the association */
							if (isset($orig_data_source_to_input{$save["task_item_id"]})) {
								db_replace("graph_template_input_defs",array("graph_template_input_id"=>$orig_data_source_to_input{$save["task_item_id"]},"graph_template_item_id"=>$graph_template_item_id),array("graph_template_input_id","graph_template_item_id"),true);
							}
						}

						/* an input for the current data source does NOT currently exist, let's create one */
						if (!isset($orig_data_source_to_input{$save["task_item_id"]})) {
							$ds_name = db_fetch_cell("select data_source_name from data_template_rrd where id=" . $_POST["task_item_id"]);

							/* db_replace() won't work since an insert_id is needed */
							db_execute("delete from graph_template_input where graph_template_id = " . $save["graph_template_id"] . " and name = 'Data Source [$ds_name]' and column_name = 'task_item_id'");
							$graph_template_input_id = db_fetch_cell("select max(id)+1 from graph_template_input");
							db_execute("insert into graph_template_input (id,hash,graph_template_id,name,column_name) values ($graph_template_input_id,'" . get_hash_graph_template(0, "graph_template_input") . "',". $save["graph_template_id"].",'Data Source [$ds_name]','task_item_id')");

//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:graph_templates_items.php

示例15: update_link_payment

function update_link_payment($pid, $data, $success, $raw)
{
    global $db, $tables;
    $pdata = $db->GetRow("SELECT * FROM `{$tables['payment']['name']}` WHERE `ID` = " . $db->qstr($pid));
    if (!$pdata['ID']) {
        return false;
    }
    $pdata['NAME'] = $data['name'];
    $pdata['EMAIL'] = $data['email'];
    $pdata['PAYED_TOTAL'] = (int) $data['total'];
    $pdata['PAYED_QUANTITY'] = (double) $data['quantity'];
    $pdata['CONFIRMED'] = $success ? 1 : 0;
    $pdata['CONFIRM_DATE'] = gmdate('Y-m-d H:i:s');
    $pdate['RAW_LOG'] = $raw;
    if ((double) $pdata['PAYED_TOTAL'] < (double) $pdata['TOTAL']) {
        $pdata['CONFIRMED'] = -1;
    }
    db_replace('payment', $pdata, 'ID');
    $ldata = $db->GetRow("SELECT * FROM `{$tables['link']['name']}` WHERE `ID` = " . $db->qstr($pdata['LINK_ID']));
    send_payment_notifications($pdata, $ldata);
    //Take no action if link not found
    if (!$ldata['ID']) {
        return false;
    }
    $ldata['EXPIRY_DATE'] = '';
    if ($pdata['CONFIRMED'] != 1 || (double) $pdata['PAYED_TOTAL'] < (double) $pdata['TOTAL']) {
        $ldata['PAYED'] = 0;
    } else {
        $ldata['PAYED'] = $pdata['ID'];
        if (PAY_AUTO_ACCEPT) {
            $ldata['STATUS'] = 2;
            $exp_date = calculate_expiry_date(time(), $pdata['QUANTITY'], $pdata['UM']);
            if ($exp_date != 0) {
                $ldata['EXPIRY_DATE'] = gmdate('Y-m-d H:i:s', $exp_date);
            }
        }
    }
    db_replace('link', $ldata, 'ID');
}
开发者ID:smcaleer,项目名称:scriptmind-links,代码行数:39,代码来源:functions.php


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