function contacttemplate_validate($app, $deployment, $contactTemplateInfo) { foreach ($contactTemplateInfo as $key => $value) { switch ($key) { case "use": case "host_notification_period": case "service_notification_period": case "host_notification_commands": case "service_notification_commands": validateForbiddenChars($app, $deployment, '/[^\\w.-]/s', $key, $value); break; case "retain_status_information": case "retain_nonstatus_information": case "host_notifications_enabled": case "service_notifications_enabled": case "can_submit_commands": validateBinary($app, $deployment, $key, $value); break; case "host_notification_options": $opts = validateOptions($app, $deployment, $key, $value, array('d', 'u', 'r', 's', 'n'), true); $contactTemplateInfo[$key] = $opts; break; case "service_notification_options": $opts = validateOptions($app, $deployment, $key, $value, array('w', 'u', 'c', 'r', 's', 'n'), true); $contactTemplateInfo[$key] = $opts; break; default: break; } } // Don't register since we are a template $contactTemplateInfo['register'] = 0; return $contactTemplateInfo; }
function contact_validate($app, $deployment, $contactInfo) { foreach ($contactInfo as $key => $value) { switch ($key) { case "use": case "host_notification_period": case "service_notification_period": case "host_notification_commands": case "service_notification_commands": validateForbiddenChars($app, $deployment, '/[^\\w.-]/s', $key, $value); break; case "retain_status_information": case "retain_nonstatus_information": case "host_notifications_enabled": case "service_notifications_enabled": case "can_submit_commands": validateBinary($app, $deployment, $key, $value); break; case "host_notification_options": $opts = validateOptions($app, $deployment, $key, $value, array('d', 'u', 'r', 's', 'n'), true); $contactInfo[$key] = $opts; break; case "service_notification_options": $opts = validateOptions($app, $deployment, $key, $value, array('w', 'u', 'c', 'r', 's', 'n'), true); $contactInfo[$key] = $opts; break; case "email": validateEmail($app, $deployment, $key, $value); break; case "pager": if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) { if (!preg_match("/^(?[2-9][0-8][0-9])?-[2-9][0-0]{2}-[0-9]{4}\$/", $value)) { $apiResponse = new APIViewData(1, $deployment, "Unable use pager number provided, the value provided doesn't match the regex for pager or email address"); $apiResponse->setExtraResponseData('parameter', $key); $apiResponse->setExtraResponseData('parameter-value', $value); $apiResponse->setExtraResponseData('parameter-pager-regex', "/^(?[2-9][0-8][0-9])?-[2-9][0-0]{2}-[0-9]{4}\$/"); $app->halt(404, $apiResponse->returnJson()); } } break; case "contactgroups": if (is_array($value)) { $value = implode(',', $value); } validateForbiddenChars($app, $deployment, '/[^\\w.-]/s', $key, $value); break; default: break; } } return $contactInfo; }
function servicedependency_validate($app, $deployment, $serviceDependencyInfo) { foreach ($serviceDependencyInfo as $key => $value) { switch ($key) { case "inherits_parent": validateBinary($app, $deployment, $key, $value); break; case "service_description": case "dependent_service_description": case "dependency_period": validateForbiddenChars($app, $deployment, '/[^\\w.-]/s', $key, $value); break; case "execution_failure_criteria": case "notification_failure_criteria": $opts = validateOptions($app, $deployment, $key, $value, array('o', 'w', 'u', 'c', 'p', 'n'), true); $serviceDependencyInfo[$key] = $opts; break; default: break; } } return $serviceDependencyInfo; }
function servicetemplate_validate($app, $deployment, $serviceTemplateInfo) { foreach ($serviceTemplateInfo as $key => $value) { switch ($key) { case "use": case "check_period": case "event_handler": case "notification_period": case "icon_image": validateForbiddenChars($app, $deployment, '/[^\\w.-]/s', $key, $value); break; case "servicegroups": if (is_array($value)) { $value = implode(',', $value); } validateForbiddenChars($app, $deployment, '/[^\\w.-]/s', $key, $value); break; case "is_volatile": case "active_checks_enabled": case "passive_checks_enabled": case "obsess_over_service": case "check_freshness": case "event_handler_enabled": case "flap_detection_enabled": case "parallelize_check": case "process_perf_data": case "retain_status_information": case "retain_nonstatus_information": case "notifications_enabled": validateBinary($app, $deployment, $key, $value); break; case "check_command": validateForbiddenChars($app, $deployment, '/[^\\w.-$\\/]/s', $key, $value); break; case "initial_state": $opts = validateOptions($app, $deployment, $key, $value, array('o', 'w', 'u', 'c'), true); $serviceTemplateInfo[$key] = $opts; break; case "max_check_attempts": validateInterval($app, $deployment, $key, $value, 1, 20); break; case "check_interval": validateInterval($app, $deployment, $key, $value, 1, 1440); break; case "retry_interval": validateInterval($app, $deployment, $key, $value, 1, 720); break; case "freshness_threshold": validateInterval($app, $deployment, $key, $value, 0, 86400); break; case "low_flap_threshold": validateInterval($app, $deployment, $key, $value, 0, 99); break; case "high_flap_threshold": validateInterval($app, $deployment, $key, $value, 0, 100); break; case "flap_detection_options": $opts = validateOptions($app, $deployment, $key, $value, array('o', 'w', 'c', 'u'), true); $serviceTemplateInfo[$key] = $opts; break; case "notification_interval": case "first_notification_delay": validateInterval($app, $deployment, $key, $value, 0, 1440); break; case "notification_options": $opts = validateOptions($app, $deployment, $key, $value, array('w', 'u', 'c', 'r', 'f', 's'), true); $serviceTemplateInfo[$key] = $opts; break; case "contacts": case "contact_groups": if (is_array($value)) { $value = implode(',', $value); } validateForbiddenChars($app, $deployment, '/[^\\w.-]/s', $key, $value); break; case "stalking_options": $opts = validateOptions($app, $deployment, $key, $value, array('o', 'w', 'u', 'c'), true); $serviceTemplateInfo[$key] = $opts; break; case "icon_image_alt": validateForbiddenChars($app, $deployment, '/[^\\w.-\\s]/s', $key, $value); break; default: break; } } // We never want to see single threaded checks running, force this... if (!isset($serviceTemplateInfo['parallelize_check']) || empty($serviceTemplateInfo['parallelize_check'])) { $serviceTemplateInfo['parallelize_check'] = 1; } // Don't register since we are a template $serviceTemplateInfo['register'] = 0; return $serviceTemplateInfo; }
case "obsess_over_hosts": case "obsess_over_services": case "passive_host_checks_are_soft": case "retained_contact_host_attribute_mask": case "retained_contact_service_attribute_mask": case "retained_host_attribute_mask": case "retained_service_attribute_mask": case "retained_process_host_attribute_mask": case "retained_process_service_attribute_mask": case "translate_passive_host_checks": case "use_aggressive_host_checking": case "use_embedded_perl_implicitly": case "use_regexp_matching": case "use_true_regexp_matching": case "process_performance_data": validateBinary($app, $deployment, $key, $nagiosConfigInfo[$key]); break; case "host_perfdata_file_processing_interval": case "service_perfdata_file_processing_interval": case "max_check_result_file_age": validateInterval($app, $deployment, $key, $nagiosConfigInfo[$key], 0, 86400); break; case "cached_host_check_horizon": case "cached_service_check_horizon": case "host_freshness_check_interval": validateInterval($app, $deployment, $key, $nagiosConfigInfo[$key], 0, 3600); break; case "check_result_reaper_frequency": case "event_handler_timeout": case "host_check_timeout": case "max_check_result_reaper_time":
$tmpl->setvar('bin_unzip', $cfg["bin_unzip"]); $tmpl->setvar('validate_unzip', validateBinary($cfg["bin_unzip"])); $tmpl->setvar('bin_cksfv', $cfg["bin_cksfv"]); $tmpl->setvar('validate_cksfv', validateBinary($cfg["bin_cksfv"])); $tmpl->setvar('bin_vlc', $cfg["bin_vlc"]); $tmpl->setvar('validate_vlc', validateBinary($cfg["bin_vlc"])); $tmpl->setvar('php_uname1', php_uname('s')); $tmpl->setvar('php_uname2', php_uname('r')); $tmpl->setvar('bin_unrar', $cfg["bin_unrar"]); $tmpl->setvar('validate_unrar', validateBinary($cfg["bin_unrar"])); switch ($cfg["_OS"]) { case 1: $tmpl->setvar('loadavg_path', $cfg["loadavg_path"]); $tmpl->setvar('validate_loadavg', validateFile($cfg["loadavg_path"])); $tmpl->setvar('bin_netstat', $cfg["bin_netstat"]); $tmpl->setvar('validate_netstat', validateBinary($cfg["bin_netstat"])); break; case 2: $tmpl->setvar('bin_sockstat', $cfg["bin_sockstat"]); $tmpl->setvar('validate_sockstat', validateBinary($cfg["bin_sockstat"])); break; } // $tmpl->setvar('_OS', $cfg["_OS"]); // tmplSetTitleBar("Administration - Server Settings"); tmplSetAdminMenu(); tmplSetFoot(); tmplSetIidVars(); // parse template $tmpl->pparse();
function hosttemplate_validate($app, $deployment, $hostTemplateInfo) { foreach ($hostTemplateInfo as $key => $value) { switch ($key) { case "check_command": validateForbiddenChars($app, $deployment, '/[^\\w.-$\\/]/s', $key, $value); break; case "initial_state": $opts = validateOptions($app, $deployment, $key, $value, array('o', 'd', 'u'), true); $hostTemplateInfo[$key] = $opts; break; case "max_check_attempts": validateInterval($app, $deployment, $key, $value, 1, 20); break; case "check_interval": case "notification_interval": case "first_notification_delay": validateInterval($app, $deployment, $key, $value, 1, 1440); break; case "retry_interval": validateInterval($app, $deployment, $key, $value, 1, 720); break; case "active_checks_enabled": case "passive_checks_enabled": case "obsess_over_host": case "check_freshness": case "event_handler_enabled": case "flap_detection_enabled": case "process_perf_data": case "retain_status_information": case "retain_nonstatus_information": case "notifications_enabled": validateBinary($app, $deployment, $key, $value); break; case "check_period": case "event_handler": case "notification_period": case "icon_image": case "vrml_image": case "statusmap_image": case "use": validateForbiddenChars($app, $deployment, '/[^\\w.-]/s', $key, $value); break; case "freshness_threshold": validateInterval($app, $deployment, $key, $value, 0, 86400); break; case "low_flap_threshold": validateInterval($app, $deployment, $key, $value, 0, 99); break; case "high_flap_threshold": validateInterval($app, $deployment, $key, $value, 0, 100); break; case "flap_detection_options": $opts = validateOptions($app, $deployment, $key, $value, array('o', 'd', 'u'), true); $hostTemplateInfo[$key] = $opts; break; case "notification_options": $opts = validateOptions($app, $deployment, $key, $value, array('d', 'u', 'r', 'f', 's'), true); $hostTemplateInfo[$key] = $opts; break; case "stalking_options": $opts = validateOptions($app, $deployment, $key, $value, array('o', 'd', 'u'), true); $hostTemplateInfo[$key] = $opts; break; case "notes_url": case "action_url": validateUrl($app, $deployment, $key, $value); break; case "icon_image_alt": case "notes": validateForbiddenChars($app, $deployment, '/[^\\w.-\\s]/s', $key, $value); break; case "hostgroups": case "parents": if (is_array($value)) { $value = implode(',', $value); } validateForbiddenChars($app, $deployment, '/[^\\w.-]/s', $key, $value); break; default: break; } } // Don't register since we are a template $hostTemplateInfo['register'] = 0; return $hostTemplateInfo; }