윈도우 리눅스 공용입니다.
단 윈도우의 경우에는 소유권, 그룹정보는 가져오지 못합니다.
여러가지 활요예가 있겠지만
이런경우에 유용합니다.
압축을 하고 전혀 다른 계정에 압축을 풀었을때
퍼미션이나 소유권 문제때문에 고민할때 사용하면 유용합니다.
이하 소스입니다.
function Ysave_dir_owner_perm($dir, $debug=false){
if (!is_dir($dir)) return false;
if (!preg_match("`/$`", $dir)) $dir .= '/';
if (preg_match("`win`i", PHP_OS)) $os = 'windows';
else $os = 'unix or linux';
$text = '';
$d = dir($dir);
while (false !== ($entry = $d->read())) {
if (substr($entry, 0, 1) == '.') continue;
if ($os != 'windows') $text .= 'chown ' . fileowner($dir . $entry) . '.' . filegroup($dir . $entry) . ' ' . $dir . $entry . " \n";
$text .= 'chmod ' . substr(decoct(fileperms($dir . $entry)), -4) . ' ' . $dir . $entry . " \n";
if ($debug == true) {
if ($os != 'windows') echo 'chown ' . fileowner($dir . $entry) . '.' . filegroup($dir . $entry) . ' ' . $dir . $entry . " <br>\n";
echo 'chmod ' . substr(decoct(fileperms($dir . $entry)), -4) . ' ' . $dir . $entry . " <br>\n";
}
if (is_dir($dir . $entry)){
$text .= Ysave_dir_owner_perm($dir . $entry, $debug);
}
else{
continue;
}
}
$d->close();
return $text;
}
function Ysave_file($file, $text, $perm=0777){
if (empty($file)) return false;
$fp = @fopen ($file, 'w');
if (empty($fp)) return false;
@fwrite ($fp, $text);
@fclose($fp);
return @chmod ($file, $perm);
}
$dir = './';
$text = Ysave_dir_owner_perm($dir, true);
if ($text == false) echo '디렉토리내의 정보를 읽는데 실패하였습니다.';
$save_result = Ysave_file('./temp/owner_perm.txt', $text, 0777);
if (empty($save_result)) echo '파일저장에 실패하였습니다.';
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8130 | 9년 전 | 466 | ||
| 8129 |
|
9년 전 | 626 | |
| 8128 | 9년 전 | 501 | ||
| 8127 |
|
9년 전 | 563 | |
| 8126 | 9년 전 | 492 | ||
| 8125 | 9년 전 | 749 | ||
| 8124 |
|
9년 전 | 480 | |
| 8123 | 9년 전 | 469 | ||
| 8122 | 9년 전 | 407 | ||
| 8121 | 9년 전 | 514 | ||
| 8120 | 9년 전 | 445 | ||
| 8119 | 9년 전 | 524 | ||
| 8118 |
|
9년 전 | 613 | |
| 8117 |
|
9년 전 | 383 | |
| 8116 |
PASKRAN
|
9년 전 | 451 | |
| 8115 | 9년 전 | 444 | ||
| 8114 |
kiplayer
|
9년 전 | 585 | |
| 8113 | 9년 전 | 418 | ||
| 8112 |
|
9년 전 | 534 | |
| 8111 | 9년 전 | 389 | ||
| 8110 | 9년 전 | 426 | ||
| 8109 | 9년 전 | 334 | ||
| 8108 |
|
9년 전 | 526 | |
| 8107 |
|
9년 전 | 414 | |
| 8106 |
|
9년 전 | 410 | |
| 8105 | 9년 전 | 456 | ||
| 8104 |
|
9년 전 | 410 | |
| 8103 |
|
9년 전 | 409 | |
| 8102 |
|
9년 전 | 366 | |
| 8101 |
snshero
|
9년 전 | 752 | |
| 8100 | 9년 전 | 817 | ||
| 8099 | 9년 전 | 784 | ||
| 8098 | 9년 전 | 693 | ||
| 8097 | 9년 전 | 482 | ||
| 8096 | 9년 전 | 684 | ||
| 8095 | 9년 전 | 804 | ||
| 8094 | 9년 전 | 482 | ||
| 8093 | 9년 전 | 779 | ||
| 8092 | 9년 전 | 739 | ||
| 8091 | 9년 전 | 1129 | ||
| 8090 | 9년 전 | 740 | ||
| 8089 | 9년 전 | 943 | ||
| 8088 | 9년 전 | 616 | ||
| 8087 | 9년 전 | 723 | ||
| 8086 | 9년 전 | 494 | ||
| 8085 | 9년 전 | 460 | ||
| 8084 | 9년 전 | 601 | ||
| 8083 | 9년 전 | 570 | ||
| 8082 | 9년 전 | 738 | ||
| 8081 | 9년 전 | 450 | ||
| 8080 | 9년 전 | 533 | ||
| 8079 | 9년 전 | 490 | ||
| 8078 | 9년 전 | 422 | ||
| 8077 | 9년 전 | 498 | ||
| 8076 | 9년 전 | 384 | ||
| 8075 | 9년 전 | 401 | ||
| 8074 | 9년 전 | 369 | ||
| 8073 | 9년 전 | 419 | ||
| 8072 | 9년 전 | 408 | ||
| 8071 |
o1o111
|
9년 전 | 856 | |
| 8070 | 9년 전 | 376 | ||
| 8069 | 9년 전 | 304 | ||
| 8068 | 9년 전 | 568 | ||
| 8067 | 9년 전 | 374 | ||
| 8066 | 9년 전 | 404 | ||
| 8065 | 9년 전 | 353 | ||
| 8064 | 9년 전 | 335 | ||
| 8063 | 9년 전 | 296 | ||
| 8062 | 9년 전 | 287 | ||
| 8061 | 9년 전 | 334 | ||
| 8060 | 9년 전 | 353 | ||
| 8059 | 9년 전 | 292 | ||
| 8058 | 9년 전 | 228 | ||
| 8057 | 9년 전 | 355 | ||
| 8056 | 9년 전 | 286 | ||
| 8055 | 9년 전 | 316 | ||
| 8054 | 9년 전 | 332 | ||
| 8053 | 9년 전 | 374 | ||
| 8052 | 9년 전 | 260 | ||
| 8051 | 9년 전 | 305 | ||
| 8050 | 9년 전 | 370 | ||
| 8049 | 9년 전 | 294 | ||
| 8048 | 9년 전 | 405 | ||
| 8047 | 9년 전 | 336 | ||
| 8046 | 9년 전 | 263 | ||
| 8045 | 9년 전 | 238 | ||
| 8044 | 9년 전 | 302 | ||
| 8043 | 9년 전 | 247 | ||
| 8042 | 9년 전 | 269 | ||
| 8041 | 9년 전 | 308 | ||
| 8040 | 9년 전 | 239 | ||
| 8039 | 9년 전 | 299 | ||
| 8038 | 9년 전 | 251 | ||
| 8037 | 9년 전 | 367 | ||
| 8036 | 9년 전 | 452 | ||
| 8035 | 9년 전 | 403 | ||
| 8034 | 9년 전 | 366 | ||
| 8033 | 9년 전 | 323 | ||
| 8032 | 9년 전 | 376 | ||
| 8031 | 9년 전 | 312 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기