File: graphs_items.php

package info (click to toggle)
cacti 0.6.7-2.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,000 kB
  • ctags: 1,120
  • sloc: php: 5,059; sql: 922; sh: 302; perl: 81; makefile: 56
file content (475 lines) | stat: -rw-r--r-- 22,218 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
<?/*
+-------------------------------------------------------------------------+
| Copyright (C) 2002 Ian Berry                                            |
|                                                                         |
| This program is free software; you can redistribute it and/or           |
| modify it under the terms of the GNU General Public License             |
| as published by the Free Software Foundation; either version 2          |
| of the License, or (at your option) any later version.                  |
|                                                                         |
| This program is distributed in the hope that it will be useful,         |
| but WITHOUT ANY WARRANTY; without even the implied warranty of          |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
| GNU General Public License for more details.                            |
+-------------------------------------------------------------------------+
| cacti: the rrdtool frontend [php-auth, php-tree, php-form]              |
+-------------------------------------------------------------------------+
| This code is currently maintained and debugged by Ian Berry, any        |
| questions or comments regarding this code should be directed to:        |
| - iberry@raxnet.net                                                     |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/                                       |
+-------------------------------------------------------------------------+
*/?>
<? 	$section = "Add/Edit Graphs"; include ('auth/include/auth.php');
	header("Cache-control: no-cache");
	include ('include/database.php');
	include ('include/config.php');
	include_once ('include/utility_functions.php');
	include_once ('include/form.php');
	
/* if the user wants to change the grouping status of this
graph, do it here */
if (isset($HTTP_GET_VARS["graph_grouping"]) == true) {
	$sql_id_grouping = mysql_query("select grouping from rrd_graph where id=$id", $cnn_id);
	$current_graph_grouping = mysql_result($sql_id_grouping, 0, "grouping");
	
	switch ($graph_grouping) {
		case 'on':
			/* make sure graph grouping is already OFF */
			if ($current_graph_grouping == "") {
				group_graph_items($id);
				mysql_query("update rrd_graph set grouping=\"on\" where id=$id", $cnn_id);
			}
			
			break;
		case 'off':
			/* make sure graph grouping is already ON */
			if ($current_graph_grouping == "on") {
				ungroup_graph_items($id);
				mysql_query("update rrd_graph set grouping=\"\" where id=$id", $cnn_id);
			}
			
			break;
	}
	
	header ("Location: graphs_items.php?id=$id"); exit;
}

if (isset($HTTP_GET_VARS["graph_preview"]) == true) {
	switch ($HTTP_GET_VARS["graph_preview"]) {
		case 'on':
			header ("Set-Cookie: graph_preview=on; path=/;");
			break;
		case 'off':
			header ("Set-Cookie: graph_preview=off; path=/;");
			break;
	}
	
	header ("Location: graphs_items.php?id=$id"); exit;
}

if (isset($HTTP_GET_VARS["graph_output_preview"]) == true) {
	switch ($HTTP_GET_VARS["graph_output_preview"]) {
		case 'on':
			header ("Set-Cookie: graph_output_preview=on; path=/;");
			break;
		case 'off':
			header ("Set-Cookie: graph_output_preview=off; path=/;");
			break;
	}
	
	header ("Location: graphs_items.php?id=$id"); exit;
}

$graph_preview = $HTTP_COOKIE_VARS["graph_preview"];
$graph_output_preview = $HTTP_COOKIE_VARS["graph_output_preview"];

