Dreamhost有時會無法刪除檔案和資料夾,可能是因為使用者變成 ‘dhapache’ ,其中之一的原因是若沒有設定PHP as CGI,執行某些PHP script時就會變這樣,但也有不知名的原因。

這裡提供一個script可以清理這些檔案,將 $startpath 設為要掃除的資料夾即可,記得使用前先備份。

<?php
$startpath = “/home/.raggs/DH_USERNAME/PATH/PATH/";

function ls($curpath) {
$dir = dir($curpath);
while ($file = $dir->read()) {
if($file != “." && $file != “..") {
if (is_dir($curpath.$file)) {
$stat = stat($curpath.$file);
if ($stat[4] == 999) {
// Once all of the dhapache files are deleted, uncomment the following line and refresh to delete the directories. Non-empty dirs will not be deleted, so any files not owned by “dhapache" may need to be manually deleted via FTP in order to delete the dhapache-owned directory.
// rmdir($curpath.$file);
echo(“$file – $stat[4]" . ‘
‘);
}
ls($curpath.$file."/");
} else {
$stat = stat($curpath.$file);
if ($stat[4] == 999) {
unlink($curpath.$file);
echo(“$file – $stat[4]" . ‘
‘);
}
}
}
}
$dir->close();
return;
}

ls($startpath);
?>

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: