note 51619 added to function.get-loaded-extensions
| From: | saidevATgmail dot com at osu1 dot php dot net | Date: | Tue, 05 Apr 2005 20:46:51 +0000 |
| Subject: | note 51619 added to function.get-loaded-extensions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87532@lists.php.net to get a copy of this message | ||
I was compiling a new server, my previous version had all kinds of modules installed but thinking
the new server should only support the modules that is in production.
/*
This script is to use to see if any of the web pages is using
the loaded modules, it will parse all php files of a given't path to search every page
for those functions that might be associated with the modules.
This is useful if you have many modules compile in the current version of PHP but
wanting to upgrade with less modules and not knowing which module functions the programmer
might have used.
*/
//get all extensions that are loaded
$loadedExt = get_loaded_extensions();
$extFuns = array();
$fileslist = array();
$fileslist = getAllPHP("/usr/local/apache/htdocs");
//there might be files with no read permission, avoiding getting warning message
ini_set("display_errors",0);
foreach ($loadedExt as $ext) {
//skipping some standard modules
if (strtolower($ext) != "standard" && strtolower($ext) != "sybase_ct"
&&
strtolower($ext) != "session" && strtolower($ext) != "mysql"
&&
strtolower($ext) != "gettext") {
echo "Scanning Module <strong>$ext</strong><BR>";
//get all functions for current scanning modules
$extFuns = get_extension_funcs($ext);
//loop thru each module functions
foreach ($extFuns as $function) {
for ($i = 0 ; $i < count($fileslist); $i++) {
$fileRead = fopen($fileslist[$i],"r");
$fileContent = fread($fileRead,filesize($fileslist[$i]));
if (ereg($function,$fileContent)) {
echo "<strong>$function</strong> used in
".$fileslist[$i]."<BR>";
}
unset($fileContent);
fclose($fileRead);
}
}
}
}
ini_set("display_errors",1);
//get all php files from given directory
//modified version of Jason Wong @ http://us3.php.net/manual/en/function.readdir.php
example
function getAllPHP($dir) {
$file_list = '';
$stack[] = $dir;
while ($stack) {
$current_dir = array_pop($stack);
if ($dh = opendir($current_dir)) {
while (($file = readdir($dh)) !== false) {
if ($file !== '.' AND $file !== '..') {
$current_file = "{$current_dir}/{$file}";
if (is_file($current_file)) {
if (eregi(".php",$file) || eregi(".inc",$file)) {
$file_list[] = "{$current_dir}/{$file}";
}
} elseif (is_dir($current_file)) {
$stack[] = $current_file;
}
}
}
}
}
return $file_list;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.get-loaded-extensions.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51619
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51619&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51619&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51619&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51619&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51619&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51619&report=yes
Search -- http://master.php.net/manage/user-notes.php