PDA

View Full Version : Max searchdepth for install.php in plugin installer


JBJBJB
11-26-2005, 06:44 PM
Hello,

While working on a plugin (indeed, the same one as my previous posting) I encountered that the plugin installer page of Subdreamer aggressively searches all subdirectories of the plugins directory for files with the name install.php and expects them all to be install files for a plugin.

This approach fails when a subdirectory of a plugin contains another product. The folks of that product also got the bright idea of calling *their* install file install.php (how surprising). Ofcourse this might happen with other things as well.

I worked around this by modifying the plugins.php page to assign a max searchdepth for the install.php files. Personally, I think it would be acceptable to demand plugins to put their install.php file in the subdirectory of their plugin or one level deeper, but no deeper than that. A searchdepth of 2 levels would then solve my problem.

Here's my modified code:


// ADDED: Define the current nesting level at which we are searching plugins
// This is used to prevent Subdreamer from looking too deep for install.php files
$currentSearchLevel=1;

function DisplayNewPlugins($dirname)
{
global $DB, $currentSearchLevel;
static $availableplugins;

// initialize some variables
$installtype = '';
$currentversion = '';

$d = dir($dirname);
while($entry = $d->read())
{
if($entry != "." && $entry != "..")
{
if(is_dir($dirname."/".$entry))
{
// ADDED, JB, 5-11-2005
// Added the currentSearchLevel check to prevent searching deeper than 2 levels
// Update the nesting level when entering a deeper level
if (&#036;currentSearchLevel<=2)
{
&#036;currentSearchLevel++;
DisplayNewPlugins(&#036;dirname."/".&#036;entry);
&#036;currentSearchLevel--;
}
}
...
...


Thanks in advance,
Jeroen