PHP 8.4.24 Released!

Voting

: min(one, eight)?
(Example: nine)

The Note You're Voting On

piotr dot stop dot spam at gmail dot com
12 years ago
You can check general purpose flag to test if the zip file is encrypted. Example function below.

<?php

/**
 * Check if the file is encrypted
 * 
 * Notice: if file doesn't exists or cannot be opened, function
 * also return false.
 * 
 * @param string $pathToArchive
 * @return boolean return true if file is encrypted
 */
function isEncryptedZip( $pathToArchive ) {
    $fp = @fopen( $pathToArchive, 'r' );
    $encrypted = false;
    if ( $fp && fseek( $fp, 6 ) == 0 ) {
        $string = fread( $fp, 2 );
        if ( false !== $string ) {
            $data = unpack("vgeneral", $string);
            $encrypted = $data[ 'general' ] & 0x01 ? true : false;
        }
        fclose( $fp );
    }
    return $encrypted;
}

<< Back to user notes page

To Top