윈도우 리눅스 공용입니다.
단 윈도우의 경우에는 소유권, 그룹정보는 가져오지 못합니다.
여러가지 활요예가 있겠지만
이런경우에 유용합니다.
압축을 하고 전혀 다른 계정에 압축을 풀었을때
퍼미션이나 소유권 문제때문에 고민할때 사용하면 유용합니다.
이하 소스입니다.
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 '파일저장에 실패하였습니다.';
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7630 | 10년 전 | 647 | ||
| 7629 |
|
10년 전 | 2379 | |
| 7628 | 10년 전 | 786 | ||
| 7627 |
|
10년 전 | 1017 | |
| 7626 |
|
10년 전 | 1785 | |
| 7625 | 10년 전 | 689 | ||
| 7624 | 10년 전 | 708 | ||
| 7623 |
|
10년 전 | 3074 | |
| 7622 | 10년 전 | 718 | ||
| 7621 |
leeleeleelee
|
10년 전 | 580 | |
| 7620 | 10년 전 | 537 | ||
| 7619 | 10년 전 | 478 | ||
| 7618 | 10년 전 | 1011 | ||
| 7617 | 10년 전 | 721 | ||
| 7616 | 10년 전 | 632 | ||
| 7615 | 10년 전 | 725 | ||
| 7614 | 10년 전 | 1251 | ||
| 7613 |
|
10년 전 | 2080 | |
| 7612 | 10년 전 | 1135 | ||
| 7611 | 10년 전 | 1404 | ||
| 7610 |
|
10년 전 | 1897 | |
| 7609 |
|
10년 전 | 1328 | |
| 7608 |
mwdkim
|
10년 전 | 1126 | |
| 7607 |
|
10년 전 | 1048 | |
| 7606 |
mwdkim
|
10년 전 | 3919 | |
| 7605 | 10년 전 | 685 | ||
| 7604 | 10년 전 | 1021 | ||
| 7603 | 10년 전 | 1645 | ||
| 7602 |
|
10년 전 | 1064 | |
| 7601 |
AniNest
|
10년 전 | 2783 | |
| 7600 |
port443
|
10년 전 | 1021 | |
| 7599 | 10년 전 | 940 | ||
| 7598 | 10년 전 | 1011 | ||
| 7597 | 10년 전 | 4566 | ||
| 7596 |
SeungYeon
|
10년 전 | 885 | |
| 7595 |
untitled
|
10년 전 | 2414 | |
| 7594 |
프로그래머7
|
10년 전 | 1718 | |
| 7593 |
untitled
|
10년 전 | 2357 | |
| 7592 |
untitled
|
10년 전 | 1930 | |
| 7591 |
untitled
|
10년 전 | 2673 | |
| 7590 |
아리마2001
|
10년 전 | 849 | |
| 7589 | 10년 전 | 1104 | ||
| 7588 |
|
10년 전 | 2912 | |
| 7587 | 10년 전 | 1301 | ||
| 7586 | 10년 전 | 666 | ||
| 7585 | 10년 전 | 1686 | ||
| 7584 | 10년 전 | 1406 | ||
| 7583 |
leeleeleelee
|
10년 전 | 1157 | |
| 7582 |
|
10년 전 | 1103 | |
| 7581 | 10년 전 | 1320 | ||
| 7580 | 10년 전 | 982 | ||
| 7579 |
|
10년 전 | 602 | |
| 7578 | 10년 전 | 1426 | ||
| 7577 |
|
10년 전 | 1868 | |
| 7576 | 10년 전 | 1382 | ||
| 7575 |
멋진남자임
|
10년 전 | 1459 | |
| 7574 | 10년 전 | 2114 | ||
| 7573 | 10년 전 | 3247 | ||
| 7572 | 10년 전 | 756 | ||
| 7571 |
|
10년 전 | 778 | |
| 7570 |
|
10년 전 | 1306 | |
| 7569 | 10년 전 | 1545 | ||
| 7568 |
this1mg
|
10년 전 | 1045 | |
| 7567 |
|
10년 전 | 754 | |
| 7566 | 10년 전 | 914 | ||
| 7565 |
Angel하늘
|
10년 전 | 987 | |
| 7564 |
seoldi
|
10년 전 | 1228 | |
| 7563 |
|
10년 전 | 1364 | |
| 7562 |
멋진남자임
|
10년 전 | 2075 | |
| 7561 | 10년 전 | 708 | ||
| 7560 |
leeleeleelee
|
10년 전 | 895 | |
| 7559 | 10년 전 | 5035 | ||
| 7558 |
RinaP
|
10년 전 | 774 | |
| 7557 |
|
10년 전 | 1235 | |
| 7556 | 10년 전 | 1188 | ||
| 7555 |
hyohyojj1234
|
10년 전 | 1655 | |
| 7554 | 10년 전 | 1089 | ||
| 7553 |
senseme
|
10년 전 | 1334 | |
| 7552 |
ehdltdoit
|
10년 전 | 1432 | |
| 7551 |
|
10년 전 | 1814 | |
| 7550 |
leeleeleelee
|
10년 전 | 1584 | |
| 7549 | 10년 전 | 2416 | ||
| 7548 | 10년 전 | 1835 | ||
| 7547 |
멋진남자임
|
10년 전 | 1956 | |
| 7546 | 10년 전 | 998 | ||
| 7545 |
ILMare1003
|
10년 전 | 1277 | |
| 7544 |
|
10년 전 | 1245 | |
| 7543 | 10년 전 | 881 | ||
| 7542 | 10년 전 | 652 | ||
| 7541 |
울라라라우
|
10년 전 | 859 | |
| 7540 | 10년 전 | 1595 | ||
| 7539 | 10년 전 | 926 | ||
| 7538 |
|
10년 전 | 1828 | |
| 7537 | 10년 전 | 3607 | ||
| 7536 |
Gaumi
|
10년 전 | 1406 | |
| 7535 |
프로그램은어려워
|
10년 전 | 1261 | |
| 7534 |
senseme
|
10년 전 | 1202 | |
| 7533 | 10년 전 | 1190 | ||
| 7532 | 10년 전 | 853 | ||
| 7531 | 10년 전 | 2044 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기