enabled) { $media->format(); $total_size += sprintf("%.2f",($media->size/1048576)); $dirname = ''; $parent = $media->get_parent(); if ($parent != null) { $pobj = new $parent['object_type']($parent['object_id']); $pobj->format(); $dirname = $pobj->get_fullname(); } if (!array_key_exists($dirname, $media_files)) { $media_files[$dirname] = array(); } array_push($media_files[$dirname], Core::conv_lc_file($media->file)); } } return array($media_files, $total_size); } //get_media_files /** * send_zip * * takes array of full paths to medias * zips them and sends them * * @param string $name name of the zip file to be created * @param array $media_files array of full paths to medias to zip create w/ call to get_media_files */ function send_zip($name, $media_files) { /* Require needed library */ if (!@include_once(AmpConfig::get('prefix') . '/lib/vendor/maennchen/zipstream-php/src/ZipStream.php')) { throw new Exception('Missing ZipStream dependency.'); } $arc = new ZipStream\ZipStream($name . ".zip" ); $options = array( 'comment' => AmpConfig::get('file_zip_comment'), ); foreach ($media_files as $dir => $files) { foreach ($files as $file) { $arc->addFileFromPath($dir . "/" . basename($file), $file, $options); } } $arc->finish(); } // send_zip /** * check_can_zip * * Check that an object type is allowed to be zipped. * * @param string $object_type */ function check_can_zip($object_type) { $allowed = true; if (AmpConfig::get('allow_zip_types')) { $allowed = false; $allowed_types = explode(',', AmpConfig::get('allow_zip_types')); foreach ($allowed_types as $atype) { if (trim($atype) == $object_type) { $allowed = true; break; } } } return $allowed; }