diff -ruBbd cacti-0.8.6h/cacti.sql yak/cacti.sql --- cacti-0.8.6h/cacti.sql 2006-01-03 22:08:36.000000000 -0500 +++ yak/cacti.sql 2006-01-07 16:21:36.406250000 -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/database.php yak/lib/database.php --- cacti-0.8.6h/lib/database.php 2006-01-03 22:08:36.000000000 -0500 +++ yak/lib/database.php 2006-01-07 14:43:36.156250000 -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/template.php yak/lib/template.php --- cacti-0.8.6h/lib/template.php 2006-01-03 22:08:36.000000000 -0500 +++ yak/lib/template.php 2006-01-07 15:08:31.953125000 -0500 @@ -643,10 +642,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"]}); + } } } }