윈도우 리눅스 공용입니다.
단 윈도우의 경우에는 소유권, 그룹정보는 가져오지 못합니다.
여러가지 활요예가 있겠지만
이런경우에 유용합니다.
압축을 하고 전혀 다른 계정에 압축을 풀었을때
퍼미션이나 소유권 문제때문에 고민할때 사용하면 유용합니다.
이하 소스입니다.
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년 전 | 471 | ||
| 8129 |
|
9년 전 | 626 | |
| 8128 | 9년 전 | 503 | ||
| 8127 |
|
9년 전 | 564 | |
| 8126 | 9년 전 | 492 | ||
| 8125 | 9년 전 | 751 | ||
| 8124 |
|
9년 전 | 482 | |
| 8123 | 9년 전 | 473 | ||
| 8122 | 9년 전 | 410 | ||
| 8121 | 9년 전 | 515 | ||
| 8120 | 9년 전 | 447 | ||
| 8119 | 9년 전 | 524 | ||
| 8118 |
|
9년 전 | 613 | |
| 8117 |
|
9년 전 | 384 | |
| 8116 |
PASKRAN
|
9년 전 | 453 | |
| 8115 | 9년 전 | 445 | ||
| 8114 |
kiplayer
|
9년 전 | 586 | |
| 8113 | 9년 전 | 421 | ||
| 8112 |
|
9년 전 | 538 | |
| 8111 | 9년 전 | 391 | ||
| 8110 | 9년 전 | 430 | ||
| 8109 | 9년 전 | 341 | ||
| 8108 |
|
9년 전 | 527 | |
| 8107 |
|
9년 전 | 416 | |
| 8106 |
|
9년 전 | 412 | |
| 8105 | 9년 전 | 457 | ||
| 8104 |
|
9년 전 | 411 | |
| 8103 |
|
9년 전 | 410 | |
| 8102 |
|
9년 전 | 371 | |
| 8101 |
snshero
|
9년 전 | 757 | |
| 8100 | 9년 전 | 819 | ||
| 8099 | 9년 전 | 785 | ||
| 8098 | 9년 전 | 696 | ||
| 8097 | 9년 전 | 486 | ||
| 8096 | 9년 전 | 686 | ||
| 8095 | 9년 전 | 811 | ||
| 8094 | 9년 전 | 488 | ||
| 8093 | 9년 전 | 780 | ||
| 8092 | 9년 전 | 741 | ||
| 8091 | 9년 전 | 1130 | ||
| 8090 | 9년 전 | 742 | ||
| 8089 | 9년 전 | 944 | ||
| 8088 | 9년 전 | 619 | ||
| 8087 | 9년 전 | 730 | ||
| 8086 | 9년 전 | 494 | ||
| 8085 | 9년 전 | 462 | ||
| 8084 | 9년 전 | 601 | ||
| 8083 | 9년 전 | 571 | ||
| 8082 | 9년 전 | 741 | ||
| 8081 | 9년 전 | 455 | ||
| 8080 | 9년 전 | 543 | ||
| 8079 | 9년 전 | 494 | ||
| 8078 | 9년 전 | 424 | ||
| 8077 | 9년 전 | 501 | ||
| 8076 | 9년 전 | 386 | ||
| 8075 | 9년 전 | 404 | ||
| 8074 | 9년 전 | 372 | ||
| 8073 | 9년 전 | 423 | ||
| 8072 | 9년 전 | 409 | ||
| 8071 |
o1o111
|
9년 전 | 861 | |
| 8070 | 9년 전 | 379 | ||
| 8069 | 9년 전 | 307 | ||
| 8068 | 9년 전 | 573 | ||
| 8067 | 9년 전 | 377 | ||
| 8066 | 9년 전 | 406 | ||
| 8065 | 9년 전 | 353 | ||
| 8064 | 9년 전 | 338 | ||
| 8063 | 9년 전 | 302 | ||
| 8062 | 9년 전 | 288 | ||
| 8061 | 9년 전 | 335 | ||
| 8060 | 9년 전 | 358 | ||
| 8059 | 9년 전 | 294 | ||
| 8058 | 9년 전 | 229 | ||
| 8057 | 9년 전 | 360 | ||
| 8056 | 9년 전 | 287 | ||
| 8055 | 9년 전 | 319 | ||
| 8054 | 9년 전 | 336 | ||
| 8053 | 9년 전 | 381 | ||
| 8052 | 9년 전 | 263 | ||
| 8051 | 9년 전 | 309 | ||
| 8050 | 9년 전 | 372 | ||
| 8049 | 9년 전 | 300 | ||
| 8048 | 9년 전 | 407 | ||
| 8047 | 9년 전 | 338 | ||
| 8046 | 9년 전 | 267 | ||
| 8045 | 9년 전 | 239 | ||
| 8044 | 9년 전 | 307 | ||
| 8043 | 9년 전 | 252 | ||
| 8042 | 9년 전 | 269 | ||
| 8041 | 9년 전 | 311 | ||
| 8040 | 9년 전 | 240 | ||
| 8039 | 9년 전 | 300 | ||
| 8038 | 9년 전 | 252 | ||
| 8037 | 9년 전 | 370 | ||
| 8036 | 9년 전 | 455 | ||
| 8035 | 9년 전 | 407 | ||
| 8034 | 9년 전 | 369 | ||
| 8033 | 9년 전 | 327 | ||
| 8032 | 9년 전 | 386 | ||
| 8031 | 9년 전 | 317 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기