2012-03-27 72 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標籤顯得不必要。

相關問題