Since there isn't any program written to check for module usage of your
current website, I decided to write on myself, hope this might be
helpful to others.
<?php
/*
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.
saidevATgmail.com
*/
//get all extensions that are loaded
$loadedExt = get_loaded_extensions();
$extFuns = array();
$fileslist = array();
$pathToCheck = "doc root"; //replace doc root with your document root
directory
$fileslist = getAllPHP($pathToCheck);
//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;
}
?>