2012-03-27 71 views
0

我试图将Wordpress安装中的插件目录中的单个文件复制到Wordpress安装的根目录。无论安装位于何处,我都需要该功能来执行此操作。这是我的Wordpress插件,它似乎并没有在我测试的网站上工作。将文件复制到主目录中的问题PHP

不知何故,我在想我并没有在我的function destpath()函数中捕获每个可能的目录位置。我需要它成功找到Plugin文件夹的确切目录,以便它将文件(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()); 
+2

您是否检查了您的文件夹的权限? – 2012-03-27 21:14:18

+0

检查您的日志文件,以获取可能的权限错误 – 2012-03-27 21:22:45

+0

我更改了Wordpress安装顶部的所有子目录的权限。仍然没有变化。感谢您的好建议。 – 2012-03-27 21:26:12

回答

1

根据该source code,它看起来像MalwareFinder类的destpathpluginpath方法被注入到printAdminPage功能:

源代码行:83:

function printAdminPage() { 

源代码行:108(看起来如果关闭):

<?php } 

的源代码行:111-133(还是内printAdminPage):

function destpath() { ... } 

的源代码行:136-158(还是内printAdminPage):

function pluginpath() { ... } 

的源代码行:205:

}//End function printAdminPage() 

另外,在第62行和第65行,这些php标签显得不必要。

相关问题