Use opendir instead of dir. Props nbachiyski. fixes #4450

git-svn-id: http://svn.automattic.com/wordpress/trunk@5867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-08-14 02:58:33 +00:00
parent 638d5e6e39
commit dc1c54a35c
4 changed files with 28 additions and 19 deletions

View File

@ -14,9 +14,9 @@ require_once ('admin-header.php');
// Load all importers so that they can register.
$import_loc = 'wp-admin/import';
$import_root = ABSPATH.$import_loc;
$imports_dir = @ dir($import_root);
$imports_dir = @ opendir($import_root);
if ($imports_dir) {
while (($file = $imports_dir->read()) !== false) {
while (($file = readdir($imports_dir) !== false) {
if ($file{0} == '.') {
continue;
} elseif (substr($file, -4) == '.php') {
@ -24,6 +24,7 @@ if ($imports_dir) {
}
}
}
@closedir($imports_dir);
$importers = get_importers();

View File

@ -42,15 +42,15 @@ function get_plugins() {
$plugin_root = ABSPATH . PLUGINDIR;
// Files in wp-content/plugins directory
$plugins_dir = @ dir( $plugin_root);
$plugins_dir = @ opendir( $plugin_root);
if ( $plugins_dir ) {
while (($file = $plugins_dir->read() ) !== false ) {
while (($file = readdir( $plugins_dir ) ) !== false ) {
if ( substr($file, 0, 1) == '.' )
continue;
if ( is_dir( $plugin_root.'/'.$file ) ) {
$plugins_subdir = @ dir( $plugin_root.'/'.$file );
$plugins_subdir = @ opendir( $plugin_root.'/'.$file );
if ( $plugins_subdir ) {
while (($subfile = $plugins_subdir->read() ) !== false ) {
while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
if ( substr($subfile, 0, 1) == '.' )
continue;
if ( substr($subfile, -4) == '.php' )
@ -63,6 +63,8 @@ function get_plugins() {
}
}
}
@closedir( $plugins_dir );
@closedir( $plugins_subdir );
if ( !$plugins_dir || !$plugin_files )
return $wp_plugins;

View File

@ -1103,9 +1103,9 @@ function make_site_theme_from_default($theme_name, $template) {
// Copy files from the default theme to the site theme.
//$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
$theme_dir = @ dir("$default_dir");
$theme_dir = @ opendir("$default_dir");
if ($theme_dir) {
while(($theme_file = $theme_dir->read()) !== false) {
while(($theme_file = readdir( $theme_dir )) !== false) {
if (is_dir("$default_dir/$theme_file"))
continue;
if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
@ -1113,6 +1113,7 @@ function make_site_theme_from_default($theme_name, $template) {
chmod("$site_dir/$theme_file", 0777);
}
}
@closedir($theme_dir);
// Rewrite the theme header.
$stylelines = explode("\n", implode('', file("$site_dir/style.css")));
@ -1136,9 +1137,9 @@ function make_site_theme_from_default($theme_name, $template) {
return false;
}
$images_dir = @ dir("$default_dir/images");
$images_dir = @ opendir("$default_dir/images");
if ($images_dir) {
while(($image = $images_dir->read()) !== false) {
while(($image = readdir($images_dir)) !== false) {
if (is_dir("$default_dir/images/$image"))
continue;
if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
@ -1146,6 +1147,7 @@ function make_site_theme_from_default($theme_name, $template) {
chmod("$site_dir/images/$image", 0777);
}
}
@closedir($images_dir);
}
// Create a site theme from the default theme.

View File

@ -118,46 +118,50 @@ function get_themes() {
$theme_loc = str_replace(ABSPATH, '', $theme_root);
// Files in wp-content/themes directory and one subdir down
$themes_dir = @ dir($theme_root);
$themes_dir = @ opendir($theme_root);
if ( !$themes_dir )
return false;
while ( ($theme_dir = $themes_dir->read()) !== false ) {
while ( ($theme_dir = readdir($themes_dir)) !== false ) {
if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
continue;
$stylish_dir = @ dir($theme_root . '/' . $theme_dir);
$stylish_dir = @ opendir($theme_root . '/' . $theme_dir);
$found_stylesheet = false;
while ( ($theme_file = $stylish_dir->read()) !== false ) {
while ( ($theme_file = readdir($stylish_dir)) !== false ) {
if ( $theme_file == 'style.css' ) {
$theme_files[] = $theme_dir . '/' . $theme_file;
$found_stylesheet = true;
break;
}
}
@closedir($stylish_dir);
if ( !$found_stylesheet ) { // look for themes in that dir
$subdir = "$theme_root/$theme_dir";
$subdir_name = $theme_dir;
$theme_subdir = @dir( $subdir );
while ( ($theme_dir = $theme_subdir->read()) !== false ) {
$theme_subdir = @ opendir( $subdir );
while ( ($theme_dir = readdir($theme_subdir)) !== false ) {
if ( is_dir( $subdir . '/' . $theme_dir) && is_readable($subdir . '/' . $theme_dir) ) {
if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
continue;
$stylish_dir = @ dir($subdir . '/' . $theme_dir);
$stylish_dir = @ opendir($subdir . '/' . $theme_dir);
$found_stylesheet = false;
while ( ($theme_file = $stylish_dir->read()) !== false ) {
while ( ($theme_file = readdir($stylish_dir)) !== false ) {
if ( $theme_file == 'style.css' ) {
$theme_files[] = $subdir_name . '/' . $theme_dir . '/' . $theme_file;
$found_stylesheet = true;
break;
}
}
@closedir($stylish_dir);
}
}
@closedir($theme_subdir);
$wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
}
}
}
@closedir($theme_dir);
if ( !$themes_dir || !$theme_files )
return $themes;