我正在尝试将一个文件从Wordpress安装的Plugin目录复制到Wordpress的根目录。无论安装在哪里,我都需要这样的功能。它是为我的Wordpress插件设计的,在我测试过的网站上似乎不起作用。
不知怎么的,我在想我没有在function destpath()
函数中捕获每个可能的目录位置。我需要它成功地找到插件文件夹的确切目录,以便它将文件(process.php)复制到确切的根目录,无论Wordpress安装的位置如何。
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());
根据源代码,MalwareFinder
类的destpath
和pluginpath
方法似乎被注入到printAdminPage
函数中:
源代码行:83:
function printAdminPage() {
源代码行:108(如果出现则关闭):
<?php }
源代码行:111-133(仍在printAdminPage中):
function destpath() { ... }
源代码行:136-158(仍在printAdminPage中):
function pluginpath() { ... }
源代码行:205:
}//End function printAdminPage()
此外,在第62行和第65行,这些php标记似乎是不必要的。