Make WordPress Core

Ticket #4450: opendir-instead-of-dir.diff

File opendir-instead-of-dir.diff, 5.9 KB (added by nbachiyski, 18 years ago)
  • wp-includes/theme.php

     
    118118        $theme_loc = str_replace(ABSPATH, '', $theme_root);
    119119
    120120        // Files in wp-content/themes directory and one subdir down
    121         $themes_dir = @ dir($theme_root);
     121        $themes_dir = @ opendir($theme_root);
    122122        if ( !$themes_dir )
    123123                return false;
    124124
    125         while ( ($theme_dir = $themes_dir->read()) !== false ) {
     125        while ( ($theme_dir = readdir($themes_dir)) !== false ) {
    126126                if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
    127127                        if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
    128128                                continue;
    129                         $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
     129                        $stylish_dir = @ opendir($theme_root . '/' . $theme_dir);
    130130                        $found_stylesheet = false;
    131                         while ( ($theme_file = $stylish_dir->read()) !== false ) {
     131                        while ( ($theme_file = readdir($stylish_dir)) !== false ) {
    132132                                if ( $theme_file == 'style.css' ) {
    133133                                        $theme_files[] = $theme_dir . '/' . $theme_file;
    134134                                        $found_stylesheet = true;
    135135                                        break;
    136136                                }
    137137                        }
     138                        @closedir($stylish_dir);
    138139                        if ( !$found_stylesheet ) { // look for themes in that dir
    139140                                $subdir = "$theme_root/$theme_dir";
    140141                                $subdir_name = $theme_dir;
    141                                 $theme_subdir = @dir( $subdir );
    142                                 while ( ($theme_dir = $theme_subdir->read()) !== false ) {
     142                                $theme_subdir = @ opendir( $subdir );
     143                                while ( ($theme_dir = readdir($theme_subdir)) !== false ) {
    143144                                        if ( is_dir( $subdir . '/' . $theme_dir) && is_readable($subdir . '/' . $theme_dir) ) {
    144145                                                if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
    145146                                                        continue;
    146                                                 $stylish_dir = @ dir($subdir . '/' . $theme_dir);
     147                                                $stylish_dir = @ opendir($subdir . '/' . $theme_dir);
    147148                                                $found_stylesheet = false;
    148                                                 while ( ($theme_file = $stylish_dir->read()) !== false ) {
     149                                                while ( ($theme_file = readdir($stylish_dir)) !== false ) {
    149150                                                        if ( $theme_file == 'style.css' ) {
    150151                                                                $theme_files[] = $subdir_name . '/' . $theme_dir . '/' . $theme_file;
    151152                                                                $found_stylesheet = true;
    152153                                                                break;
    153154                                                        }
    154155                                                }
     156                                                @closedir($stylish_dir);
    155157                                        }
    156158                                }
     159                                @closedir($theme_subdir);
    157160                                $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
    158161                        }
    159162                }
    160163        }
     164        @closedir($theme_dir);
    161165
    162166        if ( !$themes_dir || !$theme_files )
    163167                return $themes;
  • wp-admin/includes/plugin.php

     
    4242        $plugin_root = ABSPATH . PLUGINDIR;
    4343
    4444        // Files in wp-content/plugins directory
    45         $plugins_dir = @ dir( $plugin_root);
     45        $plugins_dir = @ opendir( $plugin_root);
    4646        if ( $plugins_dir ) {
    47                 while (($file = $plugins_dir->read() ) !== false ) {
     47                while (($file = readdir( $plugins_dir ) ) !== false ) {
    4848                        if ( substr($file, 0, 1) == '.' )
    4949                                continue;
    5050                        if ( is_dir( $plugin_root.'/'.$file ) ) {
    51                                 $plugins_subdir = @ dir( $plugin_root.'/'.$file );
     51                                $plugins_subdir = @ opendir( $plugin_root.'/'.$file );
    5252                                if ( $plugins_subdir ) {
    53                                         while (($subfile = $plugins_subdir->read() ) !== false ) {
     53                                        while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
    5454                                                if ( substr($subfile, 0, 1) == '.' )
    5555                                                        continue;
    5656                                                if ( substr($subfile, -4) == '.php' )
     
    6363                        }
    6464                }
    6565        }
     66        @closedir( $plugins_dir );
     67        @closedir( $plugins_subdir );
    6668
    6769        if ( !$plugins_dir || !$plugin_files )
    6870                return $wp_plugins;
     
    377379        return true;
    378380}
    379381
    380 ?>
    381  No newline at end of file
     382?>
  • wp-admin/includes/upgrade.php

     
    10891089        // Copy files from the default theme to the site theme.
    10901090        //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
    10911091
    1092         $theme_dir = @ dir("$default_dir");
     1092        $theme_dir = @ opendir("$default_dir");
    10931093        if ($theme_dir) {
    1094                 while(($theme_file = $theme_dir->read()) !== false) {
     1094                while(($theme_file = readdir( $theme_dir )) !== false) {
    10951095                        if (is_dir("$default_dir/$theme_file"))
    10961096                                continue;
    10971097                        if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
     
    10991099                        chmod("$site_dir/$theme_file", 0777);
    11001100                }
    11011101        }
     1102        @closedir($theme_dir);
    11021103
    11031104        // Rewrite the theme header.
    11041105        $stylelines = explode("\n", implode('', file("$site_dir/style.css")));
     
    11221123                return false;
    11231124        }
    11241125
    1125         $images_dir = @ dir("$default_dir/images");
     1126        $images_dir = @ opendir("$default_dir/images");
    11261127        if ($images_dir) {
    1127                 while(($image = $images_dir->read()) !== false) {
     1128                while(($image = readdir($images_dir)) !== false) {
    11281129                        if (is_dir("$default_dir/images/$image"))
    11291130                                continue;
    11301131                        if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
     
    11321133                        chmod("$site_dir/images/$image", 0777);
    11331134                }
    11341135        }
     1136        @closedir($images_dir);
    11351137}
    11361138
    11371139// Create a site theme from the default theme.
     
    12181220        }
    12191221}
    12201222
    1221 ?>
    1222  No newline at end of file
     1223?>
  • wp-admin/import.php

     
    1414// Load all importers so that they can register.
    1515$import_loc = 'wp-admin/import';
    1616$import_root = ABSPATH.$import_loc;
    17 $imports_dir = @ dir($import_root);
     17$imports_dir = @ opendir($import_root);
    1818if ($imports_dir) {
    19         while (($file = $imports_dir->read()) !== false) {
     19        while (($file = readdir($imports_dir) !== false) {
    2020                if ($file{0} == '.') {
    2121                        continue;
    2222                } elseif (substr($file, -4) == '.php') {
     
    2424                }
    2525        }
    2626}
     27@closedir($imports_dir);
    2728
    2829$importers = get_importers();
    2930