1 diff -urbB cacti-0.8.6g/data_queries.php cacti/data_queries.php
2 --- cacti-0.8.6g/data_queries.php 2005-09-09 01:56:25.000000000 +0200
3 +++ cacti/data_queries.php 2005-11-24 19:32:45.000000000 +0100
5 $data_templates = db_fetch_assoc("select
8 - from data_template, data_template_rrd, graph_templates_item
9 + from (data_template, data_template_rrd, graph_templates_item)
10 where graph_templates_item.task_item_id=data_template_rrd.id
11 and data_template_rrd.data_template_id=data_template.id
12 and data_template_rrd.local_data_id=0
14 graph_templates.name as graph_template_name,
17 - left join graph_templates on snmp_query_graph.graph_template_id=graph_templates.id
18 + left join graph_templates on (snmp_query_graph.graph_template_id=graph_templates.id)
19 where snmp_query_graph.snmp_query_id=" . $snmp_query["id"] . "
20 order by snmp_query_graph.name");
25 data_input.name AS data_input_method
26 - FROM snmp_query INNER JOIN data_input ON snmp_query.data_input_id = data_input.id
27 + FROM snmp_query INNER JOIN data_input ON (snmp_query.data_input_id = data_input.id)
28 ORDER BY snmp_query.name");
31 diff -urbB cacti-0.8.6g/data_sources.php cacti/data_sources.php
32 --- cacti-0.8.6g/data_sources.php 2005-09-09 01:56:25.000000000 +0200
33 +++ cacti/data_sources.php 2005-11-24 19:32:45.000000000 +0100
35 data_input_fields.allow_nulls,
36 data_input_fields.type_code
37 from data_template_data
38 - left join data_input_fields on data_input_fields.data_input_id=data_template_data.data_input_id
39 - left join data_local on data_template_data.local_data_id=data_local.id
40 + left join data_input_fields on (data_input_fields.data_input_id=data_template_data.data_input_id)
41 + left join data_local on (data_template_data.local_data_id=data_local.id)
42 where data_template_data.id=" . $_POST["data_template_data_id"] . "
43 and data_input_fields.input_output='in'");
46 case '3': /* delete all graphs tied to this data source */
47 $graphs = db_fetch_assoc("select
48 graph_templates_graph.local_graph_id
49 - from data_template_rrd,graph_templates_item,graph_templates_graph
50 + from (data_template_rrd,graph_templates_item,graph_templates_graph)
51 where graph_templates_item.task_item_id=data_template_rrd.id
52 and graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id
53 and " . array_to_sql_or($selected_items, "data_template_rrd.local_data_id") . "
55 $graphs = db_fetch_assoc("select
56 graph_templates_graph.local_graph_id,
57 graph_templates_graph.title_cache
58 - from data_template_rrd,graph_templates_item,graph_templates_graph
59 + from (data_template_rrd,graph_templates_item,graph_templates_graph)
60 where graph_templates_item.task_item_id=data_template_rrd.id
61 and graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id
62 and " . array_to_sql_or($ds_array, "data_template_rrd.local_data_id") . "
64 $data = db_fetch_row("select id,data_input_id,data_template_id,name,local_data_id from data_template_data where local_data_id=" . $_GET["id"]);
65 $template_data = db_fetch_row("select id,data_input_id from data_template_data where data_template_id=" . $data["data_template_id"] . " and local_data_id=0");
67 - $host = db_fetch_row("select host.id,host.hostname from data_local,host where data_local.host_id=host.id and data_local.id=" . $_GET["id"]);
68 + $host = db_fetch_row("select host.id,host.hostname from (data_local,host) where data_local.host_id=host.id and data_local.id=" . $_GET["id"]);
70 $header_label = "[edit: " . $data["name"] . "]";
74 if (!empty($data["data_input_id"])) {
75 /* get each INPUT field for this data input source */
76 - $fields = db_fetch_assoc("select * from data_input_fields where data_input_id=" . $data["data_input_id"] . " and input_output='in' order by name");
77 + $fields = db_fetch_assoc("select * from data_input_fields where data_input_id=" . $data["data_input_id"] . " and input_output='in' order by sequence");
79 html_start_box("<strong>Custom Data</strong> [data input: " . db_fetch_cell("select name from data_input where id=" . $data["data_input_id"]) . "]", "98%", $colors["header"], "3", "center", "");
83 $total_rows = sizeof(db_fetch_assoc("select
85 - from data_local,data_template_data
86 + from (data_local,data_template_data)
87 where data_local.id=data_template_data.local_data_id
89 $data_sources = db_fetch_assoc("select
90 @@ -1002,11 +1002,11 @@
91 data_input.name as data_input_name,
92 data_template.name as data_template_name,
94 - from data_local,data_template_data
95 + from (data_local,data_template_data)
97 - on data_input.id=data_template_data.data_input_id
98 + on (data_input.id=data_template_data.data_input_id)
99 left join data_template
100 - on data_local.data_template_id=data_template.id
101 + on (data_local.data_template_id=data_template.id)
102 where data_local.id=data_template_data.local_data_id
104 order by data_template_data.name_cache,data_local.host_id
105 diff -urbB cacti-0.8.6g/data_templates.php cacti/data_templates.php
106 --- cacti-0.8.6g/data_templates.php 2005-09-09 01:56:25.000000000 +0200
107 +++ cacti/data_templates.php 2005-11-24 19:32:45.000000000 +0100
110 if (!empty($_GET["id"])) {
111 /* get each INPUT field for this data input source */
112 - $fields = db_fetch_assoc("select * from data_input_fields where data_input_id=" . $template_data["data_input_id"] . " and input_output='in' order by name");
113 + $fields = db_fetch_assoc("select * from data_input_fields where data_input_id=" . $template_data["data_input_id"] . " and input_output='in' order by sequence");
115 html_start_box("<strong>Custom Data</strong> [data input: " . db_fetch_cell("select name from data_input where id=" . $template_data["data_input_id"]) . "]", "98%", $colors["header"], "3", "center", "");
119 data_input.name as data_input_method,
120 data_template_data.active as active
121 - from data_template,data_template_data
122 - left join data_input on data_template_data.data_input_id = data_input.id
123 + from (data_template,data_template_data)
124 + left join data_input on (data_template_data.data_input_id = data_input.id)
125 where data_template.id = data_template_data.data_template_id
126 and data_template_data.local_data_id = 0
127 order by data_template.name");
129 Tylko w cacti/docs: build
130 diff -urbB cacti-0.8.6g/graph.php cacti/graph.php
131 --- cacti-0.8.6g/graph.php 2005-09-09 01:56:25.000000000 +0200
132 +++ cacti/graph.php 2005-11-24 19:32:45.000000000 +0100
134 /* find the step and how often this graph is updated with new data */
135 $ds_step = db_fetch_cell("select
136 data_template_data.rrd_step
137 - from data_template_data,data_template_rrd,graph_templates_item
138 + from (data_template_data,data_template_rrd,graph_templates_item)
139 where graph_templates_item.task_item_id=data_template_rrd.id
140 and data_template_rrd.local_data_id=data_template_data.local_data_id
141 and graph_templates_item.local_graph_id=" . $_GET["local_graph_id"] .
142 diff -urbB cacti-0.8.6g/graphs_items.php cacti/graphs_items.php
143 --- cacti-0.8.6g/graphs_items.php 2005-09-09 01:56:25.000000000 +0200
144 +++ cacti/graphs_items.php 2005-11-24 19:32:45.000000000 +0100
146 $struct_graph_item["task_item_id"]["sql"] = "select
147 CONCAT_WS('',data_template_data.name_cache,' (',data_template_rrd.data_source_name,')') as name,
149 - from data_template_data,data_template_rrd,data_local
150 - left join host on data_local.host_id=host.id
151 + from (data_template_data,data_template_rrd,data_local)
152 + left join host on (data_local.host_id=host.id)
153 where data_template_rrd.local_data_id=data_local.id
154 and data_template_data.local_data_id=data_local.id
155 " . (((!empty($host_id)) || (!empty($_REQUEST["host_id"]))) ? (!empty($host_id) ? " and data_local.host_id=$host_id" : " and data_local.host_id=" . $_REQUEST["host_id"]) : "") . "
156 diff -urbB cacti-0.8.6g/graphs_new.php cacti/graphs_new.php
157 --- cacti-0.8.6g/graphs_new.php 2005-09-09 01:56:25.000000000 +0200
158 +++ cacti/graphs_new.php 2005-11-24 19:32:45.000000000 +0100
160 data_template.name as data_template_name,
161 data_template_rrd.data_source_name,
163 - from data_template, data_template_rrd, data_template_data, graph_templates_item
164 + from (data_template, data_template_rrd, data_template_data, graph_templates_item)
165 where graph_templates_item.task_item_id=data_template_rrd.id
166 and data_template_rrd.data_template_id=data_template.id
167 and data_template_data.data_template_id=data_template.id
169 $graph_template = db_fetch_row("select
170 graph_templates.name as graph_template_name,
171 graph_templates_graph.*
172 - from graph_templates, graph_templates_graph
173 + from (graph_templates, graph_templates_graph)
174 where graph_templates.id=graph_templates_graph.graph_template_id
175 and graph_templates.id=" . $graph_template_id . "
176 and graph_templates_graph.local_graph_id=0");
177 @@ -441,14 +441,14 @@
178 $graph_templates = db_fetch_assoc("select
179 graph_templates.id as graph_template_id,
180 graph_templates.name as graph_template_name
181 - from host_graph,graph_templates
182 + from (host_graph,graph_templates)
183 where host_graph.graph_template_id=graph_templates.id
184 and host_graph.host_id=" . $_REQUEST["host_id"] . "
185 order by graph_templates.name");
187 $template_graphs = db_fetch_assoc("select
188 graph_local.graph_template_id
189 - from graph_local,host_graph
190 + from (graph_local,host_graph)
191 where graph_local.graph_template_id=host_graph.graph_template_id
192 and graph_local.host_id=host_graph.host_id
193 and graph_local.host_id=" . $host["id"] . "
195 $available_graph_templates = db_fetch_assoc("SELECT
196 graph_templates.id, graph_templates.name
197 FROM snmp_query_graph RIGHT JOIN graph_templates
198 - ON snmp_query_graph.graph_template_id = graph_templates.id
199 + ON (snmp_query_graph.graph_template_id = graph_templates.id)
200 WHERE (((snmp_query_graph.name) Is Null)) ORDER BY graph_templates.name");
202 /* create a row at the bottom that lets the user create any graph they choose */
207 - from snmp_query,host_snmp_query
208 + from (snmp_query,host_snmp_query)
209 where host_snmp_query.snmp_query_id=snmp_query.id
210 and host_snmp_query.host_id=" . $host["id"] . "
211 order by snmp_query.name");
213 foreach ($snmp_query_graphs as $snmp_query_graph) {
214 $created_graphs = db_fetch_assoc("select distinct
215 data_local.snmp_index
216 - from data_local,data_template_data
217 - left join data_input_data on data_template_data.id=data_input_data.data_template_data_id
218 - left join data_input_fields on data_input_data.data_input_field_id=data_input_fields.id
219 + from (data_local,data_template_data)
220 + left join data_input_data on (data_template_data.id=data_input_data.data_template_data_id)
221 + left join data_input_fields on (data_input_data.data_input_field_id=data_input_fields.id)
222 where data_local.id=data_template_data.local_data_id
223 and data_input_fields.type_code='output_type'
224 and data_input_data.value='" . $snmp_query_graph["id"] . "'
225 diff -urbB cacti-0.8.6g/graphs.php cacti/graphs.php
226 --- cacti-0.8.6g/graphs.php 2005-09-09 01:56:25.000000000 +0200
227 +++ cacti/graphs.php 2005-11-24 19:32:45.000000000 +0100
229 /* we need to find out which graph items will be affected by saving this particular item */
230 $item_list = db_fetch_assoc("select
231 graph_templates_item.id
232 - from graph_template_input_defs,graph_templates_item
233 + from (graph_template_input_defs,graph_templates_item)
234 where graph_template_input_defs.graph_template_item_id=graph_templates_item.local_graph_template_item_id
235 and graph_templates_item.local_graph_id=" . $_POST["local_graph_id"] . "
236 and graph_template_input_defs.graph_template_input_id=" . $input["id"]);
238 case '2': /* delete all data sources referenced by this graph */
239 $data_sources = db_fetch_assoc("select
240 data_template_data.local_data_id
241 - from data_template_rrd,data_template_data,graph_templates_item
242 + from (data_template_rrd,data_template_data,graph_templates_item)
243 where graph_templates_item.task_item_id=data_template_rrd.id
244 and data_template_rrd.local_data_id=data_template_data.local_data_id
245 and " . array_to_sql_or($selected_items, "graph_templates_item.local_graph_id") . "
247 $data_sources = db_fetch_assoc("select
248 data_template_data.local_data_id,
249 data_template_data.name_cache
250 - from data_template_rrd,data_template_data,graph_templates_item
251 + from (data_template_rrd,data_template_data,graph_templates_item)
252 where graph_templates_item.task_item_id=data_template_rrd.id
253 and data_template_rrd.local_data_id=data_template_data.local_data_id
254 and " . array_to_sql_or($graph_array, "graph_templates_item.local_graph_id") . "
255 @@ -551,11 +551,11 @@
256 cdef.name as cdef_name,
258 from graph_templates_item
259 - left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id
260 - left join data_local on data_template_rrd.local_data_id=data_local.id
261 - left join data_template_data on data_local.id=data_template_data.local_data_id
262 - left join cdef on cdef_id=cdef.id
263 - left join colors on color_id=colors.id
264 + left join data_template_rrd on (graph_templates_item.task_item_id=data_template_rrd.id)
265 + left join data_local on (data_template_rrd.local_data_id=data_local.id)
266 + left join data_template_data on (data_local.id=data_template_data.local_data_id)
267 + left join cdef on (cdef_id=cdef.id)
268 + left join colors on (color_id=colors.id)
269 where graph_templates_item.local_graph_id=" . $_GET["id"] . "
270 order by graph_templates_item.sequence");
272 @@ -598,11 +598,12 @@
273 CONCAT_WS(' - ',data_template_data.name,data_template_rrd.data_source_name) as task_item_id,
274 cdef.name as cdef_id,
275 colors.hex as color_id
276 - from graph_templates_item left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id
277 - left join data_local on data_template_rrd.local_data_id=data_local.id
278 - left join data_template_data on data_local.id=data_template_data.local_data_id
279 - left join cdef on cdef_id=cdef.id
280 - left join colors on color_id=colors.id";
281 + from graph_templates_item
282 + left join data_template_rrd on (graph_templates_item.task_item_id=data_template_rrd.id)
283 + left join data_local on (data_template_rrd.local_data_id=data_local.id)
284 + left join data_template_data on (data_local.id=data_template_data.local_data_id)
285 + left join cdef on (cdef_id=cdef.id)
286 + left join colors on (color_id=colors.id)";
288 /* first, get information about the graph template as that's what we're going to model this
291 $graph_template_inputs = db_fetch_assoc("select
292 graph_template_input.column_name,
293 graph_template_input_defs.graph_template_item_id
294 - from graph_template_input,graph_template_input_defs
295 + from (graph_template_input,graph_template_input_defs)
296 where graph_template_input.id=graph_template_input_defs.graph_template_input_id
297 and graph_template_input.graph_template_id=" . $_GET["graph_template_id"]);
299 @@ -1037,7 +1038,7 @@
301 $total_rows = db_fetch_cell("select
302 COUNT(graph_templates_graph.id)
303 - from graph_local,graph_templates_graph
304 + from (graph_local,graph_templates_graph)
305 where graph_local.id=graph_templates_graph.local_graph_id
308 @@ -1049,8 +1050,8 @@
309 graph_templates_graph.title_cache,
310 graph_templates.name,
312 - from graph_local,graph_templates_graph
313 - left join graph_templates on graph_local.graph_template_id=graph_templates.id
314 + from (graph_local,graph_templates_graph)
315 + left join graph_templates on (graph_local.graph_template_id=graph_templates.id)
316 where graph_local.id=graph_templates_graph.local_graph_id
318 order by graph_templates_graph.title_cache,graph_local.host_id
319 diff -urbB cacti-0.8.6g/graph_templates_inputs.php cacti/graph_templates_inputs.php
320 --- cacti-0.8.6g/graph_templates_inputs.php 2005-09-09 01:56:25.000000000 +0200
321 +++ cacti/graph_templates_inputs.php 2005-11-24 19:32:45.000000000 +0100
323 graph_template_input_defs.graph_template_input_id
324 from graph_templates_item
325 left join graph_template_input_defs on (graph_template_input_defs.graph_template_item_id=graph_templates_item.id and graph_template_input_defs.graph_template_input_id=" . $_GET["id"] . ")
326 - left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id
327 - left join data_local on data_template_rrd.local_data_id=data_local.id
328 - left join data_template_data on data_local.id=data_template_data.local_data_id
329 + left join data_template_rrd on (graph_templates_item.task_item_id=data_template_rrd.id)
330 + left join data_local on (data_template_rrd.local_data_id=data_local.id)
331 + left join data_template_data on (data_local.id=data_template_data.local_data_id)
332 where graph_templates_item.local_graph_id=0
333 and graph_templates_item.graph_template_id=" . $_GET["graph_template_id"] . "
334 order by graph_templates_item.sequence");
335 diff -urbB cacti-0.8.6g/graph_templates_items.php cacti/graph_templates_items.php
336 --- cacti-0.8.6g/graph_templates_items.php 2005-09-09 01:56:25.000000000 +0200
337 +++ cacti/graph_templates_items.php 2005-11-24 19:32:45.000000000 +0100
339 graph_template_input.id,
340 graph_template_input.name,
341 graph_templates_item.task_item_id
342 - from graph_template_input,graph_template_input_defs,graph_templates_item
343 + from (graph_template_input,graph_template_input_defs,graph_templates_item)
344 where graph_template_input.id=graph_template_input_defs.graph_template_input_id
345 and graph_template_input_defs.graph_template_item_id=graph_templates_item.id
346 and graph_template_input.graph_template_id=" . $save["graph_template_id"] . "
348 /* delete the graph item input if it is empty */
349 $graph_item_inputs = db_fetch_assoc("select
350 graph_template_input.id
351 - from graph_template_input,graph_template_input_defs
352 + from (graph_template_input,graph_template_input_defs)
353 where graph_template_input.id=graph_template_input_defs.graph_template_input_id
354 and graph_template_input.graph_template_id=" . $_GET["graph_template_id"] . "
355 and graph_template_input_defs.graph_template_item_id=" . $_GET["id"] . "
357 $struct_graph_item["task_item_id"]["sql"] = "select
358 CONCAT_WS('',data_template.name,' - ',' (',data_template_rrd.data_source_name,')') as name,
360 - from data_template_data,data_template_rrd,data_template
361 + from (data_template_data,data_template_rrd,data_template)
362 where data_template_rrd.data_template_id=data_template.id
363 and data_template_data.data_template_id=data_template.id
364 and data_template_data.local_data_id=0
366 $graph_item_input_fields = db_fetch_assoc("select
367 graph_template_input.id,
368 graph_template_input.column_name
369 - from graph_template_input,graph_template_input_defs
370 + from (graph_template_input,graph_template_input_defs)
371 where graph_template_input.id=graph_template_input_defs.graph_template_input_id
372 and graph_template_input.graph_template_id=" . $_GET["graph_template_id"] . "
373 and graph_template_input_defs.graph_template_item_id=" . $_GET["id"] . "
374 diff -urbB cacti-0.8.6g/graph_templates.php cacti/graph_templates.php
375 --- cacti-0.8.6g/graph_templates.php 2005-09-09 01:56:25.000000000 +0200
376 +++ cacti/graph_templates.php 2005-11-24 19:32:45.000000000 +0100
377 @@ -292,11 +292,11 @@
378 cdef.name as cdef_name,
380 from graph_templates_item
381 - left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id
382 - left join data_local on data_template_rrd.local_data_id=data_local.id
383 - left join data_template_data on data_local.id=data_template_data.local_data_id
384 - left join cdef on cdef_id=cdef.id
385 - left join colors on color_id=colors.id
386 + left join data_template_rrd on (graph_templates_item.task_item_id=data_template_rrd.id)
387 + left join data_local on (data_template_rrd.local_data_id=data_local.id)
388 + left join data_template_data on (data_local.id=data_template_data.local_data_id)
389 + left join cdef on (cdef_id=cdef.id)
390 + left join colors on (color_id=colors.id)
391 where graph_templates_item.graph_template_id=" . $_GET["id"] . "
392 and graph_templates_item.local_graph_id=0
393 order by graph_templates_item.sequence");
394 diff -urbB cacti-0.8.6g/graph_view.php cacti/graph_view.php
395 --- cacti-0.8.6g/graph_view.php 2005-09-09 01:56:25.000000000 +0200
396 +++ cacti/graph_view.php 2005-11-24 19:32:45.000000000 +0100
398 if (read_config_option("global_auth") == "on") {
399 $sql_where = "where " . get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
401 - $sql_join = "left join host on host.id=graph_local.host_id
402 - left join graph_templates on graph_templates.id=graph_local.graph_template_id
403 + $sql_join = "left join host on (host.id=graph_local.host_id)
404 + left join graph_templates on (graph_templates.id=graph_local.graph_template_id)
405 left join user_auth_perms on ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))";
412 - $sql_base = "from graph_templates_graph,graph_local
413 + $sql_base = "from (graph_templates_graph,graph_local)
416 " . (empty($sql_where) ? "where" : "and") . " graph_templates_graph.local_graph_id > 0
418 if (read_config_option("global_auth") == "on") {
419 /* get policy information for the sql where clause */
420 $sql_where = "where " . get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
421 - $sql_join = "left join host on host.id=graph_local.host_id
422 - left join graph_templates on graph_templates.id=graph_local.graph_template_id
423 + $sql_join = "left join host on (host.id=graph_local.host_id)
424 + left join graph_templates on (graph_templates.id=graph_local.graph_template_id)
425 left join user_auth_perms on ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))";
432 - $sql_base = "from graph_templates_graph,graph_local
433 + $sql_base = "from (graph_templates_graph,graph_local)
436 " . (empty($sql_where) ? "where" : "and") . " graph_templates_graph.local_graph_id > 0
437 diff -urbB cacti-0.8.6g/host.php cacti/host.php
438 --- cacti-0.8.6g/host.php 2005-09-09 01:56:25.000000000 +0200
439 +++ cacti/host.php 2005-11-24 19:32:45.000000000 +0100
441 $selected_graph_templates = db_fetch_assoc("select
444 - from graph_templates,host_graph
445 + from (graph_templates,host_graph)
446 where graph_templates.id=host_graph.graph_template_id
447 and host_graph.host_id=" . $_GET["id"] . "
448 order by graph_templates.name");
450 $available_graph_templates = db_fetch_assoc("SELECT
451 graph_templates.id, graph_templates.name
452 FROM snmp_query_graph RIGHT JOIN graph_templates
453 - ON snmp_query_graph.graph_template_id = graph_templates.id
454 + ON (snmp_query_graph.graph_template_id = graph_templates.id)
455 WHERE (((snmp_query_graph.name) Is Null)) ORDER BY graph_templates.name");
461 host_snmp_query.reindex_method
462 - from snmp_query,host_snmp_query
463 + from (snmp_query,host_snmp_query)
464 where snmp_query.id=host_snmp_query.snmp_query_id
465 and host_snmp_query.host_id=" . $_GET["id"] . "
466 order by snmp_query.name");
467 diff -urbB cacti-0.8.6g/host_templates.php cacti/host_templates.php
468 --- cacti-0.8.6g/host_templates.php 2005-09-09 01:56:25.000000000 +0200
469 +++ cacti/host_templates.php 2005-11-24 19:32:45.000000000 +0100
471 $selected_graph_templates = db_fetch_assoc("select
474 - from graph_templates,host_template_graph
475 + from (graph_templates,host_template_graph)
476 where graph_templates.id=host_template_graph.graph_template_id
477 and host_template_graph.host_template_id=" . $_GET["id"] . "
478 order by graph_templates.name");
480 $selected_data_queries = db_fetch_assoc("select
483 - from snmp_query,host_template_snmp_query
484 + from (snmp_query,host_template_snmp_query)
485 where snmp_query.id=host_template_snmp_query.snmp_query_id
486 and host_template_snmp_query.host_template_id=" . $_GET["id"] . "
487 order by snmp_query.name");
488 diff -urbB cacti-0.8.6g/include/config_form.php cacti/include/config_form.php
489 --- cacti-0.8.6g/include/config_form.php 2005-09-09 01:56:25.000000000 +0200
490 +++ cacti/include/config_form.php 2005-11-24 19:32:42.000000000 +0100
492 "form_id" => "|arg1:id|",
493 "sql" => "select rra_id as id,data_template_data_id from data_template_data_rra where data_template_data_id=|arg1:id|",
494 "sql_all" => "select rra.id from rra order by id",
495 - "sql_print" => "select rra.name from data_template_data_rra,rra where data_template_data_rra.rra_id=rra.id and data_template_data_rra.data_template_data_id=|arg1:id|",
496 + "sql_print" => "select rra.name from (data_template_data_rra,rra) where data_template_data_rra.rra_id=rra.id and data_template_data_rra.data_template_data_id=|arg1:id|",
497 "flags" => "ALWAYSTEMPLATE"
502 CONCAT_WS('',case when host.description is null then 'No Host' when host.description is not null then host.description end,' - ',data_template_data.name,' (',data_template_rrd.data_source_name,')') as name,
504 - from data_template_data,data_template_rrd,data_local
505 - left join host on data_local.host_id=host.id
506 + from (data_template_data,data_template_rrd,data_local)
507 + left join host on (data_local.host_id=host.id)
508 where data_template_rrd.local_data_id=data_local.id
509 and data_template_data.local_data_id=data_local.id
512 "description" => "Choose what type of host, host template this is. The host template will govern what kinds of data should be gathered from this type of host.",
513 "value" => "|arg1:host_template_id|",
514 "none_value" => "None",
515 - "sql" => "select id,name from host_template",
516 + "sql" => "select id,name from host_template order by name",
519 "method" => "checkbox",
520 diff -urbB cacti-0.8.6g/install/0_8_6_to_0_8_6a.php cacti/install/0_8_6_to_0_8_6a.php
521 --- cacti-0.8.6g/install/0_8_6_to_0_8_6a.php 2005-09-09 01:56:25.000000000 +0200
522 +++ cacti/install/0_8_6_to_0_8_6a.php 2005-11-24 19:32:44.000000000 +0100
524 /* find non-templated graph template items */
525 $non_templated_items = array_rekey(db_fetch_assoc("select
526 graph_template_input_defs.graph_template_item_id
527 - from graph_template_input,graph_template_input_defs
528 + from (graph_template_input,graph_template_input_defs)
529 where graph_template_input_defs.graph_template_input_id=graph_template_input.id
530 and graph_template_input.column_name = 'task_item_id'
531 and graph_template_input.graph_template_id = '" . $graph_template["id"] . "'"), "graph_template_item_id", "graph_template_item_id");
532 diff -urbB cacti-0.8.6g/lib/auth.php cacti/lib/auth.php
533 --- cacti-0.8.6g/lib/auth.php 2005-09-09 01:56:25.000000000 +0200
534 +++ cacti/lib/auth.php 2005-11-24 19:32:36.000000000 +0100
537 $graphs = db_fetch_assoc("select
538 graph_templates_graph.local_graph_id
539 - from graph_templates_graph,graph_local
540 - left join host on host.id=graph_local.host_id
541 - left join graph_templates on graph_templates.id=graph_local.graph_template_id
542 + from (graph_templates_graph,graph_local)
543 + left join host on (host.id=graph_local.host_id)
544 + left join graph_templates on (graph_templates.id=graph_local.graph_template_id)
545 left join user_auth_perms on ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))
546 where graph_templates_graph.local_graph_id=graph_local.id
547 " . (empty($sql_where) ? "" : "and $sql_where") . "
548 diff -urbB cacti-0.8.6g/lib/data_query.php cacti/lib/data_query.php
549 --- cacti-0.8.6g/lib/data_query.php 2005-09-09 01:56:25.000000000 +0200
550 +++ cacti/lib/data_query.php 2005-11-24 19:32:36.000000000 +0100
552 include_once($config["library_path"] . "/utility.php");
554 debug_log_insert("data_query", "Running data query [$snmp_query_id].");
555 - $type_id = db_fetch_cell("select data_input.type_id from snmp_query,data_input where snmp_query.data_input_id=data_input.id and snmp_query.id=$snmp_query_id");
556 + $type_id = db_fetch_cell("select data_input.type_id from (snmp_query,data_input) where snmp_query.data_input_id=data_input.id and snmp_query.id=$snmp_query_id");
558 if ($type_id == DATA_INPUT_TYPE_SNMP_QUERY) {
559 debug_log_insert("data_query", "Found type = '3' [snmp query].");
561 $field = db_fetch_assoc("select
562 data_input_fields.type_code,
563 data_input_data.value
564 - from data_input_fields,data_input_data
565 + from (data_input_fields,data_input_data)
566 where data_input_fields.id=data_input_data.data_input_field_id
567 and data_input_data.data_template_data_id=$data_template_data_id
568 and (data_input_fields.type_code='index_type' or data_input_fields.type_code='index_value' or data_input_fields.type_code='output_type')");
571 $field = data_query_field_list(db_fetch_cell("select
572 data_template_data.id
573 - from graph_templates_item,data_template_rrd,data_template_data
574 + from (graph_templates_item,data_template_rrd,data_template_data)
575 where graph_templates_item.task_item_id=data_template_rrd.id
576 and data_template_rrd.local_data_id=data_template_data.local_data_id
577 and graph_templates_item.local_graph_id=$local_graph_id
579 $sort_field_data = array_rekey(db_fetch_assoc("select
580 graph_local.snmp_index,
581 host_snmp_cache.field_value
582 - from graph_local,host_snmp_cache
583 + from (graph_local,host_snmp_cache)
584 where graph_local.host_id=host_snmp_cache.host_id
585 and graph_local.snmp_query_id=host_snmp_cache.snmp_query_id
586 and graph_local.snmp_index=host_snmp_cache.snmp_index
587 diff -urbB cacti-0.8.6g/lib/export.php cacti/lib/export.php
588 --- cacti-0.8.6g/lib/export.php 2005-09-09 01:56:25.000000000 +0200
589 +++ cacti/lib/export.php 2005-11-24 19:32:36.000000000 +0100
591 /* dep: data template */
592 $graph_template_items = db_fetch_assoc("select
593 data_template_rrd.data_template_id
594 - from graph_templates_item,data_template_rrd
595 + from (graph_templates_item,data_template_rrd)
596 where graph_templates_item.task_item_id=data_template_rrd.id
597 and graph_templates_item.graph_template_id=$id
598 and graph_templates_item.local_graph_id=0
599 diff -urbB cacti-0.8.6g/lib/functions.php cacti/lib/functions.php
600 --- cacti-0.8.6g/lib/functions.php 2005-09-09 01:56:25.000000000 +0200
601 +++ cacti/lib/functions.php 2005-11-24 19:32:36.000000000 +0100
603 data_template_data.data_input_id,
605 data_input.input_string
606 - from data_template_data,data_input
607 + from (data_template_data,data_input)
608 where data_template_data.data_input_id=data_input.id
609 and data_template_data.local_data_id=$local_data_id");
612 data_input_data.value
613 from data_input_fields
614 left join data_input_data
615 - on data_input_fields.id=data_input_data.data_input_field_id
616 + on (data_input_fields.id=data_input_data.data_input_field_id)
617 where data_input_fields.data_input_id=" . $data_source["data_input_id"] . "
618 and data_input_data.data_template_data_id=" . $data_source["id"] . "
619 and data_input_fields.input_output='in'");
621 $data_source = db_fetch_row("select
622 data_template_rrd.data_source_name,
623 data_template_data.name
624 - from data_template_rrd,data_template_data
625 + from (data_template_rrd,data_template_data)
626 where data_template_rrd.local_data_id=data_template_data.local_data_id
627 and data_template_rrd.id=$data_template_rrd_id");
630 data_local.snmp_query_id,
631 data_local.snmp_index,
632 data_template_data.name
633 - from data_template_data,data_local
634 + from (data_template_data,data_local)
635 where data_template_data.local_data_id=data_local.id
636 and data_local.id=$local_data_id");
639 graph_local.snmp_query_id,
640 graph_local.snmp_index,
641 graph_templates_graph.title
642 - from graph_templates_graph,graph_local
643 + from (graph_templates_graph,graph_local)
644 where graph_templates_graph.local_graph_id=graph_local.id
645 and graph_local.id=$local_graph_id");
648 $host_part = ""; $ds_part = "";
650 /* try any prepend the name with the host description */
651 - $host_name = db_fetch_cell("select host.description from host,data_local where data_local.host_id=host.id and data_local.id=$local_data_id");
652 + $host_name = db_fetch_cell("select host.description from (host,data_local) where data_local.host_id=host.id and data_local.id=$local_data_id");
654 if (!empty($host_name)) {
655 $host_part = strtolower(clean_up_name($host_name)) . "_";
656 @@ -1424,7 +1420,7 @@
659 data_template_data.rrd_step
660 - from graph_templates_item,data_template_data_rra,data_template_rrd,data_template_data,rra
661 + from (graph_templates_item,data_template_data_rra,data_template_rrd,data_template_data,rra)
662 where graph_templates_item.task_item_id=data_template_rrd.id
663 and data_template_rrd.local_data_id=data_template_data.local_data_id
664 and data_template_data.id=data_template_data_rra.data_template_data_id
665 diff -urbB cacti-0.8.6g/lib/graph_export.php cacti/lib/graph_export.php
666 --- cacti-0.8.6g/lib/graph_export.php 2005-09-09 01:56:25.000000000 +0200
667 +++ cacti/lib/graph_export.php 2005-11-24 19:32:36.000000000 +0100
669 graph_templates_graph.title_cache,
670 graph_templates.name,
672 - from graph_templates_graph left join graph_templates on graph_templates_graph.graph_template_id=graph_templates.id
673 - left join graph_local on graph_templates_graph.local_graph_id=graph_local.id
674 + from graph_templates_graph
675 + left join graph_templates on (graph_templates_graph.graph_template_id=graph_templates.id)
676 + left join graph_local on (graph_templates_graph.local_graph_id=graph_local.id)
677 where graph_templates_graph.local_graph_id!=0 and graph_templates_graph.export='on'
678 order by graph_templates_graph.title_cache");
681 graph_templates.name,
683 from graph_templates_graph
684 - left join graph_templates on graph_templates_graph.graph_template_id=graph_templates.id
685 - left join graph_local on graph_templates_graph.local_graph_id=graph_local.id
686 + left join graph_templates on (graph_templates_graph.graph_template_id=graph_templates.id)
687 + left join graph_local on (graph_templates_graph.local_graph_id=graph_local.id)
688 where graph_local.host_id=".get_host_id($parent_tree_item_id)."
689 and graph_templates_graph.local_graph_id!=0
690 and graph_templates_graph.export='on'
693 graph_tree_items.id as gtid
694 from graph_templates_graph
695 - left join graph_tree_items on graph_templates_graph.local_graph_id=graph_tree_items.local_graph_id
696 - left join graph_templates on graph_templates_graph.graph_template_id=graph_templates.id
697 - left join graph_local on graph_templates_graph.local_graph_id=graph_local.id
698 + left join graph_tree_items on (graph_templates_graph.local_graph_id=graph_tree_items.local_graph_id)
699 + left join graph_templates on (graph_templates_graph.graph_template_id=graph_templates.id)
700 + left join graph_local on (graph_templates_graph.local_graph_id=graph_local.id)
701 where graph_tree_items.graph_tree_id =".$tree_id."
702 and graph_templates_graph.local_graph_id!=0
703 and graph_templates_graph.export='on'
705 graph_tree_items.host_grouping_type,
706 host.description as hostname
707 from graph_tree_items
708 - left join host on host.id=graph_tree_items.host_id
709 + left join host on (host.id=graph_tree_items.host_id)
710 where graph_tree_items.graph_tree_id=" . $tree_id . "
711 and graph_tree_items.local_graph_id = 0
712 order by graph_tree_items.order_key");
714 $graph_templates = db_fetch_assoc("select
717 - from graph_local,graph_templates,graph_templates_graph
718 + from (graph_local,graph_templates,graph_templates_graph)
719 where graph_local.id=graph_templates_graph.local_graph_id
720 and graph_templates_graph.graph_template_id=graph_templates.id
721 and graph_local.host_id=" . $leaf["host_id"] . "
723 $data_queries = db_fetch_assoc("select
726 - from graph_local,snmp_query
727 + from (graph_local,snmp_query)
728 where graph_local.snmp_query_id=snmp_query.id
729 and graph_local.host_id=" . $leaf["host_id"] . "
730 group by snmp_query.id
731 diff -urbB cacti-0.8.6g/lib/html_form_template.php cacti/lib/html_form_template.php
732 --- cacti-0.8.6g/lib/html_form_template.php 2005-09-09 01:56:25.000000000 +0200
733 +++ cacti/lib/html_form_template.php 2005-11-24 19:32:36.000000000 +0100
735 when host.description is not null then ''
736 end,data_template_data.name_cache,' (',data_template_rrd.data_source_name,')') as name,
738 - from data_template_data,data_template_rrd,data_local
739 - left join host on data_local.host_id=host.id
740 + from (data_template_data,data_template_rrd,data_local)
741 + left join host on (data_local.host_id=host.id)
742 where data_template_rrd.local_data_id=data_local.id
743 and data_template_data.local_data_id=data_local.id
744 " . (empty($host_id) ? "" : " and data_local.host_id=$host_id") . "
746 $current_def_value = db_fetch_row("select
747 graph_templates_item." . $item["column_name"] . ",
748 graph_templates_item.id
749 - from graph_templates_item,graph_template_input_defs
750 + from (graph_templates_item,graph_template_input_defs)
751 where graph_template_input_defs.graph_template_item_id=graph_templates_item.local_graph_template_item_id
752 and graph_template_input_defs.graph_template_input_id=" . $item["id"] . "
753 and graph_templates_item.local_graph_id=$local_graph_id
755 $current_def_value = db_fetch_row("select
756 graph_templates_item." . $item["column_name"] . ",
757 graph_templates_item.id
758 - from graph_templates_item,graph_template_input_defs
759 + from (graph_templates_item,graph_template_input_defs)
760 where graph_template_input_defs.graph_template_item_id=graph_templates_item.id
761 and graph_template_input_defs.graph_template_input_id=" . $item["id"] . "
762 and graph_templates_item.graph_template_id=" . $graph_template_id . "
763 @@ -397,13 +397,13 @@
766 $data = db_fetch_row("select id,data_input_id,data_template_id,name,local_data_id from data_template_data where id=$data_template_data_id");
767 - $host_id = db_fetch_cell("select host.id from data_local,host where data_local.host_id=host.id and data_local.id=" . $data["local_data_id"]);
768 + $host_id = db_fetch_cell("select host.id from (data_local,host) where data_local.host_id=host.id and data_local.id=" . $data["local_data_id"]);
769 $template_data = db_fetch_row("select id,data_input_id from data_template_data where data_template_id=" . $data["data_template_id"] . " and local_data_id=0");
771 $draw_any_items = false;
773 /* get each INPUT field for this data input source */
774 - $fields = db_fetch_assoc("select * from data_input_fields where data_input_id=" . $data["data_input_id"] . " and input_output='in' order by name");
775 + $fields = db_fetch_assoc("select * from data_input_fields where data_input_id=" . $data["data_input_id"] . " and input_output='in' order by sequence");
777 /* loop through each field found */
780 if (($field["type_code"] == "index_type") && (db_fetch_cell("select local_data_id from data_template_data where id=$data_template_data_id") > 0)) {
781 $index_type = db_fetch_assoc("select
782 host_snmp_cache.field_name
783 - from data_template_data,data_local,host_snmp_cache
784 + from (data_template_data,data_local,host_snmp_cache)
785 where data_template_data.local_data_id=data_local.id
786 and data_local.snmp_query_id=host_snmp_cache.snmp_query_id
787 and data_template_data.id=$data_template_data_id
789 $output_type = db_fetch_assoc("select
791 snmp_query_graph.name
792 - from data_template_data,data_local,snmp_query_graph
793 + from (data_template_data,data_local,snmp_query_graph)
794 where data_template_data.local_data_id=data_local.id
795 and data_local.snmp_query_id=snmp_query_graph.snmp_query_id
796 and data_template_data.id=$data_template_data_id
797 diff -urbB cacti-0.8.6g/lib/html_tree.php cacti/lib/html_tree.php
798 --- cacti-0.8.6g/lib/html_tree.php 2005-09-09 01:56:25.000000000 +0200
799 +++ cacti/lib/html_tree.php 2005-11-24 19:32:36.000000000 +0100
801 /* get policy information for the sql where clause */
802 $sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
803 $sql_where = (empty($sql_where) ? "" : "and (" . $sql_where . " OR graph_tree_items.local_graph_id=0)");
804 - $sql_join = "left join graph_local on graph_templates_graph.local_graph_id=graph_local.id
805 - left join graph_templates on graph_templates.id=graph_local.graph_template_id
806 + $sql_join = "left join graph_local on (graph_templates_graph.local_graph_id=graph_local.id)
807 + left join graph_templates on (graph_templates.id=graph_local.graph_template_id)
808 left join user_auth_perms on ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))";
812 from graph_tree_items
813 left join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0)
814 left join settings_tree on (graph_tree_items.id=settings_tree.graph_tree_item_id and settings_tree.user_id=$user_id)
815 - left join host on graph_tree_items.host_id=host.id
816 + left join host on (graph_tree_items.host_id=host.id)
818 where graph_tree_items.graph_tree_id=$tree_id
819 and graph_tree_items.order_key like '$search_key%'
821 $graph_templates = db_fetch_assoc("select
824 - from graph_local,graph_templates,graph_templates_graph
825 + from (graph_local,graph_templates,graph_templates_graph)
826 where graph_local.id=graph_templates_graph.local_graph_id
827 and graph_templates_graph.graph_template_id=graph_templates.id
828 and graph_local.host_id=" . $leaf["host_id"] . "
830 $graphs = db_fetch_assoc("select
831 graph_templates_graph.title_cache,
832 graph_templates_graph.local_graph_id
833 - from graph_local,graph_templates,graph_templates_graph
834 + from (graph_local,graph_templates,graph_templates_graph)
835 where graph_local.id=graph_templates_graph.local_graph_id
836 and graph_templates_graph.graph_template_id=graph_templates.id
837 and graph_local.graph_template_id=" . $graph_template["id"] . "
839 CONCAT_WS('',description,' (',hostname,')') as hostname
840 from graph_tree_items
841 left join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0)
842 - left join host on host.id=graph_tree_items.host_id
843 + left join host on (host.id=graph_tree_items.host_id)
844 where graph_tree_items.graph_tree_id=$tree_id
845 order by graph_tree_items.order_key");
848 graph_tree_items.host_grouping_type,
849 host.description as hostname
850 from graph_tree_items
851 - left join host on host.id=graph_tree_items.host_id
852 + left join host on (host.id=graph_tree_items.host_id)
854 where graph_tree_items.graph_tree_id=" . $tree["id"] . "
857 $graph_templates = db_fetch_assoc("select
860 - from graph_local,graph_templates,graph_templates_graph
861 + from (graph_local,graph_templates,graph_templates_graph)
862 where graph_local.id=graph_templates_graph.local_graph_id
863 and graph_templates_graph.graph_template_id=graph_templates.id
864 and graph_local.host_id=" . $leaf["host_id"] . "
866 $data_queries = db_fetch_assoc("select
869 - from graph_local,snmp_query
870 + from (graph_local,snmp_query)
871 where graph_local.snmp_query_id=snmp_query.id
872 and graph_local.host_id=" . $leaf["host_id"] . "
873 group by snmp_query.id
874 @@ -477,15 +477,15 @@
875 $sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
876 $sql_where = (empty($sql_where) ? "" : "and $sql_where");
878 - left join host on host.id=graph_local.host_id
879 - left join graph_templates on graph_templates.id=graph_local.graph_template_id
880 + left join host on (host.id=graph_local.host_id)
881 + left join graph_templates on (graph_templates.id=graph_local.graph_template_id)
882 left join user_auth_perms on ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))";
885 /* get information for the headers */
886 if (!empty($tree_id)) { $tree_name = db_fetch_cell("select name from graph_tree where id=$tree_id"); }
887 if (!empty($leaf_id)) { $leaf_name = $leaf["title"]; }
888 - if (!empty($leaf_id)) { $host_name = db_fetch_cell("select host.description from graph_tree_items,host where graph_tree_items.host_id=host.id and graph_tree_items.id=$leaf_id"); }
889 + if (!empty($leaf_id)) { $host_name = db_fetch_cell("select host.description from (graph_tree_items,host) where graph_tree_items.host_id=host.id and graph_tree_items.id=$leaf_id"); }
891 $host_group_data_array = explode(":", $host_group_data);
894 graph_tree_items.rra_id,
895 graph_tree_items.order_key,
896 graph_templates_graph.title_cache as title_cache
897 - from graph_tree_items,graph_local
898 + from (graph_tree_items,graph_local)
899 left join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0)
901 where graph_tree_items.graph_tree_id=$tree_id
903 $graph_templates = db_fetch_assoc("select
906 - from graph_local,graph_templates,graph_templates_graph
907 + from (graph_local,graph_templates,graph_templates_graph)
908 where graph_local.id=graph_templates_graph.local_graph_id
909 and graph_templates_graph.graph_template_id=graph_templates.id
910 and graph_local.host_id=" . $leaf["host_id"] . "
912 $graphs = db_fetch_assoc("select
913 graph_templates_graph.title_cache,
914 graph_templates_graph.local_graph_id
915 - from graph_local,graph_templates_graph
916 + from (graph_local,graph_templates_graph)
918 where graph_local.id=graph_templates_graph.local_graph_id
919 and graph_local.graph_template_id=" . $graph_template["id"] . "
921 $data_queries = db_fetch_assoc("select
924 - from graph_local,snmp_query
925 + from (graph_local,snmp_query)
926 where graph_local.snmp_query_id=snmp_query.id
927 and graph_local.host_id=" . $leaf["host_id"] . "
928 " . (!isset($data_query_id) ? "" : "and snmp_query.id=$data_query_id") . "
930 graph_templates_graph.title_cache,
931 graph_templates_graph.local_graph_id,
932 graph_local.snmp_index
933 - from graph_local,graph_templates_graph
934 + from (graph_local,graph_templates_graph)
936 where graph_local.id=graph_templates_graph.local_graph_id
937 and graph_local.snmp_query_id=" . $data_query["id"] . "
938 diff -urbB cacti-0.8.6g/lib/import.php cacti/lib/import.php
939 --- cacti-0.8.6g/lib/import.php 2005-09-09 01:56:25.000000000 +0200
940 +++ cacti/lib/import.php 2005-11-24 19:32:36.000000000 +0100
943 /* import into: graph_templates_graph */
945 - $save["id"] = (empty($_graph_template_id) ? "0" : db_fetch_cell("select graph_templates_graph.id from graph_templates,graph_templates_graph where graph_templates.id=graph_templates_graph.graph_template_id and graph_templates.id=$graph_template_id and graph_templates_graph.local_graph_id=0"));
946 + $save["id"] = (empty($_graph_template_id) ? "0" : db_fetch_cell("select graph_templates_graph.id from (graph_templates,graph_templates_graph) where graph_templates.id=graph_templates_graph.graph_template_id and graph_templates.id=$graph_template_id and graph_templates_graph.local_graph_id=0"));
947 $save["graph_template_id"] = $graph_template_id;
949 /* parse information from the hash */
952 /* import into: data_template_data */
954 - $save["id"] = (empty($_data_template_id) ? "0" : db_fetch_cell("select data_template_data.id from data_template,data_template_data where data_template.id=data_template_data.data_template_id and data_template.id=$data_template_id and data_template_data.local_data_id=0"));
955 + $save["id"] = (empty($_data_template_id) ? "0" : db_fetch_cell("select data_template_data.id from (data_template,data_template_data) where data_template.id=data_template_data.data_template_id and data_template.id=$data_template_id and data_template_data.local_data_id=0"));
956 $save["data_template_id"] = $data_template_id;
958 reset($struct_data_source);
959 diff -urbB cacti-0.8.6g/lib/poller.php cacti/lib/poller.php
960 --- cacti-0.8.6g/lib/poller.php 2005-09-09 01:56:25.000000000 +0200
961 +++ cacti/lib/poller.php 2005-11-24 19:32:36.000000000 +0100
964 $host = db_fetch_row("select hostname,snmp_community,snmp_version,snmp_username,snmp_password,snmp_port,snmp_timeout from host where id=$host_id");
965 $data_query = db_fetch_row("select reindex_method,sort_field from host_snmp_query where host_id=$host_id and snmp_query_id=$data_query_id");
966 - $data_query_type = db_fetch_cell("select data_input.type_id from data_input,snmp_query where data_input.id=snmp_query.data_input_id and snmp_query.id=$data_query_id");
967 + $data_query_type = db_fetch_cell("select data_input.type_id from (data_input,snmp_query) where data_input.id=snmp_query.data_input_id and snmp_query.id=$data_query_id");
968 $data_query_xml = get_data_query_array($data_query_id);
970 switch ($data_query["reindex_method"]) {
972 poller_item.rrd_path,
973 poller_item.rrd_name,
975 - from poller_output,poller_item
976 + from (poller_output,poller_item)
977 where (poller_output.local_data_id=poller_item.local_data_id and poller_output.rrd_name=poller_item.rrd_name)");
979 if (sizeof($results) > 0) {
981 $rrd_field_names = array_rekey(db_fetch_assoc("select
982 data_template_rrd.data_source_name,
983 data_input_fields.data_name
984 - from data_template_rrd,data_input_fields
985 + from (data_template_rrd,data_input_fields)
986 where data_template_rrd.data_input_field_id=data_input_fields.id
987 and data_template_rrd.local_data_id=" . $item["local_data_id"]), "data_name", "data_source_name");
989 diff -urbB cacti-0.8.6g/lib/rrd.php cacti/lib/rrd.php
990 --- cacti-0.8.6g/lib/rrd.php 2005-09-09 01:56:25.000000000 +0200
991 +++ cacti/lib/rrd.php 2005-11-24 19:32:36.000000000 +0100
993 rra_cf.consolidation_function_id,
994 (rra.rows*rra.steps) as rra_order
995 from data_template_data
996 - left join data_template_data_rra on data_template_data.id=data_template_data_rra.data_template_data_id
997 - left join rra on data_template_data_rra.rra_id=rra.id
998 - left join rra_cf on rra.id=rra_cf.rra_id
999 + left join data_template_data_rra on (data_template_data.id=data_template_data_rra.data_template_data_id)
1000 + left join rra on (data_template_data_rra.rra_id=rra.id)
1001 + left join rra_cf on (rra.id=rra_cf.rra_id)
1002 where data_template_data.local_data_id=$local_data_id
1003 and (rra.steps is not null or rra.rows is not null)
1004 order by rra_cf.consolidation_function_id,rra_order");
1006 /* find the step and how often this graph is updated with new data */
1007 $ds_step = db_fetch_cell("select
1008 data_template_data.rrd_step
1009 - from data_template_data,data_template_rrd,graph_templates_item
1010 + from (data_template_data,data_template_rrd,graph_templates_item)
1011 where graph_templates_item.task_item_id=data_template_rrd.id
1012 and data_template_rrd.local_data_id=data_template_data.local_data_id
1013 and graph_templates_item.local_graph_id=$local_graph_id
1015 graph_templates_graph.unit_value,
1016 graph_templates_graph.unit_exponent_value,
1017 graph_templates_graph.export
1018 - from graph_templates_graph,graph_local
1019 + from (graph_templates_graph,graph_local)
1020 where graph_local.id=graph_templates_graph.local_graph_id
1021 and graph_templates_graph.local_graph_id=$local_graph_id");
1024 data_template_rrd.data_source_name,
1025 data_template_rrd.local_data_template_rrd_id
1026 from graph_templates_item
1027 - left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id
1028 - left join colors on graph_templates_item.color_id=colors.id
1029 - left join graph_templates_gprint on graph_templates_item.gprint_id=graph_templates_gprint.id
1030 + left join data_template_rrd on (graph_templates_item.task_item_id=data_template_rrd.id)
1031 + left join colors on (graph_templates_item.color_id=colors.id)
1032 + left join graph_templates_gprint on (graph_templates_item.gprint_id=graph_templates_gprint.id)
1033 where graph_templates_item.local_graph_id=$local_graph_id
1034 order by graph_templates_item.sequence");
1036 diff -urbB cacti-0.8.6g/lib/template.php cacti/lib/template.php
1037 --- cacti-0.8.6g/lib/template.php 2005-09-09 01:56:25.000000000 +0200
1038 +++ cacti/lib/template.php 2005-11-24 19:32:36.000000000 +0100
1040 data_input_data.value,
1041 data_input_data.t_value
1042 from data_input_fields left join data_input_data
1043 - on data_input_fields.id=data_input_data.data_input_field_id
1044 + on (data_input_fields.id=data_input_data.data_input_field_id)
1045 where data_input_data.data_template_data_id=" . $data_template["id"] . "
1046 and data_input_fields.input_output='in'");
1049 $graph_item_inputs = db_fetch_assoc("select
1050 graph_template_input.column_name,
1051 graph_template_input_defs.graph_template_item_id
1052 - from graph_template_input, graph_template_input_defs
1053 + from (graph_template_input, graph_template_input_defs)
1054 where graph_template_input.graph_template_id=" . $graph_template_item["graph_template_id"] . "
1055 and graph_template_input.id=graph_template_input_defs.graph_template_input_id
1056 and graph_template_input_defs.graph_template_item_id=$graph_template_item_id");
1058 $graph_template_inputs = db_fetch_assoc("select
1059 graph_template_input.column_name,
1060 graph_template_input_defs.graph_template_item_id
1061 - from graph_template_input,graph_template_input_defs
1062 + from (graph_template_input,graph_template_input_defs)
1063 where graph_template_input.id=graph_template_input_defs.graph_template_input_id
1064 and graph_template_input.graph_template_id=$graph_template_id");
1069 data_template_rrd.data_source_name
1070 - from data_template, data_template_rrd, graph_templates_item
1071 + from (data_template, data_template_rrd, graph_templates_item)
1072 where graph_templates_item.task_item_id=data_template_rrd.id
1073 and data_template_rrd.data_template_id=data_template.id
1074 and data_template_rrd.local_data_id=0
1076 $data_input_field = array_rekey(db_fetch_assoc("select
1077 data_input_fields.id,
1078 data_input_fields.type_code
1079 - from snmp_query,data_input,data_input_fields
1080 + from (snmp_query,data_input,data_input_fields)
1081 where snmp_query.data_input_id=data_input.id
1082 and data_input.id=data_input_fields.data_input_id
1083 and (data_input_fields.type_code='index_type' or data_input_fields.type_code='index_value' or data_input_fields.type_code='output_type')
1085 graph_templates_item.id,
1086 data_template_rrd.id as data_template_rrd_id,
1087 data_template_rrd.data_template_id
1088 - from graph_templates_item,data_template_rrd
1089 + from (graph_templates_item,data_template_rrd)
1090 where graph_templates_item.task_item_id=data_template_rrd.id
1091 and graph_templates_item.graph_template_id=$graph_template_id
1092 and local_graph_id=0
1093 diff -urbB cacti-0.8.6g/lib/tree.php cacti/lib/tree.php
1094 --- cacti-0.8.6g/lib/tree.php 2005-09-09 01:56:25.000000000 +0200
1095 +++ cacti/lib/tree.php 2005-11-24 19:32:36.000000000 +0100
1097 CONCAT_WS('',description,' (',hostname,')') as hostname
1098 from graph_tree_items
1099 left join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0)
1100 - left join host on host.id=graph_tree_items.host_id
1101 + left join host on (host.id=graph_tree_items.host_id)
1103 order by graph_tree_items.order_key");
1105 diff -urbB cacti-0.8.6g/lib/utility.php cacti/lib/utility.php
1106 --- cacti-0.8.6g/lib/utility.php 2005-09-09 01:56:25.000000000 +0200
1107 +++ cacti/lib/utility.php 2005-11-24 19:32:36.000000000 +0100
1109 data_template_data.id as data_template_data_id,
1110 data_template_data.data_template_id,
1111 data_template_data.active
1112 - from data_template_data,data_input
1113 + from (data_template_data,data_input)
1114 where data_template_data.data_input_id=data_input.id
1115 and data_template_data.local_data_id=$local_data_id");
1118 $outputs = db_fetch_assoc("select
1119 snmp_query_graph_rrd.snmp_field_name,
1120 data_template_rrd.id as data_template_rrd_id
1121 - from snmp_query_graph_rrd,data_template_rrd
1122 + from (snmp_query_graph_rrd,data_template_rrd)
1123 where snmp_query_graph_rrd.data_template_rrd_id=data_template_rrd.local_data_template_rrd_id
1124 and snmp_query_graph_rrd.snmp_query_graph_id=" . $field["output_type"] . "
1125 and snmp_query_graph_rrd.data_template_id=" . $data_input["data_template_id"] . "
1127 data_template_data.data_input_id,
1128 data_template_data.local_data_id,
1129 data_template_data.local_data_template_data_id
1130 - from data_local,data_template_data
1131 + from (data_local,data_template_data)
1132 where " . (empty($local_data_id) ? "data_local.host_id=$host_id" : "data_local.id=$local_data_id") . "
1133 and data_local.id=data_template_data.local_data_id
1134 and data_template_data.data_input_id>0");
1135 diff -urbB cacti-0.8.6g/tree.php cacti/tree.php
1136 --- cacti-0.8.6g/tree.php 2005-09-09 01:56:25.000000000 +0200
1137 +++ cacti/tree.php 2005-11-24 19:32:45.000000000 +0100
1139 Choose a graph from this list to add it to the tree.
1142 - <?php form_dropdown("local_graph_id", db_fetch_assoc("select graph_templates_graph.local_graph_id as id,graph_templates_graph.title_cache as name from graph_templates_graph,graph_local where graph_local.id=graph_templates_graph.local_graph_id and local_graph_id != 0 order by title_cache"), "name", "id", (isset($tree_item["local_graph_id"]) ? $tree_item["local_graph_id"] : ""), "", "");?>
1143 + <?php form_dropdown("local_graph_id", db_fetch_assoc("select graph_templates_graph.local_graph_id as id,graph_templates_graph.title_cache as name from (graph_templates_graph,graph_local) where graph_local.id=graph_templates_graph.local_graph_id and local_graph_id != 0 order by title_cache"), "name", "id", (isset($tree_item["local_graph_id"]) ? $tree_item["local_graph_id"] : ""), "", "");?>
1146 <?php form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],1); ?>
1147 diff -urbB cacti-0.8.6g/user_admin.php cacti/user_admin.php
1148 --- cacti-0.8.6g/user_admin.php 2005-09-09 01:56:25.000000000 +0200
1149 +++ cacti/user_admin.php 2005-11-24 19:32:45.000000000 +0100
1152 html_header(array("User Name", "Full Name", "Realm", "Default Graph Policy", "Last Login"), 2);
1154 - $user_list = db_fetch_assoc("select id, user_auth.username, full_name, realm, policy_graphs, DATE_FORMAT(max(time),'%M %e %Y %H:%i:%s') as time from user_auth left join user_log on user_auth.id = user_log.user_id group by id");
1155 + $user_list = db_fetch_assoc("select id, user_auth.username, full_name, realm, policy_graphs, DATE_FORMAT(max(time),'%M %e %Y %H:%i:%s') as time from user_auth left join user_log on (user_auth.id = user_log.user_id) group by id");
1158 if (sizeof($user_list) > 0) {
1159 diff -urbB cacti-0.8.6g/utilities.php cacti/utilities.php
1160 --- cacti-0.8.6g/utilities.php 2005-09-09 01:56:25.000000000 +0200
1161 +++ cacti/utilities.php 2005-11-24 19:32:45.000000000 +0100
1163 $snmp_cache = db_fetch_assoc("select host_snmp_cache.*,
1166 - from host_snmp_cache,snmp_query,host
1167 + from (host_snmp_cache,snmp_query,host)
1168 where host_snmp_cache.host_id=host.id
1169 and host_snmp_cache.snmp_query_id=snmp_query.id
1170 order by host_snmp_cache.host_id,host_snmp_cache.snmp_query_id,host_snmp_cache.snmp_index");
1173 data_template_data.name_cache,
1175 - from poller_item,data_template_data,data_local
1176 + from (poller_item,data_template_data,data_local)
1177 where poller_item.local_data_id=data_template_data.local_data_id
1178 and data_template_data.local_data_id=data_local.id");