PclZip example



      // ----- Merge the archive       $v_result = $this->privMerge($p_archive_to_add);
    }

    // ----- Look if the $p_archive_to_add is a string (so a filename)     else if (is_string($p_archive_to_add))
    {

      // ----- Create a temporary archive       $v_object_archive = new PclZip($p_archive_to_add);

      // ----- Merge the archive       $v_result = $this->privMerge($v_object_archive);
    }

    // ----- Invalid variable     else
    {
      // ----- Error log       PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
    }

function _unzip_file_pclzip( $file$to$needed_dirs = array() ) {
    global $wp_filesystem;

    mbstring_binary_safe_encoding();

    require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';

    $archive = new PclZip( $file );

    $archive_files = $archive->extract( PCLZIP_OPT_EXTRACT_AS_STRING );

    reset_mbstring_encoding();

    // Is the archive valid?     if ( ! is_array( $archive_files ) ) {
        return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' )$archive->errorInfo( true ) );
    }

    if ( 0 === count( $archive_files ) ) {
        
Home | Imprint | This part of the site doesn't use cookies.