From e5ae1698cac8f0eb222e23170cf3459bdff103c5 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 10 Jul 2007 17:36:59 +0000 Subject: [PATCH] more failsafe "glob()" method. git-svn-id: file:///svn/phpbb/trunk@7863 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_file.php | 11 ++++++++--- phpBB/includes/functions_module.php | 20 ++++++++++++++++++-- phpBB/includes/ucp/ucp_main.php | 2 +- phpBB/install/install_update.php | 21 ++++++++++++++++++++- phpBB/style.php | 21 ++++++++++++++++++++- 5 files changed, 67 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index 63eaa341f5..64a85db0b0 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -39,7 +39,7 @@ class acm global $phpEx; if (file_exists($this->cache_dir . 'data_global.' . $phpEx)) { - include($this->cache_dir . 'data_global.' . $phpEx); + @include($this->cache_dir . 'data_global.' . $phpEx); } else { @@ -159,7 +159,7 @@ class acm return false; } - include($this->cache_dir . "data{$var_name}.$phpEx"); + @include($this->cache_dir . "data{$var_name}.$phpEx"); return (isset($data)) ? $data : false; } else @@ -256,7 +256,12 @@ class acm } // The following method is more failproof than simply assuming the query is on line 3 (which it should be) - $check_line = file_get_contents($this->cache_dir . $entry); + $check_line = @file_get_contents($this->cache_dir . $entry); + + if (empty($check_line)) + { + continue; + } // Now get the contents between /* and */ $check_line = substr($check_line, strpos($check_line, '/* ') + 3, strpos($check_line, ' */') - strpos($check_line, '/* ') - 3); diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 073dfa60ad..ec7f7e230b 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -127,9 +127,25 @@ class p_master if (file_exists($user->lang_path . 'mods')) { $add_files = array(); - $info_files = glob($user->lang_path . 'mods/info_' . strtolower($this->p_class) . '_*.' . $phpEx, GLOB_NOSORT); + $info_files = @glob($user->lang_path . 'mods/info_' . strtolower($this->p_class) . '_*.' . $phpEx, GLOB_NOSORT); - if ($info_files !== false && sizeof($info_files)) + if (!is_array($info_files)) + { + $dir = @opendir($user->lang_path . 'mods'); + + if ($dir) + { + while (($entry = readdir($dir)) !== false) + { + if (strpos($entry, 'info_' . strtolower($this->p_class) . '_') === 0 && substr(strrchr($entry, '.'), 1) == $phpEx) + { + $add_files[] = 'mods/' . substr(basename($entry), 0, -(strlen($phpEx) + 1)); + } + } + closedir($dir); + } + } + else { foreach ($info_files as $file) { diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index f542bddec9..ba40397a55 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -235,7 +235,7 @@ class ucp_main if ($config['allow_forum_notify']) { - $forbidden_forums = $forbidden_forums = $auth->acl_getf('!f_read', true); + $forbidden_forums = $auth->acl_getf('!f_read', true); $forbidden_forums = array_unique(array_keys($forbidden_forums)); $sql_array = array( diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 2140e557e4..9bf475abfa 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -433,8 +433,27 @@ class install_update extends module else if (!$recache) { $last_change = $theme['theme_mtime']; + $file_list = @glob("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/*.css", GLOB_NOSORT); - foreach (glob("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/*.css", GLOB_NOSORT) as $file) + if ($file_list === false || $file_list === NULL) + { + $file_list = array(); + $dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme"); + + if ($dir) + { + while (($entry = readdir($dir)) !== false) + { + if (substr(strrchr($entry, '.'), 1) == 'css') + { + $file_list[] = $entry; + } + } + closedir($dir); + } + } + + foreach ($file_list as $file) { if ($last_change < @filemtime($file)) { diff --git a/phpBB/style.php b/phpBB/style.php index 58eabd0e7f..f49acc44d3 100644 --- a/phpBB/style.php +++ b/phpBB/style.php @@ -141,8 +141,27 @@ if ($id && $sid) else if (!$recache) { $last_change = $theme['theme_mtime']; + $file_list = @glob("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/*.css", GLOB_NOSORT); - foreach (glob("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/*.css", GLOB_NOSORT) as $file) + if (!is_array($file_list)) + { + $file_list = array(); + $dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme"); + + if ($dir) + { + while (($entry = readdir($dir)) !== false) + { + if (substr(strrchr($entry, '.'), 1) == 'css') + { + $file_list[] = $entry; + } + } + closedir($dir); + } + } + + foreach ($file_list as $file) { if ($last_change < @filemtime($file)) {