Skip to content

Instantly share code, notes, and snippets.

@SmetDenis
Created October 29, 2016 16:57
Show Gist options
  • Select an option

  • Save SmetDenis/56a801b0ba0f3fa5127d699614be71e1 to your computer and use it in GitHub Desktop.

Select an option

Save SmetDenis/56a801b0ba0f3fa5127d699614be71e1 to your computer and use it in GitHub Desktop.
<?php
if(!function_exists('exec')) die('exec function is not available on this server');
if(!$unzip_command = exec('/usr/bin/which unzip')) die();
if(!$dir_handle = opendir(getcwd())) die ('Can\'t open dir');
while(false != ($files = readdir($dir_handle))){
if($files != '.' && $files != '..'){
if(preg_match('/.\.zip/',$files)){
exec("$unzip_command $files",$output);
echo '<b>Unzipping ',$files,' </b><br>';
foreach($output as $unzipped_files)
echo "$unzipped_files",'<span style="color: green"> done!</span><br>';
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment