note 84848 added to function.ziparchive-open

From: Date: Fri, 01 Aug 2008 20:25:57 +0000
Subject: note 84848 added to function.ziparchive-open
Groups: php.notes 
Request: Send a blank email to php-notes+get-143029@lists.php.net to get a copy of this message
/* Hi! I made a little script about checking content and "secure repacking" */ $somefile = "zip.zip"; $someurl = "/some/url" $zip = new ZipArchive; $open = $zip->open($somefile, ZIPARCHIVE::CHECKCONS); // If the archive is broken(or just another file renamed to *.zip) the function will return error on httpd under windows, so it's good to check if the archive is ok with ZIPARCHIVE::CHECKCONS if ($open === TRUE) { if(!$zip->extractTo($someurl)) { die ("Error during extracting"); } $zip->close(); } $new_archive_name = "new.zip"; $new_zip = new ZipArchive; $new_open = $new_zip->open($new_archive_name, ZIPARCHIVE::CREATE); if ($new_open === TRUE) { $dir = opendir($someurl); while ($file = readdir($dir)) { if ($file == "." || $file == "..") { } else { //We do not wanna this files in the new zip archive if (!$new_zip->addFile($file)) { print $file."was not added!<br />"; } } } } $new_zip->close(); ---- Server IP: 89.190.194.18 Probable Submitter: 78.90.31.207 ---- Manual Page -- http://www.php.net/manual/en/function.ziparchive-open.php Edit -- https://master.php.net/note/edit/84848 Del: integrated -- https://master.php.net/note/delete/84848/integrated Del: useless -- https://master.php.net/note/delete/84848/useless Del: bad code -- https://master.php.net/note/delete/84848/bad+code Del: spam -- https://master.php.net/note/delete/84848/spam Del: non-english -- https://master.php.net/note/delete/84848/non-english Del: in docs -- https://master.php.net/note/delete/84848/in+docs Del: other reasons-- https://master.php.net/note/delete/84848 Reject -- https://master.php.net/note/reject/84848 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143029) next »