Funzioni per File Zip (Accesso di Sola Lettura)
Introduzione
Questo modulo abilita l'accesso trasperente in lettura degli archivi compressi con ZIP e dei file in essi contenuti.
Requisiti
Questo modulo usa le funzioni » ZZIPlib della libreria di Guido Draheim. Sono richieste le ZZIPlib versione >= 0.10.6.
Notare che ZZIPlib rende disponbili solo un sottogruppo di quelle funzioni disponibili in una implementazione completa dell'algoritmo di compressione ZIP e può solamente leggere i file in formato ZIP. Una normale utility ZIP è richiesta per creare i file ZIP letti da questa libreria.
Installazione
This » PECL extension is not bundled with PHP. Informazioni per l'installazione di questa estensione PECL possono essere trovate nel capitolo del manuale intitolato Installazione delle estensioni PECL. Informazioni aggiuntive come nuove release, download, file sorgenti, informazioni del manutentore e un CHANGELOG possono essere trovate qui: » https://pecl.php.net/package/zip.
In PHP 4 this PECL extensions source can be found in the ext/ directory within the PHP source or at the PECL link above. Per utilizzare questo modulo è necessario usare l'opzione di configurazione --with-zip[=DIR] durante la compilazione di PHP.
Per utilizzare queste funzioni, gli utenti Windows dovranno abilitare php_zip.dll all'interno del php.ini. In PHP 4 this DLL resides in the extensions/ directory within the PHP Windows binaries download. La DLL per questa estensione PECL può essere scaricata dalla pagina » PHP Downloads oppure da » https://pecl4win.php.net/
Nota: Il supporto Zip precedentemente alla versione 4.1.0 di PHP è sperimentale. Questa sezione riflette l'estensione Zip così come essa esiste in PHP 4.1.0 e successivi.
Configurazione di Runtime
Questa estensione non definisce alcuna direttiva di configurazione in php.ini
Tipi di risorse
Questa estensione non definisce alcun tipo di risorsa.
Costanti predefinite
Questa estensione non definisce alcuna costante.
Esempi
Questo esempio apre un archivio ZIP, legge tutti i file presenti nell'archivio e stampa il contenuto. L'archivio test2.zip usato in questo esempio è uno degli archivi dimostrativi presenti nella distribuzione di ZZIPlib.
Example#1 Esempio di Utilizzo Zip
<?php
$zip = zip_open("/tmp/test2.zip");
if ($zip) {
while ($zip_entry = zip_read($zip)) {
echo "Nome: " . zip_entry_name($zip_entry) . "\n";
echo "Dimensione File: " . zip_entry_filesize($zip_entry) . "\n";
echo "Dimensione Compressa: " . zip_entry_compressedsize($zip_entry) . "\n";
echo "Metodo di Compressione: " . zip_entry_compressionmethod($zip_entry) . "\n";
if (zip_entry_open($zip, $zip_entry, "r")) {
echo "Contenuto File:\n";
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
echo "$buf\n";
zip_entry_close($zip_entry);
}
echo "\n";
}
zip_close($zip);
}
?>
Indice dei contenuti
- zip_close — Chiude un archivio Zip
- zip_entry_close — Chiude il puntatore a una directory
- zip_entry_compressedsize — Ottiene la dimensione compressa di una Directory
- zip_entry_compressionmethod — Ottiene il metodo di compressione di una voce directory
- zip_entry_filesize — Ottiene la dimensione attuale di una directory
- zip_entry_name — Ottiene il nome di una directory
- zip_entry_open — Apre una voce directory in lettura
- zip_entry_read — Legge da una directory aperta
- zip_open — Apre un archivio zip
- zip_read — Legge la prossima voce in un archivio file zip
- ZipArchive::addEmptyDir — Add a new directory
- ZipArchive::addFile — Adds a file to a ZIP archive from the given path
- ZipArchive::addFromString — Add a file to a ZIP archive using its contents
- ZipArchive::close — Close the active archive (opened or newly created)
- ZipArchive::deleteIndex — delete an entry in the archive using its index
- ZipArchive::deleteName — delete an entry in the archive using its name
- ZipArchive::extractTo — Extract the archive contents
- ZipArchive::getArchiveComment — Returns the Zip archive comment
- ZipArchive::getCommentIndex — Returns the comment of an entry using the entry index
- ZipArchive::getCommentName — Returns the comment of an entry using the entry name
- ZipArchive::getFromIndex — Returns the entry contents using its index.
- ZipArchive::getFromName — Returns the entry contents using its name.
- ZipArchive::getNameIndex — Returns the name of an entry using its index
- ZipArchive::getStream — Get a file handler to the entry defined by its name (read only).
- ZipArchive::locateName — Returns the index of the entry in the archive
- ZipArchive::open — Open a ZIP file archive
- ZipArchive::renameIndex — Renames an entry defined by its index
- ZipArchive::renameName — Renames an entry defined by its name
- ZipArchive::setArchiveComment — Set the comment of a ZIP archive
- ZipArchive::setCommentIndex — Set the comment of an entry defined by its index
- ZipArchive::setCommentName — Set the comment of an entry defined by its name
- ZipArchive::statIndex — Get the details of an entry defined by its index.
- ZipArchive::statName — Get the details of an entry defined by its name.
- ZipArchive::unchangeAll — Undo all changes done in the archive.
- ZipArchive::unchangeArchive — Revert all global changes done in the archive.
- ZipArchive::unchangeIndex — Revert all changes done to an entry at the given index.
- ZipArchive::unchangeName — Revert all changes done to an entry with the given name.