I’m trying copy a single file from the Plugin directory inside of my WordPress installation to the root directory of the WordPress installation. I need the functionality to do this no matter where the installation is located. It’s for my WordPress plugin, and it doesn’t seem to be working on a site I tested.
Somehow I’m thinking that I’m not capturing each possible directory location in my function destpath() function. I need it to successfully find the exact directories of the Plugin folder so that it copies the file (process.php) to the exact root directory, no matter the location of the WordPress install.
function destpath()
{
$base = dirname(__FILE__);
$path = false;
if (@file_exists(dirname(dirname($base))."/wp-config.php")) {
$path = dirname(dirname($base))."/process.php";
} else
if (@file_exists(dirname(dirname(dirname($base)))."/wp-config.php")) {
$path = dirname(dirname(dirname($base)))."/process.php";
} else
$path = false;
if ($path != false) {
$path = str_replace("\\", "/", $path);
}
return $path;
}
function pluginpath()
{
$base = dirname(__FILE__);
$path = false;
if (@file_exists(dirname(dirname($base))."/wp-content/plugins/malware finder/process.php")) {
$path = dirname(dirname($base))."/wp-content/plugins/malware finder/process.php";
} else
if (@file_exists(dirname(dirname(dirname($base)))."/wp-content/plugins/malware finder/process.php")) {
$path = dirname(dirname(dirname($base)))."/wp-content/plugins/malware finder/process.php";
} else
$path = false;
if ($path != false) {
$path = str_replace("\\", "/", $path);
}
return $path;
}
copy(pluginpath(), destpath());
According to the source code, it looks like the
destpathandpluginpathmethods of theMalwareFinderclass are being injected into theprintAdminPagefunction:Source code line:83:
Source code line:108 (appears to close if):
Source code line:111-133 (still within printAdminPage):
Source code line:136-158 (still within printAdminPage):
Source code line:205:
Also, on lines 62 and 65, these php tags appear unnecessary.