윈도우 리눅스 공용입니다.
단 윈도우의 경우에는 소유권, 그룹정보는 가져오지 못합니다.
여러가지 활요예가 있겠지만
이런경우에 유용합니다.
압축을 하고 전혀 다른 계정에 압축을 풀었을때
퍼미션이나 소유권 문제때문에 고민할때 사용하면 유용합니다.
이하 소스입니다.
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 '파일저장에 실패하였습니다.';
게시글 목록
| 번호 | 제목 |
|---|---|
| 12072 |
MySQL
mysql 실시간 processlist
|
| 12071 | |
| 12070 | |
| 12069 |
MySQL
mysql 일반적인 최적화 팁
|
| 12068 |
기타
간단한 리눅스 명령어
|
| 12067 | |
| 12066 |
MySQL
mysql 데이터 경로 바꾸기
|
| 12065 |
MySQL
mysql 운영팁. 느린 쿼리를 발견하기
|
| 20376 | |
| 12064 | |
| 12063 |
MySQL
mysql index에 대해..
|
| 12062 |
MySQL
구분자는 enum으로
|
| 12061 |
MySQL
mysql zerofill에 대해
|
| 334 | |
| 12052 | |
| 12051 | |
| 328 | |
| 327 | |
| 20375 | |
| 12050 | |
| 12049 | |
| 325 | |
| 12047 | |
| 319 | |
| 12045 |
MySQL
phpMyAdmin 시간 늘리기
1
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기