mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-24 22:18:00 +01:00
00f24a5c12
* Adopt PSR-2 coding style The Laravel framework adopts the PSR-2 coding style in version 5.1. Laravel apps *should* adopt this coding style as well. Read the [PSR-2 coding style guide][1] for more details and check out [PHPCS][2] to use as a code formatting tool. [1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md [2]: https://github.com/squizlabs/PHP_CodeSniffer * Adopt PHP short array syntax Laravel 5 adopted the short array syntax which became available in PHP 5.4. * Remove SelfHandling from Jobs Jobs are self handling by default in Laravel 5.2. * Add new exceptions to `$dontReport` property * Shift core files * Shift Middleware Laravel 5.2 adjusts the `Guard` object used within middleware. In addition, new `can` and `throttles` middleware were added. * Shift Input to Request facade Laravel 5.2 no longer registers the `Input` facade by default. Laravel now prefers using the `Request` facade or the `$request` object within *Controllers* instead. Review the [HTTP Requests][1] documentation for more details. [1]: https://laravel.com/docs/5.2/requests * Shift configuration Laravel 5.2 introduces the `env` app configuration option and removes the `pretend` mail configuration option. In addition, a few of the default `providers` and `aliases` bindings were removed. * Shift Laravel dependencies * Shift cleanup * Updated composer.lock * Updated Middleware to 5.2 * Config update for Laravel 5.2 * [Laravel 5.2] Updated validation strings * Updated auth config * Updated to use middleware groups * Added laravel 5.2 sessions migration
102 lines
5.4 KiB
PHP
102 lines
5.4 KiB
PHP
<?php
|
|
/////////////////////////////////////////////////////////////////
|
|
/// getID3() by James Heinrich <info@getid3.org> //
|
|
// available at http://getid3.sourceforge.net //
|
|
// or http://www.getid3.org //
|
|
// also https://github.com/JamesHeinrich/getID3 //
|
|
/////////////////////////////////////////////////////////////////
|
|
// //
|
|
// /demo/demo.zip.php - part of getID3() //
|
|
// Sample script how to use getID3() to decompress zip files //
|
|
// See readme.txt for more details //
|
|
// ///
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
function UnzipFileContents($filename, &$errors)
|
|
{
|
|
$errors = [];
|
|
$DecompressedFileContents = [];
|
|
if (!class_exists('getID3')) {
|
|
$errors[] = 'class getID3 not defined, please include getid3.php';
|
|
} elseif (include_once('module.archive.zip.php')) {
|
|
$getid3 = new getID3();
|
|
$getid3->info['filesize'] = filesize($filename);
|
|
ob_start();
|
|
if ($getid3->fp = fopen($filename, 'rb')) {
|
|
ob_end_clean();
|
|
$getid3_zip = new getid3_zip($getid3);
|
|
$getid3_zip->analyze($filename);
|
|
if (($getid3->info['fileformat'] == 'zip') && !empty($getid3->info['zip']['files'])) {
|
|
if (!empty($getid3->info['zip']['central_directory'])) {
|
|
$ZipDirectoryToWalk = $getid3->info['zip']['central_directory'];
|
|
} elseif (!empty($getid3->info['zip']['entries'])) {
|
|
$ZipDirectoryToWalk = $getid3->info['zip']['entries'];
|
|
} else {
|
|
$errors[] = 'failed to parse ZIP attachment "'.$piece_filename.'" (no central directory)<br>';
|
|
fclose($getid3->fp);
|
|
return false;
|
|
}
|
|
foreach ($ZipDirectoryToWalk as $key => $valuearray) {
|
|
fseek($getid3->fp, $valuearray['entry_offset'], SEEK_SET);
|
|
$LocalFileHeader = $getid3_zip->ZIPparseLocalFileHeader($getid3->fp);
|
|
if ($LocalFileHeader['flags']['encrypted']) {
|
|
// password-protected
|
|
$DecompressedFileContents[$valuearray['filename']] = '';
|
|
} else {
|
|
fseek($getid3->fp, $LocalFileHeader['data_offset'], SEEK_SET);
|
|
$compressedFileData = '';
|
|
while ((strlen($compressedFileData) < $LocalFileHeader['compressed_size']) && !feof($getid3->fp)) {
|
|
$compressedFileData .= fread($getid3->fp, 32768);
|
|
}
|
|
switch ($LocalFileHeader['raw']['compression_method']) {
|
|
case 0: // store - great, just copy data unchanged
|
|
$uncompressedFileData = $compressedFileData;
|
|
break;
|
|
|
|
case 8: // deflate
|
|
ob_start();
|
|
$uncompressedFileData = gzinflate($compressedFileData);
|
|
$gzinflate_errors = trim(strip_tags(ob_get_contents()));
|
|
ob_end_clean();
|
|
if ($gzinflate_errors) {
|
|
$errors[] = 'gzinflate() failed for file ['.$LocalFileHeader['filename'].']: "'.$gzinflate_errors.'"';
|
|
continue 2;
|
|
}
|
|
break;
|
|
|
|
case 1: // shrink
|
|
case 2: // reduce-1
|
|
case 3: // reduce-2
|
|
case 4: // reduce-3
|
|
case 5: // reduce-4
|
|
case 6: // implode
|
|
case 7: // tokenize
|
|
case 9: // deflate64
|
|
case 10: // PKWARE Date Compression Library Imploding
|
|
$DecompressedFileContents[$valuearray['filename']] = '';
|
|
$errors[] = 'unsupported ZIP compression method ('.$LocalFileHeader['raw']['compression_method'].' = '.$getid3_zip->ZIPcompressionMethodLookup($LocalFileHeader['raw']['compression_method']).')';
|
|
continue 2;
|
|
|
|
default:
|
|
$DecompressedFileContents[$valuearray['filename']] = '';
|
|
$errors[] = 'unknown ZIP compression method ('.$LocalFileHeader['raw']['compression_method'].')';
|
|
continue 2;
|
|
}
|
|
$DecompressedFileContents[$valuearray['filename']] = $uncompressedFileData;
|
|
unset($compressedFileData);
|
|
}
|
|
}
|
|
} else {
|
|
$errors[] = $filename.' does not appear to be a zip file';
|
|
}
|
|
} else {
|
|
$error_message = ob_get_contents();
|
|
ob_end_clean();
|
|
$errors[] = 'failed to fopen('.$filename.', rb): '.$error_message;
|
|
}
|
|
} else {
|
|
$errors[] = 'failed to include_once(module.archive.zip.php)';
|
|
}
|
|
return $DecompressedFileContents;
|
|
}
|