Ticket #4450: opendir-instead-of-dir.diff
File opendir-instead-of-dir.diff, 5.9 KB (added by , 18 years ago) |
---|
-
wp-includes/theme.php
118 118 $theme_loc = str_replace(ABSPATH, '', $theme_root); 119 119 120 120 // Files in wp-content/themes directory and one subdir down 121 $themes_dir = @ dir($theme_root);121 $themes_dir = @ opendir($theme_root); 122 122 if ( !$themes_dir ) 123 123 return false; 124 124 125 while ( ($theme_dir = $themes_dir->read()) !== false ) {125 while ( ($theme_dir = readdir($themes_dir)) !== false ) { 126 126 if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { 127 127 if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) 128 128 continue; 129 $stylish_dir = @ dir($theme_root . '/' . $theme_dir);129 $stylish_dir = @ opendir($theme_root . '/' . $theme_dir); 130 130 $found_stylesheet = false; 131 while ( ($theme_file = $stylish_dir->read()) !== false ) {131 while ( ($theme_file = readdir($stylish_dir)) !== false ) { 132 132 if ( $theme_file == 'style.css' ) { 133 133 $theme_files[] = $theme_dir . '/' . $theme_file; 134 134 $found_stylesheet = true; 135 135 break; 136 136 } 137 137 } 138 @closedir($stylish_dir); 138 139 if ( !$found_stylesheet ) { // look for themes in that dir 139 140 $subdir = "$theme_root/$theme_dir"; 140 141 $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 ) { 143 144 if ( is_dir( $subdir . '/' . $theme_dir) && is_readable($subdir . '/' . $theme_dir) ) { 144 145 if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) 145 146 continue; 146 $stylish_dir = @ dir($subdir . '/' . $theme_dir);147 $stylish_dir = @ opendir($subdir . '/' . $theme_dir); 147 148 $found_stylesheet = false; 148 while ( ($theme_file = $stylish_dir->read()) !== false ) {149 while ( ($theme_file = readdir($stylish_dir)) !== false ) { 149 150 if ( $theme_file == 'style.css' ) { 150 151 $theme_files[] = $subdir_name . '/' . $theme_dir . '/' . $theme_file; 151 152 $found_stylesheet = true; 152 153 break; 153 154 } 154 155 } 156 @closedir($stylish_dir); 155 157 } 156 158 } 159 @closedir($theme_subdir); 157 160 $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); 158 161 } 159 162 } 160 163 } 164 @closedir($theme_dir); 161 165 162 166 if ( !$themes_dir || !$theme_files ) 163 167 return $themes; -
wp-admin/includes/plugin.php
42 42 $plugin_root = ABSPATH . PLUGINDIR; 43 43 44 44 // Files in wp-content/plugins directory 45 $plugins_dir = @ dir( $plugin_root);45 $plugins_dir = @ opendir( $plugin_root); 46 46 if ( $plugins_dir ) { 47 while (($file = $plugins_dir->read() ) !== false ) {47 while (($file = readdir( $plugins_dir ) ) !== false ) { 48 48 if ( substr($file, 0, 1) == '.' ) 49 49 continue; 50 50 if ( is_dir( $plugin_root.'/'.$file ) ) { 51 $plugins_subdir = @ dir( $plugin_root.'/'.$file );51 $plugins_subdir = @ opendir( $plugin_root.'/'.$file ); 52 52 if ( $plugins_subdir ) { 53 while (($subfile = $plugins_subdir->read() ) !== false ) {53 while (($subfile = readdir( $plugins_subdir ) ) !== false ) { 54 54 if ( substr($subfile, 0, 1) == '.' ) 55 55 continue; 56 56 if ( substr($subfile, -4) == '.php' ) … … 63 63 } 64 64 } 65 65 } 66 @closedir( $plugins_dir ); 67 @closedir( $plugins_subdir ); 66 68 67 69 if ( !$plugins_dir || !$plugin_files ) 68 70 return $wp_plugins; … … 377 379 return true; 378 380 } 379 381 380 ?> 381 No newline at end of file 382 ?> -
wp-admin/includes/upgrade.php
1089 1089 // Copy files from the default theme to the site theme. 1090 1090 //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css'); 1091 1091 1092 $theme_dir = @ dir("$default_dir");1092 $theme_dir = @ opendir("$default_dir"); 1093 1093 if ($theme_dir) { 1094 while(($theme_file = $theme_dir->read()) !== false) {1094 while(($theme_file = readdir( $theme_dir )) !== false) { 1095 1095 if (is_dir("$default_dir/$theme_file")) 1096 1096 continue; 1097 1097 if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) … … 1099 1099 chmod("$site_dir/$theme_file", 0777); 1100 1100 } 1101 1101 } 1102 @closedir($theme_dir); 1102 1103 1103 1104 // Rewrite the theme header. 1104 1105 $stylelines = explode("\n", implode('', file("$site_dir/style.css"))); … … 1122 1123 return false; 1123 1124 } 1124 1125 1125 $images_dir = @ dir("$default_dir/images");1126 $images_dir = @ opendir("$default_dir/images"); 1126 1127 if ($images_dir) { 1127 while(($image = $images_dir->read()) !== false) {1128 while(($image = readdir($images_dir)) !== false) { 1128 1129 if (is_dir("$default_dir/images/$image")) 1129 1130 continue; 1130 1131 if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) … … 1132 1133 chmod("$site_dir/images/$image", 0777); 1133 1134 } 1134 1135 } 1136 @closedir($images_dir); 1135 1137 } 1136 1138 1137 1139 // Create a site theme from the default theme. … … 1218 1220 } 1219 1221 } 1220 1222 1221 ?> 1222 No newline at end of file 1223 ?> -
wp-admin/import.php
14 14 // Load all importers so that they can register. 15 15 $import_loc = 'wp-admin/import'; 16 16 $import_root = ABSPATH.$import_loc; 17 $imports_dir = @ dir($import_root);17 $imports_dir = @ opendir($import_root); 18 18 if ($imports_dir) { 19 while (($file = $imports_dir->read()) !== false) {19 while (($file = readdir($imports_dir) !== false) { 20 20 if ($file{0} == '.') { 21 21 continue; 22 22 } elseif (substr($file, -4) == '.php') { … … 24 24 } 25 25 } 26 26 } 27 @closedir($imports_dir); 27 28 28 29 $importers = get_importers(); 29 30