note 51619 deleted from function.get-loaded-extensions by betz

From: Date: Tue, 05 Apr 2005 20:59:47 +0000
Subject: note 51619 deleted from function.get-loaded-extensions by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-87534@lists.php.net to get a copy of this message
Note Submitter: saidevATgmail.com Reason: bad code ---- 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; } ?>

« previous php.notes (#87534) next »