diff -ruBbd cacti-0.8.6h/cacti.sql cacti-0.8.6h-patched/cacti.sql --- cacti-0.8.6h/cacti.sql 2006-01-03 22:08:30.000000000 -0500 +++ cacti-0.8.6h-patched/cacti.sql 2006-01-25 00:16:43.000000000 -0500 @@ -1846,7 +1846,7 @@ avg_time decimal(10,5) default '0.00000', total_polls int(12) unsigned default '0', failed_polls int(12) unsigned default '0', - availability decimal(7,5) NOT NULL default '100.00000', + availability decimal(8,5) NOT NULL default '100.00000', PRIMARY KEY (id) ) TYPE=MyISAM; diff -ruBbd cacti-0.8.6h/lib/auth.php cacti-0.8.6h-patched/lib/auth.php --- cacti-0.8.6h/lib/auth.php 2006-01-03 22:08:30.000000000 -0500 +++ cacti-0.8.6h-patched/lib/auth.php 2006-01-25 00:20:48.000000000 -0500 @@ -40,25 +40,25 @@ $user_auth_perms = db_fetch_assoc("select * from user_auth_perms where user_id = '$old_id'"); foreach ($user_auth_perms as $row) { $row['user_id'] = $new_id; - sql_save($row, 'user_auth_perms', array('user_id', 'item_id', 'type')); + sql_save($row, 'user_auth_perms', array('user_id', 'item_id', 'type'), false); } $user_auth_realm = db_fetch_assoc("select * from user_auth_realm where user_id = '$old_id'"); foreach ($user_auth_realm as $row) { $row['user_id'] = $new_id; - sql_save($row, 'user_auth_realm', array('realm_id', 'user_id')); + sql_save($row, 'user_auth_realm', array('realm_id', 'user_id'), false); } $settings_graphs = db_fetch_assoc("select * from settings_graphs where user_id = '$old_id'"); foreach ($settings_graphs as $row) { $row['user_id'] = $new_id; - sql_save($row, 'settings_graphs', array('user_id', 'name')); + sql_save($row, 'settings_graphs', array('user_id', 'name'), false); } $settings_tree = db_fetch_assoc("select * from settings_tree where user_id = '$old_id'"); foreach ($settings_tree as $row) { $row['user_id'] = $new_id; - sql_save($row, 'settings_tree', array('user_id', 'graph_tree_item_id')); + sql_save($row, 'settings_tree', array('user_id', 'graph_tree_item_id'), false); } } diff -ruBbd cacti-0.8.6h/lib/database.php cacti-0.8.6h-patched/lib/database.php --- cacti-0.8.6h/lib/database.php 2006-01-03 22:08:30.000000000 -0500 +++ cacti-0.8.6h-patched/lib/database.php 2006-01-25 00:16:43.000000000 -0500 @@ -214,14 +214,14 @@ @arg $table_name - the name of the table to make the replacement in @arg $key_cols - the primary key(s) @returns - the auto incriment id column (if applicable) */ -function sql_save($array_items, $table_name, $key_cols = "id") { +function sql_save($array_items, $table_name, $key_cols = "id", $autoinc = TRUE) { global $cnn_id; while (list ($key, $value) = each ($array_items)) { $array_items[$key] = "\"" . sql_sanitize($value) . "\""; } - if (!$cnn_id->Replace($table_name, $array_items, $key_cols, false)) { return 0; } + if (!$cnn_id->Replace($table_name, $array_items, $key_cols, FALSE, $autoinc)) { return 0; } /* get the last AUTO_ID and return it */ if ($cnn_id->Insert_ID() == "0") { diff -ruBbd cacti-0.8.6h/lib/import.php cacti-0.8.6h-patched/lib/import.php --- cacti-0.8.6h/lib/import.php 2006-01-03 22:08:30.000000000 -0500 +++ cacti-0.8.6h-patched/lib/import.php 2006-01-25 00:21:16.000000000 -0500 @@ -341,7 +341,7 @@ $save["t_value"] = $item_array["t_value"]; $save["value"] = addslashes(xml_character_decode($item_array["value"])); - sql_save($save, "data_input_data", array("data_template_data_id", "data_input_field_id")); + sql_save($save, "data_input_data", array("data_template_data_id", "data_input_field_id"), false); } } @@ -419,7 +419,7 @@ $save["data_template_rrd_id"] = resolve_hash_to_id($sub_item_array["data_template_rrd_id"], $hash_cache); $save["snmp_field_name"] = $sub_item_array["snmp_field_name"]; - sql_save($save, "snmp_query_graph_rrd", array("snmp_query_graph_id", "data_template_id", "data_template_rrd_id")); + sql_save($save, "snmp_query_graph_rrd", array("snmp_query_graph_id", "data_template_id", "data_template_rrd_id"), false); } } diff -ruBbd cacti-0.8.6h/lib/template.php cacti-0.8.6h-patched/lib/template.php --- cacti-0.8.6h/lib/template.php 2006-01-03 22:08:30.000000000 -0500 +++ cacti-0.8.6h-patched/lib/template.php 2006-01-25 00:16:43.000000000 -0500 @@ -643,10 +643,16 @@ /* if there are no '|' characters, all of the substitutions were successful */ if (!strstr($subs_string, "|query")) { + if (sizeof(db_fetch_row("show columns from data_template_data like '" . $suggested_value["field_name"] . "'"))) { db_execute("update data_template_data set " . $suggested_value["field_name"] . "='" . addslashes($suggested_value["text"]) . "' where local_data_id=" . $cache_array["local_data_id"]{$data_template["id"]}); + } /* once we find a working value, stop */ $suggested_values_ds{$data_template["id"]}{$suggested_value["field_name"]} = true; + + if (sizeof(db_fetch_row("show columns from data_template_rrd like '" . $suggested_value["field_name"] . "'"))) { + db_execute("update data_template_rrd set " . $suggested_value["field_name"] . "='" . $subs_string . "' where local_data_id=" . $cache_array["local_data_id"]{$data_template["id"]}); + } } } }