it has been decided amongst the team that using glob() is bad practice, after determining the overall usage among projects as well as the security history of the function.

git-svn-id: file:///svn/phpbb/trunk@7900 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2007-07-17 16:08:42 +00:00
parent cc42f6ed22
commit 484d214ef7
3 changed files with 21 additions and 60 deletions

View file

@ -127,30 +127,19 @@ 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);
if (!is_array($info_files))
$dir = @opendir($user->lang_path . 'mods');
if ($dir)
{
$dir = @opendir($user->lang_path . 'mods');
if ($dir)
while (($entry = readdir($dir)) !== false)
{
while (($entry = readdir($dir)) !== false)
if (strpos($entry, 'info_' . strtolower($this->p_class) . '_') === 0 && substr(strrchr($entry, '.'), 1) == $phpEx)
{
if (strpos($entry, 'info_' . strtolower($this->p_class) . '_') === 0 && substr(strrchr($entry, '.'), 1) == $phpEx)
{
$add_files[] = 'mods/' . substr(basename($entry), 0, -(strlen($phpEx) + 1));
}
$add_files[] = 'mods/' . substr(basename($entry), 0, -(strlen($phpEx) + 1));
}
closedir($dir);
}
}
else
{
foreach ($info_files as $file)
{
$add_files[] = 'mods/' . substr(basename($file), 0, -(strlen($phpEx) + 1));
}
closedir($dir);
}
if (sizeof($add_files))

View file

@ -441,33 +441,19 @@ 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);
$dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme");
if ($file_list === false || $file_list === NULL)
if ($dir)
{
$file_list = array();
$dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme");
if ($dir)
while (($entry = readdir($dir)) !== false)
{
while (($entry = readdir($dir)) !== false)
if (substr(strrchr($entry, '.'), 1) == 'css' && $last_change < @filemtime("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/{$entry}"))
{
if (substr(strrchr($entry, '.'), 1) == 'css')
{
$file_list[] = "{$phpbb_root_path}styles/{$theme['theme_path']}/theme/{$entry}";
}
$recache = true;
break;
}
closedir($dir);
}
}
foreach ($file_list as $file)
{
if ($last_change < @filemtime($file))
{
$recache = true;
break;
}
closedir($dir);
}
}

View file

@ -141,33 +141,19 @@ 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);
$dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme");
if (!is_array($file_list))
if ($dir)
{
$file_list = array();
$dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme");
if ($dir)
while (($entry = readdir($dir)) !== false)
{
while (($entry = readdir($dir)) !== false)
if (substr(strrchr($entry, '.'), 1) == 'css' && $last_change < @filemtime("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/{$entry}"))
{
if (substr(strrchr($entry, '.'), 1) == 'css')
{
$file_list[] = "{$phpbb_root_path}styles/{$theme['theme_path']}/theme/{$entry}";
}
$recache = true;
break;
}
closedir($dir);
}
}
foreach ($file_list as $file)
{
if ($last_change < @filemtime($file))
{
$recache = true;
break;
}
closedir($dir);
}
}