opendir() should be rewritten to GET_DIR_AS_ARRAY()
authorRoland Häder <roland@mxchange.org>
Wed, 11 Mar 2009 18:17:29 +0000 (18:17 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 11 Mar 2009 18:17:29 +0000 (18:17 +0000)
inc/modules/admin/admin-inc.php
inc/modules/admin/overview-inc.php

index 7fbc40432c7cd187b575c972704b115b7a747026..7508d5c0275b3a7edd84c56ed9c121c3cea9ceee 100644 (file)
@@ -656,14 +656,14 @@ function ADMIN_SAVE_SETTINGS (&$POST, $tableName = "_config", $whereStatement =
 // Generate a selection box
 function ADMIN_MAKE_MENU_SELECTION ($menu, $type, $name, $default="") {
        // Open the requested menu directory
-       $handle = opendir(sprintf("%sinc/modules/%s/", constant('PATH'), $menu)) or mxchange_die("Cannot load menu ".$menu."!");
+       $menuArray = GET_DIR_AS_ARRAY(sprintf("inc/modules/%s/", $menu), "", false, false);
 
        // Init the selection box
        $OUT = "<select name=\"".$name."\" class=\"admin_select\" size=\"1\">
        <option value=\"\">{--IS_TOP_MENU--}</option>\n";
 
        // Walk through all files
-       while ($file = readdir($handle)) {
+       foreach ($menuArray as $file) {
                // Is this a PHP script?
                if (($file != ".") && ($file != "..") && ($file != "lost+found") && (strpos($file, "".$type."-") > -1) && (strpos($file, ".php") > 0)) {
                        // Then test if the file is readable
@@ -683,10 +683,9 @@ function ADMIN_MAKE_MENU_SELECTION ($menu, $type, $name, $default="") {
                                } // END - if
                        } // END - if
                } // END - if
-       } // END - while
+       } // END - foreach
 
-       // Close dir and selection box
-       closedir($handle);
+       // Close selection box
        $OUT .= "</select>\n";
        
        // Return contents
index 54f0fbf5b6cc90896814aed1a55745732bab1f1a..0ffec8391190adf76fed5d029ffb72774d6a6754 100644 (file)
@@ -52,8 +52,8 @@ function OUTPUT_STANDARD_OVERVIEW(&$result_tasks) {
        $jobsDone = true;
 
        // Open the extension directory
-       $handle = opendir(constant('PATH')."inc/extensions/") or mxchange_die("Cannot read extension directory!");
-       while ($file = readdir($handle)) {
+       $extensionList = GET_DIR_AS_ARRAY("inc/extensions/", "ext-", false, false);
+       foreach ($extensionList as $file) {
                // Is this file an extension?
                if ((substr($file, 0, 4) == "ext-") && (substr($file, -4) == ".php")) {
                        //* DEBUG: */ echo $file."<br />\n";
@@ -96,10 +96,7 @@ function OUTPUT_STANDARD_OVERVIEW(&$result_tasks) {
                                } // END - if
                        }
                } // END - if
-       } // END - while
-
-       // Close directory handle
-       closedir($handle);
+       } // END - foreach
 
        // At last - but not least - check for own and new unassigned tasks...
        $result_tasks = SQL_QUERY_ESC("SELECT id, assigned_admin, userid, task_type, subject, text, task_created