2012-11-05 56 views
0

我正在尋找一種方法來打開文檔,在這種情況下,下面的代碼是我寫的函數的輸出。在這個輸出中,我可以訪問一些我想編輯的附加文件,在這種情況下是css文件。PHP管理和編輯CSS或其他文件

我點擊它們後可以獲得如何打開/編輯它們的想法嗎?

<tr> 
     <td class="form_select"><input id="select_all_form15" name="select_all_form15" type="checkbox" value="Forms" class="case" /></td> 
     <td class="form_id">1334261250</td> 
     <td class="form_url"><a href="/forms/hatternet/deland/email/index.php" target="_blank">Lifetime Email Request</a></td> 
     <td class="form_autofill">HATTERNET</td> 
     <td class="form_save">form.css</td> 
     <td class="form_save"></td> 
     <td class="form_save"></td> 
     <td class="form_save"></td> 
     <td class="form_dates"></td> 
</tr> 
+1

您需要閱讀文件的內容並將其放入textarea。 – Pitchinnate

+0

但我該如何處理呢?我正在考慮使用fopen – Gromstone

回答

3

你會需要一個額外的腳本來處理這個問題,但你正在尋找的功能,從磁盤中讀取整個文件,以一個變量是:

file_get_contents(); // Reads the contents of a file into a variable 
file_put_contents(); // Writes a variable to a file 

文檔是在這裏:http://ca3.php.net/manual/en/function.file-get-contents.php 和:http://ca3.php.net/manual/en/function.file-put-contents.php

然後你必須輸出文件的內容正在編輯一個文本,這樣就可以對其進行編輯,然後當你發佈的更改回來,你必須把它們寫再次到文件。

但是,使用這種技術,你必須非常小心,可能會徹底搞砸自己。您只需將文件編輯限制爲您實際希望用戶編輯的文件。因此,如果只有style.css應該是可編輯的,那麼請確保您的腳本只能讀取和寫入該文件,而不是其他文件。

您還需要確保在此腳本前面有某種身份驗證,以便其他人無法更改您的網站。

0

您可以使用file_get_contents()來獲取文件的內容。您可以將此數據回顯到文本區域或其他任何地方,然後使用file_put_contents()來更新文件。

編輯:哎呀,捱打吧! :)