루트 권한이 없는 경우, data 폴더 삭제하기
data 폴더의 속성을 '707'이나 '777'로 바꿔줘도 삭제되지 않는 경우가 있습니다.
무료 웹 호스팅의 경우가 그런 것 같습니다.
첨부파일을 루트에 올리고, 브라우저에서 다음과 같이 실행해주면 됩니다.
(주소창에 아래와 같이 파일 주소를 넣고, Enter)
사이트 주소/del_directory.php
파일이름은 바꿔도 됩니다.
실행하면 폴더는 남아있지만, 내용은 모두 삭제됩니다.
내용은 사라지니 폴더는 FTP에서 삭제하면 됩니다.
실행 후, 위 파일(del_directory.php)은 FTP에서 삭제하십시오.
아래는 파일의 내용입니다.
[code]<?
function recusive_delete($directory) {
$dir = opendir($directory);
while ($d = readdir($dir)) {
if ($d == "." || $d == "..")
continue;
$xxx = "$directory/$d";
// 파일 그룹이 99 이면 nobody
$fgroup = filegroup($xxx);
if (is_dir($xxx)) {
recusive_delete($xxx);
if ($fgroup == 99) {
rmdir($xxx);
}
} else {
if ($fgroup == 99) {
unlink($xxx);
}
}
}
closedir($dir);
}
$directory = "data";
recusive_delete($directory);
?>[/code]
$directory = "삭제할 폴더";
출처 : http://free4u.wo.tc/1291
무료 웹 호스팅의 경우가 그런 것 같습니다.
첨부파일을 루트에 올리고, 브라우저에서 다음과 같이 실행해주면 됩니다.
(주소창에 아래와 같이 파일 주소를 넣고, Enter)
사이트 주소/del_directory.php
파일이름은 바꿔도 됩니다.
실행하면 폴더는 남아있지만, 내용은 모두 삭제됩니다.
내용은 사라지니 폴더는 FTP에서 삭제하면 됩니다.
실행 후, 위 파일(del_directory.php)은 FTP에서 삭제하십시오.
아래는 파일의 내용입니다.
[code]<?
function recusive_delete($directory) {
$dir = opendir($directory);
while ($d = readdir($dir)) {
if ($d == "." || $d == "..")
continue;
$xxx = "$directory/$d";
// 파일 그룹이 99 이면 nobody
$fgroup = filegroup($xxx);
if (is_dir($xxx)) {
recusive_delete($xxx);
if ($fgroup == 99) {
rmdir($xxx);
}
} else {
if ($fgroup == 99) {
unlink($xxx);
}
}
}
closedir($dir);
}
$directory = "data";
recusive_delete($directory);
?>[/code]
$directory = "삭제할 폴더";
출처 : http://free4u.wo.tc/1291
댓글 12개
Terrorboy
10년 전
기본적으로 폴더 삭제시 하위 폴더가 있을경우삭제가 안되는 경우가 간혹 있더라구요.
그래서 저는 아래 주어온 코드를 많이 사용합니다.
[code]
/*
지정 폴더의 자신을 포함한 하위 파일 까지 모두 삭제 한다.
http://flystone.tistory.com/54
*/
function rmdirAll($dir) {
$dirs = dir($dir);
while(false !== ($entry = $dirs->read())) {
if(($entry != '.') && ($entry != '..')) {
if(is_dir($dir.'/'.$entry)) {
rmdirAll($dir.'/'.$entry);
} else {
@unlink($dir.'/'.$entry);
}
}
}
$dirs->close();
@rmdir($dir);
}
[/code]
# 응용
[code]
define('DEL_DAYS', 3); // 삭제기준일
$DelDir = opendir(IMG_SERVER_PATH);
while($DelFile = readdir($DelDir)) {
# 중요파일 pass
if($DelFile=="."||$DelFile==".."||$DelFile=="index.html"||$DelFile=="index.php") continue;
# 업체 폴더 지정
$DelCorpDir = opendir(IMG_SERVER_PATH.'/'.$DelFile);
# 업체 폴더 내부로 진행
while($DelCorpFile = readdir($DelCorpDir)) {
if($DelCorpFile=="."||$DelCorpFile==".."||$DelCorpFile=="index.html"||$DelCorpFile=="index.php") continue;
$DelCorpPATH = IMG_SERVER_PATH.'/'.$DelFile.'/'.$DelCorpFile;
$DelCorpFileTime = floor((time() - strtotime($DelCorpFile))/86400);
if($DelCorpFileTime < DEL_DAYS) continue;
@rmdirAll(IMG_SERVER_PATH.'/'.$DelFile.'/'.$DelCorpFile);
}
}
[/code]
그래서 저는 아래 주어온 코드를 많이 사용합니다.
[code]
/*
지정 폴더의 자신을 포함한 하위 파일 까지 모두 삭제 한다.
http://flystone.tistory.com/54
*/
function rmdirAll($dir) {
$dirs = dir($dir);
while(false !== ($entry = $dirs->read())) {
if(($entry != '.') && ($entry != '..')) {
if(is_dir($dir.'/'.$entry)) {
rmdirAll($dir.'/'.$entry);
} else {
@unlink($dir.'/'.$entry);
}
}
}
$dirs->close();
@rmdir($dir);
}
[/code]
# 응용
[code]
define('DEL_DAYS', 3); // 삭제기준일
$DelDir = opendir(IMG_SERVER_PATH);
while($DelFile = readdir($DelDir)) {
# 중요파일 pass
if($DelFile=="."||$DelFile==".."||$DelFile=="index.html"||$DelFile=="index.php") continue;
# 업체 폴더 지정
$DelCorpDir = opendir(IMG_SERVER_PATH.'/'.$DelFile);
# 업체 폴더 내부로 진행
while($DelCorpFile = readdir($DelCorpDir)) {
if($DelCorpFile=="."||$DelCorpFile==".."||$DelCorpFile=="index.html"||$DelCorpFile=="index.php") continue;
$DelCorpPATH = IMG_SERVER_PATH.'/'.$DelFile.'/'.$DelCorpFile;
$DelCorpFileTime = floor((time() - strtotime($DelCorpFile))/86400);
if($DelCorpFileTime < DEL_DAYS) continue;
@rmdirAll(IMG_SERVER_PATH.'/'.$DelFile.'/'.$DelCorpFile);
}
}
[/code]
10년 전
감사합니다.
10년 전
우비 호스팅의 경우...
우비 사이트에 로그인 후,
계정 관리 → 디렉토리 및 파일 삭제
에서 삭제가 가능하네요.
우비 사이트에 로그인 후,
계정 관리 → 디렉토리 및 파일 삭제
에서 삭제가 가능하네요.
runga
9년 전
감사합니다~
10년 전
감사합니다.
10년 전
감사합니다
10년 전
매번 그누보드5 설치할때마다.. data 폴더 삭제가 안되서 고민하고.. 웹호스팅 업체에 문의 했었는데
이제 그럴 필요가 없네요^^
완전 좋네요^^ 한방에 해결!! 감사합니다.
이제 그럴 필요가 없네요^^
완전 좋네요^^ 한방에 해결!! 감사합니다.
돼지코구뇽
10년 전
스크랩합니다^^
runga
9년 전
주의하세요. db 파일까지 몽땅 날라갑니다. ㅠㅠ
9년 전
그렇던가요?
그 부분까지 확인해보지는 않았으나, 이 팁은 모든 것을 삭제하기 위한 것이니 DB까지 자동으로 삭제된다면 오히려 더 편한 일입니다.
그 부분까지 확인해보지는 않았으나, 이 팁은 모든 것을 삭제하기 위한 것이니 DB까지 자동으로 삭제된다면 오히려 더 편한 일입니다.
돼지코구뇽
8년 전
감사합니다
Winter0
4년 전
그누보드가 업데이트가 돼서 더이상 안되네요..ㅠㅠ
게시글 목록
| 번호 | 제목 |
|---|---|
| 24149 | |
| 24140 | |
| 24133 | |
| 24125 | |
| 24119 | |
| 24109 | |
| 24105 | |
| 24101 | |
| 24093 | |
| 24089 | |
| 24077 | |
| 24074 | |
| 24071 | |
| 24070 | |
| 24067 | |
| 24056 | |
| 24050 | |
| 24046 | |
| 24043 | |
| 24040 | |
| 24037 | |
| 24036 | |
| 24035 | |
| 24034 | |
| 24021 | |
| 24017 | |
| 24005 | |
| 24002 | |
| 23990 | |
| 23980 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기