From c99fee75df563bacab8731bc839ef119fc191661 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Thu, 21 Apr 2016 08:08:17 +1000 Subject: [PATCH] Sort services list --- html/includes/modal/new_service.inc.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/html/includes/modal/new_service.inc.php b/html/includes/modal/new_service.inc.php index e1b973c74f..9891c2441e 100644 --- a/html/includes/modal/new_service.inc.php +++ b/html/includes/modal/new_service.inc.php @@ -11,17 +11,20 @@ * the source code distribution for details. */ -if(is_admin() !== false) { +if (is_admin() !== false) { // Build the types list. - if ($handle = opendir($config['nagios_plugins'])) { - while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) { - list(,$check_name) = explode('_',$file,2); + $dir = $config['nagios_plugins']; + if (file_exists($dir) && is_dir($dir)) { + $files = scandir($dir); + $dir .= DIRECTORY_SEPARATOR; + d_print_r($files); + foreach ($files as $file) { + if (is_executable($dir.$file) && is_file($dir.$file) && strstr($file, 'check_')) { + list(,$check_name) = explode('_', $file, 2); $stype .= ""; } } - closedir($handle); } ?> @@ -142,4 +145,4 @@ $('#service-submit').click('', function(e) {