switch ($action) {
	case 'save':
		include_once ('include/functions.php');
		
		$sql_id = mysql_query("replace into rrd_graph_item (id,dsid,colorid,textformat,
			sequence,graphid,graphtypeid,consolidationfunction,hardreturn,cdefid,value,sequenceparent,
			parent) values ($id,$dsid,$colorid,\"$textformat\",$sequence,$gid,$graphtypeid,
			$consolidationfunction,\"$hardreturn\",$cdefid,\"$value\",$sequenceparent,$parent)",$cnn_id);
		
		if ($id == 0) {
			/* get graphid if this is a new save */
			$sql_id = mysql_query("select LAST_INSERT_ID()",$cnn_id);
			
			if (mysql_result($sql_id,"",0) != 0) {
				/* we are using new_id so only the next two queries so the 
				sequence code does not know about it...therefore forcing a new
				sequence number if this is a new save */
				$new_id = mysql_result($sql_id,"",0);
			}
		}else{
			$new_id = $id;
		}
		
		$sql_id = mysql_query("select grouping from rrd_graph where id=$gid", $cnn_id);
		$sql_id_item = mysql_query("select t.name from rrd_graph_item i left join def_graph_type t
			on i.graphtypeid=t.id where i.id=$new_id", $cnn_id);
		
		if (mysql_result($sql_id, 0, "grouping") == "on") {
			if (mysql_result($sql_id_item, $i, "name") != "GPRINT") {
				$max_sequence = GetSequence($id, "sequenceparent", "rrd_graph_item", "graphid", $gid);
				
				mysql_query("update rrd_graph_item set sequenceparent=$max_sequence where id=$new_id", $cnn_id);
				mysql_query("update rrd_graph_item set parent=$new_id where id=$new_id", $cnn_id);
				
				/* this is a save on a parent item: if this parent has children with all of the same
				data source, then update the data source change in the parent to the children as 
				well. this saves the user some clicks */
				$sql_id = mysql_query("select dsid from rrd_graph_item where parent=$new_id and parent!=id group by dsid", $cnn_id);
				
				if (mysql_num_rows($sql_id) == "1") {
					/* there is only one data source in use for this group */
					mysql_query("update rrd_graph_item set dsid=$dsid where parent=$new_id", $cnn_id);
				}
			}else{
				/* if the group changes, force a new sequence */
				if ($old_parent != $parent) { $id = 0; }
				
				$max_sequence = GetSequence($id, "sequence", "rrd_graph_item", "graphid", "$gid and parent=$parent");
				
				if ($parent != 0) {
					$sql_id = mysql_query("select sequenceparent from rrd_graph_item where id=$parent", $cnn_id);
					$sequenceparent = mysql_result($sql_id, 0, "sequenceparent");
				}
				
				mysql_query("update rrd_graph_item set sequence=$max_sequence where id=$new_id", $cnn_id);
				mysql_query("update rrd_graph_item set sequenceparent=$sequenceparent where id=$new_id", $cnn_id);
			}
		}else{
			$max_sequence = GetSequence($id, "sequence", "rrd_graph_item", "graphid", $gid);
			
			mysql_query("update rrd_graph_item set sequence=$max_sequence where id=$new_id", $cnn_id);
		}
		
		header ("Location: graphs_items.php?id=$gid");
		break;
	case 'remove':
		$sql_id = mysql_query("select grouping from rrd_graph where id=$gid", $cnn_id);
		$sql_id_item = mysql_query("select t.name from rrd_graph_item i left join def_graph_type t
			on i.graphtypeid=t.id where i.id=$id", $cnn_id);
		
		if (mysql_result($sql_id, 0, "grouping") == "on") {
			if (mysql_result($sql_id_item, $i, "name") != "GPRINT") {
				mysql_query("delete from rrd_graph_item where parent=$tid",$cnn_id);
			}else{
				mysql_query("delete from rrd_graph_item where id=$id",$cnn_id);
			}
		}else{
			mysql_query("delete from rrd_graph_item where id=$id",$cnn_id);
		}
		
		header ("Location: graphs_items.php?id=$gid&graph_preview=$graph_preview&graph_output_preview=$graph_output_preview");
		break;
	case 'movedown':
		include_once ('include/functions.php');
		
		$sql_id = mysql_query("select grouping from rrd_graph where id=$gid", $cnn_id);
		$sql_id_item = mysql_query("select t.name from rrd_graph_item i left join def_graph_type t
			on i.graphtypeid=t.id where i.id=$id", $cnn_id);
		
		if (mysql_result($sql_id, 0, "grouping") == "on") {
			if (mysql_result($sql_id_item, $i, "name") != "GPRINT") {
				$sequence_column = "sequenceparent";
				$sequence_query = "$gid";
			}else{
				$sequence_column = "sequence";
				$sequence_query = "$gid and parent=$tid";
			}
		}else{
			$sequence_column = "sequence";
			$sequence_query = "$gid";
		}
		
		$next_item = GetNextItem($cnn_id,"rrd_graph_item",$sequence_column,$id,"graphid",$sequence_query);
		
		if ($sequence_column == "sequenceparent") { /* group order */
			$sql_id_id = mysql_query("select parent from rrd_graph_item where $sequence_column=$next_item and graphid=$gid",$cnn_id);
			$sql_id_seq = mysql_query("select $sequence_column from rrd_graph_item where id=$id",$cnn_id);
			$sql_id = mysql_query("update rrd_graph_item set $sequence_column=$next_item where parent=$id",$cnn_id);
			$sql_id = mysql_query("update rrd_graph_item set $sequence_column=" . mysql_result($sql_id_seq, 0, $sequence_column) . " where parent=" . mysql_result($sql_id_id, 0, "parent"),$cnn_id);
		}elseif ($sequence_column == "sequence") { /* item order */
			$sql_id_id = mysql_query("select id from rrd_graph_item where $sequence_column=$next_item and graphid=$gid and parent=$tid",$cnn_id);
			$sql_id_seq = mysql_query("select $sequence_column from rrd_graph_item where id=$id",$cnn_id);
			$sql_id = mysql_query("update rrd_graph_item set $sequence_column=$next_item where id=$id",$cnn_id);
			$sql_id = mysql_query("update rrd_graph_item set $sequence_column=" . mysql_result($sql_id_seq, 0, $sequence_column) . " where id=" . mysql_result($sql_id_id, 0, "id"),$cnn_id);
		}
		
		header ("Location: graphs_items.php?id=$gid&graph_preview=$graph_preview&graph_output_preview=$graph_output_preview"); exit;
		break;
	case 'moveup':
		include_once ('include/functions.php');
		
		$sql_id = mysql_query("select grouping from rrd_graph where id=$gid", $cnn_id);
		$sql_id_item = mysql_query("select t.name from rrd_graph_item i left join def_graph_type t
			on i.graphtypeid=t.id where i.id=$id", $cnn_id);
		
		if (mysql_result($sql_id, 0, "grouping") == "on") {
			if (mysql_result($sql_id_item, $i, "name") != "GPRINT") {
				$sequence_column = "sequenceparent";
				$sequence_query = "$gid";
			}else{
				$sequence_column = "sequence";
				$sequence_query = "$gid and parent=$tid";
			}
		}else{
			$sequence_column = "sequence";
			$sequence_query = "$gid";
		}
		
		$last_item = GetLastItem($cnn_id,"rrd_graph_item",$sequence_column,$id,"graphid",$sequence_query);
		
		if ($sequence_column == "sequenceparent") { /* group order */
			$sql_id_id = mysql_query("select parent from rrd_graph_item where $sequence_column=$last_item and graphid=$gid",$cnn_id);
			$sql_id_seq = mysql_query("select $sequence_column from rrd_graph_item where id=$id",$cnn_id);
			$sql_id = mysql_query("update rrd_graph_item set $sequence_column=$last_item where parent=$id",$cnn_id);
			$sql_id = mysql_query("update rrd_graph_item set $sequence_column=" . mysql_result($sql_id_seq, 0, $sequence_column) . " where parent=" . mysql_result($sql_id_id, 0, "parent"),$cnn_id);
		}elseif ($sequence_column == "sequence") { /* item order */
			$sql_id_id = mysql_query("select id from rrd_graph_item where $sequence_column=$last_item and graphid=$gid and parent=$tid",$cnn_id);
			$sql_id_seq = mysql_query("select $sequence_column from rrd_graph_item where id=$id",$cnn_id);
			$sql_id = mysql_query("update rrd_graph_item set $sequence_column=$last_item where id=$id",$cnn_id);
			$sql_id = mysql_query("update rrd_graph_item set $sequence_column=" . mysql_result($sql_id_seq, 0, $sequence_column) . " where id=" . mysql_result($sql_id_id, 0, "id"),$cnn_id);
		}
		
		header ("Location: graphs_items.php?id=$gid&graph_preview=$graph_preview&graph_output_preview=$graph_output_preview"); exit;
		break;
	case 'edit':
		include_once ('include/top_header.php');
		
		/* get current graph name for the header text */
		$sql_id_title = mysql_query("select title,grouping from rrd_graph where id=$gid", $cnn_id);
		$graph_title = mysql_result($sql_id_title, 0, "title");
		
		if ($id != "") {
			$sql_id = mysql_query("select * from rrd_graph_item where id=$id", $cnn_id);
			$old_parent = mysql_result($sql_id, 0, "parent");
		}
		
		DrawFormHeader("Graph Item Configuration for: $graph_title","",false);
		
		/* by default, select the LAST DS chosen to make everyone's lives easier */
		$sql_id_default = mysql_query("select dsid from rrd_graph_item where graphid=$gid order by sequenceparent,sequence", $cnn_id);
		
		if (mysql_num_rows($sql_id_default) != 0) {
			$default_item = mysql_result($sql_id_default, (mysql_num_rows($sql_id_default)-1), "dsid");
		}else{
			$default_item = 0;
		}
		
		DrawFormItem("Data Source","The data source to use for this graph item; not used for COMMENT fields.");
		DrawFormItemDropdownFromSQL("dsid",$cnn_id,"select id,name from rrd_ds where isparent=0 order by name",
			"name","id",$sql_id,"None",$default_item);
		
		if (mysql_result($sql_id_title, 0, "grouping") == "on") {
			/* default item (last item) */
			$sql_id_default = mysql_query("select CONCAT_WS('',t.name,': ',d.name) as name,
				i.id from rrd_graph_item i left join def_graph_type t on i.graphtypeid=t.id left join
				rrd_ds d on i.dsid=d.id where graphid=$gid and (t.name = 'AREA' or t.name = 'STACK' or t.name = 'LINE1'
				or t.name = 'LINE2' or t.name = 'LINE3') order by i.sequenceparent", $cnn_id);
			
			if (mysql_num_rows($sql_id_default) == 0) {
				DrawFormItemHiddenIDField("parent","0");
			}else{
				$default_item = mysql_result($sql_id_default, (mysql_num_rows($sql_id_default)-1), "id");
				
				DrawFormItem("Item Group","Choose which graph item this GPRINT is associated with. NOTE: This field
					will be ignored if it is not a GPRINT.");
				DrawFormItemDropdownFromSQL("parent",$cnn_id,"select CONCAT_WS('',t.name,': ',d.name) as name,
					i.id from rrd_graph_item i left join def_graph_type t on i.graphtypeid=t.id left join
					rrd_ds d on i.dsid=d.id where graphid=$gid and (t.name = 'AREA' or t.name = 'STACK' or t.name = 'LINE1'
					or t.name = 'LINE2' or t.name = 'LINE3') order by i.sequenceparent","name","id",$sql_id,"",$default_item);
			}
		}else{
			DrawFormItemHiddenIDField("parent","0");
		}
		
		DrawFormItem("Color","The color that is used for this item; not used for COMMENT fields.");
		DrawFormItemColorSelect("colorid",$cnn_id,$sql_id,"None","0");
		
		DrawFormItem("Graph Item Type","How data for this item is displayed.");
		DrawFormItemDropdownFromSQL("graphtypeid",$cnn_id,"select id,name from def_graph_type order by name",
			"name","id",$sql_id,"","");
		
		DrawFormItem("Consolidation Function","How data is to be represented on the graph.");
		DrawFormItemDropdownFromSQL("consolidationfunction",$cnn_id,"select * from def_cf order by name",
			"name","id",$sql_id,"","");
		
		DrawFormItem("CDEF Function","A CDEF Function to apply to this item on the graph.");
		DrawFormItemDropdownFromSQL("cdefid",$cnn_id,"select * from rrd_ds_cdef order by name",
			"name","id",$sql_id,"None","");
		
		DrawFormItem("Value","For use with VRULE and HRULE, <i>numbers only</i>, and<br> staggered CDEF Calculations, format start=<<i>Data Source Position</i>>&skip<<i>Skip Count</i>>.");
		DrawFormItemTextBox("value",$sql_id,"","");
		
		DrawFormItem("Text Format","The text of the comment or legend, input and output keywords are allowed.");
		DrawFormItemTextBox("textformat",$sql_id,"","");
		DrawFormItemCheckBox("hardreturn",$sql_id,"Insert Hard Return","");
		
		DrawFormSaveButton();
		DrawFormItemHiddenIDField("gid",$gid);
		DrawFormItemHiddenIDField("sequenceparent",$sql_id);
		DrawFormItemHiddenIDField("sequence",$sql_id);
		DrawFormItemHiddenIDField("old_parent",$old_parent);
		DrawFormItemHiddenIDField("id",$id);
		DrawFormFooter();
		
		include_once ("include/bottom_footer.php");
		
		break;
	default:
		include_once ('include/top_header.php');
		include_once ('include/rrd_functions.php');
		
		/* get current graph name for the header text */
		$sql_id = mysql_query("select title,grouping from rrd_graph where id=$id", $cnn_id);
		$graph_title = mysql_result($sql_id, 0, "title");
		$allow_grouping = mysql_result($sql_id, 0, "grouping");
		
		DrawMatrixTableBegin("97%");
		DrawMatrixRowBegin();
			DrawMatrixHeaderTop("Graph Items for: $graph_title",$color_dark_bar,"","6");
			DrawMatrixHeaderAdd($color_dark_bar,"","graphs_items.php?action=edit&gid=$id");
		DrawMatrixRowEnd();
		
		DrawMatrixRowBegin();
		?>
		<td bgcolor="#<?print $color_panel;?>" colspan="7">
			<table width="100%">
				<tr>
					<td rowspan="2" valign="top">
						<a href="graphs_items.php?id=<?print $id;?>&graph_preview=<?if ($graph_preview == "on") { print "off"; }else{ print "on"; }?>">Turn Graph Preview <?if ($graph_preview == "on") { print "<strong>Off</strong>"; }else{ print "<strong>On</strong>"; }?></a><br>
						<a href="graphs_items.php?id=<?print $id;?>&graph_output_preview=<?if ($graph_output_preview == "on") { print "off"; }else{ print "on"; }?>">Turn Graph Output Preview <?if ($graph_output_preview == "on") { print "<strong>Off</strong>"; }else{ print "<strong>On</strong>"; }?></a><br>
						<a href="graphs_items.php?id=<?print $id;?>&graph_grouping=<?if ($allow_grouping == "on") { print "off"; }else{ print "on"; }?>">Turn Graph Grouping <?if ($allow_grouping == "on") { print "<strong>Off</strong>"; }else{ print "<strong>On</strong>"; }?></a><br>
					</td>
					<td align="right">
						<?if ($graph_preview == "on") {?>
						<img src="graph_image.php?graphid=<?print $id;?>&rraid=1&graph_start=-86400&graph_height=100&graph_width=350">
						<?}?>
					</td>
				</tr>
				<tr>
					<td align="right">
						<?if ($graph_output_preview == "on") {
						$graph_data_array["output_flag"] = 2;
						?><PRE><?print rrdtool_function_graph($id, 1, $graph_data_array);?></PRE><?
						}?>
					</td>
				</tr>
			</table>
		</td>
		<?
		DrawMatrixRowEnd();
		
		DrawMatrixRowBegin();
			DrawMatrixHeaderItem("Graph Item",$color_panel,$color_panel_text);
			DrawMatrixHeaderItem("Data Source Name",$color_panel,$color_panel_text);
			DrawMatrixHeaderItem("Graph Item Type",$color_panel,$color_panel_text);
			DrawMatrixCustom("<td bgcolor=\"$color_panel\" colspan=\"2\">Item Color</td>");
			DrawMatrixHeaderItem("Sequence",$color_panel,$color_panel_text);
			DrawMatrixHeaderAdd($color_panel,"","graphs_items.php?action=edit&gid=$id");
		DrawMatrixRowEnd();
		
		$sql_id = mysql_query("select 
			d.id as did, d.name as dname, 
			t.id as tid, t.name, 
			c.id as cid,c.hex, 
			cf.name as cfname,
			g.*,
			cd.name as cdefname
			from rrd_graph_item g 
			left join def_graph_type t on g.graphtypeid=t.id
			left join def_colors c on g.colorid=c.id 
			left join def_cf cf on g.consolidationfunction=cf.id
			left join rrd_ds d on g.dsid=d.id
			left join rrd_ds_cdef cd on g.cdefid=cd.id
			where g.graphid=$id order by g.sequenceparent,g.sequence", $cnn_id);
		$rows = mysql_num_rows($sql_id); $i = 0;
		
		while ($i < $rows) {
			$current_color = DrawMatrixRowAlternateColorBegin($color_alternate,$color_light,$i);
				/* grouping options */
				if ($allow_grouping == "on") { /* GROUPING ON, PARENT */
					if (mysql_result($sql_id, $i, "name") != "GPRINT") {
						$items_bold = true;
						$title_bold = true;
						$items_indent = "";
					}else{ /* GROUPING ON, CHILD */
						$items_bold = false;
						$title_bold = false;
						$items_indent = "<img src=\"images/gray_line.gif\" width=\"7\" height=\"1\" border=\"0\">";
					}
				}else{ /* GROUPING OFF */
					$items_bold = false;
					$title_bold = html_boolean($config["vis_main_column_bold"]["value"]);
					$items_indent = "";
				}
				
				DrawMatrixLoopItem("$items_indent Item #" . ($i+1),"","",$title_bold,"graphs_items.php?action=edit&id=" . mysql_result($sql_id, $i, "id") . "&gid=$id");
				
				switch (mysql_result($sql_id, $i, "name")) {
					case 'COMMENT':
						$matrix_title = "COMMENT: " . mysql_result($sql_id, $i, "textformat");
						break;
					case 'GPRINT':
						$matrix_title = mysql_result($sql_id, $i, "dname") . ": " . mysql_result($sql_id, $i, "textformat");
						break;
					case 'HRULE':
						$matrix_title = "HRULE: " . mysql_result($sql_id, $i, "value");
						break;
					case 'VRULE':
						$matrix_title = "VRULE: " . mysql_result($sql_id, $i, "value");
						break;
					default:
						$matrix_title = mysql_result($sql_id, $i, "dname");
						break;
				}
				
				/* for display only */
				$matrix_title = htmlspecialchars($matrix_title);
				
				/* use the cdef name (if in use) if all else fails */
				if ($matrix_title == "") {
					if (mysql_result($sql_id, $i, "cdefname") != "") {
						$matrix_title .= "CDEF: " . mysql_result($sql_id, $i, "cdefname");
					}
				}
				
				if (mysql_result($sql_id, $i, "hardreturn") == "on") {
					$matrix_title .= "<strong><font color=\"#FF0000\">&lt;HR&gt;</font></strong>";
				}
				
				if (mysql_result($sql_id, $i, "name") != "GPRINT") {
					if (mysql_result($sql_id, $i, "cfname") != "AVERAGE") {
						$matrix_title .= " (" . mysql_result($sql_id, $i, "cfname") . ")";
					}
				}
				
				DrawMatrixLoopItem($matrix_title,"","",$items_bold,"");
				DrawMatrixLoopItem($sql_id,"name",$i,$items_bold,"");
				
				if (mysql_result($sql_id, $i, "hex") != "") {
					$matrix_bgcolor = mysql_result($sql_id, $i, "hex");
				}else{
					$matrix_bgcolor = $current_color;
				}
				
				DrawMatrixLoopItemAction("&nbsp;",$matrix_bgcolor,"",$items_bold,""); /* color preview */
				DrawMatrixLoopItem($sql_id,"hex",$i,$items_bold,""); /* hex value */
				DrawMatrixLoopItem("[<a href=\"graphs_items.php?action=movedown&id=" . mysql_result($sql_id, $i, "id") . "&gid=$id&tid=" . mysql_result($sql_id, $i, "parent") . "\">Down</a>], [<a href=\"graphs_items.php?action=moveup&id=" . mysql_result($sql_id, $i, "id") . "&gid=$id&tid=" . mysql_result($sql_id, $i, "parent") . "\">Up</a>]","","",$items_bold,"");
				DrawMatrixLoopItemAction("Remove",$color_panel,"",$items_bold,"graphs_items.php?action=remove&id=" . mysql_result($sql_id, $i, "id") . "&gid=$id&tid=" . mysql_result($sql_id, $i, "parent"));
				
			DrawMatrixRowEnd();
			$i++;
		}
		
		DrawMatrixTableEnd();
		include_once ("include/bottom_footer.php");
		
		break;
} ?>