public static function generateFso($path, $recursive = true)
 {
     if (is_file($path)) {
         $content = FilesHelper::readFile($path);
         $type = 'text';
         $ext = pathinfo($path, PATHINFO_EXTENSION);
         if (in_array($ext, ['jpg', 'jpeg', 'bmp', 'png', 'gif'])) {
             $type = 'data';
             $content = base64_encode($content);
         }
         return array('type' => $type, 'content' => $content);
     }
     if (!is_dir($path)) {
         return array();
     }
     $result = array('type' => 'dir', 'items' => array());
     if ($handle = opendir($path)) {
         while (($name = readdir($handle)) !== false) {
             if (preg_match('#^\\.#', $name)) {
                 continue;
             }
             $result['items'][$name] = FilesHelper::generateFso($path . "/" . $name, $recursive);
         }
         closedir($handle);
     }
     return $result;
 }
function unZip($themeName, $filename, $tmp_path)
{
    $base_upload_dir = get_base_upload_dir();
    $archive_file = $base_upload_dir . '/' . $filename . '.tmp';
    $tmp_dir = $base_upload_dir . '/zip-data.tmp';
    FilesHelper::emptyDirRecursive($tmp_dir);
    $archive = new PclZip($archive_file);
    if (0 == $archive->extract(PCLZIP_OPT_PATH, $tmp_dir)) {
        return array('status' => 'error', 'message' => "<p><b>Invalid zip</b></p>Extract error : " . $archive->errorInfo(true));
    }
    $fso = FilesHelper::generateFso($tmp_dir);
    FilesHelper::deleteFile($archive_file);
    FilesHelper::emptyDirRecursive($tmp_dir);
    return array('status' => 'done', 'fso' => $fso);
}