diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acm/acm_file.php | 30 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_board.php | 26 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_database.php | 28 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_language.php | 30 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_modules.php | 8 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_permission_roles.php | 8 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_search.php | 16 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_styles.php | 73 | ||||
-rw-r--r-- | phpBB/includes/captcha/captcha_gd.php | 8 | ||||
-rw-r--r-- | phpBB/includes/functions_admin.php | 12 | ||||
-rw-r--r-- | phpBB/includes/functions_template.php | 3 | ||||
-rw-r--r-- | phpBB/includes/session.php | 2 |
12 files changed, 163 insertions, 81 deletions
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index ecc4db8a89..e5ffe16d72 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -100,7 +100,13 @@ class acm { global $phpEx; - $dir = opendir($this->cache_dir); + $dir = @opendir($this->cache_dir); + + if (!$dir) + { + return; + } + while (($entry = readdir($dir)) !== false) { if (!preg_match('/^(sql_|data_(?!global))/', $entry)) @@ -115,7 +121,7 @@ class acm @unlink($this->cache_dir . $entry); } } - @closedir($dir); + closedir($dir); if (file_exists($this->cache_dir . 'data_global.' . $phpEx)) { @@ -190,7 +196,13 @@ class acm function purge() { // Purge all phpbb cache files - $dir = opendir($this->cache_dir); + $dir = @opendir($this->cache_dir); + + if (!$dir) + { + return; + } + while (($entry = readdir($dir)) !== false) { if (strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) @@ -200,7 +212,7 @@ class acm @unlink($this->cache_dir . $entry); } - @closedir($dir); + closedir($dir); unset($this->vars); unset($this->var_expires); @@ -221,7 +233,13 @@ class acm { $regex = '(' . ((is_array($table)) ? implode('|', $table) : $table) . ')'; - $dir = opendir($this->cache_dir); + $dir = @opendir($this->cache_dir); + + if (!$dir) + { + return; + } + while (($entry = readdir($dir)) !== false) { if (strpos($entry, 'sql_') !== 0) @@ -238,7 +256,7 @@ class acm @unlink($this->cache_dir . $entry); } } - @closedir($dir); + closedir($dir); return; } diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 3d3254d7d3..4216464718 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -397,16 +397,21 @@ class acp_board // Retrieve a list of auth plugins and check their config values $auth_plugins = array(); - $dp = opendir($phpbb_root_path . 'includes/auth'); - while (($file = readdir($dp)) !== false) + $dp = @opendir($phpbb_root_path . 'includes/auth'); + + if ($dp) { - if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file)) + while (($file = readdir($dp)) !== false) { - $auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file); + if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file)) + { + $auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file); + } } - } + closedir($dp); - sort($auth_plugins); + sort($auth_plugins); + } $updated_auth_settings = false; $old_auth_config = array(); @@ -575,7 +580,13 @@ class acp_board $auth_plugins = array(); - $dp = opendir($phpbb_root_path . 'includes/auth'); + $dp = @opendir($phpbb_root_path . 'includes/auth'); + + if (!$dp) + { + return ''; + } + while (($file = readdir($dp)) !== false) { if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file)) @@ -583,6 +594,7 @@ class acp_board $auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file); } } + closedir($dp); sort($auth_plugins); diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index 4cbbdf750b..2e75e59456 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -1212,24 +1212,28 @@ class acp_database } $dir = $phpbb_root_path . 'store/'; - $dh = opendir($dir); - while (($file = readdir($dh)) !== false) + $dh = @opendir($dir); + + if ($dh) { - if (preg_match('#^backup_(\d{10,})_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches)) + while (($file = readdir($dh)) !== false) { - $supported = in_array($matches[2], $methods); - - if ($supported == 'true') + if (preg_match('#^backup_(\d{10,})_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches)) { - $template->assign_block_vars('files', array( - 'FILE' => $file, - 'NAME' => gmdate("d-m-Y H:i:s", $matches[1]), - 'SUPPORTED' => $supported - )); + $supported = in_array($matches[2], $methods); + + if ($supported == 'true') + { + $template->assign_block_vars('files', array( + 'FILE' => $file, + 'NAME' => gmdate("d-m-Y H:i:s", $matches[1]), + 'SUPPORTED' => $supported + )); + } } } + closedir($dh); } - closedir($dh); $template->assign_vars(array( 'U_ACTION' => $this->u_action . '&action=submit' diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php index e83445eeed..a5b7974d70 100644 --- a/phpBB/includes/acp/acp_language.php +++ b/phpBB/includes/acp/acp_language.php @@ -940,31 +940,35 @@ class acp_language $db->sql_freeresult($result); $new_ary = $iso = array(); - $dp = opendir("{$phpbb_root_path}language"); + $dp = @opendir("{$phpbb_root_path}language"); - while (($file = readdir($dp)) !== false) + if ($dp) { - if ($file[0] != '.' && file_exists("{$phpbb_root_path}language/$file/iso.txt")) + while (($file = readdir($dp)) !== false) { - if (!in_array($file, $installed)) + if ($file[0] != '.' && file_exists("{$phpbb_root_path}language/$file/iso.txt")) { - if ($iso = file("{$phpbb_root_path}language/$file/iso.txt")) + if (!in_array($file, $installed)) { - if (sizeof($iso) == 3) + if ($iso = file("{$phpbb_root_path}language/$file/iso.txt")) { - $new_ary[$file] = array( - 'iso' => $file, - 'name' => trim($iso[0]), - 'local_name'=> trim($iso[1]), - 'author' => trim($iso[2]) - ); + if (sizeof($iso) == 3) + { + $new_ary[$file] = array( + 'iso' => $file, + 'name' => trim($iso[0]), + 'local_name'=> trim($iso[1]), + 'author' => trim($iso[2]) + ); + } } } } } + closedir($dp); } + unset($installed); - @closedir($dp); if (sizeof($new_ary)) { diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 9b42b7b8ba..24a9ed832f 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -512,7 +512,13 @@ class acp_modules if (!$module) { - $dh = opendir($directory); + $dh = @opendir($directory); + + if (!$dh) + { + return $fileinfo; + } + while (($file = readdir($dh)) !== false) { // Is module? diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 36068fe2dd..fe583c5a4a 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -394,8 +394,10 @@ class acp_permission_roles $s_role_options = ''; while ($row = $db->sql_fetchrow($result)) { + $role_name = (!empty($user->lang[$row['role_name']])) ? $user->lang[$row['role_name']] : $row['role_name']; + $template->assign_block_vars('roles', array( - 'ROLE_NAME' => (!empty($user->lang[$row['role_name']])) ? $user->lang[$row['role_name']] : $row['role_name'], + 'ROLE_NAME' => $role_name, 'ROLE_DESCRIPTION' => (!empty($user->lang[$row['role_description']])) ? $user->lang[$row['role_description']] : nl2br($row['role_description']), 'U_EDIT' => $this->u_action . '&action=edit&role_id=' . $row['role_id'], @@ -405,12 +407,12 @@ class acp_permission_roles 'U_DISPLAY_ITEMS' => ($row['role_id'] == $display_item) ? '' : $this->u_action . '&display_item=' . $row['role_id'] . '#assigned_to') ); - $s_role_options .= '<option value="' . $row['role_id'] . '">' . $row['role_name'] . '</option>'; + $s_role_options .= '<option value="' . $row['role_id'] . '">' . $role_name . '</option>'; if ($display_item == $row['role_id']) { $template->assign_vars(array( - 'L_ROLE_ASSIGNED_TO' => sprintf($user->lang['ROLE_ASSIGNED_TO'], $row['role_name'])) + 'L_ROLE_ASSIGNED_TO' => sprintf($user->lang['ROLE_ASSIGNED_TO'], $role_name)) ); } } diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index ad3e770fbb..4dcb8876e1 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -485,15 +485,21 @@ class acp_search $search_types = array(); - $dp = opendir($phpbb_root_path . 'includes/search'); - while (($file = readdir($dp)) !== false) + $dp = @opendir($phpbb_root_path . 'includes/search'); + + if ($dp) { - if ((preg_match('#\.' . $phpEx . '$#', $file)) && ($file != "search.$phpEx")) + while (($file = readdir($dp)) !== false) { - $search_types[] = preg_replace('#^(.*?)\.' . $phpEx . '$#', '\1', $file); + if ((preg_match('#\.' . $phpEx . '$#', $file)) && ($file != "search.$phpEx")) + { + $search_types[] = preg_replace('#^(.*?)\.' . $phpEx . '$#', '\1', $file); + } } + closedir($dp); + + sort($search_types); } - sort($search_types); return $search_types; } diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 29d38a4c19..b301f6d2ce 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -527,30 +527,35 @@ parse_css_file = {PARSE_CSS_FILE} // Grab uninstalled items $new_ary = $cfg = array(); - $dp = opendir("{$phpbb_root_path}styles"); - while (($file = readdir($dp)) !== false) + $dp = @opendir("{$phpbb_root_path}styles"); + + if ($dp) { - $subpath = ($mode != 'style') ? "$mode/" : ''; - if ($file[0] != '.' && file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) + while (($file = readdir($dp)) !== false) { - if ($cfg = file("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) + $subpath = ($mode != 'style') ? "$mode/" : ''; + if ($file[0] != '.' && file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) { - $items = parse_cfg_file('', $cfg); - $name = (isset($items['name'])) ? trim($items['name']) : false; - - if ($name && !in_array($name, $installed)) + if ($cfg = file("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) { - $new_ary[] = array( - 'path' => $file, - 'name' => $name, - 'copyright' => $items['copyright'], - ); + $items = parse_cfg_file('', $cfg); + $name = (isset($items['name'])) ? trim($items['name']) : false; + + if ($name && !in_array($name, $installed)) + { + $new_ary[] = array( + 'path' => $file, + 'name' => $name, + 'copyright' => $items['copyright'], + ); + } } } } + @closedir($dp); } + unset($installed); - @closedir($dp); if (sizeof($new_ary)) { @@ -1431,28 +1436,38 @@ parse_css_file = {PARSE_CSS_FILE} $imagesetlist = array('nolang' => array(), 'lang' => array()); $dir = "{$phpbb_root_path}styles/$imageset_path/imageset"; - $dp = opendir($dir); - while (($file = readdir($dp)) !== false) + $dp = @opendir($dir); + + if ($dp) { - if (!is_file($dir . '/' . $file) && !is_link($dir . '/' . $file) && $file[0] != '.' && strtoupper($file) != 'CVS' && !sizeof($imagesetlist['lang'])) + while (($file = readdir($dp)) !== false) { - $dp2 = opendir("$dir/$file"); - while (($file2 = readdir($dp2)) !== false) + if (!is_file($dir . '/' . $file) && !is_link($dir . '/' . $file) && $file[0] != '.' && strtoupper($file) != 'CVS' && !sizeof($imagesetlist['lang'])) { - $imglang = $file; - if (preg_match('#\.(?:gif|jpg|png)$#', $file2)) + $dp2 = @opendir("$dir/$file"); + + if (!$dp2) { - $imagesetlist['lang'][] = "$file/$file2"; + continue; } + + while (($file2 = readdir($dp2)) !== false) + { + $imglang = $file; + if (preg_match('#\.(?:gif|jpg|png)$#', $file2)) + { + $imagesetlist['lang'][] = "$file/$file2"; + } + } + closedir($dp2); + } + else if (preg_match('#\.(?:gif|jpg|png)$#', $file)) + { + $imagesetlist['nolang'][] = $file; } - closedir($dp2); - } - else if (preg_match('#\.(?:gif|jpg|png)$#', $file)) - { - $imagesetlist['nolang'][] = $file; } + closedir($dp); } - closedir($dp); // Make sure the list of possible images is sorted alphabetically sort($imagesetlist['nolang']); diff --git a/phpBB/includes/captcha/captcha_gd.php b/phpBB/includes/captcha/captcha_gd.php index c513c45fe7..e76358d2a7 100644 --- a/phpBB/includes/captcha/captcha_gd.php +++ b/phpBB/includes/captcha/captcha_gd.php @@ -137,7 +137,13 @@ class captcha { global $phpbb_root_path; - $dr = opendir($phpbb_root_path . 'includes/captcha/fonts'); + $dr = @opendir($phpbb_root_path . 'includes/captcha/fonts'); + + if (!$dr) + { + trigger_error('Unable to open includes/captcha/fonts directory.', E_USER_ERROR); + } + while (false !== ($entry = readdir($dr))) { if (strtolower(pathinfo($entry, PATHINFO_EXTENSION)) == 'ttf') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index cb31e3567a..4b40525881 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -345,7 +345,13 @@ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') return false; } - $dh = opendir($rootdir . $dir); + $dh = @opendir($rootdir . $dir); + + if (!$dh) + { + return false; + } + while (($fname = readdir($dh)) !== false) { if (is_file("$rootdir$dir$fname")) @@ -2677,9 +2683,9 @@ function add_permission_language() // Now search in acp and mods folder for permissions_ files. foreach (array('acp/', 'mods/') as $path) { - $dh = opendir($user->lang_path . $path); + $dh = @opendir($user->lang_path . $path); - if ($dh !== false) + if ($dh) { while (($file = readdir($dh)) !== false) { diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index 2bbd812678..3c7259fe0a 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -483,6 +483,7 @@ class template_compile // Allow checking if loops are set with .loopname // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example $blocks = explode('.', $varrefs[1]); + // If the block is nested, we have a reference that we can grab. // If the block is not nested, we just go and grab the block from _tpldata if (sizeof($blocks) > 1) @@ -490,12 +491,14 @@ class template_compile $block = array_pop($blocks); $namespace = implode('.', $blocks); $varref = $this->generate_block_data_ref($namespace, true); + // Add the block reference for the last child. $varref .= "['" . $block . "']"; } else { $varref = '$this->_tpldata'; + // Add the block reference for the last child. $varref .= "['" . $blocks[0] . "']"; } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 5ab9cf618d..dcc60f88b2 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1306,7 +1306,7 @@ class user extends session } $stylesheet = str_replace($match, $content, $stylesheet); } - unset ($content); + unset($content); } $stylesheet = str_replace('./', 'styles/' . $this->theme['theme_path'] . '/theme/', $stylesheet); |