From 179c77ccddcd8bd4df2f29d05b460c6365396d49 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 9 Jul 2007 11:33:14 +0000 Subject: - do not include if there are no files fetched with glob() - allow options for merged files on update (merge, new file, old file) git-svn-id: file:///svn/phpbb/trunk@7848 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_module.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_module.php') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 1010de643b..073dfa60ad 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -127,10 +127,14 @@ 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); - foreach (glob($user->lang_path . 'mods/info_' . strtolower($this->p_class) . '_*.' . $phpEx, GLOB_NOSORT) as $file) + if ($info_files !== false && sizeof($info_files)) { - $add_files[] = 'mods/' . substr(basename($file), 0, -(strlen($phpEx) + 1)); + foreach ($info_files as $file) + { + $add_files[] = 'mods/' . substr(basename($file), 0, -(strlen($phpEx) + 1)); + } } if (sizeof($add_files)) -- cgit v1.2.1 From e5ae1698cac8f0eb222e23170cf3459bdff103c5 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 10 Jul 2007 17:36:59 +0000 Subject: more failsafe "glob()" method. git-svn-id: file:///svn/phpbb/trunk@7863 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_module.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_module.php') 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) { -- cgit v1.2.1 From 484d214ef71540b462fb72a0867cb56e61c2bb7f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 17 Jul 2007 16:08:42 +0000 Subject: 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 --- phpBB/includes/functions_module.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'phpBB/includes/functions_module.php') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index ec7f7e230b..cb5536eb1d 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -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'); + $dir = @opendir($user->lang_path . 'mods'); - if ($dir) + 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)) -- cgit v1.2.1 From 959448c9353b36791ca51b9dc9d84d53b8db8072 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 24 Jul 2007 15:20:32 +0000 Subject: + some fixes git-svn-id: file:///svn/phpbb/trunk@7938 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_module.php | 56 ++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'phpBB/includes/functions_module.php') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index cb5536eb1d..9db2c4fa25 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -124,29 +124,7 @@ class p_master $this->module_cache['modules'] = array_merge($this->module_cache['modules']); // Include MOD _info files for populating language entries within the menus - if (file_exists($user->lang_path . 'mods')) - { - $add_files = array(); - - $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); - } - - if (sizeof($add_files)) - { - $user->add_lang($add_files); - } - } + $this->add_mod_info($this->p_class); // Now build the module array, but exclude completely empty categories... $right_id = false; @@ -824,6 +802,38 @@ class p_master } } } + + /** + * Add custom MOD info language file + */ + function add_mod_info($module_class) + { + global $user, $phpEx; + + if (file_exists($user->lang_path . 'mods')) + { + $add_files = array(); + + $dir = @opendir($user->lang_path . 'mods'); + + if ($dir) + { + while (($entry = readdir($dir)) !== false) + { + if (strpos($entry, 'info_' . strtolower($module_class) . '_') === 0 && substr(strrchr($entry, '.'), 1) == $phpEx) + { + $add_files[] = 'mods/' . substr(basename($entry), 0, -(strlen($phpEx) + 1)); + } + } + closedir($dir); + } + + if (sizeof($add_files)) + { + $user->add_lang($add_files); + } + } + } } ?> \ No newline at end of file -- cgit v1.2.1