'압축'에 해당되는 글 2건

  1. 2009/07/07 PHP - Detects what compression file uses
  2. 2009/03/23 sunyruru의 미투데이 - 2009년 3월 22일
2009/07/07 00:35

PHP - Detects what compression file uses


유명한 MySQL 관리 툴이죠. phpMyAdmin 소스를 보던 중 좋은 내용을 발췌합니다.

libraries\import.lib.php 파일에 있던 내용이고요.

코드는 아래와 같습니다.



/**
 *  Detects what compression filse uses
 *
 *  @param  string filename to check
 *  @return string MIME type of compression, none for none
 *  @access public
 */
function PMA_detectCompression($filepath)
{
    $file = @fopen($filepath, 'rb');
    if (!$file) {
        return FALSE;
    }
    $test = fread($file, 4);
    $len = strlen($test);
    fclose($file);
    if ($len >= 2 && $test[0] == chr(31) && $test[1] == chr(139)) {
        return 'application/gzip';
    }
    if ($len >= 3 && substr($test, 0, 3) == 'BZh') {
        return 'application/bzip2';
    }
    if ($len >= 4 && $test == "PK\003\004") {
        return 'application/zip';
    }
    return 'none';
}

저작자 표시 비영리 변경 금지
크리에이티브 커먼즈 라이선스
Creative Commons License
올블로그추천버튼 블코추천버튼 블로그뉴스추천버튼 믹시추천버튼 한RSS추가버튼 구글리더기추천버튼


이 포스팅이 도움이 되었다면 구글에서 관련 정보를 찾아 보세요 ^^


Trackback 0 Comment 0

Trackback : http://i-ruru.com/trackback/473 관련글 쓰기

2009/03/23 04:31

sunyruru의 미투데이 - 2009년 3월 22일

이 글은 sunyruru님의 2009년 3월 22일의 미투데이 내용입니다.

크리에이티브 커먼즈 라이선스
Creative Commons License
올블로그추천버튼 블코추천버튼 블로그뉴스추천버튼 믹시추천버튼 한RSS추가버튼 구글리더기추천버튼


이 포스팅이 도움이 되었다면 구글에서 관련 정보를 찾아 보세요 ^^


Trackback 0 Comment 0

Trackback : http://i-ruru.com/trackback/437 관련글 쓰기