1 /***********************************************************************
2  *
3  * CONFIG.C - Nagios Configuration CGI (View Only)
4  *
5  *
6  * This CGI program will display various configuration information.
7  *
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  ***********************************************************************/
22 
23 #include "../include/config.h"
24 #include "../include/common.h"
25 #include "../include/objects.h"
26 #include "../include/macros.h"
27 #include "../include/cgiutils.h"
28 #include "../include/cgiauth.h"
29 #include "../include/getcgi.h"
30 
31 static nagios_macros *mac;
32 
33 extern char   main_config_file[MAX_FILENAME_LENGTH];
34 extern char   url_html_path[MAX_FILENAME_LENGTH];
35 extern char   url_docs_path[MAX_FILENAME_LENGTH];
36 extern char   url_images_path[MAX_FILENAME_LENGTH];
37 extern char   url_logo_images_path[MAX_FILENAME_LENGTH];
38 extern char   url_stylesheets_path[MAX_FILENAME_LENGTH];
39 
40 #define DISPLAY_NONE                     0
41 #define DISPLAY_HOSTS                    1
42 #define DISPLAY_HOSTGROUPS               2
43 #define DISPLAY_CONTACTS                 3
44 #define DISPLAY_CONTACTGROUPS            4
45 #define DISPLAY_SERVICES                 5
46 #define DISPLAY_TIMEPERIODS              6
47 #define DISPLAY_COMMANDS                 7
48 #define DISPLAY_HOSTGROUPESCALATIONS     8    /* no longer implemented */
49 #define DISPLAY_SERVICEDEPENDENCIES      9
50 #define DISPLAY_SERVICEESCALATIONS       10
51 #define DISPLAY_HOSTDEPENDENCIES         11
52 #define DISPLAY_HOSTESCALATIONS          12
53 #define DISPLAY_SERVICEGROUPS            15
54 #define DISPLAY_COMMAND_EXPANSION        16211
55 
56 void document_header(int);
57 void document_footer(void);
58 int process_cgivars(void);
59 
60 void display_options(void);
61 
62 void display_hosts(void);
63 void display_hostgroups(void);
64 void display_servicegroups(void);
65 void display_contacts(void);
66 void display_contactgroups(void);
67 void display_services(void);
68 void display_timeperiods(void);
69 void display_commands(void);
70 void display_servicedependencies(void);
71 void display_serviceescalations(void);
72 void display_hostdependencies(void);
73 void display_hostescalations(void);
74 void display_command_expansion(void);
75 
76 void unauthorized_message(void);
77 
78 
79 authdata current_authdata;
80 
81 int display_type = DISPLAY_NONE;
82 char to_expand[MAX_COMMAND_BUFFER];
83 char hashed_color[8];
84 
85 int embedded = FALSE;
86 
print_expand_input(int type)87 static void print_expand_input(int type) {
88 	const char *seldesc = "";
89 
90 	if(type == DISPLAY_COMMAND_EXPANSION) return;	/* Has its own form, w/ larger <input> */
91 	else if(type == DISPLAY_SERVICES) {
92 		seldesc = " Services Named or on Host";
93 		}
94 	else if(type == DISPLAY_SERVICEDEPENDENCIES) {
95 		seldesc = " Dependencies with Host";
96 		}
97 	else if(type == DISPLAY_SERVICEESCALATIONS) {
98 		seldesc = " Escalations on Host";
99 		}
100 	else if(type == DISPLAY_HOSTDEPENDENCIES) {
101 		seldesc = " Dependencies on/of Host";
102 		}
103 	else if(type == DISPLAY_HOSTESCALATIONS) {
104 		seldesc = " Escalations for Host";
105 		}
106 	printf("<tr><td align=left class='reportSelectSubTitle'>Show Only%s:</td></tr>\n", seldesc);
107 	printf("<tr><td align=left class='reportSelectItem'><input type='text' name='expand'\n");
108 	printf("value='%s'>", html_encode(to_expand, FALSE));
109 	}
110 
main(void)111 int main(void) {
112 	mac = get_global_macros();
113 
114 	/* get the arguments passed in the URL */
115 	process_cgivars();
116 
117 	/* reset internal variables */
118 	reset_cgi_vars();
119 
120 	cgi_init(document_header, document_footer, READ_ALL_OBJECT_DATA, 0);
121 
122 	/* initialize macros */
123 	init_macros();
124 
125 	document_header(TRUE);
126 
127 	/* get authentication information */
128 	get_authentication_information(&current_authdata);
129 
130 	/* begin top table */
131 	printf("<table border=0 width=100%%>\n");
132 	printf("<tr>\n");
133 
134 	/* left column of the first row */
135 	printf("<td align=left valign=top width=50%%>\n");
136 	display_info_table("Configuration", FALSE, &current_authdata);
137 	printf("</td>\n");
138 
139 	/* right hand column of top row */
140 	printf("<td align=right valign=bottom width=50%%>\n");
141 
142 	if(display_type != DISPLAY_NONE) {
143 
144 		printf("<form method=\"get\" action=\"%s\">\n", CONFIG_CGI);
145 		printf("<table border=0>\n");
146 
147 		printf("<tr><td align=left class='reportSelectSubTitle'>Object Type:</td></tr>\n");
148 		printf("<tr><td align=left class='reportSelectItem'>");
149 		printf("<select name='type'>\n");
150 		printf("<option value='hosts' %s>Hosts\n", (display_type == DISPLAY_HOSTS) ? "SELECTED" : "");
151 		printf("<option value='hostdependencies' %s>Host Dependencies\n", (display_type == DISPLAY_HOSTDEPENDENCIES) ? "SELECTED" : "");
152 		printf("<option value='hostescalations' %s>Host Escalations\n", (display_type == DISPLAY_HOSTESCALATIONS) ? "SELECTED" : "");
153 		printf("<option value='hostgroups' %s>Host Groups\n", (display_type == DISPLAY_HOSTGROUPS) ? "SELECTED" : "");
154 		printf("<option value='services' %s>Services\n", (display_type == DISPLAY_SERVICES) ? "SELECTED" : "");
155 		printf("<option value='servicegroups' %s>Service Groups\n", (display_type == DISPLAY_SERVICEGROUPS) ? "SELECTED" : "");
156 		printf("<option value='servicedependencies' %s>Service Dependencies\n", (display_type == DISPLAY_SERVICEDEPENDENCIES) ? "SELECTED" : "");
157 		printf("<option value='serviceescalations' %s>Service Escalations\n", (display_type == DISPLAY_SERVICEESCALATIONS) ? "SELECTED" : "");
158 		printf("<option value='contacts' %s>Contacts\n", (display_type == DISPLAY_CONTACTS) ? "SELECTED" : "");
159 		printf("<option value='contactgroups' %s>Contact Groups\n", (display_type == DISPLAY_CONTACTGROUPS) ? "SELECTED" : "");
160 		printf("<option value='timeperiods' %s>Timeperiods\n", (display_type == DISPLAY_TIMEPERIODS) ? "SELECTED" : "");
161 		printf("<option value='commands' %s>Commands\n", (display_type == DISPLAY_COMMANDS) ? "SELECTED" : "");
162 		printf("<option value='command' %s>Command Expansion\n", (display_type == DISPLAY_COMMAND_EXPANSION) ? "SELECTED" : "");
163 		printf("</select>\n");
164 		printf("</td></tr>\n");
165 
166 		print_expand_input(display_type);
167 
168 		printf("<tr><td class='reportSelectItem'><input type='submit' value='Update'></td></tr>\n");
169 		printf("</table>\n");
170 		printf("</form>\n");
171 		}
172 
173 	/* display context-sensitive help */
174 	switch(display_type) {
175 		case DISPLAY_HOSTS:
176 			display_context_help(CONTEXTHELP_CONFIG_HOSTS);
177 			break;
178 		case DISPLAY_HOSTGROUPS:
179 			display_context_help(CONTEXTHELP_CONFIG_HOSTGROUPS);
180 			break;
181 		case DISPLAY_SERVICEGROUPS:
182 			display_context_help(CONTEXTHELP_CONFIG_SERVICEGROUPS);
183 			break;
184 		case DISPLAY_CONTACTS:
185 			display_context_help(CONTEXTHELP_CONFIG_CONTACTS);
186 			break;
187 		case DISPLAY_CONTACTGROUPS:
188 			display_context_help(CONTEXTHELP_CONFIG_CONTACTGROUPS);
189 			break;
190 		case DISPLAY_SERVICES:
191 			display_context_help(CONTEXTHELP_CONFIG_SERVICES);
192 			break;
193 		case DISPLAY_TIMEPERIODS:
194 			display_context_help(CONTEXTHELP_CONFIG_TIMEPERIODS);
195 			break;
196 		case DISPLAY_COMMANDS:
197 			display_context_help(CONTEXTHELP_CONFIG_COMMANDS);
198 			break;
199 		case DISPLAY_SERVICEDEPENDENCIES:
200 			display_context_help(CONTEXTHELP_CONFIG_SERVICEDEPENDENCIES);
201 			break;
202 		case DISPLAY_SERVICEESCALATIONS:
203 			display_context_help(CONTEXTHELP_CONFIG_HOSTESCALATIONS);
204 			break;
205 		case DISPLAY_HOSTDEPENDENCIES:
206 			display_context_help(CONTEXTHELP_CONFIG_HOSTDEPENDENCIES);
207 			break;
208 		case DISPLAY_HOSTESCALATIONS:
209 			display_context_help(CONTEXTHELP_CONFIG_HOSTESCALATIONS);
210 			break;
211 		case DISPLAY_COMMAND_EXPANSION:
212 			/* Reusing DISPLAY_COMMANDS help until further notice */
213 			display_context_help(CONTEXTHELP_CONFIG_COMMANDS);
214 			break;
215 		default:
216 			display_context_help(CONTEXTHELP_CONFIG_MENU);
217 			break;
218 		}
219 
220 	printf("</td>\n");
221 
222 	/* end of top table */
223 	printf("</tr>\n");
224 	printf("</table>\n");
225 
226 
227 	switch(display_type) {
228 		case DISPLAY_HOSTS:
229 			display_hosts();
230 			break;
231 		case DISPLAY_HOSTGROUPS:
232 			display_hostgroups();
233 			break;
234 		case DISPLAY_SERVICEGROUPS:
235 			display_servicegroups();
236 			break;
237 		case DISPLAY_CONTACTS:
238 			display_contacts();
239 			break;
240 		case DISPLAY_CONTACTGROUPS:
241 			display_contactgroups();
242 			break;
243 		case DISPLAY_SERVICES:
244 			display_services();
245 			break;
246 		case DISPLAY_TIMEPERIODS:
247 			display_timeperiods();
248 			break;
249 		case DISPLAY_COMMANDS:
250 			display_commands();
251 			break;
252 		case DISPLAY_SERVICEDEPENDENCIES:
253 			display_servicedependencies();
254 			break;
255 		case DISPLAY_SERVICEESCALATIONS:
256 			display_serviceescalations();
257 			break;
258 		case DISPLAY_HOSTDEPENDENCIES:
259 			display_hostdependencies();
260 			break;
261 		case DISPLAY_HOSTESCALATIONS:
262 			display_hostescalations();
263 			break;
264 		case DISPLAY_COMMAND_EXPANSION:
265 			display_command_expansion();
266 			break;
267 		default:
268 			display_options();
269 			break;
270 		}
271 
272 	document_footer();
273 
274 	return OK;
275 	}
276 
277 
278 
279 
document_header(int use_stylesheet)280 void document_header(int use_stylesheet) {
281 	char date_time[MAX_DATETIME_LENGTH];
282 	time_t t;
283 
284 	if(embedded == TRUE)
285 		return;
286 
287 	time(&t);
288 	get_time_string(&t, date_time, sizeof(date_time), HTTP_DATE_TIME);
289 
290 	printf("Cache-Control: no-store\r\n");
291 	printf("Pragma: no-cache\r\n");
292 	printf("Last-Modified: %s\r\n", date_time);
293 	printf("Expires: %s\r\n", date_time);
294 	printf("Content-type: text/html; charset=utf-8\r\n\r\n");
295 
296 	printf("<html>\n");
297 	printf("<head>\n");
298 	printf("<link rel=\"shortcut icon\" href=\"%sfavicon.ico\" type=\"image/ico\">\n", url_images_path);
299 	printf("<META HTTP-EQUIV='Pragma' CONTENT='no-cache'>\n");
300 	printf("<title>\n");
301 	printf("Configuration\n");
302 	printf("</title>\n");
303 
304 	if(use_stylesheet == TRUE) {
305 		printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>\n", url_stylesheets_path, COMMON_CSS);
306 		printf("<LINK REL='stylesheet' TYPE='text/css' HREF='%s%s'>\n", url_stylesheets_path, CONFIG_CSS);
307 		}
308 
309 	printf("</head>\n");
310 
311 	printf("<body CLASS='config'>\n");
312 
313 	/* include user SSI header */
314 	include_ssi_files(CONFIG_CGI, SSI_HEADER);
315 
316 	return;
317 	}
318 
319 
document_footer(void)320 void document_footer(void) {
321 
322 	if(embedded == TRUE)
323 		return;
324 
325 	/* include user SSI footer */
326 	include_ssi_files(CONFIG_CGI, SSI_FOOTER);
327 
328 	printf("</body>\n");
329 	printf("</html>\n");
330 
331 	return;
332 	}
333 
334 
process_cgivars(void)335 int process_cgivars(void) {
336 	char **variables;
337 	int error = FALSE;
338 	int x;
339 
340 	variables = getcgivars();
341 	to_expand[0] = '\0';
342 
343 	for(x = 0; variables[x]; x++) {
344 
345 		/* do some basic length checking on the variable identifier to prevent buffer overflows */
346 		if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
347 			continue;
348 			}
349 
350 		/* we found the configuration type argument */
351 		else if(!strcmp(variables[x], "type")) {
352 			x++;
353 			if(variables[x] == NULL) {
354 				error = TRUE;
355 				break;
356 				}
357 
358 			/* what information should we display? */
359 			if(!strcmp(variables[x], "hosts"))
360 				display_type = DISPLAY_HOSTS;
361 			else if(!strcmp(variables[x], "hostgroups"))
362 				display_type = DISPLAY_HOSTGROUPS;
363 			else if(!strcmp(variables[x], "servicegroups"))
364 				display_type = DISPLAY_SERVICEGROUPS;
365 			else if(!strcmp(variables[x], "contacts"))
366 				display_type = DISPLAY_CONTACTS;
367 			else if(!strcmp(variables[x], "contactgroups"))
368 				display_type = DISPLAY_CONTACTGROUPS;
369 			else if(!strcmp(variables[x], "services"))
370 				display_type = DISPLAY_SERVICES;
371 			else if(!strcmp(variables[x], "timeperiods"))
372 				display_type = DISPLAY_TIMEPERIODS;
373 			else if(!strcmp(variables[x], "commands"))
374 				display_type = DISPLAY_COMMANDS;
375 			else if(!strcmp(variables[x], "servicedependencies"))
376 				display_type = DISPLAY_SERVICEDEPENDENCIES;
377 			else if(!strcmp(variables[x], "serviceescalations"))
378 				display_type = DISPLAY_SERVICEESCALATIONS;
379 			else if(!strcmp(variables[x], "hostdependencies"))
380 				display_type = DISPLAY_HOSTDEPENDENCIES;
381 			else if(!strcmp(variables[x], "hostescalations"))
382 				display_type = DISPLAY_HOSTESCALATIONS;
383 			else if(!strcmp(variables[x], "command"))
384 				display_type = DISPLAY_COMMAND_EXPANSION;
385 
386 			/* we found the embed option */
387 			else if(!strcmp(variables[x], "embedded"))
388 				embedded = TRUE;
389 			}
390 
391 		/* we found the string-to-expand argument */
392 		else if(!strcmp(variables[x], "expand")) {
393 			x++;
394 			if(variables[x] == NULL) {
395 				error = TRUE;
396 				break;
397 				}
398 			strncpy(to_expand, variables[x], MAX_COMMAND_BUFFER);
399 			to_expand[MAX_COMMAND_BUFFER - 1] = '\0';
400 			}
401 
402 
403 		/* we received an invalid argument */
404 		else
405 			error = TRUE;
406 
407 		}
408 
409 	/* free memory allocated to the CGI variables */
410 	free_cgivars(variables);
411 
412 	return error;
413 	}
414 
415 
416 
display_hosts(void)417 void display_hosts(void) {
418 	host *temp_host = NULL;
419 	hostsmember *temp_hostsmember = NULL;
420 	contactsmember *temp_contactsmember = NULL;
421 	contactgroupsmember *temp_contactgroupsmember = NULL;
422 	char *processed_string = NULL;
423 	int options = 0;
424 	int odd = 0;
425 	char time_string[16];
426 	const char *bg_class = "";
427 	int num_contacts = 0;
428 
429 	/* see if user is authorized to view host information... */
430 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
431 		unauthorized_message();
432 		return;
433 		}
434 
435 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Host%s%s</DIV></P>\n",
436 	       (*to_expand == '\0' ? "s" : " "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
437 
438 	printf("<P><DIV ALIGN=CENTER>\n");
439 	printf("<TABLE BORDER=0 CLASS='data'>\n");
440 
441 	printf("<TR>\n");
442 	printf("<TH CLASS='data'>Host Name</TH>");
443 	printf("<TH CLASS='data'>Alias/Description</TH>");
444 	printf("<TH CLASS='data'>Address</TH>");
445 	printf("<TH CLASS='data'>Importance (Host)</TH>");
446 	printf("<TH CLASS='data'>Importance (Host + Services)</TH>");
447 	printf("<TH CLASS='data'>Parent Hosts</TH>");
448 	printf("<TH CLASS='data'>Max. Check Attempts</TH>");
449 	printf("<TH CLASS='data'>Check Interval</TH>\n");
450 	printf("<TH CLASS='data'>Retry Interval</TH>\n");
451 	printf("<TH CLASS='data'>Host Check Command</TH>");
452 	printf("<TH CLASS='data'>Check Period</TH>");
453 	printf("<TH CLASS='data'>Obsess Over</TH>\n");
454 	printf("<TH CLASS='data'>Enable Active Checks</TH>\n");
455 	printf("<TH CLASS='data'>Enable Passive Checks</TH>\n");
456 	printf("<TH CLASS='data'>Check Freshness</TH>\n");
457 	printf("<TH CLASS='data'>Freshness Threshold</TH>\n");
458 	printf("<TH CLASS='data'>Default Contacts/Groups</TH>\n");
459 	printf("<TH CLASS='data'>Notification Interval</TH>");
460 	printf("<TH CLASS='data'>First Notification Delay</TH>");
461 	printf("<TH CLASS='data'>Notification Options</TH>");
462 	printf("<TH CLASS='data'>Notification Period</TH>");
463 	printf("<TH CLASS='data'>Event Handler</TH>");
464 	printf("<TH CLASS='data'>Enable Event Handler</TH>");
465 	printf("<TH CLASS='data'>Stalking Options</TH>\n");
466 	printf("<TH CLASS='data'>Enable Flap Detection</TH>");
467 	printf("<TH CLASS='data'>Low Flap Threshold</TH>");
468 	printf("<TH CLASS='data'>High Flap Threshold</TH>");
469 	printf("<TH CLASS='data'>Flap Detection Options</TH>\n");
470 	printf("<TH CLASS='data'>Process Performance Data</TH>");
471 	printf("<TH CLASS='data'>Notes</TH>");
472 	printf("<TH CLASS='data'>Notes URL</TH>");
473 	printf("<TH CLASS='data'>Action URL</TH>");
474 	printf("<TH CLASS='data'>2-D Coords</TH>");
475 	printf("<TH CLASS='data'>3-D Coords</TH>");
476 	printf("<TH CLASS='data'>Statusmap Image</TH>");
477 	printf("<TH CLASS='data'>VRML Image</TH>");
478 	printf("<TH CLASS='data'>Logo Image</TH>");
479 	printf("<TH CLASS='data'>Image Alt</TH>");
480 	printf("<TH CLASS='data'>Retention Options</TH>");
481 	printf("</TR>\n");
482 
483 	/* check all the hosts... */
484 	for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) if(((*to_expand) == '\0') || !strcmp(to_expand, temp_host->name)) {
485 
486 			/* grab macros */
487 			grab_host_macros_r(mac, temp_host);
488 
489 			if(odd) {
490 				odd = 0;
491 				bg_class = "dataOdd";
492 				}
493 			else {
494 				odd = 1;
495 				bg_class = "dataEven";
496 				}
497 
498 			printf("<TR CLASS='%s'>\n", bg_class);
499 
500 			printf("<TD CLASS='%s'><a name='%s'><a href='%s?type=services&expand=%s'>%s</a></a></TD>\n", bg_class,
501 			       url_encode(temp_host->name), CONFIG_CGI, url_encode(temp_host->name), html_encode(temp_host->name, FALSE));
502 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_host->alias, FALSE));
503 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_host->address, FALSE));
504 			printf("<TD CLASS='%s'>%u</TD>\n", bg_class, temp_host->hourly_value);
505 			printf("<TD CLASS='%s'>%u</TD>\n", bg_class, temp_host->hourly_value + host_services_value(temp_host));
506 
507 			printf("<TD CLASS='%s'>", bg_class);
508 			for(temp_hostsmember = temp_host->parent_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
509 
510 				if(temp_hostsmember != temp_host->parent_hosts)
511 					printf(", ");
512 
513 				printf("<a href='%s?type=hosts&expand=%s'>%s</a>\n", CONFIG_CGI, url_encode(temp_hostsmember->host_name), html_encode(temp_hostsmember->host_name, FALSE));
514 				}
515 			if(temp_host->parent_hosts == NULL)
516 				printf("&nbsp;");
517 			printf("</TD>\n");
518 
519 			printf("<TD CLASS='%s'>%d</TD>\n", bg_class, temp_host->max_attempts);
520 
521 			get_interval_time_string(temp_host->check_interval, time_string, sizeof(time_string));
522 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, time_string);
523 
524 			get_interval_time_string(temp_host->retry_interval, time_string, sizeof(time_string));
525 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, time_string);
526 
527 			printf("<TD CLASS='%s'>", bg_class);
528 			if(temp_host->check_command == NULL)
529 				printf("&nbsp;");
530 			else
531 				printf("<a href='%s?type=command&expand=%s'>%s</a></TD>\n", CONFIG_CGI, url_encode(temp_host->check_command), html_encode(temp_host->check_command, FALSE));
532 			printf("</TD>\n");
533 
534 			printf("<TD CLASS='%s'>", bg_class);
535 			if(temp_host->check_period == NULL)
536 				printf("&nbsp;");
537 			else
538 				printf("<A HREF='%s?type=timeperiods&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_host->check_period), html_encode(temp_host->check_period, FALSE));
539 			printf("</TD>\n");
540 
541 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_host->obsess == TRUE) ? "Yes" : "No");
542 
543 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_host->checks_enabled == TRUE) ? "Yes" : "No");
544 
545 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_host->accept_passive_checks == TRUE) ? "Yes" : "No");
546 
547 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_host->check_freshness == TRUE) ? "Yes" : "No");
548 
549 			printf("<TD CLASS='%s'>", bg_class);
550 			if(temp_host->freshness_threshold == 0)
551 				printf("Auto-determined value\n");
552 			else
553 				printf("%d seconds\n", temp_host->freshness_threshold);
554 			printf("</TD>\n");
555 
556 			printf("<TD CLASS='%s'>", bg_class);
557 
558 			/* find all the contacts for this host... */
559 			num_contacts = 0;
560 			for(temp_contactsmember = temp_host->contacts; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
561 				num_contacts++;
562 				if(num_contacts > 1)
563 					printf(", ");
564 
565 				printf("<A HREF='%s?type=contacts&expand=%s'>%s</A>\n", CONFIG_CGI, url_encode(temp_contactsmember->contact_name), html_encode(temp_contactsmember->contact_name, FALSE));
566 				}
567 			for(temp_contactgroupsmember = temp_host->contact_groups; temp_contactgroupsmember != NULL; temp_contactgroupsmember = temp_contactgroupsmember->next) {
568 				num_contacts++;
569 				if(num_contacts > 1)
570 					printf(", ");
571 				printf("<A HREF='%s?type=contactgroups&expand=%s'>%s</A>\n", CONFIG_CGI, url_encode(temp_contactgroupsmember->group_name), html_encode(temp_contactgroupsmember->group_name, FALSE));
572 				}
573 			if(num_contacts == 0)
574 				printf("&nbsp;");
575 			printf("</TD>\n");
576 
577 			get_interval_time_string(temp_host->notification_interval, time_string, sizeof(time_string));
578 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_host->notification_interval == 0) ? "<i>No Re-notification</I>" : html_encode(time_string, FALSE));
579 
580 			get_interval_time_string(temp_host->first_notification_delay, time_string, sizeof(time_string));
581 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, time_string);
582 
583 			printf("<TD CLASS='%s'>", bg_class);
584 			options = 0;
585 			if(flag_isset(temp_host->notification_options, OPT_DOWN) == TRUE) {
586 				options = 1;
587 				printf("Down");
588 				}
589 			if(flag_isset(temp_host->notification_options, OPT_UNREACHABLE) == TRUE) {
590 				printf("%sUnreachable", (options) ? ", " : "");
591 				options = 1;
592 				}
593 			if(flag_isset(temp_host->notification_options, OPT_RECOVERY) == TRUE) {
594 				printf("%sRecovery", (options) ? ", " : "");
595 				options = 1;
596 				}
597 			if(flag_isset(temp_host->notification_options, OPT_FLAPPING) == TRUE) {
598 				printf("%sFlapping", (options) ? ", " : "");
599 				options = 1;
600 				}
601 			if(flag_isset(temp_host->notification_options, OPT_DOWNTIME) == TRUE) {
602 				printf("%sDowntime", (options) ? ", " : "");
603 				options = 1;
604 				}
605 			if(options == 0)
606 				printf("None");
607 			printf("</TD>\n");
608 
609 			printf("<TD CLASS='%s'>", bg_class);
610 			if(temp_host->notification_period == NULL)
611 				printf("&nbsp;");
612 			else
613 				printf("<a href='%s?type=timeperiods&expand=%s'>%s</a>", CONFIG_CGI, url_encode(temp_host->notification_period), html_encode(temp_host->notification_period, FALSE));
614 			printf("</TD>\n");
615 
616 			printf("<TD CLASS='%s'>", bg_class);
617 			if(temp_host->event_handler == NULL)
618 				printf("&nbsp");
619 			else
620 				/* printf("<a href='%s?type=commands&expand=%s'>%s</a></TD>\n",CONFIG_CGI,url_encode(strtok(temp_host->event_handler,"!")),html_encode(temp_host->event_handler,FALSE)); */
621 				printf("<a href='%s?type=command&expand=%s'>%s</a></TD>\n", CONFIG_CGI, url_encode(temp_host->event_handler), html_encode(temp_host->event_handler, FALSE));
622 			printf("</TD>\n");
623 
624 			printf("<TD CLASS='%s'>", bg_class);
625 			printf("%s\n", (temp_host->event_handler_enabled == TRUE) ? "Yes" : "No");
626 			printf("</TD>\n");
627 
628 			printf("<TD CLASS='%s'>", bg_class);
629 			options = 0;
630 			if(flag_isset(temp_host->stalking_options, OPT_UP) == TRUE) {
631 				options = 1;
632 				printf("Up");
633 				}
634 			if(flag_isset(temp_host->stalking_options, OPT_DOWN) == TRUE) {
635 				printf("%sDown", (options) ? ", " : "");
636 				options = 1;
637 				}
638 			if(flag_isset(temp_host->stalking_options, OPT_UNREACHABLE) == TRUE) {
639 				printf("%sUnreachable", (options) ? ", " : "");
640 				options = 1;
641 				}
642 			if(options == 0)
643 				printf("None");
644 			printf("</TD>\n");
645 
646 			printf("<TD CLASS='%s'>", bg_class);
647 			printf("%s\n", (temp_host->flap_detection_enabled == TRUE) ? "Yes" : "No");
648 			printf("</TD>\n");
649 
650 			printf("<TD CLASS='%s'>", bg_class);
651 			if(temp_host->low_flap_threshold == 0.0)
652 				printf("Program-wide value\n");
653 			else
654 				printf("%3.1f%%\n", temp_host->low_flap_threshold);
655 			printf("</TD>\n");
656 
657 			printf("<TD CLASS='%s'>", bg_class);
658 			if(temp_host->high_flap_threshold == 0.0)
659 				printf("Program-wide value\n");
660 			else
661 				printf("%3.1f%%\n", temp_host->high_flap_threshold);
662 			printf("</TD>\n");
663 
664 			printf("<TD CLASS='%s'>", bg_class);
665 			options = 0;
666 			if(flag_isset(temp_host->flap_detection_options, OPT_UP) == TRUE) {
667 				options = 1;
668 				printf("Up");
669 				}
670 			if(flag_isset(temp_host->flap_detection_options, OPT_DOWN) == TRUE) {
671 				printf("%sDown", (options) ? ", " : "");
672 				options = 1;
673 				}
674 			if(flag_isset(temp_host->flap_detection_options, OPT_UNREACHABLE) == TRUE) {
675 				printf("%sUnreachable", (options) ? ", " : "");
676 				options = 1;
677 				}
678 			if(options == 0)
679 				printf("None");
680 			printf("</TD>\n");
681 
682 			printf("<TD CLASS='%s'>", bg_class);
683 			printf("%s\n", (temp_host->process_performance_data == TRUE) ? "Yes" : "No");
684 			printf("</TD>\n");
685 
686 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_host->notes == NULL) ? "&nbsp;" : html_encode(temp_host->notes, FALSE));
687 
688 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_host->notes_url == NULL) ? "&nbsp;" : html_encode(temp_host->notes_url, FALSE));
689 
690 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_host->action_url == NULL) ? "&nbsp;" : html_encode(temp_host->action_url, FALSE));
691 
692 			if(temp_host->have_2d_coords == FALSE)
693 				printf("<TD CLASS='%s'>&nbsp;</TD>", bg_class);
694 			else
695 				printf("<TD CLASS='%s'>%d,%d</TD>", bg_class, temp_host->x_2d, temp_host->y_2d);
696 
697 			if(temp_host->have_3d_coords == FALSE)
698 				printf("<TD CLASS='%s'>&nbsp;</TD>", bg_class);
699 			else
700 				printf("<TD CLASS='%s'>%.2f,%.2f,%.2f</TD>", bg_class, temp_host->x_3d, temp_host->y_3d, temp_host->z_3d);
701 
702 			if(temp_host->statusmap_image == NULL)
703 				printf("<TD CLASS='%s'>&nbsp;</TD>", bg_class);
704 			else
705 				printf("<TD CLASS='%s' valign='center'><img src='%s%s' border='0' width='20' height='20'> %s</TD>", bg_class, url_logo_images_path, temp_host->statusmap_image, html_encode(temp_host->statusmap_image, FALSE));
706 
707 			if(temp_host->vrml_image == NULL)
708 				printf("<TD CLASS='%s'>&nbsp;</TD>", bg_class);
709 			else
710 				printf("<TD CLASS='%s' valign='center'><img src='%s%s' border='0' width='20' height='20'> %s</TD>", bg_class, url_logo_images_path, temp_host->vrml_image, html_encode(temp_host->vrml_image, FALSE));
711 
712 			if(temp_host->icon_image == NULL)
713 				printf("<TD CLASS='%s'>&nbsp;</TD>", bg_class);
714 			else {
715 				process_macros_r(mac, temp_host->icon_image, &processed_string, 0);
716 				printf("<TD CLASS='%s' valign='center'><img src='%s%s' border='0' width='20' height='20'> %s</TD>", bg_class, url_logo_images_path, processed_string, html_encode(temp_host->icon_image, FALSE));
717 				free(processed_string);
718 				}
719 
720 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_host->icon_image_alt == NULL) ? "&nbsp;" : html_encode(temp_host->icon_image_alt, FALSE));
721 
722 			printf("<TD CLASS='%s'>", bg_class);
723 			options = 0;
724 			if(temp_host->retain_status_information == TRUE) {
725 				options = 1;
726 				printf("Status Information");
727 				}
728 			if(temp_host->retain_nonstatus_information == TRUE) {
729 				printf("%sNon-Status Information", (options == 1) ? ", " : "");
730 				options = 1;
731 				}
732 			if(options == 0)
733 				printf("None");
734 			printf("</TD>\n");
735 
736 			printf("</TR>\n");
737 			}
738 
739 	printf("</TABLE>\n");
740 	printf("</DIV>\n");
741 	printf("</P>\n");
742 
743 	return;
744 	}
745 
746 
747 
display_hostgroups(void)748 void display_hostgroups(void) {
749 	hostgroup *temp_hostgroup;
750 	hostsmember *temp_hostsmember;
751 	int odd = 0;
752 	const char *bg_class = "";
753 
754 	/* see if user is authorized to view hostgroup information... */
755 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
756 		unauthorized_message();
757 		return;
758 		}
759 
760 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Host Group%s%s</DIV></P>\n",
761 	       (*to_expand == '\0' ? "s" : " "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
762 
763 	printf("<P>\n");
764 	printf("<DIV ALIGN=CENTER>\n");
765 
766 	printf("<TABLE BORDER=0 CLASS='data'>\n");
767 	printf("<TR>\n");
768 	printf("<TH CLASS='data'>Group Name</TH>");
769 	printf("<TH CLASS='data'>Description</TH>");
770 	printf("<TH CLASS='data'>Host Members</TH>");
771 	printf("<TH CLASS='data'>Notes</TH>");
772 	printf("<TH CLASS='data'>Notes URL</TH>");
773 	printf("<TH CLASS='data'>Action URL</TH>");
774 	printf("</TR>\n");
775 
776 	/* check all the hostgroups... */
777 	for(temp_hostgroup = hostgroup_list; temp_hostgroup != NULL; temp_hostgroup = temp_hostgroup->next) if(((*to_expand) == '\0') || (!strcmp(to_expand, temp_hostgroup->group_name))) {
778 
779 			if(odd) {
780 				odd = 0;
781 				bg_class = "dataOdd";
782 				}
783 			else {
784 				odd = 1;
785 				bg_class = "dataEven";
786 				}
787 
788 			printf("<TR CLASS='%s'>\n", bg_class);
789 
790 			printf("<TD CLASS='%s'>%s</TD>", bg_class, html_encode(temp_hostgroup->group_name, FALSE));
791 
792 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_hostgroup->alias, FALSE));
793 
794 			printf("<TD CLASS='%s'>", bg_class);
795 
796 			/* find all the hosts that are members of this hostgroup... */
797 			for(temp_hostsmember = temp_hostgroup->members; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
798 
799 				if(temp_hostsmember != temp_hostgroup->members)
800 					printf(", ");
801 				printf("<A HREF='%s?type=hosts&expand=%s'>%s</A>\n", CONFIG_CGI, url_encode(temp_hostsmember->host_name), html_encode(temp_hostsmember->host_name, FALSE));
802 				}
803 			printf("</TD>\n");
804 
805 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_hostgroup->notes == NULL) ? "&nbsp;" : html_encode(temp_hostgroup->notes, FALSE));
806 
807 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_hostgroup->notes_url == NULL) ? "&nbsp;" : html_encode(temp_hostgroup->notes_url, FALSE));
808 
809 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_hostgroup->action_url == NULL) ? "&nbsp;" : html_encode(temp_hostgroup->action_url, FALSE));
810 
811 			printf("</TR>\n");
812 			}
813 
814 	printf("</TABLE>\n");
815 	printf("</DIV>\n");
816 	printf("</P>\n");
817 
818 	return;
819 	}
820 
821 
822 
display_servicegroups(void)823 void display_servicegroups(void) {
824 	servicegroup *temp_servicegroup;
825 	servicesmember *temp_servicesmember;
826 	int odd = 0;
827 	const char *bg_class = "";
828 
829 	/* see if user is authorized to view servicegroup information... */
830 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
831 		unauthorized_message();
832 		return;
833 		}
834 
835 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Service Group%s%s</DIV></P>\n",
836 	       (*to_expand == '\0' ? "s" : " "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
837 
838 	printf("<P>\n");
839 	printf("<DIV ALIGN=CENTER>\n");
840 
841 	printf("<TABLE BORDER=0 CLASS='data'>\n");
842 	printf("<TR>\n");
843 	printf("<TH CLASS='data'>Group Name</TH>");
844 	printf("<TH CLASS='data'>Description</TH>");
845 	printf("<TH CLASS='data'>Service Members</TH>");
846 	printf("<TH CLASS='data'>Notes</TH>");
847 	printf("<TH CLASS='data'>Notes URL</TH>");
848 	printf("<TH CLASS='data'>Action URL</TH>");
849 	printf("</TR>\n");
850 
851 	/* check all the servicegroups... */
852 	for(temp_servicegroup = servicegroup_list; temp_servicegroup != NULL; temp_servicegroup = temp_servicegroup->next) if(((*to_expand) == '\0') || (!strcmp(to_expand, temp_servicegroup->group_name))) {
853 
854 			if(odd) {
855 				odd = 0;
856 				bg_class = "dataOdd";
857 				}
858 			else {
859 				odd = 1;
860 				bg_class = "dataEven";
861 				}
862 
863 			printf("<TR CLASS='%s'>\n", bg_class);
864 
865 			printf("<TD CLASS='%s'>%s</TD>", bg_class, html_encode(temp_servicegroup->group_name, FALSE));
866 
867 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_servicegroup->alias, FALSE));
868 
869 			printf("<TD CLASS='%s'>", bg_class);
870 
871 			/* find all the services that are members of this servicegroup... */
872 			for(temp_servicesmember = temp_servicegroup->members; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
873 
874 				printf("%s<A HREF='%s?type=hosts&expand=%s'>%s</A> / ", (temp_servicesmember == temp_servicegroup->members) ? "" : ", ", CONFIG_CGI, url_encode(temp_servicesmember->host_name), html_encode(temp_servicesmember->host_name, FALSE));
875 
876 				printf("<A HREF='%s?type=services&expand=%s#%s;", CONFIG_CGI, url_encode(temp_servicesmember->host_name), url_encode(temp_servicesmember->host_name));
877 				printf("%s'>%s</A>\n", url_encode(temp_servicesmember->service_description), html_encode(temp_servicesmember->service_description, FALSE));
878 				}
879 
880 			printf("</TD>\n");
881 
882 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_servicegroup->notes == NULL) ? "&nbsp;" : html_encode(temp_servicegroup->notes, FALSE));
883 
884 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_servicegroup->notes_url == NULL) ? "&nbsp;" : html_encode(temp_servicegroup->notes_url, FALSE));
885 
886 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_servicegroup->action_url == NULL) ? "&nbsp;" : html_encode(temp_servicegroup->action_url, FALSE));
887 
888 			printf("</TR>\n");
889 			}
890 
891 	printf("</TABLE>\n");
892 	printf("</DIV>\n");
893 	printf("</P>\n");
894 
895 	return;
896 	}
897 
898 
899 
display_contacts(void)900 void display_contacts(void) {
901 	contact *temp_contact;
902 	commandsmember *temp_commandsmember;
903 	int odd = 0;
904 	int options;
905 	int found;
906 	const char *bg_class = "";
907 
908 	/* see if user is authorized to view contact information... */
909 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
910 		unauthorized_message();
911 		return;
912 		}
913 
914 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Contact%s%s</DIV></P>\n",
915 	       (*to_expand == '\0' ? "s" : " "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
916 
917 	printf("<P>\n");
918 	printf("<DIV ALIGN=CENTER>\n");
919 
920 	printf("<TABLE CLASS='data'>\n");
921 
922 	printf("<TR>\n");
923 	printf("<TH CLASS='data'>Contact Name</TH>");
924 	printf("<TH CLASS='data'>Alias</TH>");
925 	printf("<TH CLASS='data'>Email Address</TH>");
926 	printf("<TH CLASS='data'>Pager Address/Number</TH>");
927 	printf("<TH CLASS='data'>Minimum Importance</TH>");
928 	printf("<TH CLASS='data'>Service Notification Options</TH>");
929 	printf("<TH CLASS='data'>Host Notification Options</TH>");
930 	printf("<TH CLASS='data'>Service Notification Period</TH>");
931 	printf("<TH CLASS='data'>Host Notification Period</TH>");
932 	printf("<TH CLASS='data'>Service Notification Commands</TH>");
933 	printf("<TH CLASS='data'>Host Notification Commands</TH>");
934 	printf("<TH CLASS='data'>Retention Options</TH>");
935 	printf("</TR>\n");
936 
937 	/* check all contacts... */
938 	for(temp_contact = contact_list; temp_contact != NULL; temp_contact = temp_contact->next) if(((*to_expand) == '\0') || (!strcmp(to_expand, temp_contact->name))) {
939 
940 			if(odd) {
941 				odd = 0;
942 				bg_class = "dataOdd";
943 				}
944 			else {
945 				odd = 1;
946 				bg_class = "dataEven";
947 				}
948 
949 			printf("<TR CLASS='%s'>\n", bg_class);
950 
951 			printf("<TD CLASS='%s'><A NAME='%s'>%s</a></TD>\n", bg_class, url_encode(temp_contact->name), html_encode(temp_contact->name, FALSE));
952 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_contact->alias, FALSE));
953 			printf("<TD CLASS='%s'><A HREF='mailto:%s'>%s</A></TD>\n", bg_class, (temp_contact->email == NULL) ? "&nbsp;" : url_encode(temp_contact->email), (temp_contact->email == NULL) ? "&nbsp;" : html_encode(temp_contact->email, FALSE));
954 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_contact->pager == NULL) ? "&nbsp;" : html_encode(temp_contact->pager, FALSE));
955 			printf("<TD CLASS='%s'>%u</TD>\n", bg_class, temp_contact->minimum_value);
956 
957 			printf("<TD CLASS='%s'>", bg_class);
958 			options = 0;
959 			if(flag_isset(temp_contact->service_notification_options, OPT_UNKNOWN)) {
960 				options = 1;
961 				printf("Unknown");
962 				}
963 			if(flag_isset(temp_contact->service_notification_options, OPT_WARNING)) {
964 				printf("%sWarning", (options) ? ", " : "");
965 				options = 1;
966 				}
967 			if(flag_isset(temp_contact->service_notification_options, OPT_CRITICAL)) {
968 				printf("%sCritical", (options) ? ", " : "");
969 				options = 1;
970 				}
971 			if(flag_isset(temp_contact->service_notification_options, OPT_RECOVERY)) {
972 				printf("%sRecovery", (options) ? ", " : "");
973 				options = 1;
974 				}
975 			if(flag_isset(temp_contact->service_notification_options, OPT_FLAPPING)) {
976 				printf("%sFlapping", (options) ? ", " : "");
977 				options = 1;
978 				}
979 			if(flag_isset(temp_contact->service_notification_options, OPT_DOWNTIME)) {
980 				printf("%sDowntime", (options) ? ", " : "");
981 				options = 1;
982 				}
983 			if(!options)
984 				printf("None");
985 			printf("</TD>\n");
986 
987 			printf("<TD CLASS='%s'>", bg_class);
988 			options = 0;
989 			if(flag_isset(temp_contact->host_notification_options, OPT_DOWN) == TRUE) {
990 				options = 1;
991 				printf("Down");
992 				}
993 			if(flag_isset(temp_contact->host_notification_options, OPT_UNREACHABLE) == TRUE) {
994 				printf("%sUnreachable", (options) ? ", " : "");
995 				options = 1;
996 				}
997 			if(flag_isset(temp_contact->host_notification_options, OPT_RECOVERY) == TRUE) {
998 				printf("%sRecovery", (options) ? ", " : "");
999 				options = 1;
1000 				}
1001 			if(flag_isset(temp_contact->host_notification_options, OPT_FLAPPING) == TRUE) {
1002 				printf("%sFlapping", (options) ? ", " : "");
1003 				options = 1;
1004 				}
1005 			if(flag_isset(temp_contact->host_notification_options, OPT_DOWNTIME) == TRUE) {
1006 				printf("%sDowntime", (options) ? ", " : "");
1007 				options = 1;
1008 				}
1009 			if(!options)
1010 				printf("None");
1011 			printf("</TD>\n");
1012 
1013 			printf("<TD CLASS='%s'>\n", bg_class);
1014 			if(temp_contact->service_notification_period == NULL)
1015 				printf("&nbsp;");
1016 			else
1017 				printf("<A HREF='%s?type=timeperiods&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_contact->service_notification_period), html_encode(temp_contact->service_notification_period, FALSE));
1018 			printf("</TD>\n");
1019 
1020 			printf("<TD CLASS='%s'>\n", bg_class);
1021 			if(temp_contact->host_notification_period == NULL)
1022 				printf("&nbsp;");
1023 			else
1024 				printf("<A HREF='%s?type=timeperiods&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_contact->host_notification_period), html_encode(temp_contact->host_notification_period, FALSE));
1025 			printf("</TD>\n");
1026 
1027 			printf("<TD CLASS='%s'>", bg_class);
1028 			found = FALSE;
1029 			for(temp_commandsmember = temp_contact->service_notification_commands; temp_commandsmember != NULL; temp_commandsmember = temp_commandsmember->next) {
1030 
1031 				if(temp_commandsmember != temp_contact->service_notification_commands)
1032 					printf(", ");
1033 
1034 				/* printf("<A HREF='%s?type=commands&expand=%s'>%s</A>",CONFIG_CGI,url_encode(strtok(temp_commandsmember->command,"!")),html_encode(temp_commandsmember->command,FALSE)); */
1035 				printf("<A HREF='%s?type=command&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_commandsmember->command), html_encode(temp_commandsmember->command, FALSE));
1036 
1037 				found = TRUE;
1038 				}
1039 			if(found == FALSE)
1040 				printf("None");
1041 			printf("</TD>\n");
1042 
1043 			printf("<TD CLASS='%s'>", bg_class);
1044 			found = FALSE;
1045 			for(temp_commandsmember = temp_contact->host_notification_commands; temp_commandsmember != NULL; temp_commandsmember = temp_commandsmember->next) {
1046 
1047 				if(temp_commandsmember != temp_contact->host_notification_commands)
1048 					printf(", ");
1049 
1050 				/* printf("<A HREF='%s?type=commands&expand=%s'>%s</A>",CONFIG_CGI,url_encode(strtok(temp_commandsmember->command,"!")),html_encode(temp_commandsmember->command,FALSE)); */
1051 				printf("<A HREF='%s?type=command&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_commandsmember->command), html_encode(temp_commandsmember->command, FALSE));
1052 
1053 				found = TRUE;
1054 				}
1055 			if(found == FALSE)
1056 				printf("None");
1057 			printf("</TD>\n");
1058 
1059 			printf("<TD CLASS='%s'>", bg_class);
1060 			options = 0;
1061 			if(temp_contact->retain_status_information == TRUE) {
1062 				options = 1;
1063 				printf("Status Information");
1064 				}
1065 			if(temp_contact->retain_nonstatus_information == TRUE) {
1066 				printf("%sNon-Status Information", (options == 1) ? ", " : "");
1067 				options = 1;
1068 				}
1069 			if(options == 0)
1070 				printf("None");
1071 			printf("</TD>\n");
1072 
1073 			printf("</TR>\n");
1074 			}
1075 
1076 	printf("</TABLE>\n");
1077 	printf("</DIV>\n");
1078 	printf("</P>\n");
1079 
1080 	return;
1081 	}
1082 
1083 
1084 
display_contactgroups(void)1085 void display_contactgroups(void) {
1086 	contactgroup *temp_contactgroup;
1087 	contactsmember *temp_contactsmember;
1088 	int odd = 0;
1089 	const char *bg_class = "";
1090 
1091 	/* see if user is authorized to view contactgroup information... */
1092 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
1093 		unauthorized_message();
1094 		return;
1095 		}
1096 
1097 
1098 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Contact Group%s%s</DIV></P>\n",
1099 	       (*to_expand == '\0' ? "s" : " "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
1100 
1101 	printf("<P>\n");
1102 	printf("<DIV ALIGN=CENTER>\n");
1103 
1104 	printf("<TABLE BORDER=0 CELLSPACING=3 CELLPADDING=0>\n");
1105 
1106 	printf("<TR>\n");
1107 	printf("<TH CLASS='data'>Group Name</TH>\n");
1108 	printf("<TH CLASS='data'>Description</TH>\n");
1109 	printf("<TH CLASS='data'>Contact Members</TH>\n");
1110 	printf("</TR>\n");
1111 
1112 	/* check all the contact groups... */
1113 	for(temp_contactgroup = contactgroup_list; temp_contactgroup != NULL; temp_contactgroup = temp_contactgroup->next) if(((*to_expand) == '\0') || (!strcmp(to_expand, temp_contactgroup->group_name))) {
1114 
1115 			if(odd) {
1116 				odd = 0;
1117 				bg_class = "dataOdd";
1118 				}
1119 			else {
1120 				odd = 1;
1121 				bg_class = "dataEven";
1122 				}
1123 
1124 			printf("<TR CLASS='%s'>\n", bg_class);
1125 
1126 			printf("<TD CLASS='%s'><A NAME='%s'></A>%s</TD>\n", bg_class, url_encode(temp_contactgroup->group_name), html_encode(temp_contactgroup->group_name, FALSE));
1127 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_contactgroup->alias, FALSE));
1128 
1129 			/* find all the contact who are members of this contact group... */
1130 			printf("<TD CLASS='%s'>", bg_class);
1131 			for(temp_contactsmember = temp_contactgroup->members; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
1132 
1133 				if(temp_contactsmember != temp_contactgroup->members)
1134 					printf(", ");
1135 
1136 				printf("<A HREF='%s?type=contacts&expand=%s'>%s</A>\n", CONFIG_CGI, url_encode(temp_contactsmember->contact_name), html_encode(temp_contactsmember->contact_name, FALSE));
1137 				}
1138 			printf("</TD>\n");
1139 
1140 			printf("</TR>\n");
1141 			}
1142 
1143 	printf("</TABLE>\n");
1144 	printf("</DIV>\n");
1145 	printf("</P>\n");
1146 
1147 	return;
1148 	}
1149 
1150 
1151 
display_services(void)1152 void display_services(void) {
1153 	service *temp_service = NULL;
1154 	contactsmember *temp_contactsmember = NULL;
1155 	contactgroupsmember *temp_contactgroupsmember = NULL;
1156 	char *processed_string = NULL;
1157 	char command_line[MAX_INPUT_BUFFER];
1158 	char *command_name;
1159 	int options;
1160 	int odd = 0;
1161 	char time_string[16];
1162 	const char *bg_class;
1163 	int num_contacts = 0;
1164 
1165 
1166 	/* see if user is authorized to view service information... */
1167 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
1168 		unauthorized_message();
1169 		return;
1170 		}
1171 
1172 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Service%s%s</DIV></P>\n",
1173 	       (*to_expand == '\0' ? "s" : "s Named or on Host "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
1174 
1175 	printf("<P>\n");
1176 	printf("<DIV ALIGN=CENTER>\n");
1177 
1178 	printf("<TABLE BORDER=0 CLASS='data'>\n");
1179 	printf("<TR>\n");
1180 	printf("<TH CLASS='data' COLSPAN=2>Service</TH>");
1181 	printf("</TR>\n");
1182 	printf("<TR>\n");
1183 	printf("<TH CLASS='data'>Host</TH>\n");
1184 	printf("<TH CLASS='data'>Description</TH>\n");
1185 	printf("<TH CLASS='data'>Importance</TH>\n");
1186 	printf("<TH CLASS='data'>Max. Check Attempts</TH>\n");
1187 	printf("<TH CLASS='data'>Normal Check Interval</TH>\n");
1188 	printf("<TH CLASS='data'>Retry Check Interval</TH>\n");
1189 	printf("<TH CLASS='data'>Check Command</TH>\n");
1190 	printf("<TH CLASS='data'>Check Period</TH>\n");
1191 	printf("<TH CLASS='data'>Parallelize</TH>\n");
1192 	printf("<TH CLASS='data'>Volatile</TH>\n");
1193 	printf("<TH CLASS='data'>Obsess Over</TH>\n");
1194 	printf("<TH CLASS='data'>Enable Active Checks</TH>\n");
1195 	printf("<TH CLASS='data'>Enable Passive Checks</TH>\n");
1196 	printf("<TH CLASS='data'>Check Freshness</TH>\n");
1197 	printf("<TH CLASS='data'>Freshness Threshold</TH>\n");
1198 	printf("<TH CLASS='data'>Default Contacts/Groups</TH>\n");
1199 	printf("<TH CLASS='data'>Enable Notifications</TH>\n");
1200 	printf("<TH CLASS='data'>Notification Interval</TH>\n");
1201 	printf("<TH CLASS='data'>First Notification Delay</TH>\n");
1202 	printf("<TH CLASS='data'>Notification Options</TH>\n");
1203 	printf("<TH CLASS='data'>Notification Period</TH>\n");
1204 	printf("<TH CLASS='data'>Event Handler</TH>");
1205 	printf("<TH CLASS='data'>Enable Event Handler</TH>");
1206 	printf("<TH CLASS='data'>Stalking Options</TH>\n");
1207 	printf("<TH CLASS='data'>Enable Flap Detection</TH>");
1208 	printf("<TH CLASS='data'>Low Flap Threshold</TH>");
1209 	printf("<TH CLASS='data'>High Flap Threshold</TH>");
1210 	printf("<TH CLASS='data'>Flap Detection Options</TH>");
1211 	printf("<TH CLASS='data'>Process Performance Data</TH>");
1212 	printf("<TH CLASS='data'>Notes</TH>");
1213 	printf("<TH CLASS='data'>Notes URL</TH>");
1214 	printf("<TH CLASS='data'>Action URL</TH>");
1215 	printf("<TH CLASS='data'>Logo Image</TH>");
1216 	printf("<TH CLASS='data'>Image Alt</TH>");
1217 	printf("<TH CLASS='data'>Retention Options</TH>");
1218 	printf("</TR>\n");
1219 
1220 	/* check all the services... */
1221 	for(temp_service = service_list; temp_service != NULL; temp_service = temp_service->next)
1222 		if(((*to_expand) == '\0') || (!strcmp(to_expand, temp_service->host_name)) || (!strcmp(to_expand, temp_service->description))) {
1223 
1224 			/* grab macros */
1225 			grab_service_macros_r(mac, temp_service);
1226 
1227 			if(odd) {
1228 				odd = 0;
1229 				bg_class = "dataOdd";
1230 				}
1231 			else {
1232 				odd = 1;
1233 				bg_class = "dataEven";
1234 				}
1235 
1236 			printf("<TR CLASS='%s'>\n", bg_class);
1237 
1238 			printf("<TD CLASS='%s'><A NAME='%s;", bg_class, url_encode(temp_service->host_name));
1239 			printf("%s'></A>", url_encode(temp_service->description));
1240 			printf("<A HREF='%s?type=hosts&expand=%s'>%s</A></TD>\n", CONFIG_CGI, url_encode(temp_service->host_name), html_encode(temp_service->host_name, FALSE));
1241 
1242 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_service->description, FALSE));
1243 			printf("<TD CLASS='%s'>%u</TD>\n", bg_class, temp_service->hourly_value);
1244 
1245 			printf("<TD CLASS='%s'>%d</TD>\n", bg_class, temp_service->max_attempts);
1246 
1247 			get_interval_time_string(temp_service->check_interval, time_string, sizeof(time_string));
1248 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, time_string);
1249 			get_interval_time_string(temp_service->retry_interval, time_string, sizeof(time_string));
1250 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, time_string);
1251 
1252 			strncpy(command_line, temp_service->check_command, sizeof(command_line));
1253 			command_line[sizeof(command_line) - 1] = '\x0';
1254 			command_name = strtok(strdup(command_line), "!");
1255 
1256 			/* printf("<TD CLASS='%s'><A HREF='%s?type=commands&expand=%s'>%s</A></TD>\n",bg_class,CONFIG_CGI,url_encode(command_name),html_encode(command_line,FALSE)); */
1257 			printf("<TD CLASS='%s'><A HREF='%s?type=command&expand=%s'>%s</A></TD>\n", bg_class, CONFIG_CGI, url_encode(command_line), html_encode(command_line, FALSE));
1258 			free(command_name);
1259 			printf("<TD CLASS='%s'>", bg_class);
1260 			if(temp_service->check_period == NULL)
1261 				printf("&nbsp;");
1262 			else
1263 				printf("<A HREF='%s?type=timeperiods&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_service->check_period), html_encode(temp_service->check_period, FALSE));
1264 			printf("</TD>\n");
1265 
1266 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_service->parallelize == TRUE) ? "Yes" : "No");
1267 
1268 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_service->is_volatile == TRUE) ? "Yes" : "No");
1269 
1270 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_service->obsess == TRUE) ? "Yes" : "No");
1271 
1272 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_service->checks_enabled == TRUE) ? "Yes" : "No");
1273 
1274 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_service->accept_passive_checks == TRUE) ? "Yes" : "No");
1275 
1276 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_service->check_freshness == TRUE) ? "Yes" : "No");
1277 
1278 			printf("<TD CLASS='%s'>", bg_class);
1279 			if(temp_service->freshness_threshold == 0)
1280 				printf("Auto-determined value\n");
1281 			else
1282 				printf("%d seconds\n", temp_service->freshness_threshold);
1283 			printf("</TD>\n");
1284 
1285 			printf("<TD CLASS='%s'>", bg_class);
1286 			num_contacts = 0;
1287 			for(temp_contactsmember = temp_service->contacts; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
1288 				num_contacts++;
1289 				if(num_contacts > 1)
1290 					printf(", ");
1291 				printf("<A HREF='%s?type=contacts&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_contactsmember->contact_name), html_encode(temp_contactsmember->contact_name, FALSE));
1292 				}
1293 			for(temp_contactgroupsmember = temp_service->contact_groups; temp_contactgroupsmember != NULL; temp_contactgroupsmember = temp_contactgroupsmember->next) {
1294 				num_contacts++;
1295 				if(num_contacts > 1)
1296 					printf(", ");
1297 				printf("<A HREF='%s?type=contactgroups&expand=%s'>%s</A>\n", CONFIG_CGI, url_encode(temp_contactgroupsmember->group_name), html_encode(temp_contactgroupsmember->group_name, FALSE));
1298 				}
1299 			if(num_contacts == 0)
1300 				printf("&nbsp;");
1301 			printf("</TD>\n");
1302 
1303 			printf("<TD CLASS='%s'>", bg_class);
1304 			printf("%s\n", (temp_service->notifications_enabled == TRUE) ? "Yes" : "No");
1305 			printf("</TD>\n");
1306 
1307 			get_interval_time_string(temp_service->notification_interval, time_string, sizeof(time_string));
1308 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, (temp_service->notification_interval == 0) ? "<i>No Re-notification</i>" : html_encode(time_string, FALSE));
1309 
1310 			get_interval_time_string(temp_service->first_notification_delay, time_string, sizeof(time_string));
1311 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, time_string);
1312 
1313 			printf("<TD CLASS='%s'>", bg_class);
1314 			options = 0;
1315 			if(flag_isset(temp_service->notification_options, OPT_UNKNOWN) == TRUE) {
1316 				options = 1;
1317 				printf("Unknown");
1318 				}
1319 			if(flag_isset(temp_service->notification_options, OPT_WARNING) == TRUE) {
1320 				printf("%sWarning", (options) ? ", " : "");
1321 				options = 1;
1322 				}
1323 			if(flag_isset(temp_service->notification_options, OPT_CRITICAL) == TRUE) {
1324 				printf("%sCritical", (options) ? ", " : "");
1325 				options = 1;
1326 				}
1327 			if(flag_isset(temp_service->notification_options, OPT_RECOVERY) == TRUE) {
1328 				printf("%sRecovery", (options) ? ", " : "");
1329 				options = 1;
1330 				}
1331 			if(flag_isset(temp_service->notification_options, OPT_FLAPPING) == TRUE) {
1332 				printf("%sFlapping", (options) ? ", " : "");
1333 				options = 1;
1334 				}
1335 			if(flag_isset(temp_service->notification_options, OPT_DOWNTIME) == TRUE) {
1336 				printf("%sDowntime", (options) ? ", " : "");
1337 				options = 1;
1338 				}
1339 			if(!options)
1340 				printf("None");
1341 			printf("</TD>\n");
1342 			printf("<TD CLASS='%s'>", bg_class);
1343 			if(temp_service->notification_period == NULL)
1344 				printf("&nbsp;");
1345 			else
1346 				printf("<A HREF='%s?type=timeperiods&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_service->notification_period), html_encode(temp_service->notification_period, FALSE));
1347 			printf("</TD>\n");
1348 			printf("<TD CLASS='%s'>", bg_class);
1349 			if(temp_service->event_handler == NULL)
1350 				printf("&nbsp;");
1351 			else
1352 				/* printf("<A HREF='%s?type=commands&expand=%s'>%s</A>",CONFIG_CGI,url_encode(strtok(temp_service->event_handler,"!")),html_encode(temp_service->event_handler,FALSE)); */
1353 				printf("<A HREF='%s?type=command&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_service->event_handler), html_encode(temp_service->event_handler, FALSE));
1354 			printf("</TD>\n");
1355 
1356 			printf("<TD CLASS='%s'>", bg_class);
1357 			printf("%s\n", (temp_service->event_handler_enabled == TRUE) ? "Yes" : "No");
1358 			printf("</TD>\n");
1359 
1360 			printf("<TD CLASS='%s'>", bg_class);
1361 			options = 0;
1362 			if(flag_isset(temp_service->stalking_options, OPT_OK) == TRUE) {
1363 				options = 1;
1364 				printf("Ok");
1365 				}
1366 			if(flag_isset(temp_service->stalking_options, OPT_WARNING) == TRUE) {
1367 				printf("%sWarning", (options) ? ", " : "");
1368 				options = 1;
1369 				}
1370 			if(flag_isset(temp_service->stalking_options, OPT_UNKNOWN) == TRUE) {
1371 				printf("%sUnknown", (options) ? ", " : "");
1372 				options = 1;
1373 				}
1374 			if(flag_isset(temp_service->stalking_options, OPT_CRITICAL) == TRUE) {
1375 				printf("%sCritical", (options) ? ", " : "");
1376 				options = 1;
1377 				}
1378 			if(options == 0)
1379 				printf("None");
1380 			printf("</TD>\n");
1381 
1382 			printf("<TD CLASS='%s'>", bg_class);
1383 			printf("%s\n", (temp_service->flap_detection_enabled == TRUE) ? "Yes" : "No");
1384 			printf("</TD>\n");
1385 
1386 			printf("<TD CLASS='%s'>", bg_class);
1387 			if(temp_service->low_flap_threshold == 0.0)
1388 				printf("Program-wide value\n");
1389 			else
1390 				printf("%3.1f%%\n", temp_service->low_flap_threshold);
1391 			printf("</TD>\n");
1392 
1393 			printf("<TD CLASS='%s'>", bg_class);
1394 			if(temp_service->high_flap_threshold == 0.0)
1395 				printf("Program-wide value\n");
1396 			else
1397 				printf("%3.1f%%\n", temp_service->high_flap_threshold);
1398 			printf("</TD>\n");
1399 
1400 			printf("<TD CLASS='%s'>", bg_class);
1401 			options = 0;
1402 			if(flag_isset(temp_service->flap_detection_options, OPT_OK) == TRUE) {
1403 				options = 1;
1404 				printf("Ok");
1405 				}
1406 			if(flag_isset(temp_service->flap_detection_options, OPT_WARNING) == TRUE) {
1407 				printf("%sWarning", (options) ? ", " : "");
1408 				options = 1;
1409 				}
1410 			if(flag_isset(temp_service->flap_detection_options, OPT_UNKNOWN) == TRUE) {
1411 				printf("%sUnknown", (options) ? ", " : "");
1412 				options = 1;
1413 				}
1414 			if(flag_isset(temp_service->flap_detection_options, OPT_CRITICAL) == TRUE) {
1415 				printf("%sCritical", (options) ? ", " : "");
1416 				options = 1;
1417 				}
1418 			if(options == 0)
1419 				printf("None");
1420 			printf("</TD>\n");
1421 
1422 			printf("<TD CLASS='%s'>", bg_class);
1423 			printf("%s\n", (temp_service->process_performance_data == TRUE) ? "Yes" : "No");
1424 			printf("</TD>\n");
1425 
1426 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_service->notes == NULL) ? "&nbsp;" : html_encode(temp_service->notes, FALSE));
1427 
1428 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_service->notes_url == NULL) ? "&nbsp;" : html_encode(temp_service->notes_url, FALSE));
1429 
1430 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_service->action_url == NULL) ? "&nbsp;" : html_encode(temp_service->action_url, FALSE));
1431 
1432 			if(temp_service->icon_image == NULL)
1433 				printf("<TD CLASS='%s'>&nbsp;</TD>", bg_class);
1434 			else {
1435 				process_macros_r(mac, temp_service->icon_image, &processed_string, 0);
1436 				printf("<TD CLASS='%s' valign='center'><img src='%s%s' border='0' width='20' height='20'> %s</TD>", bg_class, url_logo_images_path, processed_string, html_encode(temp_service->icon_image, FALSE));
1437 				free(processed_string);
1438 				}
1439 
1440 			printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_service->icon_image_alt == NULL) ? "&nbsp;" : html_encode(temp_service->icon_image_alt, FALSE));
1441 
1442 			printf("<TD CLASS='%s'>", bg_class);
1443 			options = 0;
1444 			if(temp_service->retain_status_information == TRUE) {
1445 				options = 1;
1446 				printf("Status Information");
1447 				}
1448 			if(temp_service->retain_nonstatus_information == TRUE) {
1449 				printf("%sNon-Status Information", (options == 1) ? ", " : "");
1450 				options = 1;
1451 				}
1452 			if(options == 0)
1453 				printf("None");
1454 			printf("</TD>\n");
1455 
1456 			printf("</TR>\n");
1457 			}
1458 
1459 	printf("</TABLE>\n");
1460 	printf("</DIV>\n");
1461 	printf("</P>\n");
1462 
1463 	return;
1464 	}
1465 
1466 
1467 
display_timeperiods(void)1468 void display_timeperiods(void) {
1469 	timerange *temp_timerange = NULL;
1470 	daterange *temp_daterange = NULL;
1471 	timeperiod *temp_timeperiod = NULL;
1472 	timeperiodexclusion *temp_timeperiodexclusion = NULL;
1473 	const char *months[12] = {"january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"};
1474 	const char *days[7] = {"sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"};
1475 	int odd = 0;
1476 	int day = 0;
1477 	int x = 0;
1478 	const char *bg_class = "";
1479 	char timestring[10];
1480 	int hours = 0;
1481 	int minutes = 0;
1482 	int seconds = 0;
1483 	int line = 0;
1484 	int item = 0;
1485 
1486 	/* see if user is authorized to view time period information... */
1487 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
1488 		unauthorized_message();
1489 		return;
1490 		}
1491 
1492 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Time Period%s%s</DIV></P>\n",
1493 	       (*to_expand == '\0' ? "s" : " "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
1494 
1495 	printf("<P>\n");
1496 	printf("<DIV ALIGN=CENTER>\n");
1497 
1498 	printf("<TABLE BORDER=0 CLASS='data'>\n");
1499 	printf("<TR>\n");
1500 	printf("<TH CLASS='data'>Name</TH>\n");
1501 	printf("<TH CLASS='data'>Alias/Description</TH>\n");
1502 	printf("<TH CLASS='data'>Exclusions</TH>\n");
1503 	printf("<TH CLASS='data'>Days/Dates</TH>\n");
1504 	printf("<TH CLASS='data'>Times</TH>\n");
1505 	printf("</TR>\n");
1506 
1507 	/* check all the time periods... */
1508 	for(temp_timeperiod = timeperiod_list; temp_timeperiod != NULL; temp_timeperiod = temp_timeperiod->next) if(((*to_expand) == '\0') || (!strcmp(to_expand, temp_timeperiod->name))) {
1509 
1510 			if(odd) {
1511 				odd = 0;
1512 				bg_class = "dataOdd";
1513 				}
1514 			else {
1515 				odd = 1;
1516 				bg_class = "dataEven";
1517 				}
1518 
1519 			printf("<TR CLASS='%s'>\n", bg_class);
1520 
1521 			printf("<TD CLASS='%s'><A NAME='%s'>%s</A></TD>\n", bg_class, url_encode(temp_timeperiod->name), html_encode(temp_timeperiod->name, FALSE));
1522 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_timeperiod->alias, FALSE));
1523 
1524 			printf("<TD CLASS='%s'>", bg_class);
1525 			item = 0;
1526 			for(temp_timeperiodexclusion = temp_timeperiod->exclusions; temp_timeperiodexclusion != NULL; temp_timeperiodexclusion = temp_timeperiodexclusion->next) {
1527 				item++;
1528 				printf("%s<A HREF='#%s'>%s</A>", (item == 1) ? "" : ",&nbsp;", url_encode(temp_timeperiodexclusion->timeperiod_name), html_encode(temp_timeperiodexclusion->timeperiod_name, FALSE));
1529 				}
1530 			printf("</TD>");
1531 
1532 			printf("<TD CLASS='%s'>", bg_class);
1533 
1534 			line = 0;
1535 			for(x = 0; x < DATERANGE_TYPES; x++) {
1536 				for(temp_daterange = temp_timeperiod->exceptions[x]; temp_daterange != NULL; temp_daterange = temp_daterange->next) {
1537 
1538 					line++;
1539 
1540 					if(line > 1)
1541 						printf("<TR><TD COLSPAN='3'></TD><TD CLASS='%s'>\n", bg_class);
1542 
1543 					switch(temp_daterange->type) {
1544 						case DATERANGE_CALENDAR_DATE:
1545 							printf("%d-%02d-%02d", temp_daterange->syear, temp_daterange->smon + 1, temp_daterange->smday);
1546 							if((temp_daterange->smday != temp_daterange->emday) || (temp_daterange->smon != temp_daterange->emon) || (temp_daterange->syear != temp_daterange->eyear))
1547 								printf(" - %d-%02d-%02d", temp_daterange->eyear, temp_daterange->emon + 1, temp_daterange->emday);
1548 							if(temp_daterange->skip_interval > 1)
1549 								printf(" / %d", temp_daterange->skip_interval);
1550 							break;
1551 						case DATERANGE_MONTH_DATE:
1552 							printf("%s %d", months[temp_daterange->smon], temp_daterange->smday);
1553 							if((temp_daterange->smon != temp_daterange->emon) || (temp_daterange->smday != temp_daterange->emday)) {
1554 								printf(" - %s %d", months[temp_daterange->emon], temp_daterange->emday);
1555 								if(temp_daterange->skip_interval > 1)
1556 									printf(" / %d", temp_daterange->skip_interval);
1557 								}
1558 							break;
1559 						case DATERANGE_MONTH_DAY:
1560 							printf("day %d", temp_daterange->smday);
1561 							if(temp_daterange->smday != temp_daterange->emday) {
1562 								printf(" - %d", temp_daterange->emday);
1563 								if(temp_daterange->skip_interval > 1)
1564 									printf(" / %d", temp_daterange->skip_interval);
1565 								}
1566 							break;
1567 						case DATERANGE_MONTH_WEEK_DAY:
1568 							printf("%s %d %s", days[temp_daterange->swday], temp_daterange->swday_offset, months[temp_daterange->smon]);
1569 							if((temp_daterange->smon != temp_daterange->emon) || (temp_daterange->swday != temp_daterange->ewday) || (temp_daterange->swday_offset != temp_daterange->ewday_offset)) {
1570 								printf(" - %s %d %s", days[temp_daterange->ewday], temp_daterange->ewday_offset, months[temp_daterange->emon]);
1571 								if(temp_daterange->skip_interval > 1)
1572 									printf(" / %d", temp_daterange->skip_interval);
1573 								}
1574 							break;
1575 						case DATERANGE_WEEK_DAY:
1576 							printf("%s %d", days[temp_daterange->swday], temp_daterange->swday_offset);
1577 							if((temp_daterange->swday != temp_daterange->ewday) || (temp_daterange->swday_offset != temp_daterange->ewday_offset)) {
1578 								printf(" - %s %d", days[temp_daterange->ewday], temp_daterange->ewday_offset);
1579 								if(temp_daterange->skip_interval > 1)
1580 									printf(" / %d", temp_daterange->skip_interval);
1581 								}
1582 							break;
1583 						default:
1584 							break;
1585 						}
1586 
1587 					printf("</TD><TD CLASS='%s'>\n", bg_class);
1588 
1589 					for(temp_timerange = temp_daterange->times; temp_timerange != NULL; temp_timerange = temp_timerange->next) {
1590 
1591 						if(temp_timerange != temp_daterange->times)
1592 							printf(", ");
1593 
1594 						hours = temp_timerange->range_start / 3600;
1595 						minutes = (temp_timerange->range_start - (hours * 3600)) / 60;
1596 						seconds = temp_timerange->range_start - (hours * 3600) - (minutes * 60);
1597 						snprintf(timestring, sizeof(timestring) - 1, "%02d:%02d:%02d", hours, minutes, seconds);
1598 						timestring[sizeof(timestring) - 1] = '\x0';
1599 						printf("%s - ", timestring);
1600 
1601 						hours = temp_timerange->range_end / 3600;
1602 						minutes = (temp_timerange->range_end - (hours * 3600)) / 60;
1603 						seconds = temp_timerange->range_end - (hours * 3600) - (minutes * 60);
1604 						snprintf(timestring, sizeof(timestring) - 1, "%02d:%02d:%02d", hours, minutes, seconds);
1605 						timestring[sizeof(timestring) - 1] = '\x0';
1606 						printf("%s", timestring);
1607 						}
1608 
1609 					printf("</TD>\n");
1610 					printf("</TR>\n");
1611 					}
1612 				}
1613 			for(day = 0; day < 7; day++) {
1614 
1615 				if(temp_timeperiod->days[day] == NULL)
1616 					continue;
1617 
1618 				line++;
1619 
1620 				if(line > 1)
1621 					printf("<TR><TD COLSPAN='3'></TD><TD CLASS='%s'>\n", bg_class);
1622 
1623 				printf("%s", days[day]);
1624 
1625 				printf("</TD><TD CLASS='%s'>\n", bg_class);
1626 
1627 				for(temp_timerange = temp_timeperiod->days[day]; temp_timerange != NULL; temp_timerange = temp_timerange->next) {
1628 
1629 					if(temp_timerange != temp_timeperiod->days[day])
1630 						printf(", ");
1631 
1632 					hours = temp_timerange->range_start / 3600;
1633 					minutes = (temp_timerange->range_start - (hours * 3600)) / 60;
1634 					seconds = temp_timerange->range_start - (hours * 3600) - (minutes * 60);
1635 					snprintf(timestring, sizeof(timestring) - 1, "%02d:%02d:%02d", hours, minutes, seconds);
1636 					timestring[sizeof(timestring) - 1] = '\x0';
1637 					printf("%s - ", timestring);
1638 
1639 					hours = temp_timerange->range_end / 3600;
1640 					minutes = (temp_timerange->range_end - (hours * 3600)) / 60;
1641 					seconds = temp_timerange->range_end - (hours * 3600) - (minutes * 60);
1642 					snprintf(timestring, sizeof(timestring) - 1, "%02d:%02d:%02d", hours, minutes, seconds);
1643 					timestring[sizeof(timestring) - 1] = '\x0';
1644 					printf("%s", timestring);
1645 					}
1646 
1647 				printf("&nbsp;</TD>\n");
1648 				printf("</TR>\n");
1649 				}
1650 
1651 			if(line == 0) {
1652 				printf("</TD>\n");
1653 				printf("</TR>\n");
1654 				}
1655 			}
1656 
1657 	printf("</TABLE>\n");
1658 	printf("</DIV>\n");
1659 	printf("</P>\n");
1660 
1661 	return;
1662 	}
1663 
1664 
1665 
display_commands(void)1666 void display_commands(void) {
1667 	command *temp_command;
1668 	int odd = 0;
1669 	const char *bg_class = "";
1670 
1671 	/* see if user is authorized to view command information... */
1672 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
1673 		unauthorized_message();
1674 		return;
1675 		}
1676 
1677 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Command%s%s</DIV></P>\n",
1678 	       (*to_expand == '\0' ? "s" : " "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
1679 
1680 	printf("<P><DIV ALIGN=CENTER>\n");
1681 	printf("<TABLE BORDER=0 CLASS='data'>\n");
1682 	printf("<TR><TH CLASS='data'>Command Name</TH><TH CLASS='data'>Command Line</TH></TR>\n");
1683 
1684 	/* check all commands */
1685 	for(temp_command = command_list; temp_command != NULL; temp_command = temp_command->next) if(((*to_expand) == '\0') || (!strcmp(to_expand, temp_command->name))) {
1686 
1687 			if(odd) {
1688 				odd = 0;
1689 				bg_class = "dataEven";
1690 				}
1691 			else {
1692 				odd = 1;
1693 				bg_class = "dataOdd";
1694 				}
1695 
1696 			printf("<TR CLASS='%s'>\n", bg_class);
1697 
1698 			printf("<TD CLASS='%s'><A NAME='%s'></A>%s</TD>\n", bg_class, url_encode(temp_command->name), html_encode(temp_command->name, FALSE));
1699 			printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_command->command_line, FALSE));
1700 
1701 			printf("</TR>\n");
1702 			}
1703 
1704 	printf("</TABLE>\n");
1705 	printf("</DIV></P>\n");
1706 
1707 	return;
1708 	}
1709 
1710 
display_servicedependency(servicedependency * temp_sd)1711 static void display_servicedependency(servicedependency *temp_sd)
1712 {
1713 	const char *bg_class;
1714 	static int odd = 0;
1715 	int options;
1716 
1717 	if(*to_expand != '\0' && (strcmp(to_expand, temp_sd->dependent_host_name) || strcmp(to_expand, temp_sd->host_name)))
1718 		return;
1719 
1720 	if(odd)
1721 		bg_class = "dataOdd";
1722 	else
1723 		bg_class = "dataEven";
1724 	odd ^= 1; /* xor with 1 always flips the switch */
1725 
1726 	printf("<TR CLASS='%s'>\n", bg_class);
1727 
1728 	printf("<TD CLASS='%s'><A HREF='%s?type=hosts&expand=%s'>%s</A></TD>", bg_class, CONFIG_CGI, url_encode(temp_sd->dependent_host_name), html_encode(temp_sd->dependent_host_name, FALSE));
1729 
1730 	printf("<TD CLASS='%s'><A HREF='%s?type=services&expand=%s#%s;", bg_class, CONFIG_CGI, url_encode(temp_sd->dependent_host_name), url_encode(temp_sd->dependent_host_name));
1731 	printf("%s'>%s</A></TD>\n", url_encode(temp_sd->dependent_service_description), html_encode(temp_sd->dependent_service_description, FALSE));
1732 
1733 	printf("<TD CLASS='%s'><A HREF='%s?type=hosts&expand=%s'>%s</A></TD>", bg_class, CONFIG_CGI, url_encode(temp_sd->host_name), html_encode(temp_sd->host_name, FALSE));
1734 
1735 	printf("<TD CLASS='%s'><A HREF='%s?type=services&expand=%s#%s;", bg_class, CONFIG_CGI, url_encode(temp_sd->host_name), url_encode(temp_sd->host_name));
1736 	printf("%s'>%s</A></TD>\n", url_encode(temp_sd->service_description), html_encode(temp_sd->service_description, FALSE));
1737 
1738 	printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_sd->dependency_type == NOTIFICATION_DEPENDENCY) ? "Notification" : "Check Execution");
1739 
1740 	printf("<TD CLASS='%s'>", bg_class);
1741 	if(temp_sd->dependency_period == NULL)
1742 		printf("&nbsp;");
1743 	else
1744 		printf("<A HREF='%s?type=timeperiods&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_sd->dependency_period), html_encode(temp_sd->dependency_period, FALSE));
1745 	printf("</TD>\n");
1746 
1747 	printf("<TD CLASS='%s'>", bg_class);
1748 	options = FALSE;
1749 	if(flag_isset(temp_sd->failure_options, OPT_OK) == TRUE) {
1750 		printf("Ok");
1751 		options = TRUE;
1752 		}
1753 	if(flag_isset(temp_sd->failure_options, OPT_WARNING) == TRUE) {
1754 		printf("%sWarning", (options == TRUE) ? ", " : "");
1755 		options = TRUE;
1756 		}
1757 	if(flag_isset(temp_sd->failure_options, OPT_UNKNOWN) == TRUE) {
1758 		printf("%sUnknown", (options == TRUE) ? ", " : "");
1759 		options = TRUE;
1760 		}
1761 	if(flag_isset(temp_sd->failure_options, OPT_CRITICAL) == TRUE) {
1762 		printf("%sCritical", (options == TRUE) ? ", " : "");
1763 		options = TRUE;
1764 		}
1765 	if(flag_isset(temp_sd->failure_options, OPT_PENDING) == TRUE) {
1766 		printf("%sPending", (options == TRUE) ? ", " : "");
1767 		options = TRUE;
1768 		}
1769 	printf("</TD>\n");
1770 	printf("</TR>\n");
1771 	}
1772 
display_servicedependencies(void)1773 void display_servicedependencies(void) {
1774 	unsigned int i;
1775 
1776 	/* see if user is authorized to view hostgroup information... */
1777 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
1778 		unauthorized_message();
1779 		return;
1780 		}
1781 
1782 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Service Dependencie%s%s</DIV></P>\n",
1783 	       (*to_expand == '\0' ? "s" : "s Involving Host "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
1784 
1785 	printf("<P>\n");
1786 	printf("<DIV ALIGN=CENTER>\n");
1787 
1788 	printf("<TABLE BORDER=0 CLASS='data'>\n");
1789 	printf("<TR>\n");
1790 	printf("<TH CLASS='data' COLSPAN=2>Dependent Service</TH>");
1791 	printf("<TH CLASS='data' COLSPAN=2>Master Service</TH>");
1792 	printf("</TR>\n");
1793 	printf("<TR>\n");
1794 	printf("<TH CLASS='data'>Host</TH>");
1795 	printf("<TH CLASS='data'>Service</TH>");
1796 	printf("<TH CLASS='data'>Host</TH>");
1797 	printf("<TH CLASS='data'>Service</TH>");
1798 	printf("<TH CLASS='data'>Dependency Type</TH>");
1799 	printf("<TH CLASS='data'>Dependency Period</TH>");
1800 	printf("<TH CLASS='data'>Dependency Failure Options</TH>");
1801 	printf("</TR>\n");
1802 
1803 	for(i = 0; i < num_objects.servicedependencies; i++) {
1804 		display_servicedependency(servicedependency_ary[i]);
1805 		}
1806 
1807 	printf("</TABLE>\n");
1808 	printf("</DIV>\n");
1809 	printf("</P>\n");
1810 
1811 	return;
1812 	}
1813 
1814 
1815 
display_serviceescalations(void)1816 void display_serviceescalations(void) {
1817 	serviceescalation *temp_se = NULL;
1818 	contactsmember *temp_contactsmember = NULL;
1819 	contactgroupsmember *temp_contactgroupsmember = NULL;
1820 	char time_string[16] = "";
1821 	int options = FALSE;
1822 	int odd = 0;
1823 	const char *bg_class = "";
1824 	int num_contacts = 0;
1825 	unsigned int i;
1826 
1827 	/* see if user is authorized to view hostgroup information... */
1828 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
1829 		unauthorized_message();
1830 		return;
1831 		}
1832 
1833 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Service Escalation%s%s</DIV></P>\n",
1834 	       (*to_expand == '\0' ? "s" : "s on Host "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
1835 
1836 	printf("<P>\n");
1837 	printf("<DIV ALIGN=CENTER>\n");
1838 
1839 	printf("<TABLE BORDER=0 CLASS='data'>\n");
1840 	printf("<TR>\n");
1841 	printf("<TH CLASS='data' COLSPAN=2>Service</TH>");
1842 	printf("</TR>\n");
1843 	printf("<TR>\n");
1844 	printf("<TH CLASS='data'>Host</TH>");
1845 	printf("<TH CLASS='data'>Description</TH>");
1846 	printf("<TH CLASS='data'>Contacts/Groups</TH>");
1847 	printf("<TH CLASS='data'>First Notification</TH>");
1848 	printf("<TH CLASS='data'>Last Notification</TH>");
1849 	printf("<TH CLASS='data'>Notification Interval</TH>");
1850 	printf("<TH CLASS='data'>Escalation Period</TH>");
1851 	printf("<TH CLASS='data'>Escalation Options</TH>");
1852 	printf("</TR>\n");
1853 
1854 
1855 	for(i = 0; i < num_objects.serviceescalations; i++) {
1856 		temp_se = serviceescalation_ary[i];
1857 		if(*to_expand != '\0' && strcmp(to_expand, temp_se->host_name))
1858 			continue;
1859 
1860 		if(odd) {
1861 			odd = 0;
1862 			bg_class = "dataOdd";
1863 			}
1864 		else {
1865 			odd = 1;
1866 			bg_class = "dataEven";
1867 			}
1868 
1869 		printf("<TR CLASS='%s'>\n", bg_class);
1870 
1871 		printf("<TD CLASS='%s'><A HREF='%s?type=hosts&expand=%s'>%s</A></TD>", bg_class, CONFIG_CGI, url_encode(temp_se->host_name), html_encode(temp_se->host_name, FALSE));
1872 
1873 		printf("<TD CLASS='%s'><A HREF='%s?type=services&expand=%s#%s;", bg_class, CONFIG_CGI, url_encode(temp_se->host_name), url_encode(temp_se->host_name));
1874 		printf("%s'>%s</A></TD>\n", url_encode(temp_se->description), html_encode(temp_se->description, FALSE));
1875 
1876 		printf("<TD CLASS='%s'>", bg_class);
1877 		num_contacts = 0;
1878 		for(temp_contactsmember = temp_se->contacts; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
1879 			num_contacts++;
1880 			if(num_contacts > 1)
1881 				printf(", ");
1882 			printf("<A HREF='%s?type=contacts&expand=%s'>%s</A>\n", CONFIG_CGI, url_encode(temp_contactsmember->contact_name), html_encode(temp_contactsmember->contact_name, FALSE));
1883 			}
1884 		for(temp_contactgroupsmember = temp_se->contact_groups; temp_contactgroupsmember != NULL; temp_contactgroupsmember = temp_contactgroupsmember->next) {
1885 			num_contacts++;
1886 			if(num_contacts > 1)
1887 				printf(", ");
1888 			printf("<A HREF='%s?type=contactgroups&expand=%s'>%s</A>\n", CONFIG_CGI, url_encode(temp_contactgroupsmember->group_name), html_encode(temp_contactgroupsmember->group_name, FALSE));
1889 			}
1890 		if(num_contacts == 0)
1891 			printf("&nbsp;");
1892 		printf("</TD>\n");
1893 
1894 		printf("<TD CLASS='%s'>%d</TD>", bg_class, temp_se->first_notification);
1895 
1896 		printf("<TD CLASS='%s'>", bg_class);
1897 		if(temp_se->last_notification == 0)
1898 			printf("Infinity");
1899 		else
1900 			printf("%d", temp_se->last_notification);
1901 		printf("</TD>\n");
1902 
1903 		get_interval_time_string(temp_se->notification_interval, time_string, sizeof(time_string));
1904 		printf("<TD CLASS='%s'>", bg_class);
1905 		if(temp_se->notification_interval == 0.0)
1906 			printf("Notify Only Once (No Re-notification)");
1907 		else
1908 			printf("%s", time_string);
1909 		printf("</TD>\n");
1910 
1911 		printf("<TD CLASS='%s'>", bg_class);
1912 		if(temp_se->escalation_period == NULL)
1913 			printf("&nbsp;");
1914 		else
1915 			printf("<A HREF='%s?type=timeperiods&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_se->escalation_period), html_encode(temp_se->escalation_period, FALSE));
1916 		printf("</TD>\n");
1917 
1918 		printf("<TD CLASS='%s'>", bg_class);
1919 		options = FALSE;
1920 		if(flag_isset(temp_se->escalation_options, OPT_WARNING) == TRUE) {
1921 			printf("%sWarning", (options == TRUE) ? ", " : "");
1922 			options = TRUE;
1923 			}
1924 		if(flag_isset(temp_se->escalation_options, OPT_UNKNOWN) == TRUE) {
1925 			printf("%sUnknown", (options == TRUE) ? ", " : "");
1926 			options = TRUE;
1927 			}
1928 		if(flag_isset(temp_se->escalation_options, OPT_CRITICAL) == TRUE) {
1929 			printf("%sCritical", (options == TRUE) ? ", " : "");
1930 			options = TRUE;
1931 			}
1932 		if(flag_isset(temp_se->escalation_options, OPT_RECOVERY) == TRUE) {
1933 			printf("%sRecovery", (options == TRUE) ? ", " : "");
1934 			options = TRUE;
1935 			}
1936 		if(options == FALSE)
1937 			printf("None");
1938 		printf("</TD>\n");
1939 
1940 		printf("</TR>\n");
1941 		}
1942 
1943 	printf("</TABLE>\n");
1944 	printf("</DIV>\n");
1945 	printf("</P>\n");
1946 
1947 	return;
1948 	}
1949 
display_hostdependency(hostdependency * temp_hd)1950 static void display_hostdependency(hostdependency *temp_hd)
1951 {
1952 	int options;
1953 	const char *bg_class = "";
1954 	static int odd = 0;
1955 
1956 	if(*to_expand != '\0' && (strcmp(to_expand, temp_hd->dependent_host_name) && !strcmp(to_expand, temp_hd->host_name)))
1957 		return;
1958 
1959 	if(odd)
1960 		bg_class = "dataOdd";
1961 	else
1962 		bg_class = "dataEven";
1963 	odd ^= 1;
1964 
1965 	printf("<TR CLASS='%s'>\n", bg_class);
1966 
1967 	printf("<TD CLASS='%s'><A HREF='%s?type=hosts&expand=%s'>%s</A></TD>", bg_class, CONFIG_CGI, url_encode(temp_hd->dependent_host_name), html_encode(temp_hd->dependent_host_name, FALSE));
1968 
1969 	printf("<TD CLASS='%s'><A HREF='%s?type=hosts&expand=%s'>%s</A></TD>", bg_class, CONFIG_CGI, url_encode(temp_hd->host_name), html_encode(temp_hd->host_name, FALSE));
1970 
1971 	printf("<TD CLASS='%s'>%s</TD>", bg_class, (temp_hd->dependency_type == NOTIFICATION_DEPENDENCY) ? "Notification" : "Check Execution");
1972 
1973 	printf("<TD CLASS='%s'>", bg_class);
1974 	if(temp_hd->dependency_period == NULL)
1975 		printf("&nbsp;");
1976 	else
1977 		printf("<A HREF='%s?type=timeperiods&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_hd->dependency_period), html_encode(temp_hd->dependency_period, FALSE));
1978 	printf("</TD>\n");
1979 
1980 	printf("<TD CLASS='%s'>", bg_class);
1981 	options = FALSE;
1982 	if(flag_isset(temp_hd->failure_options, OPT_UP) == TRUE) {
1983 		printf("Up");
1984 		options = TRUE;
1985 		}
1986 	if(flag_isset(temp_hd->failure_options, OPT_DOWN) == TRUE) {
1987 		printf("%sDown", (options == TRUE) ? ", " : "");
1988 		options = TRUE;
1989 		}
1990 	if(flag_isset(temp_hd->failure_options, OPT_UNREACHABLE) == TRUE) {
1991 		printf("%sUnreachable", (options == TRUE) ? ", " : "");
1992 		options = TRUE;
1993 		}
1994 	if(flag_isset(temp_hd->failure_options, OPT_PENDING) == TRUE) {
1995 		printf("%sPending", (options == TRUE) ? ", " : "");
1996 		options = TRUE;
1997 		}
1998 	printf("</TD>\n");
1999 
2000 	printf("</TR>\n");
2001 	}
2002 
display_hostdependencies(void)2003 void display_hostdependencies(void) {
2004 	unsigned int i;
2005 
2006 	/* see if user is authorized to view hostdependency information... */
2007 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
2008 		unauthorized_message();
2009 		return;
2010 		}
2011 
2012 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Host Dependencie%s%s</DIV></P>\n",
2013 	       (*to_expand == '\0' ? "s" : "s Involving Host "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
2014 
2015 	printf("<P>\n");
2016 	printf("<DIV ALIGN=CENTER>\n");
2017 
2018 	printf("<TABLE BORDER=0 CLASS='data'>\n");
2019 	printf("<TR>\n");
2020 	printf("<TH CLASS='data'>Dependent Host</TH>");
2021 	printf("<TH CLASS='data'>Master Host</TH>");
2022 	printf("<TH CLASS='data'>Dependency Type</TH>");
2023 	printf("<TH CLASS='data'>Dependency Period</TH>");
2024 	printf("<TH CLASS='data'>Dependency Failure Options</TH>");
2025 	printf("</TR>\n");
2026 
2027 	/* print all host dependencies... */
2028 	for(i = 0; i < num_objects.hostdependencies; i++)
2029 		display_hostdependency(hostdependency_ary[i]);
2030 
2031 	printf("</TABLE>\n");
2032 	printf("</DIV>\n");
2033 	printf("</P>\n");
2034 
2035 	return;
2036 	}
2037 
2038 
2039 
display_hostescalations(void)2040 void display_hostescalations(void) {
2041 	hostescalation *temp_he = NULL;
2042 	contactsmember *temp_contactsmember = NULL;
2043 	contactgroupsmember *temp_contactgroupsmember = NULL;
2044 	char time_string[16] = "";
2045 	int options = FALSE;
2046 	int odd = 0;
2047 	const char *bg_class = "";
2048 	int num_contacts = 0;
2049 	unsigned int i;
2050 
2051 	/* see if user is authorized to view hostgroup information... */
2052 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
2053 		unauthorized_message();
2054 		return;
2055 		}
2056 
2057 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Host Escalation%s%s</DIV></P>\n",
2058 	       (*to_expand == '\0' ? "s" : "s for Host "), (*to_expand == '\0' ? "" : html_encode(to_expand, FALSE)));
2059 
2060 	printf("<P>\n");
2061 	printf("<DIV ALIGN=CENTER>\n");
2062 
2063 	printf("<TABLE BORDER=0 CLASS='data'>\n");
2064 	printf("<TR>\n");
2065 	printf("<TH CLASS='data'>Host</TH>");
2066 	printf("<TH CLASS='data'>Contacts/Groups</TH>");
2067 	printf("<TH CLASS='data'>First Notification</TH>");
2068 	printf("<TH CLASS='data'>Last Notification</TH>");
2069 	printf("<TH CLASS='data'>Notification Interval</TH>");
2070 	printf("<TH CLASS='data'>Escalation Period</TH>");
2071 	printf("<TH CLASS='data'>Escalation Options</TH>");
2072 	printf("</TR>\n");
2073 
2074 	/* print all hostescalations... */
2075 	for(i = 0; i < num_objects.hostescalations; i++) {
2076 		temp_he = hostescalation_ary[i];
2077 		if(*to_expand != '\0' && strcmp(to_expand, temp_he->host_name))
2078 			continue;
2079 
2080 		if(odd) {
2081 			odd = 0;
2082 			bg_class = "dataOdd";
2083 			}
2084 		else {
2085 			odd = 1;
2086 			bg_class = "dataEven";
2087 			}
2088 
2089 		printf("<TR CLASS='%s'>\n", bg_class);
2090 
2091 		printf("<TD CLASS='%s'><A HREF='%s?type=hosts&expand=%s'>%s</A></TD>", bg_class, CONFIG_CGI, url_encode(temp_he->host_name), html_encode(temp_he->host_name, FALSE));
2092 
2093 		printf("<TD CLASS='%s'>", bg_class);
2094 		num_contacts = 0;
2095 		for(temp_contactsmember = temp_he->contacts; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
2096 			num_contacts++;
2097 			if(num_contacts > 1)
2098 				printf(", ");
2099 			printf("<A HREF='%s?type=contacts&expand=%s'>%s</A>\n", CONFIG_CGI, url_encode(temp_contactsmember->contact_name), html_encode(temp_contactsmember->contact_name, FALSE));
2100 			}
2101 		for(temp_contactgroupsmember = temp_he->contact_groups; temp_contactgroupsmember != NULL; temp_contactgroupsmember = temp_contactgroupsmember->next) {
2102 			num_contacts++;
2103 			if(num_contacts > 1)
2104 				printf(", ");
2105 			printf("<A HREF='%s?type=contactgroups&expand=%s'>%s</A>\n", CONFIG_CGI, url_encode(temp_contactgroupsmember->group_name), html_encode(temp_contactgroupsmember->group_name, FALSE));
2106 			}
2107 		if(num_contacts == 0)
2108 			printf("&nbsp;");
2109 		printf("</TD>\n");
2110 
2111 		printf("<TD CLASS='%s'>%d</TD>", bg_class, temp_he->first_notification);
2112 
2113 		printf("<TD CLASS='%s'>", bg_class);
2114 		if(temp_he->last_notification == 0)
2115 			printf("Infinity");
2116 		else
2117 			printf("%d", temp_he->last_notification);
2118 		printf("</TD>\n");
2119 
2120 		get_interval_time_string(temp_he->notification_interval, time_string, sizeof(time_string));
2121 		printf("<TD CLASS='%s'>", bg_class);
2122 		if(temp_he->notification_interval == 0.0)
2123 			printf("Notify Only Once (No Re-notification)");
2124 		else
2125 			printf("%s", time_string);
2126 		printf("</TD>\n");
2127 
2128 		printf("<TD CLASS='%s'>", bg_class);
2129 		if(temp_he->escalation_period == NULL)
2130 			printf("&nbsp;");
2131 		else
2132 			printf("<A HREF='%s?type=timeperiods&expand=%s'>%s</A>", CONFIG_CGI, url_encode(temp_he->escalation_period), html_encode(temp_he->escalation_period, FALSE));
2133 		printf("</TD>\n");
2134 
2135 		printf("<TD CLASS='%s'>", bg_class);
2136 		options = FALSE;
2137 		if(flag_isset(temp_he->escalation_options, OPT_DOWN) == TRUE) {
2138 			printf("%sDown", (options == TRUE) ? ", " : "");
2139 			options = TRUE;
2140 			}
2141 		if(flag_isset(temp_he->escalation_options, OPT_UNREACHABLE) == TRUE) {
2142 			printf("%sUnreachable", (options == TRUE) ? ", " : "");
2143 			options = TRUE;
2144 			}
2145 		if(flag_isset(temp_he->escalation_options, OPT_RECOVERY) == TRUE) {
2146 			printf("%sRecovery", (options == TRUE) ? ", " : "");
2147 			options = TRUE;
2148 			}
2149 		if(options == FALSE)
2150 			printf("None");
2151 		printf("</TD>\n");
2152 
2153 		printf("</TR>\n");
2154 		}
2155 
2156 	printf("</TABLE>\n");
2157 	printf("</DIV>\n");
2158 	printf("</P>\n");
2159 
2160 	return;
2161 	}
2162 
2163 
2164 
unauthorized_message(void)2165 void unauthorized_message(void) {
2166 
2167 	printf("<P><DIV CLASS='errorMessage'>It appears as though you do not have permission to view the configuration information you requested...</DIV></P>\n");
2168 	printf("<P><DIV CLASS='errorDescription'>If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI<br>");
2169 	printf("and check the authorization options in your CGI configuration file.</DIV></P>\n");
2170 
2171 	return;
2172 	}
2173 
2174 
hash_color(int i)2175 static const char *hash_color(int i) {
2176 	char c;
2177 
2178 	/* This is actually optimized for MAX_COMMAND_ARGUMENTS==32 ... */
2179 
2180 	if((i % 32) < 16) {
2181 		if((i % 32) < 8) c = '7';
2182 		else c = '4';
2183 		}
2184 	else {
2185 		if((i % 32) < 24) c = '6';
2186 		else c = '5';
2187 		}
2188 
2189 	/* Computation for standard case */
2190 	hashed_color[0] = '#';
2191 	hashed_color[1] = hashed_color[2] = ((i % 2) ? c : '0');
2192 	hashed_color[3] = hashed_color[4] = (((i / 2) % 2) ? c : '0');
2193 	hashed_color[5] = hashed_color[6] = (((i / 4) % 2) ? c : '0');
2194 	hashed_color[7] = '\0';
2195 
2196 	/* Override shades of grey */
2197 	if((i % 8) == 7) hashed_color[1] = hashed_color[3] = '0';
2198 	if((i % 8) == 0) hashed_color[2] = hashed_color[3] = hashed_color[4] = hashed_color[6] = c;
2199 
2200 	return(hashed_color);
2201 	}
2202 
display_command_expansion(void)2203 void display_command_expansion(void) {
2204 	command *temp_command;
2205 	int odd = 0;
2206 	const char *bg_class = "";
2207 	int i, j;
2208 	char *c, *cc;
2209 	char commandline[MAX_COMMAND_BUFFER];
2210 	char *command_args[MAX_COMMAND_ARGUMENTS];
2211 	int arg_count[MAX_COMMAND_ARGUMENTS],
2212 	    lead_space[MAX_COMMAND_ARGUMENTS],
2213 	    trail_space[MAX_COMMAND_ARGUMENTS];
2214 
2215 	/* see if user is authorized to view command information... */
2216 	if(is_authorized_for_configuration_information(&current_authdata) == FALSE) {
2217 		unauthorized_message();
2218 		return;
2219 		}
2220 
2221 	printf("<P><DIV ALIGN=CENTER CLASS='dataTitle'>Command Expansion</DIV></P>\n");
2222 
2223 	/* Parse to_expand into parts */
2224 	for(i = 0; i < MAX_COMMAND_ARGUMENTS; i++) command_args[i] = NULL;
2225 	for(i = 0, command_args[0] = cc = c = strdup(to_expand); c && ((*c) != '\0') && (i < MAX_COMMAND_ARGUMENTS); c++, cc++) {
2226 		if((*c) == '\\') c++;
2227 		else if((*c) == '!') {
2228 			(*cc) = '\0';
2229 			cc = c++;
2230 			command_args[++i] = (c--);
2231 			}
2232 		(*cc) = (*c);
2233 		}
2234 	if((*c) == '\0')(*cc) = '\0';
2235 	/* Precompute indexes of dangling whitespace */
2236 	for(i = 0; i < MAX_COMMAND_ARGUMENTS; i++) {
2237 		for(cc = command_args[i], lead_space[i] = 0; cc && isspace(*cc); cc++, lead_space[i]++) ;
2238 		trail_space[i] = 0;
2239 		for(; cc && ((*cc) != '\0'); cc++) if(isspace(*cc)) trail_space[i]++;
2240 			else trail_space[i] = 0;
2241 		}
2242 
2243 	printf("<P><DIV ALIGN=CENTER>\n");
2244 	printf("<TABLE BORDER=0 CLASS='data'>\n");
2245 	printf("<TR><TH CLASS='data'>Command Name</TH><TH CLASS='data'>Command Line</TH></TR>\n");
2246 
2247 	if((*to_expand) != '\0') {
2248 		arg_count[0] = 0;
2249 
2250 		printf("<TR CLASS='dataEven'><TD CLASS='dataEven'>To expand:</TD><TD CLASS='dataEven'>%s", escape_string(command_args[0]));
2251 		for(i = 1; (i < MAX_COMMAND_ARGUMENTS) && command_args[i]; i++)
2252 			printf("!<FONT\n   COLOR='%s'>%s</FONT>", hash_color(i), escape_string(command_args[i]));
2253 		printf("\n</TD></TR>\n");
2254 
2255 		/* check all commands */
2256 		for(temp_command = command_list; temp_command != NULL; temp_command = temp_command->next) {
2257 
2258 			if(!strcmp(temp_command->name, command_args[0])) {
2259 
2260 				arg_count[0]++;
2261 
2262 				if(odd) {
2263 					odd = 0;
2264 					bg_class = "dataEven";
2265 					}
2266 				else {
2267 					odd = 1;
2268 					bg_class = "dataOdd";
2269 					}
2270 
2271 				printf("<TR CLASS='%s'>\n", bg_class);
2272 
2273 				printf("<TD CLASS='%s'><A NAME='%s'></A>%s</TD>\n", bg_class, url_encode(temp_command->name), html_encode(temp_command->name, FALSE));
2274 				printf("<TD CLASS='%s'>%s</TD>\n", bg_class, html_encode(temp_command->command_line, FALSE));
2275 
2276 				printf("</TR>\n<TR CLASS='%s'>\n", bg_class);
2277 
2278 				for(i = 1; i < MAX_COMMAND_ARGUMENTS; i++) arg_count[i] = 0;
2279 
2280 				printf("<TD CLASS='%s' ALIGN='right'>-&gt;</TD>\n", bg_class);
2281 				printf("<TD CLASS='%s'>", bg_class);
2282 				strncpy(commandline, temp_command->command_line, MAX_COMMAND_BUFFER);
2283 				commandline[MAX_COMMAND_BUFFER - 1] = '\0';
2284 				for(c = commandline; c && (cc = strstr(c, "$"));) {
2285 					(*(cc++)) = '\0';
2286 					printf("%s", html_encode(c, FALSE));
2287 					if((*cc) == '$') {
2288 						/* Escaped '$' */
2289 						printf("<FONT COLOR='#444444'>$</FONT>");
2290 						c = (++cc);
2291 						}
2292 					else if(strncmp("ARG", cc, 3)) {
2293 						/* Non-$ARGn$ macro */
2294 						c = strstr(cc, "$");
2295 						if(c)(*(c++)) = '\0';
2296 						printf("<FONT COLOR='#777777'>$%s%s</FONT>", html_encode(cc, FALSE), (c ? "$" : ""));
2297 						if(!c) printf("<FONT COLOR='#FF0000'> (not properly terminated)</FONT>");
2298 						}
2299 					else {
2300 						/* $ARGn$ macro */
2301 						for(c = (cc += 3); isdigit(*c); c++) ;
2302 						if(((*c) == '\0') || ((*c) == '$')) {
2303 							/* Index is numeric */
2304 							i = atoi(cc);
2305 							if((i > 0) && (i <= MAX_COMMAND_ARGUMENTS)) {
2306 								arg_count[i]++;
2307 								if(command_args[i]) {
2308 									if(*(command_args[i]) != '\0') printf("<FONT COLOR='%s'><B>%s%s%s</B></FONT>",
2309 										                                      hash_color(i), ((lead_space[i] > 0) || (trail_space[i] > 0) ? "<U>&zwj;" : ""),
2310 										                                      html_encode(command_args[i], FALSE), ((lead_space[i] > 0) || (trail_space[i] > 0) ? "&zwj;</U>" : ""));
2311 									else printf("<FONT COLOR='#0000FF'>(empty)</FONT>");
2312 									}
2313 								else printf("<FONT COLOR='#0000FF'>(undefined)</FONT>");
2314 								}
2315 							else printf("<FONT COLOR='#FF0000'>(not a valid $ARGn$ index: %u)</FONT>", i);
2316 							if((*c) != '\0') c++;
2317 							else printf("<FONT COLOR='#FF0000'> (not properly terminated)</FONT>");
2318 							}
2319 						else {
2320 							/* Syntax err in index */
2321 							c = strstr(cc, "$");
2322 							printf("<FONT COLOR='#FF0000'>(not an $ARGn$ index: &quot;%s&quot;)</FONT>", html_encode(strtok(cc, "$"), FALSE));
2323 							if(c) c++;
2324 							}
2325 						}
2326 					}
2327 				if(c) printf("%s", html_encode(c, FALSE));
2328 
2329 				printf("</TD></TR>\n");
2330 
2331 				for(i = 1; (i < MAX_COMMAND_ARGUMENTS) && (command_args[i]); i++) {
2332 					if(arg_count[i] == 0) {
2333 						printf("<TR CLASS='%s'><TD CLASS='%s' ALIGN='right'><FONT COLOR='#FF0000'>unused:</FONT></TD>\n", bg_class, bg_class);
2334 						printf("<TD CLASS='%s'>$ARG%u$=<FONT COLOR='%s'>%s%s%s</FONT></TD></TR>\n", bg_class, i, hash_color(i),
2335 						       ((lead_space[i] > 0) || (trail_space[i] > 0) ? "<U>&zwj;" : ""), html_encode(command_args[i], FALSE),
2336 						       ((lead_space[i] > 0) || (trail_space[i] > 0) ? "&zwj;</U>" : ""));
2337 						}
2338 					else if(arg_count[i] > 1) {
2339 						printf("<TR CLASS='%s'><TD CLASS='%s' ALIGN='right'>used %u x:</TD>\n", bg_class, bg_class, i);
2340 						printf("<TD CLASS='%s'>$ARG%u$=<FONT COLOR='%s'>%s%s%s</FONT></TD></TR>\n", bg_class, i, hash_color(i),
2341 						       ((lead_space[i] > 0) || (trail_space[i] > 0) ? "<U>&zwj;" : ""), html_encode(command_args[i], FALSE),
2342 						       ((lead_space[i] > 0) || (trail_space[i] > 0) ? "&zwj;</U>" : ""));
2343 						}
2344 					if((lead_space[i] > 0) || (trail_space[i] > 0)) {
2345 						printf("<TR CLASS='%s'><TD CLASS='%s' ALIGN='right'><FONT COLOR='#0000FF'>dangling whitespace:</FONT></TD>\n", bg_class, bg_class);
2346 						printf("<TD CLASS='%s'>$ARG%u$=<FONT COLOR='#0000FF'>", bg_class, i);
2347 						for(c = command_args[i], j = 0; c && isspace(*c); c++, j++)
2348 							/* TODO: As long as the hyperlinks change all whitespace into actual spaces,
2349 							   we'll output "[WS]" (whitespace) instead of "[SP]"(ace). */
2350 							/* if ((*c)==' ')		printf("[SP]"); */
2351 							if((*c) == ' ')		printf("[WS]");
2352 							else if((*c) == '\f')	printf("[FF]");
2353 							else if((*c) == '\n')	printf("[LF]");
2354 							else if((*c) == '\r')	printf("[CR]");
2355 							else if((*c) == '\t')	printf("[HT]");
2356 							else if((*c) == '\v')	printf("[VT]");
2357 							else			printf("[0x%x]", *c);
2358 						printf("</FONT><FONT COLOR='%s'>", hash_color(i));
2359 						for(; c && ((*c) != '\0') && (j < (int)strlen(command_args[i]) - trail_space[i]); c++, j++) putchar(*c);
2360 						printf("</FONT><FONT COLOR='#0000FF'>");
2361 						for(; c && ((*c) != '\0'); c++)
2362 							/* TODO: As long as the hyperlinks change all whitespace into actual spaces,
2363 							   we'll output "[WS]" (whitespace) instead of "[SP]"(ace). */
2364 							/* if ((*c)==' ')		printf("[SP]"); */
2365 							if((*c) == ' ')		printf("[WS]");
2366 							else if((*c) == '\f')	printf("[FF]");
2367 							else if((*c) == '\n')	printf("[LF]");
2368 							else if((*c) == '\r')	printf("[CR]");
2369 							else if((*c) == '\t')	printf("[HT]");
2370 							else if((*c) == '\v')	printf("[VT]");
2371 							else			printf("[0x%x]", *c);
2372 						printf("</FONT></TD></TR>\n");
2373 						}
2374 					}
2375 				}
2376 
2377 			}
2378 
2379 		if(!arg_count[0]) {
2380 			printf("<TR CLASS='dataOdd'><TD CLASS='dataOdd' ALIGN='right'><FONT\n");
2381 			printf("COLOR='#FF0000'>Error:</FONT></TD><TD CLASS='dataOdd'><FONT COLOR='#FF0000'>No\n");
2382 			printf("command &quot;%s&quot; found</FONT></TD></TR>\n", html_encode(command_args[0], FALSE));
2383 			}
2384 		}
2385 
2386 	printf("<TR CLASS='dataEven'><TD><BR/></TD><TD CLASS='dataEven'>Enter the command_check definition from a host or service definition and press Go to see the expansion of the command</TD></TR>\n");
2387 	printf("<TR CLASS='dataEven'><TD CLASS='dataEven'>To expand:</TD><TD CLASS='dataEven'><FORM\n");
2388 	printf("METHOD='GET' ACTION='%s'><INPUT TYPE='HIDDEN' NAME='type' VALUE='command'><INPUT\n", CONFIG_CGI);
2389 	printf("TYPE='text' NAME='expand' SIZE='100%%' VALUE='%s'>\n", html_encode(to_expand, FALSE));
2390 	printf("<INPUT TYPE='SUBMIT' VALUE='Go'></FORM></TD></TR>\n");
2391 
2392 	printf("</TABLE>\n");
2393 	printf("</DIV></P>\n");
2394 
2395 	return;
2396 	}
2397 
2398 
2399 
display_options(void)2400 void display_options(void) {
2401 
2402 	printf("<br><br>\n");
2403 
2404 	printf("<div align=center class='reportSelectTitle'>Select Type of Config Data You Wish To View</div>\n");
2405 
2406 	printf("<br><br>\n");
2407 
2408 	printf("<form method=\"get\" action=\"%s\">\n", CONFIG_CGI);
2409 
2410 	printf("<div align=center>\n");
2411 	printf("<table border=0>\n");
2412 
2413 	printf("<tr><td align=left class='reportSelectSubTitle'>Object Type:</td></tr>\n");
2414 	printf("<tr><td align=left class='reportSelectItem'>");
2415 	printf("<select name='type'>\n");
2416 	printf("<option value='hosts' %s>Hosts\n", (display_type == DISPLAY_HOSTS) ? "SELECTED" : "");
2417 	printf("<option value='hostdependencies' %s>Host Dependencies\n", (display_type == DISPLAY_HOSTDEPENDENCIES) ? "SELECTED" : "");
2418 	printf("<option value='hostescalations' %s>Host Escalations\n", (display_type == DISPLAY_HOSTESCALATIONS) ? "SELECTED" : "");
2419 	printf("<option value='hostgroups' %s>Host Groups\n", (display_type == DISPLAY_HOSTGROUPS) ? "SELECTED" : "");
2420 	printf("<option value='services' %s>Services\n", (display_type == DISPLAY_SERVICES) ? "SELECTED" : "");
2421 	printf("<option value='servicegroups' %s>Service Groups\n", (display_type == DISPLAY_SERVICEGROUPS) ? "SELECTED" : "");
2422 	printf("<option value='servicedependencies' %s>Service Dependencies\n", (display_type == DISPLAY_SERVICEDEPENDENCIES) ? "SELECTED" : "");
2423 	printf("<option value='serviceescalations' %s>Service Escalations\n", (display_type == DISPLAY_SERVICEESCALATIONS) ? "SELECTED" : "");
2424 	printf("<option value='contacts' %s>Contacts\n", (display_type == DISPLAY_CONTACTS) ? "SELECTED" : "");
2425 	printf("<option value='contactgroups' %s>Contact Groups\n", (display_type == DISPLAY_CONTACTGROUPS) ? "SELECTED" : "");
2426 	printf("<option value='timeperiods' %s>Timeperiods\n", (display_type == DISPLAY_TIMEPERIODS) ? "SELECTED" : "");
2427 	printf("<option value='commands' %s>Commands\n", (display_type == DISPLAY_COMMANDS) ? "SELECTED" : "");
2428 	printf("<option value='command' %s>Command Expansion\n", (display_type == DISPLAY_COMMAND_EXPANSION) ? "SELECTED" : "");
2429 	printf("</select>\n");
2430 	printf("</td></tr>\n");
2431 
2432 	printf("<tr><td class='reportSelectItem'><input type='submit' value='Continue'></td></tr>\n");
2433 	printf("</table>\n");
2434 	printf("</div>\n");
2435 
2436 	printf("</form>\n");
2437 
2438 	return;
2439 	}
2440