php - Security of unzipping user submitted files -



php - Security of unzipping user submitted files -

not much of coding problem here, general question relating security. i'm working on project allows user submitted content. key part of content user uploads zip file. zip file should contain mp3 files.

i unzip files directory on server, can stream sound on website users hear to.

my concern opens potentially damaging zip files. i've read 'zipbombs' in past, , don't want malicious zip file causing damage.

so, there safe way of doing this? can scan zip file without unzipping first, , if contains other mp3's delete or flag warning admin?

if makes difference i'm developing site on wordpress. utilize built in upload features of wordpress allow user upload zip file our server (i'm not sure if there's form of security within wordpress scan zip file?)

code, extract mp3s zip, ignore everthing else $zip = new ziparchive(); $filename = 'newzip.zip'; if ($zip->open($filename)!==true) { exit("cannot open <$filename>\n"); } ($i=0; $i<$zip->numfiles;$i++) { $info = $zip->statindex($i); $file = pathinfo($info['name']); if(strtolower($file['extension']) == "mp3") { file_put_contents(basename($info['name']), $zip->getfromindex($i)); } } $zip->close();

i utilize use id3_get_version (http://www.php.net/manual/en/function.id3-get-version.php) ensure contents of file mp3 too

php wordpress zip unzip

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -