int process_cgivars(void) { char **variables; int error = FALSE; int x; variables = getcgivars(); for (x = 0; variables[x] != NULL; x++) { /* do some basic length checking on the variable identifier to prevent buffer overflows */ if (strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) continue; /* we found the service severity divisor option */ if (!strcmp(variables[x], "service_divisor")) { x++; if (variables[x] == NULL) { error = TRUE; break; } service_severity_divisor = atoi(variables[x]); if (service_severity_divisor < 1) service_severity_divisor = 1; } /* we found the CSV output option */ else if (!strcmp(variables[x], "csvoutput")) { display_header = FALSE; content_type = CSV_CONTENT; } else if (!strcmp(variables[x], "jsonoutput")) { display_header = FALSE; content_type = JSON_CONTENT; } /* we found the embed option */ else if (!strcmp(variables[x], "embedded")) embedded = TRUE; /* we found the noheader option */ else if (!strcmp(variables[x], "noheader")) display_header = FALSE; /* we found the pause option */ else if (!strcmp(variables[x], "paused")) refresh = FALSE; /* we found the nodaemoncheck option */ else if (!strcmp(variables[x], "nodaemoncheck")) daemon_check = FALSE; } /* free memory allocated to the CGI variables */ free_cgivars(variables); return error; }
int process_cgivars(void) { char **variables; int error = FALSE; int x; variables = getcgivars(); for(x = 0; variables[x] != NULL; x++) { /* do some basic length checking on the variable identifier to prevent buffer overflows */ if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) { continue; } /* we found the archive argument */ else if(!strcmp(variables[x], "archive")) { x++; if(variables[x] == NULL) { error = TRUE; break; } log_archive = atoi(variables[x]); if(log_archive < 0) log_archive = 0; } /* we found the order argument */ else if(!strcmp(variables[x], "oldestfirst")) { use_lifo = FALSE; } /* we found the embed option */ else if(!strcmp(variables[x], "embedded")) embedded = TRUE; /* we found the noheader option */ else if(!strcmp(variables[x], "noheader")) display_header = FALSE; /* we found the nofrills option */ else if(!strcmp(variables[x], "nofrills")) display_frills = FALSE; /* we found the notimebreaks option */ else if(!strcmp(variables[x], "notimebreaks")) display_timebreaks = FALSE; /* we received an invalid argument */ else error = TRUE; } /* free memory allocated to the CGI variables */ free_cgivars(variables); return error; }
int process_cgivars(void) { char **variables; char *key = NULL; char *value = NULL; int error = FALSE; int x; variables = getcgivars(); for (x = 0; variables[x] != NULL; x+=2) { key = variables[x]; value = variables[x+1]; /* do some basic length checking on the variable identifier to prevent buffer overflows */ if (strlen(key) >= MAX_INPUT_BUFFER - 1) { error = TRUE; break; } /* likewise, check the value if it exists */ if (value != NULL) if (strlen(value) >= MAX_INPUT_BUFFER - 1) { error = TRUE; break; } /* we found the host argument */ if (!strcmp(key, "host")) { query_type = DISPLAY_HOSTS; if (value == NULL) { error = TRUE; break; } if ((query_host_name = strdup(value)) == NULL) query_host_name = ""; strip_html_brackets(query_host_name); if (!strcmp(query_host_name, "all")) find_all = TRUE; else find_all = FALSE; } /* we found the contact argument */ else if (!strcmp(key, "contact")) { query_type = DISPLAY_CONTACTS; if (value == NULL) { error = TRUE; break; } if ((query_contact_name = strdup(value)) == NULL) query_contact_name = ""; strip_html_brackets(query_contact_name); if (!strcmp(query_contact_name, "all")) find_all = TRUE; else find_all = FALSE; } /* we found the service argument */ else if (!strcmp(key, "service")) { query_type = DISPLAY_SERVICES; if (value == NULL) { error = TRUE; break; } if ((query_svc_description = strdup(value)) == NULL) query_svc_description = ""; strip_html_brackets(query_svc_description); } /* we found the hostgroup argument */ else if (!strcmp(key, "hostgroup")) { query_type = DISPLAY_HOSTGROUPS; if (value == NULL) { error = TRUE; break; } if ((query_hostgroup_name = strdup(value)) == NULL) query_hostgroup_name = ""; strip_html_brackets(query_hostgroup_name); } /* we found the servicegroup argument */ else if (!strcmp(key, "servicegroup")) { query_type = DISPLAY_SERVICEGROUPS; if (value == NULL) { error = TRUE; break; } if ((query_servicegroup_name = strdup(value)) == NULL) query_servicegroup_name = ""; strip_html_brackets(query_servicegroup_name); } /* we found the notification type argument */ else if (!strcmp(key, "type")) { if (value == NULL) { error = TRUE; break; } notification_options = atoi(value); } /* we found first time argument */ else if (!strcmp(key, "ts_start")) { if (value == NULL) { error = TRUE; break; } ts_start = (time_t)strtoul(value, NULL, 10); } /* we found last time argument */ else if (!strcmp(key, "ts_end")) { if (value == NULL) { error = TRUE; break; } ts_end = (time_t)strtoul(value, NULL, 10); } /* we found the start time */ else if (!strcmp(key, "start_time")) { if (value == NULL) { error = TRUE; break; } start_time_string = (char *)malloc(strlen(value) + 1); if (start_time_string == NULL) start_time_string = ""; else strcpy(start_time_string, value); } /* we found the end time */ else if (!strcmp(key, "end_time")) { if (value == NULL) { error = TRUE; break; } end_time_string = (char *)malloc(strlen(value) + 1); if (end_time_string == NULL) end_time_string = ""; else strcpy(end_time_string, value); } /* we found the standard timeperiod argument */ else if (!strcmp(key, "timeperiod")) { if (value == NULL) { error = TRUE; break; } if (!strcmp(value, "today")) timeperiod_type = TIMEPERIOD_TODAY; else if (!strcmp(value, "singelday")) timeperiod_type = TIMEPERIOD_SINGLE_DAY; else if (!strcmp(value, "last24hours")) timeperiod_type = TIMEPERIOD_LAST24HOURS; else if (!strcmp(value, "thisweek")) timeperiod_type = TIMEPERIOD_THISWEEK; else if (!strcmp(value, "lastweek")) timeperiod_type = TIMEPERIOD_LASTWEEK; else if (!strcmp(value, "thismonth")) timeperiod_type = TIMEPERIOD_THISMONTH; else if (!strcmp(value, "lastmonth")) timeperiod_type = TIMEPERIOD_LASTMONTH; else if (!strcmp(value, "thisyear")) timeperiod_type = TIMEPERIOD_THISYEAR; else if (!strcmp(value, "lastyear")) timeperiod_type = TIMEPERIOD_LASTYEAR; else if (!strcmp(value, "last7days")) timeperiod_type = TIMEPERIOD_LAST7DAYS; else if (!strcmp(value, "last31days")) timeperiod_type = TIMEPERIOD_LAST31DAYS; else if (!strcmp(value, "custom")) timeperiod_type = TIMEPERIOD_CUSTOM; else continue; convert_timeperiod_to_times(timeperiod_type, &ts_start, &ts_end); } /* we found the order argument */ else if (!strcmp(key, "order")) { if (value == NULL) { error = TRUE; break; } if (!strcmp(value, "new2old")) reverse = FALSE; else if (!strcmp(value, "old2new")) reverse = TRUE; } /* we found the CSV output option */ else if (!strcmp(key, "csvoutput")) { display_header = FALSE; content_type = CSV_CONTENT; } /* we found the JSON output option */ else if (!strcmp(key, "jsonoutput")) { display_header = FALSE; content_type = JSON_CONTENT; } /* we found the embed option */ else if (!strcmp(key, "embedded")) embedded = TRUE; /* we found the noheader option */ else if (!strcmp(key, "noheader")) display_header = FALSE; /* we found the nodaemoncheck option */ else if (!strcmp(key, "nodaemoncheck")) daemon_check = FALSE; /* start num results to skip on displaying statusdata */ else if (!strcmp(key, "start")) { if (value == NULL) { error = TRUE; break; } result_start = atoi(value); if (result_start < 1) result_start = 1; } /* amount of results to display */ else if (!strcmp(key, "limit")) { if (value == NULL) { error = TRUE; break; } get_result_limit = atoi(value); } } /* * Set some default values if not already set. * Done here as they won't be set if variable * not provided via cgi parameters * Only required for hosts & contacts, not services * as there is no service_name=all option */ if (query_type == DISPLAY_HOSTS && strlen(query_host_name) == 0) { query_host_name = "all"; find_all = TRUE; } if (query_type == DISPLAY_CONTACTS && strlen(query_contact_name) == 0) { query_contact_name = "all"; find_all = TRUE; } /* free memory allocated to the CGI variables */ free_cgivars(variables); return error; }
int process_cgivars(void) { char **variables; int error = FALSE; int x; variables = getcgivars(); for(x = 0; variables[x] != NULL; x++) { /* we found the hostgroup argument */ if(!strcmp(variables[x], "hostgroup")) { display_type = DISPLAY_HOSTGROUP; x++; if(variables[x] == NULL) { error = TRUE; break; } if((hostgroup_name = (char *)strdup(variables[x])) == NULL) hostgroup_name = ""; strip_html_brackets(hostgroup_name); if(!strcmp(hostgroup_name, "all")) show_all_hostgroups = TRUE; else show_all_hostgroups = FALSE; } /* we found the host argument */ else if(!strcmp(variables[x], "host")) { display_type = DISPLAY_HOST; x++; if(variables[x] == NULL) { error = TRUE; break; } if((host_name = (char *)strdup(variables[x])) == NULL) host_name = ""; strip_html_brackets(host_name); } /* we found the service argument */ else if(!strcmp(variables[x], "service")) { display_type = DISPLAY_SERVICE; x++; if(variables[x] == NULL) { error = TRUE; break; } if((service_desc = (char *)strdup(variables[x])) == NULL) service_desc = ""; strip_html_brackets(service_desc); } /* we found the hostgroup style argument */ else if(!strcmp(variables[x], "style")) { x++; if(variables[x] == NULL) { error = TRUE; break; } if(!strcmp(variables[x], "overview")) hostgroup_style = DISPLAY_HOSTGROUP_OVERVIEW; else if(!strcmp(variables[x], "summary")) hostgroup_style = DISPLAY_HOSTGROUP_SUMMARY; else if(!strcmp(variables[x], "servicedetail")) host_style = DISPLAY_HOST_SERVICES; else if(!strcmp(variables[x], "processinfo")) display_type = DISPLAY_PROCESS; else if(!strcmp(variables[x], "aprobs")) display_type = DISPLAY_ALL_PROBLEMS; else if(!strcmp(variables[x], "uprobs")) display_type = DISPLAY_UNHANDLED_PROBLEMS; else display_type = DISPLAY_QUICKSTATS; } /* we found the ping argument */ else if(!strcmp(variables[x], "ping")) { display_type = DISPLAY_PING; x++; if(variables[x] == NULL) { error = TRUE; break; } if((ping_address = (char *)strdup(variables[x])) == NULL) ping_address = ""; strip_html_brackets(ping_address); } /* we found the traceroute argument */ else if(!strcmp(variables[x], "traceroute")) { display_type = DISPLAY_TRACEROUTE; x++; if(variables[x] == NULL) { error = TRUE; break; } if((traceroute_address = (char *)strdup(variables[x])) == NULL) traceroute_address = ""; strip_html_brackets(traceroute_address); } } /* free memory allocated to the CGI variables */ free_cgivars(variables); return error; }
int process_cgivars(void) { char **variables; int error = FALSE; int x; variables = getcgivars(); for(x = 0; variables[x] != NULL; x++) { /* do some basic length checking on the variable identifier to prevent buffer overflows */ if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) continue; /* we found the host argument */ else if(!strcmp(variables[x], "host")) { x++; if(variables[x] == NULL) { error = TRUE; break; } if((host_name = (char *)strdup(variables[x])) == NULL) host_name = ""; strip_html_brackets(host_name); display_type = DISPLAY_HOSTS; if(!strcmp(host_name, "all")) show_all_hosts = TRUE; else show_all_hosts = FALSE; } /* we found the service argument */ else if(!strcmp(variables[x], "service")) { x++; if(variables[x] == NULL) { error = TRUE; break; } if((svc_description = (char *)strdup(variables[x])) == NULL) svc_description = ""; strip_html_brackets(svc_description); display_type = DISPLAY_SERVICES; } /* we found the history type argument */ else if(!strcmp(variables[x], "type")) { x++; if(variables[x] == NULL) { error = TRUE; break; } history_options = atoi(variables[x]); } /* we found the history state type argument */ else if(!strcmp(variables[x], "statetype")) { x++; if(variables[x] == NULL) { error = TRUE; break; } state_options = atoi(variables[x]); } /* we found the log archive argument */ else if(!strcmp(variables[x], "archive")) { x++; if(variables[x] == NULL) { error = TRUE; break; } log_archive = atoi(variables[x]); if(log_archive < 0) log_archive = 0; } /* we found the order argument */ else if(!strcmp(variables[x], "oldestfirst")) { use_lifo = FALSE; } /* we found the embed option */ else if(!strcmp(variables[x], "embedded")) embedded = TRUE; /* we found the noheader option */ else if(!strcmp(variables[x], "noheader")) display_header = FALSE; /* we found the nofrills option */ else if(!strcmp(variables[x], "nofrills")) display_frills = FALSE; /* we found the notimebreaks option */ else if(!strcmp(variables[x], "notimebreaks")) display_timebreaks = FALSE; /* we found the no system messages option */ else if(!strcmp(variables[x], "nosystem")) display_system_messages = FALSE; /* we found the no flapping alerts option */ else if(!strcmp(variables[x], "noflapping")) display_flapping_alerts = FALSE; /* we found the no downtime alerts option */ else if(!strcmp(variables[x], "nodowntime")) display_downtime_alerts = FALSE; } /* free memory allocated to the CGI variables */ free_cgivars(variables); return error; }
int process_cgivars(void) { char **variables; int error = FALSE; int x; variables = getcgivars(); for (x = 0; variables[x] != NULL; x++) { /* do some basic length checking on the variable identifier to prevent buffer overflows */ if (strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) continue; /* we found the host argument */ else if (!strcmp(variables[x], "host")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if ((host_name = (char *)strdup(variables[x])) == NULL) host_name = ""; strip_html_brackets(host_name); display_type = DISPLAY_HOSTS; if (!strcmp(host_name, "all")) show_all_hosts = TRUE; else show_all_hosts = FALSE; } /* we found the service argument */ else if (!strcmp(variables[x], "service")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if ((service_desc = (char *)strdup(variables[x])) == NULL) service_desc = ""; strip_html_brackets(service_desc); display_type = DISPLAY_SERVICES; } /* we found the hostgroup argument */ else if (!strcmp(variables[x], "hostgroup")) { display_type = DISPLAY_HOSTGROUPS; x++; if (variables[x] == NULL) { error = TRUE; break; } if ((hostgroup_name = strdup(variables[x])) == NULL) hostgroup_name = ""; strip_html_brackets(hostgroup_name); } /* we found the servicegroup argument */ else if (!strcmp(variables[x], "servicegroup")) { display_type = DISPLAY_SERVICEGROUPS; x++; if (variables[x] == NULL) { error = TRUE; break; } if ((servicegroup_name = strdup(variables[x])) == NULL) servicegroup_name = ""; strip_html_brackets(servicegroup_name); } /* we found the history type argument */ else if (!strcmp(variables[x], "type")) { x++; if (variables[x] == NULL) { error = TRUE; break; } history_options = atoi(variables[x]); } /* we found the history state type argument */ else if (!strcmp(variables[x], "statetype")) { x++; if (variables[x] == NULL) { error = TRUE; break; } state_options = atoi(variables[x]); } /* we found first time argument */ else if (!strcmp(variables[x], "ts_start")) { x++; if (variables[x] == NULL) { error = TRUE; break; } ts_start = (time_t)strtoul(variables[x], NULL, 10); } /* we found last time argument */ else if (!strcmp(variables[x], "ts_end")) { x++; if (variables[x] == NULL) { error = TRUE; break; } ts_end = (time_t)strtoul(variables[x], NULL, 10); } /* we found the order argument */ else if (!strcmp(variables[x], "order")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "new2old")) reverse = FALSE; else if (!strcmp(variables[x], "old2new")) reverse = TRUE; } /* we found the embed option */ else if (!strcmp(variables[x], "embedded")) embedded = TRUE; /* we found the noheader option */ else if (!strcmp(variables[x], "noheader")) display_header = FALSE; /* we found the nodaemoncheck option */ else if (!strcmp(variables[x], "nodaemoncheck")) daemon_check = FALSE; /* we found the nofrills option */ else if (!strcmp(variables[x], "nofrills")) display_frills = FALSE; /* we found the notimebreaks option */ else if (!strcmp(variables[x], "notimebreaks")) display_timebreaks = FALSE; /* we found the no system messages option */ else if (!strcmp(variables[x], "nosystem")) display_system_messages = FALSE; /* we found the no flapping alerts option */ else if (!strcmp(variables[x], "noflapping")) display_flapping_alerts = FALSE; /* we found the no downtime alerts option */ else if (!strcmp(variables[x], "nodowntime")) display_downtime_alerts = FALSE; /* start num results to skip on displaying statusdata */ else if (!strcmp(variables[x], "start")) { x++; if (variables[x] == NULL) { error = TRUE; break; } result_start = atoi(variables[x]); if (result_start < 1) result_start = 1; } /* amount of results to display */ else if (!strcmp(variables[x], "limit")) { x++; if (variables[x] == NULL) { error = TRUE; break; } get_result_limit = atoi(variables[x]); } } /* free memory allocated to the CGI variables */ free_cgivars(variables); return error; }
int process_cgivars(void) { char **variables; int error = FALSE; int x; variables = getcgivars(); for(x = 0; variables[x] != NULL; x++) { /* do some basic length checking on the variable identifier to prevent buffer overflows */ if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) { x++; continue; } /* we found the host argument */ else if(!strcmp(variables[x], "host")) { x++; if(variables[x] == NULL) { error = TRUE; break; } if((host_name = (char *)strdup(variables[x])) == NULL) host_name = "all"; else strip_html_brackets(host_name); if(!strcmp(host_name, "all")) show_all_hosts = TRUE; else show_all_hosts = FALSE; } /* we found the no textures argument*/ else if(!strcmp(variables[x], "notextures")) use_textures = FALSE; /* we found the no text argument*/ else if(!strcmp(variables[x], "notext")) use_text = FALSE; /* we found the no links argument*/ else if(!strcmp(variables[x], "nolinks")) use_links = FALSE; /* we found the layout method option */ else if(!strcmp(variables[x], "layout")) { x++; if(variables[x] == NULL) { error = TRUE; break; } layout_method = atoi(variables[x]); } /* we found custom viewpoint coord */ else if(!strcmp(variables[x], "viewx")) { x++; if(variables[x] == NULL) { error = TRUE; break; } custom_viewpoint_x = strtod(variables[x], NULL); custom_viewpoint = TRUE; } else if(!strcmp(variables[x], "viewy")) { x++; if(variables[x] == NULL) { error = TRUE; break; } custom_viewpoint_y = strtod(variables[x], NULL); custom_viewpoint = TRUE; } else if(!strcmp(variables[x], "viewz")) { x++; if(variables[x] == NULL) { error = TRUE; break; } custom_viewpoint_z = strtod(variables[x], NULL); custom_viewpoint = TRUE; } } /* free memory allocated to the CGI variables */ free_cgivars(variables); return error; }
int process_cgivars(void) { char **variables; int error = FALSE; int x; variables = getcgivars(); for (x = 0; variables[x] != NULL; x++) { /* do some basic length checking on the variable identifier to prevent buffer overflows */ if (strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) continue; /* found query string */ else if (!strcmp(variables[x], "query_string")) { x++; if (variables[x] == NULL) { error = TRUE; break; } query_string = strdup(variables[x]); strip_html_brackets(query_string); if (strlen(query_string) == 0) my_free(query_string); } /* we found first time argument */ else if (!strcmp(variables[x], "ts_start")) { x++; if (variables[x] == NULL) { error = TRUE; break; } ts_start = (time_t)strtoul(variables[x], NULL, 10); } /* we found last time argument */ else if (!strcmp(variables[x], "ts_end")) { x++; if (variables[x] == NULL) { error = TRUE; break; } ts_end = (time_t)strtoul(variables[x], NULL, 10); } /* we found the start time */ else if (!strcmp(variables[x], "start_time")) { x++; if (variables[x] == NULL) { error = TRUE; break; } start_time_string = (char *)malloc(strlen(variables[x]) + 1); if (start_time_string == NULL) start_time_string = ""; else strcpy(start_time_string, variables[x]); } /* we found the end time */ else if (!strcmp(variables[x], "end_time")) { x++; if (variables[x] == NULL) { error = TRUE; break; } end_time_string = (char *)malloc(strlen(variables[x]) + 1); if (end_time_string == NULL) end_time_string = ""; else strcpy(end_time_string, variables[x]); } /* we found the standard timeperiod argument */ else if (!strcmp(variables[x], "timeperiod")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "today")) timeperiod_type = TIMEPERIOD_TODAY; else if (!strcmp(variables[x], "singelday")) timeperiod_type = TIMEPERIOD_SINGLE_DAY; else if (!strcmp(variables[x], "last24hours")) timeperiod_type = TIMEPERIOD_LAST24HOURS; else if (!strcmp(variables[x], "thisweek")) timeperiod_type = TIMEPERIOD_THISWEEK; else if (!strcmp(variables[x], "lastweek")) timeperiod_type = TIMEPERIOD_LASTWEEK; else if (!strcmp(variables[x], "thismonth")) timeperiod_type = TIMEPERIOD_THISMONTH; else if (!strcmp(variables[x], "lastmonth")) timeperiod_type = TIMEPERIOD_LASTMONTH; else if (!strcmp(variables[x], "thisyear")) timeperiod_type = TIMEPERIOD_THISYEAR; else if (!strcmp(variables[x], "lastyear")) timeperiod_type = TIMEPERIOD_LASTYEAR; else if (!strcmp(variables[x], "last7days")) timeperiod_type = TIMEPERIOD_LAST7DAYS; else if (!strcmp(variables[x], "last31days")) timeperiod_type = TIMEPERIOD_LAST31DAYS; else if (!strcmp(variables[x], "custom")) timeperiod_type = TIMEPERIOD_CUSTOM; else continue; convert_timeperiod_to_times(timeperiod_type, &ts_start, &ts_end); } /* we found the order argument */ else if (!strcmp(variables[x], "order")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "new2old")) reverse = FALSE; else if (!strcmp(variables[x], "old2new")) reverse = TRUE; } /* show filter */ else if (!strcmp(variables[x], "display_filter")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "true")) display_filter = TRUE; } /* notification filter */ else if (!strcmp(variables[x], "noti")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "off")) show_notifications = FALSE; } /* host status filter */ else if (!strcmp(variables[x], "hst")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "off")) show_host_status = FALSE; } /* service status filter */ else if (!strcmp(variables[x], "sst")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "off")) show_service_status = FALSE; } /* external commands filter */ else if (!strcmp(variables[x], "cmd")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "off")) show_external_commands = FALSE; } /* system messages filter */ else if (!strcmp(variables[x], "sms")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "off")) show_system_messages = FALSE; } /* event handler filter */ else if (!strcmp(variables[x], "evh")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "off")) show_event_handler = FALSE; } /* flapping filter */ else if (!strcmp(variables[x], "flp")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "off")) show_flapping = FALSE; } /* downtime filter */ else if (!strcmp(variables[x], "dwn")) { x++; if (variables[x] == NULL) { error = TRUE; break; } if (!strcmp(variables[x], "off")) show_downtime = FALSE; } /* we found the CSV output option */ else if (!strcmp(variables[x], "csvoutput")) { display_header = FALSE; content_type = CSV_CONTENT; } /* we found the CSV output option */ else if (!strcmp(variables[x], "jsonoutput")) { display_header = FALSE; content_type = JSON_CONTENT; } /* we found the embed option */ else if (!strcmp(variables[x], "embedded")) embedded = TRUE; /* we found the noheader option */ else if (!strcmp(variables[x], "noheader")) display_header = FALSE; /* we found the nofrills option */ else if (!strcmp(variables[x], "nofrills")) display_frills = FALSE; /* we found the notimebreaks option */ else if (!strcmp(variables[x], "notimebreaks")) display_timebreaks = FALSE; /* we found the nodaemoncheck option */ else if (!strcmp(variables[x], "nodaemoncheck")) daemon_check = FALSE; /* start num results to skip on displaying statusdata */ else if (!strcmp(variables[x], "start")) { x++; if (variables[x] == NULL) { error = TRUE; break; } result_start = atoi(variables[x]); if (result_start < 1) result_start = 1; } /* amount of results to display */ else if (!strcmp(variables[x], "limit")) { x++; if (variables[x] == NULL) { error = TRUE; break; } get_result_limit = atoi(variables[x]); } /* we received an invalid argument */ else error = TRUE; } /* free memory allocated to the CGI variables */ free_cgivars(variables); return error; }
int process_cgivars(void) { char **variables; int error=FALSE; int x; variables=getcgivars(); for(x=0; variables[x]!=NULL; x++) { /* do some basic length checking on the variable identifier to prevent buffer overflows */ if(strlen(variables[x])>=MAX_INPUT_BUFFER-1) { x++; continue; } /* we found the host argument */ else if(!strcmp(variables[x],"host")) { query_type=FIND_HOST; x++; if(variables[x]==NULL) { error=TRUE; break; } if((query_host_name=strdup(variables[x]))==NULL) query_host_name=""; strip_html_brackets(query_host_name); if(!strcmp(query_host_name,"all")) find_all=TRUE; else find_all=FALSE; } /* we found the contact argument */ else if(!strcmp(variables[x],"contact")) { query_type=FIND_CONTACT; x++; if(variables[x]==NULL) { error=TRUE; break; } if((query_contact_name=strdup(variables[x]))==NULL) query_contact_name=""; strip_html_brackets(query_contact_name); if(!strcmp(query_contact_name,"all")) find_all=TRUE; else find_all=FALSE; } /* we found the service argument */ else if(!strcmp(variables[x],"service")) { query_type=FIND_SERVICE; x++; if(variables[x]==NULL) { error=TRUE; break; } if((query_svc_description=strdup(variables[x]))==NULL) query_svc_description=""; strip_html_brackets(query_svc_description); } /* we found the notification type argument */ else if(!strcmp(variables[x],"type")) { x++; if(variables[x]==NULL) { error=TRUE; break; } notification_options=atoi(variables[x]); } /* we found the log archive argument */ else if(!strcmp(variables[x],"archive")) { x++; if(variables[x]==NULL) { error=TRUE; break; } log_archive=atoi(variables[x]); if(log_archive<0) log_archive=0; } /* we found the order argument */ else if(!strcmp(variables[x],"oldestfirst")) { use_lifo=FALSE; } /* we found the embed option */ else if(!strcmp(variables[x],"embedded")) embedded=TRUE; /* we found the noheader option */ else if(!strcmp(variables[x],"noheader")) display_header=FALSE; } /* free memory allocated to the CGI variables */ free_cgivars(variables); return error; }