윈도우 리눅스 공용입니다.
단 윈도우의 경우에는 소유권, 그룹정보는 가져오지 못합니다.
여러가지 활요예가 있겠지만
이런경우에 유용합니다.
압축을 하고 전혀 다른 계정에 압축을 풀었을때
퍼미션이나 소유권 문제때문에 고민할때 사용하면 유용합니다.
이하 소스입니다.
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년 전 | 682 | ||
| 7629 |
|
10년 전 | 2446 | |
| 7628 | 10년 전 | 822 | ||
| 7627 |
|
10년 전 | 1055 | |
| 7626 |
|
10년 전 | 1809 | |
| 7625 | 10년 전 | 744 | ||
| 7624 | 10년 전 | 752 | ||
| 7623 |
|
10년 전 | 3144 | |
| 7622 | 10년 전 | 756 | ||
| 7621 |
leeleeleelee
|
10년 전 | 610 | |
| 7620 | 10년 전 | 559 | ||
| 7619 | 10년 전 | 528 | ||
| 7618 | 10년 전 | 1062 | ||
| 7617 | 10년 전 | 743 | ||
| 7616 | 10년 전 | 681 | ||
| 7615 | 10년 전 | 746 | ||
| 7614 | 10년 전 | 1289 | ||
| 7613 |
|
10년 전 | 2104 | |
| 7612 | 10년 전 | 1188 | ||
| 7611 | 10년 전 | 1449 | ||
| 7610 |
|
10년 전 | 1926 | |
| 7609 |
|
10년 전 | 1383 | |
| 7608 |
mwdkim
|
10년 전 | 1155 | |
| 7607 |
|
10년 전 | 1085 | |
| 7606 |
mwdkim
|
10년 전 | 3964 | |
| 7605 | 10년 전 | 713 | ||
| 7604 | 10년 전 | 1051 | ||
| 7603 | 10년 전 | 1670 | ||
| 7602 |
|
10년 전 | 1102 | |
| 7601 |
AniNest
|
10년 전 | 2818 | |
| 7600 |
port443
|
10년 전 | 1063 | |
| 7599 | 10년 전 | 968 | ||
| 7598 | 10년 전 | 1043 | ||
| 7597 | 10년 전 | 4592 | ||
| 7596 |
SeungYeon
|
10년 전 | 914 | |
| 7595 |
untitled
|
10년 전 | 2462 | |
| 7594 |
프로그래머7
|
10년 전 | 1752 | |
| 7593 |
untitled
|
10년 전 | 2393 | |
| 7592 |
untitled
|
10년 전 | 1960 | |
| 7591 |
untitled
|
10년 전 | 2698 | |
| 7590 |
아리마2001
|
10년 전 | 879 | |
| 7589 | 10년 전 | 1131 | ||
| 7588 |
|
10년 전 | 2944 | |
| 7587 | 10년 전 | 1327 | ||
| 7586 | 10년 전 | 691 | ||
| 7585 | 10년 전 | 1725 | ||
| 7584 | 10년 전 | 1428 | ||
| 7583 |
leeleeleelee
|
10년 전 | 1194 | |
| 7582 |
|
10년 전 | 1158 | |
| 7581 | 10년 전 | 1384 | ||
| 7580 | 10년 전 | 1036 | ||
| 7579 |
|
10년 전 | 630 | |
| 7578 | 10년 전 | 1446 | ||
| 7577 |
|
10년 전 | 1892 | |
| 7576 | 10년 전 | 1402 | ||
| 7575 |
멋진남자임
|
10년 전 | 1487 | |
| 7574 | 10년 전 | 2151 | ||
| 7573 | 10년 전 | 3288 | ||
| 7572 | 10년 전 | 783 | ||
| 7571 |
|
10년 전 | 800 | |
| 7570 |
|
10년 전 | 1351 | |
| 7569 | 10년 전 | 1569 | ||
| 7568 |
this1mg
|
10년 전 | 1070 | |
| 7567 |
|
10년 전 | 789 | |
| 7566 | 10년 전 | 935 | ||
| 7565 |
Angel하늘
|
10년 전 | 1036 | |
| 7564 |
seoldi
|
10년 전 | 1282 | |
| 7563 |
|
10년 전 | 1420 | |
| 7562 |
멋진남자임
|
10년 전 | 2121 | |
| 7561 | 10년 전 | 744 | ||
| 7560 |
leeleeleelee
|
10년 전 | 936 | |
| 7559 | 10년 전 | 5076 | ||
| 7558 |
RinaP
|
10년 전 | 813 | |
| 7557 |
|
10년 전 | 1273 | |
| 7556 | 10년 전 | 1217 | ||
| 7555 |
hyohyojj1234
|
10년 전 | 1685 | |
| 7554 | 10년 전 | 1114 | ||
| 7553 |
senseme
|
10년 전 | 1363 | |
| 7552 |
ehdltdoit
|
10년 전 | 1459 | |
| 7551 |
|
10년 전 | 1846 | |
| 7550 |
leeleeleelee
|
10년 전 | 1618 | |
| 7549 | 10년 전 | 2450 | ||
| 7548 | 10년 전 | 1857 | ||
| 7547 |
멋진남자임
|
10년 전 | 1982 | |
| 7546 | 10년 전 | 1024 | ||
| 7545 |
ILMare1003
|
10년 전 | 1316 | |
| 7544 |
|
10년 전 | 1272 | |
| 7543 | 10년 전 | 907 | ||
| 7542 | 10년 전 | 683 | ||
| 7541 |
울라라라우
|
10년 전 | 887 | |
| 7540 | 10년 전 | 1615 | ||
| 7539 | 10년 전 | 962 | ||
| 7538 |
|
10년 전 | 1849 | |
| 7537 | 10년 전 | 3637 | ||
| 7536 |
Gaumi
|
10년 전 | 1447 | |
| 7535 |
프로그램은어려워
|
10년 전 | 1300 | |
| 7534 |
senseme
|
10년 전 | 1224 | |
| 7533 | 10년 전 | 1224 | ||
| 7532 | 10년 전 | 894 | ||
| 7531 | 10년 전 | 2090 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기