fix install_dir in include_dir and add optional regex

git-svn-id: http://www.observium.org/svn/observer/trunk@1369 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-07-16 09:23:02 +00:00
parent b27f7e08c6
commit 103187e4f4

View File

@@ -697,17 +697,17 @@ function isHexString($str)
} }
# Include all .inc.php files in $dir # Include all .inc.php files in $dir
function include_dir($dir) function include_dir($dir, $regex = "/\.inc\.php$/")
{ {
global $device, $config; global $device, $config;
if ($handle = opendir($dir)) if ($handle = opendir($config['install_dir'] . '/' . $dir))
{ {
while (false !== ($file = readdir($handle))) while (false !== ($file = readdir($handle)))
{ {
if (filetype($dir . '/' . $file) == 'file' && substr($file,strlen($file)-8) == '.inc.php') if (filetype($config['install_dir'] . '/' . $dir . '/' . $file) == 'file' && preg_match($regex, $file))
{ {
include($dir . '/' . $file); include($config['install_dir'] . '/' . $dir . '/' . $file);
} }
} }