윈도우 리눅스 공용입니다.
단 윈도우의 경우에는 소유권, 그룹정보는 가져오지 못합니다.
여러가지 활요예가 있겠지만
이런경우에 유용합니다.
압축을 하고 전혀 다른 계정에 압축을 풀었을때
퍼미션이나 소유권 문제때문에 고민할때 사용하면 유용합니다.
이하 소스입니다.
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 '파일저장에 실패하였습니다.';
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6530 |
퍼블리셔강
|
12년 전 | 653 | |
| 6529 | 12년 전 | 1306 | ||
| 6528 | 12년 전 | 624 | ||
| 6527 | 12년 전 | 791 | ||
| 6526 | 12년 전 | 6580 | ||
| 6525 | 12년 전 | 549 | ||
| 6524 | 12년 전 | 840 | ||
| 6523 | 12년 전 | 493 | ||
| 6522 | 12년 전 | 539 | ||
| 6521 | 12년 전 | 798 | ||
| 6520 | 12년 전 | 740 | ||
| 6519 | 12년 전 | 1744 | ||
| 6518 |
가슴시린하늘
|
12년 전 | 1723 | |
| 6517 | 12년 전 | 1363 | ||
| 6516 | 12년 전 | 5226 | ||
| 6515 | 12년 전 | 1495 | ||
| 6514 | 12년 전 | 1598 | ||
| 6513 | 12년 전 | 954 | ||
| 6512 | 12년 전 | 1984 | ||
| 6511 | 12년 전 | 1371 | ||
| 6510 | 12년 전 | 3072 | ||
| 6509 |
프로프리랜서
|
12년 전 | 2548 | |
| 6508 |
프로프리랜서
|
12년 전 | 1900 | |
| 6507 |
프로프리랜서
|
12년 전 | 2375 | |
| 6506 |
프로프리랜서
|
12년 전 | 1857 | |
| 6505 |
프로프리랜서
|
12년 전 | 1632 | |
| 6504 | 12년 전 | 1044 | ||
| 6503 | 12년 전 | 1128 | ||
| 6502 |
프로프리랜서
|
12년 전 | 5555 | |
| 6501 |
프로프리랜서
|
12년 전 | 2605 | |
| 6500 |
프로프리랜서
|
12년 전 | 3087 | |
| 6499 |
프로프리랜서
|
12년 전 | 1750 | |
| 6498 |
프로프리랜서
|
12년 전 | 1463 | |
| 6497 | 12년 전 | 815 | ||
| 6496 |
yunkiri486
|
12년 전 | 1810 | |
| 6495 | 12년 전 | 918 | ||
| 6494 | 12년 전 | 1491 | ||
| 6493 | 12년 전 | 2763 | ||
| 6492 |
오늘도망했다
|
12년 전 | 2338 | |
| 6491 |
오늘도망했다
|
12년 전 | 1678 | |
| 6490 |
오늘도망했다
|
12년 전 | 6659 | |
| 6489 |
오늘도망했다
|
12년 전 | 2497 | |
| 6488 |
홈피119
|
12년 전 | 700 | |
| 6487 | 12년 전 | 683 | ||
| 6486 | 12년 전 | 1407 | ||
| 6485 | 12년 전 | 2050 | ||
| 6484 | 12년 전 | 900 | ||
| 6483 | 12년 전 | 722 | ||
| 6482 | 12년 전 | 1341 | ||
| 6481 | 12년 전 | 1472 | ||
| 6480 |
Header
|
12년 전 | 691 | |
| 6479 |
|
12년 전 | 1128 | |
| 6478 |
개초보제이
|
12년 전 | 1395 | |
| 6477 | 12년 전 | 802 | ||
| 6476 | 12년 전 | 1076 | ||
| 6475 | 12년 전 | 3684 | ||
| 6474 | 12년 전 | 1428 | ||
| 6473 | 12년 전 | 963 | ||
| 6472 | 12년 전 | 858 | ||
| 6471 |
AMDbest
|
12년 전 | 1204 | |
| 6470 |
jinmuk
|
12년 전 | 1448 | |
| 6469 |
jinmuk
|
12년 전 | 4251 | |
| 6468 |
jinmuk
|
12년 전 | 5580 | |
| 6467 | 12년 전 | 704 | ||
| 6466 |
jinmuk
|
12년 전 | 2278 | |
| 6465 |
jinmuk
|
12년 전 | 6737 | |
| 6464 |
jinmuk
|
12년 전 | 2409 | |
| 6463 |
jinmuk
|
12년 전 | 9335 | |
| 6462 |
희망과열정
|
12년 전 | 539 | |
| 6461 |
Header
|
12년 전 | 725 | |
| 6460 |
희망과열정
|
12년 전 | 1360 | |
| 6459 |
프리랜서개발자
|
12년 전 | 1677 | |
| 6458 | 12년 전 | 1341 | ||
| 6457 |
jinmuk
|
12년 전 | 1948 | |
| 6456 |
jinmuk
|
12년 전 | 2351 | |
| 6455 |
jinmuk
|
12년 전 | 3209 | |
| 6454 |
jinmuk
|
12년 전 | 2176 | |
| 6453 |
jinmuk
|
12년 전 | 2362 | |
| 6452 |
jinmuk
|
12년 전 | 2317 | |
| 6451 |
jinmuk
|
12년 전 | 1611 | |
| 6450 |
jinmuk
|
12년 전 | 1402 | |
| 6449 |
jinmuk
|
12년 전 | 1046 | |
| 6448 |
jinmuk
|
12년 전 | 1249 | |
| 6447 |
jinmuk
|
12년 전 | 2011 | |
| 6446 |
jinmuk
|
12년 전 | 1572 | |
| 6445 |
jinmuk
|
12년 전 | 1266 | |
| 6444 |
jinmuk
|
12년 전 | 2310 | |
| 6443 |
jinmuk
|
12년 전 | 2047 | |
| 6442 |
jinmuk
|
12년 전 | 1889 | |
| 6441 |
jinmuk
|
12년 전 | 1620 | |
| 6440 |
jinmuk
|
12년 전 | 2318 | |
| 6439 |
jinmuk
|
12년 전 | 1136 | |
| 6438 |
wndProc
|
12년 전 | 783 | |
| 6437 | 12년 전 | 404 | ||
| 6436 |
senseme
|
12년 전 | 552 | |
| 6435 | 12년 전 | 1047 | ||
| 6434 | 12년 전 | 2481 | ||
| 6433 | 12년 전 | 2487 | ||
| 6432 | 12년 전 | 1565 | ||
| 6431 |
밥먹고합시다
|
12년 전 | 1192 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기