Initial revision
This commit is contained in:
parent
0dee919581
commit
53e7a3d8cc
15 changed files with 9701 additions and 0 deletions
21
livesupport/modules/getid3/var/getid3.aiff.php
Normal file
21
livesupport/modules/getid3/var/getid3.aiff.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.aiff.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function getAIFFHeaderFilepointer(&$fd, &$ThisFileInfo) {
|
||||
|
||||
$ThisFileInfo['fileformat'] = 'aiff';
|
||||
|
||||
$ThisFileInfo['error'] .= "\n".'AIFF parsing not enabled in this version of getID3()';
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
?>
|
1289
livesupport/modules/getid3/var/getid3.asf.php
Normal file
1289
livesupport/modules/getid3/var/getid3.asf.php
Normal file
File diff suppressed because it is too large
Load diff
644
livesupport/modules/getid3/var/getid3.bmp.php
Normal file
644
livesupport/modules/getid3/var/getid3.bmp.php
Normal file
|
@ -0,0 +1,644 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.bmp.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function getBMPHeaderFilepointer(&$fd, &$ThisFileInfo, $ExtractPalette=false, $ExtractData=false) {
|
||||
$ThisFileInfo['fileformat'] = 'bmp';
|
||||
$ThisFileInfo['video']['dataformat'] = 'bmp';
|
||||
|
||||
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
|
||||
$offset = 0;
|
||||
|
||||
$BMPheader = fread($fd, 14 + 40);
|
||||
|
||||
// check if the hardcoded-to-1 "planes" is at offset 22 or 26
|
||||
$planes22 = LittleEndian2Int(substr($BMPheader, 22, 2));
|
||||
$planes26 = LittleEndian2Int(substr($BMPheader, 26, 2));
|
||||
if (($planes22 == 1) && ($planes26 != 1)) {
|
||||
$ThisFileInfo['bmp']['type_os'] = 'OS/2';
|
||||
$ThisFileInfo['bmp']['type_version'] = 1;
|
||||
} elseif (($planes26 == 1) && ($planes22 != 1)) {
|
||||
$ThisFileInfo['bmp']['type_os'] = 'Windows';
|
||||
$ThisFileInfo['bmp']['type_version'] = 1;
|
||||
} elseif ($ThisFileInfo['bmp']['header']['raw']['header_size'] == 12) {
|
||||
$ThisFileInfo['bmp']['type_os'] = 'OS/2';
|
||||
$ThisFileInfo['bmp']['type_version'] = 1;
|
||||
} elseif ($ThisFileInfo['bmp']['header']['raw']['header_size'] == 40) {
|
||||
$ThisFileInfo['bmp']['type_os'] = 'Windows';
|
||||
$ThisFileInfo['bmp']['type_version'] = 1;
|
||||
} elseif ($ThisFileInfo['bmp']['header']['raw']['header_size'] == 84) {
|
||||
$ThisFileInfo['bmp']['type_os'] = 'Windows';
|
||||
$ThisFileInfo['bmp']['type_version'] = 4;
|
||||
} elseif ($ThisFileInfo['bmp']['header']['raw']['header_size'] == 100) {
|
||||
$ThisFileInfo['bmp']['type_os'] = 'Windows';
|
||||
$ThisFileInfo['bmp']['type_version'] = 5;
|
||||
}
|
||||
|
||||
|
||||
// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
|
||||
// all versions
|
||||
// WORD bfType;
|
||||
// DWORD bfSize;
|
||||
// WORD bfReserved1;
|
||||
// WORD bfReserved2;
|
||||
// DWORD bfOffBits;
|
||||
$ThisFileInfo['bmp']['header']['raw']['identifier'] = substr($BMPheader, $offset, 2);
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['filesize'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['reserved1'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['reserved2'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['data_offset'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
if ($ThisFileInfo['bmp']['type_os'] == 'OS/2') {
|
||||
|
||||
// OS/2-format BMP
|
||||
// http://netghost.narod.ru/gff/graphics/summary/os2bmp.htm
|
||||
|
||||
// DWORD Size; /* Size of this structure in bytes */
|
||||
// DWORD Width; /* Bitmap width in pixels */
|
||||
// DWORD Height; /* Bitmap height in pixel */
|
||||
// WORD NumPlanes; /* Number of bit planes (color depth) */
|
||||
// WORD BitsPerPixel; /* Number of bits per pixel per plane */
|
||||
|
||||
$ThisFileInfo['bmp']['header']['raw']['header_size'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['width'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['height'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['planes'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
|
||||
$ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['bmp']['header']['raw']['width'];
|
||||
$ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['bmp']['header']['raw']['height'];
|
||||
$ThisFileInfo['video']['codec'] = 'BI_RGB '.$ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'].'-bit';
|
||||
|
||||
if ($ThisFileInfo['bmp']['type_version'] >= 2) {
|
||||
// DWORD Compression; /* Bitmap compression scheme */
|
||||
// DWORD ImageDataSize; /* Size of bitmap data in bytes */
|
||||
// DWORD XResolution; /* X resolution of display device */
|
||||
// DWORD YResolution; /* Y resolution of display device */
|
||||
// DWORD ColorsUsed; /* Number of color table indices used */
|
||||
// DWORD ColorsImportant; /* Number of important color indices */
|
||||
// WORD Units; /* Type of units used to measure resolution */
|
||||
// WORD Reserved; /* Pad structure to 4-byte boundary */
|
||||
// WORD Recording; /* Recording algorithm */
|
||||
// WORD Rendering; /* Halftoning algorithm used */
|
||||
// DWORD Size1; /* Reserved for halftoning algorithm use */
|
||||
// DWORD Size2; /* Reserved for halftoning algorithm use */
|
||||
// DWORD ColorEncoding; /* Color model used in bitmap */
|
||||
// DWORD Identifier; /* Reserved for application use */
|
||||
|
||||
$ThisFileInfo['bmp']['header']['raw']['compression'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['bmp_data_size'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['resolution_h'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['resolution_v'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['colors_used'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['colors_important'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['resolution_units'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['reserved1'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['recording'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['rendering'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['size1'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['size2'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['color_encoding'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['identifier'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
$ThisFileInfo['bmp']['header']['compression'] = BMPcompressionOS2Lookup($ThisFileInfo['bmp']['header']['raw']['compression']);
|
||||
|
||||
$ThisFileInfo['video']['codec'] = $ThisFileInfo['bmp']['header']['compression'].' '.$ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'].'-bit';
|
||||
}
|
||||
|
||||
} elseif ($ThisFileInfo['bmp']['type_os'] == 'Windows') {
|
||||
|
||||
// Windows-format BMP
|
||||
|
||||
// BITMAPINFOHEADER - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp
|
||||
// all versions
|
||||
// DWORD biSize;
|
||||
// LONG biWidth;
|
||||
// LONG biHeight;
|
||||
// WORD biPlanes;
|
||||
// WORD biBitCount;
|
||||
// DWORD biCompression;
|
||||
// DWORD biSizeImage;
|
||||
// LONG biXPelsPerMeter;
|
||||
// LONG biYPelsPerMeter;
|
||||
// DWORD biClrUsed;
|
||||
// DWORD biClrImportant;
|
||||
|
||||
$ThisFileInfo['bmp']['header']['raw']['header_size'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['width'] = LittleEndian2Int(substr($BMPheader, $offset, 4), true);
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['height'] = LittleEndian2Int(substr($BMPheader, $offset, 4), true);
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['planes'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'] = LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['bmp']['header']['raw']['compression'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['bmp_data_size'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['resolution_h'] = LittleEndian2Int(substr($BMPheader, $offset, 4), true);
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['resolution_v'] = LittleEndian2Int(substr($BMPheader, $offset, 4), true);
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['colors_used'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['colors_important'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
$ThisFileInfo['bmp']['header']['compression'] = BMPcompressionWindowsLookup($ThisFileInfo['bmp']['header']['raw']['compression']);
|
||||
$ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['bmp']['header']['raw']['width'];
|
||||
$ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['bmp']['header']['raw']['height'];
|
||||
$ThisFileInfo['video']['codec'] = $ThisFileInfo['bmp']['header']['compression'].' '.$ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'].'-bit';
|
||||
|
||||
if ($ThisFileInfo['bmp']['type_version'] >= 4) {
|
||||
$BMPheader .= fread($fd, 44);
|
||||
|
||||
// BITMAPV4HEADER - [44 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_2k1e.asp
|
||||
// Win95+, WinNT4.0+
|
||||
// DWORD bV4RedMask;
|
||||
// DWORD bV4GreenMask;
|
||||
// DWORD bV4BlueMask;
|
||||
// DWORD bV4AlphaMask;
|
||||
// DWORD bV4CSType;
|
||||
// CIEXYZTRIPLE bV4Endpoints;
|
||||
// DWORD bV4GammaRed;
|
||||
// DWORD bV4GammaGreen;
|
||||
// DWORD bV4GammaBlue;
|
||||
$ThisFileInfo['bmp']['header']['raw']['red_mask'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['green_mask'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['blue_mask'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['alpha_mask'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['cs_type'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['ciexyz_red'] = substr($BMPheader, $offset, 4);
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['ciexyz_green'] = substr($BMPheader, $offset, 4);
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['ciexyz_blue'] = substr($BMPheader, $offset, 4);
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['gamma_red'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['gamma_green'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['gamma_blue'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
$ThisFileInfo['bmp']['header']['ciexyz_red'] = FixedPoint2_30(strrev($ThisFileInfo['bmp']['header']['raw']['ciexyz_red']));
|
||||
$ThisFileInfo['bmp']['header']['ciexyz_green'] = FixedPoint2_30(strrev($ThisFileInfo['bmp']['header']['raw']['ciexyz_green']));
|
||||
$ThisFileInfo['bmp']['header']['ciexyz_blue'] = FixedPoint2_30(strrev($ThisFileInfo['bmp']['header']['raw']['ciexyz_blue']));
|
||||
}
|
||||
|
||||
if ($ThisFileInfo['bmp']['type_version'] >= 5) {
|
||||
$BMPheader .= fread($fd, 16);
|
||||
|
||||
// BITMAPV5HEADER - [16 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_7c36.asp
|
||||
// Win98+, Win2000+
|
||||
// DWORD bV5Intent;
|
||||
// DWORD bV5ProfileData;
|
||||
// DWORD bV5ProfileSize;
|
||||
// DWORD bV5Reserved;
|
||||
$ThisFileInfo['bmp']['header']['raw']['intent'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['profile_data_offset'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['profile_data_size'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['bmp']['header']['raw']['reserved3'] = LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$ThisFileInfo['error'] .= "\n".'Unknown BMP format in header.';
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($ExtractPalette || $ExtractData) {
|
||||
$PaletteEntries = 0;
|
||||
if ($ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'] < 16) {
|
||||
$PaletteEntries = pow(2, $ThisFileInfo['bmp']['header']['raw']['bits_per_pixel']);
|
||||
} elseif (isset($ThisFileInfo['bmp']['header']['raw']['colors_used']) && ($ThisFileInfo['bmp']['header']['raw']['colors_used'] > 0) && ($ThisFileInfo['bmp']['header']['raw']['colors_used'] <= 256)) {
|
||||
$PaletteEntries = $ThisFileInfo['bmp']['header']['raw']['colors_used'];
|
||||
}
|
||||
if ($PaletteEntries > 0) {
|
||||
$BMPpalette = fread($fd, 4 * $PaletteEntries);
|
||||
$paletteoffset = 0;
|
||||
for ($i = 0; $i < $PaletteEntries; $i++) {
|
||||
// RGBQUAD - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_5f8y.asp
|
||||
// BYTE rgbBlue;
|
||||
// BYTE rgbGreen;
|
||||
// BYTE rgbRed;
|
||||
// BYTE rgbReserved;
|
||||
//$ThisFileInfo['bmp']['palette']['blue'][$i] = LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
|
||||
//$ThisFileInfo['bmp']['palette']['green'][$i] = LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
|
||||
//$ThisFileInfo['bmp']['palette']['red'][$i] = LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
|
||||
$blue = LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
|
||||
$green = LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
|
||||
$red = LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
|
||||
if (($ThisFileInfo['bmp']['type_os'] == 'OS/2') && ($ThisFileInfo['bmp']['type_version'] == 1)) {
|
||||
// no padding byte
|
||||
} else {
|
||||
$paletteoffset++; // padding byte
|
||||
}
|
||||
$ThisFileInfo['bmp']['palette'][$i] = (($red << 16) | ($green << 8) | ($blue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($ExtractData) {
|
||||
fseek($fd, $ThisFileInfo['bmp']['header']['raw']['data_offset'], SEEK_SET);
|
||||
$RowByteLength = ceil(($ThisFileInfo['bmp']['header']['raw']['width'] * ($ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'] / 8)) / 4) * 4; // round up to nearest DWORD boundry
|
||||
$BMPpixelData = fread($fd, $ThisFileInfo['bmp']['header']['raw']['height'] * $RowByteLength);
|
||||
$pixeldataoffset = 0;
|
||||
switch ($ThisFileInfo['bmp']['header']['raw']['compression']) {
|
||||
|
||||
case 0: // BI_RGB
|
||||
switch ($ThisFileInfo['bmp']['header']['raw']['bits_per_pixel']) {
|
||||
case 1:
|
||||
for ($row = ($ThisFileInfo['bmp']['header']['raw']['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $ThisFileInfo['bmp']['header']['raw']['width']; $col = $col) {
|
||||
$paletteindexbyte = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
for ($i = 7; $i >= 0; $i--) {
|
||||
$paletteindex = ($paletteindexbyte & (0x01 << $i)) >> $i;
|
||||
$ThisFileInfo['bmp']['data'][$row][$col] = $ThisFileInfo['bmp']['palette'][$paletteindex];
|
||||
$col++;
|
||||
}
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
for ($row = ($ThisFileInfo['bmp']['header']['raw']['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $ThisFileInfo['bmp']['header']['raw']['width']; $col = $col) {
|
||||
$paletteindexbyte = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
for ($i = 1; $i >= 0; $i--) {
|
||||
$paletteindex = ($paletteindexbyte & (0x0F << (4 * $i))) >> (4 * $i);
|
||||
$ThisFileInfo['bmp']['data'][$row][$col] = $ThisFileInfo['bmp']['palette'][$paletteindex];
|
||||
$col++;
|
||||
}
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
for ($row = ($ThisFileInfo['bmp']['header']['raw']['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $ThisFileInfo['bmp']['header']['raw']['width']; $col++) {
|
||||
$paletteindex = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$ThisFileInfo['bmp']['data'][$row][$col] = $ThisFileInfo['bmp']['palette'][$paletteindex];
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 24:
|
||||
case 32:
|
||||
for ($row = ($ThisFileInfo['bmp']['header']['raw']['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $ThisFileInfo['bmp']['header']['raw']['width']; $col++) {
|
||||
$blue = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$green = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$red = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
if ($ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'] == 32) {
|
||||
$paletteoffset++; // filler byte
|
||||
}
|
||||
$ThisFileInfo['bmp']['data'][$row][$col] = (($red << 16) | ($green << 8) | ($blue));
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 16:
|
||||
|
||||
default:
|
||||
$ThisFileInfo['error'] .= "\n".'Unknown bits-per-pixel value ('.$ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'].') - cannot read pixel data';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 1: // BI_RLE8 - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_6x0u.asp
|
||||
switch ($ThisFileInfo['bmp']['header']['raw']['bits_per_pixel']) {
|
||||
case 8:
|
||||
$pixelcounter = 0;
|
||||
while ($pixeldataoffset < strlen($BMPpixelData)) {
|
||||
$firstbyte = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$secondbyte = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
if ($firstbyte == 0) {
|
||||
|
||||
// escaped/absolute mode - the first byte of the pair can be set to zero to
|
||||
// indicate an escape character that denotes the end of a line, the end of
|
||||
// a bitmap, or a delta, depending on the value of the second byte.
|
||||
switch ($secondbyte) {
|
||||
case 0:
|
||||
// end of line
|
||||
// no need for special processing, just ignore
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// end of bitmap
|
||||
$pixeldataoffset = strlen($BMPpixelData); // force to exit loop just in case
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// delta - The 2 bytes following the escape contain unsigned values
|
||||
// indicating the horizontal and vertical offsets of the next pixel
|
||||
// from the current position.
|
||||
$colincrement = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$rowincrement = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$col = ($pixelcounter % $ThisFileInfo['bmp']['header']['raw']['width']) + $colincrement;
|
||||
$row = ($ThisFileInfo['bmp']['header']['raw']['height'] - 1 - (($pixelcounter - $col) / $ThisFileInfo['bmp']['header']['raw']['width'])) - $rowincrement;
|
||||
$pixelcounter = ($row * $ThisFileInfo['bmp']['header']['raw']['width']) + $col;
|
||||
break;
|
||||
|
||||
default:
|
||||
// In absolute mode, the first byte is zero and the second byte is a
|
||||
// value in the range 03H through FFH. The second byte represents the
|
||||
// number of bytes that follow, each of which contains the color index
|
||||
// of a single pixel. Each run must be aligned on a word boundary.
|
||||
for ($i = 0; $i < $secondbyte; $i++) {
|
||||
$paletteindex = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$col = $pixelcounter % $ThisFileInfo['bmp']['header']['raw']['width'];
|
||||
$row = $ThisFileInfo['bmp']['header']['raw']['height'] - 1 - (($pixelcounter - $col) / $ThisFileInfo['bmp']['header']['raw']['width']);
|
||||
$ThisFileInfo['bmp']['data'][$row][$col] = $ThisFileInfo['bmp']['palette'][$paletteindex];
|
||||
$pixelcounter++;
|
||||
}
|
||||
while (($pixeldataoffset % 2) != 0) {
|
||||
// Each run must be aligned on a word boundary.
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// encoded mode - the first byte specifies the number of consecutive pixels
|
||||
// to be drawn using the color index contained in the second byte.
|
||||
for ($i = 0; $i < $firstbyte; $i++) {
|
||||
$col = $pixelcounter % $ThisFileInfo['bmp']['header']['raw']['width'];
|
||||
$row = $ThisFileInfo['bmp']['header']['raw']['height'] - 1 - (($pixelcounter - $col) / $ThisFileInfo['bmp']['header']['raw']['width']);
|
||||
$ThisFileInfo['bmp']['data'][$row][$col] = $ThisFileInfo['bmp']['palette'][$secondbyte];
|
||||
$pixelcounter++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$ThisFileInfo['error'] .= "\n".'Unknown bits-per-pixel value ('.$ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'].') - cannot read pixel data';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 2: // BI_RLE4 - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_6x0u.asp
|
||||
switch ($ThisFileInfo['bmp']['header']['raw']['bits_per_pixel']) {
|
||||
case 4:
|
||||
$pixelcounter = 0;
|
||||
while ($pixeldataoffset < strlen($BMPpixelData)) {
|
||||
$firstbyte = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$secondbyte = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
if ($firstbyte == 0) {
|
||||
|
||||
// escaped/absolute mode - the first byte of the pair can be set to zero to
|
||||
// indicate an escape character that denotes the end of a line, the end of
|
||||
// a bitmap, or a delta, depending on the value of the second byte.
|
||||
switch ($secondbyte) {
|
||||
case 0:
|
||||
// end of line
|
||||
// no need for special processing, just ignore
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// end of bitmap
|
||||
$pixeldataoffset = strlen($BMPpixelData); // force to exit loop just in case
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// delta - The 2 bytes following the escape contain unsigned values
|
||||
// indicating the horizontal and vertical offsets of the next pixel
|
||||
// from the current position.
|
||||
$colincrement = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$rowincrement = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$col = ($pixelcounter % $ThisFileInfo['bmp']['header']['raw']['width']) + $colincrement;
|
||||
$row = ($ThisFileInfo['bmp']['header']['raw']['height'] - 1 - (($pixelcounter - $col) / $ThisFileInfo['bmp']['header']['raw']['width'])) - $rowincrement;
|
||||
$pixelcounter = ($row * $ThisFileInfo['bmp']['header']['raw']['width']) + $col;
|
||||
break;
|
||||
|
||||
default:
|
||||
// In absolute mode, the first byte is zero. The second byte contains the number
|
||||
// of color indexes that follow. Subsequent bytes contain color indexes in their
|
||||
// high- and low-order 4 bits, one color index for each pixel. In absolute mode,
|
||||
// each run must be aligned on a word boundary.
|
||||
unset($paletteindexes);
|
||||
for ($i = 0; $i < ceil($secondbyte / 2); $i++) {
|
||||
$paletteindexbyte = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$paletteindexes[] = ($paletteindexbyte & 0xF0) >> 4;
|
||||
$paletteindexes[] = ($paletteindexbyte & 0x0F);
|
||||
}
|
||||
while (($pixeldataoffset % 2) != 0) {
|
||||
// Each run must be aligned on a word boundary.
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
|
||||
foreach ($paletteindexes as $paletteindex) {
|
||||
$col = $pixelcounter % $ThisFileInfo['bmp']['header']['raw']['width'];
|
||||
$row = $ThisFileInfo['bmp']['header']['raw']['height'] - 1 - (($pixelcounter - $col) / $ThisFileInfo['bmp']['header']['raw']['width']);
|
||||
$ThisFileInfo['bmp']['data'][$row][$col] = $ThisFileInfo['bmp']['palette'][$paletteindex];
|
||||
$pixelcounter++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// encoded mode - the first byte of the pair contains the number of pixels to be
|
||||
// drawn using the color indexes in the second byte. The second byte contains two
|
||||
// color indexes, one in its high-order 4 bits and one in its low-order 4 bits.
|
||||
// The first of the pixels is drawn using the color specified by the high-order
|
||||
// 4 bits, the second is drawn using the color in the low-order 4 bits, the third
|
||||
// is drawn using the color in the high-order 4 bits, and so on, until all the
|
||||
// pixels specified by the first byte have been drawn.
|
||||
$paletteindexes[0] = ($secondbyte & 0xF0) >> 4;
|
||||
$paletteindexes[1] = ($secondbyte & 0x0F);
|
||||
for ($i = 0; $i < $firstbyte; $i++) {
|
||||
$col = $pixelcounter % $ThisFileInfo['bmp']['header']['raw']['width'];
|
||||
$row = $ThisFileInfo['bmp']['header']['raw']['height'] - 1 - (($pixelcounter - $col) / $ThisFileInfo['bmp']['header']['raw']['width']);
|
||||
$ThisFileInfo['bmp']['data'][$row][$col] = $ThisFileInfo['bmp']['palette'][$paletteindexes[($i % 2)]];
|
||||
$pixelcounter++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$ThisFileInfo['error'] .= "\n".'Unknown bits-per-pixel value ('.$ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'].') - cannot read pixel data';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 3: // BI_BITFIELDS
|
||||
switch ($ThisFileInfo['bmp']['header']['raw']['bits_per_pixel']) {
|
||||
case 16:
|
||||
case 32:
|
||||
$redshift = 0;
|
||||
$greenshift = 0;
|
||||
$blueshift = 0;
|
||||
while ((($ThisFileInfo['bmp']['header']['raw']['red_mask'] >> $redshift) & 0x01) == 0) {
|
||||
$redshift++;
|
||||
}
|
||||
while ((($ThisFileInfo['bmp']['header']['raw']['green_mask'] >> $greenshift) & 0x01) == 0) {
|
||||
$greenshift++;
|
||||
}
|
||||
while ((($ThisFileInfo['bmp']['header']['raw']['blue_mask'] >> $blueshift) & 0x01) == 0) {
|
||||
$blueshift++;
|
||||
}
|
||||
for ($row = ($ThisFileInfo['bmp']['header']['raw']['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $ThisFileInfo['bmp']['header']['raw']['width']; $col++) {
|
||||
$pixelvalue = LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset, $ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'] / 8));
|
||||
$pixeldataoffset += $ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'] / 8;
|
||||
|
||||
$red = round(((($pixelvalue & $ThisFileInfo['bmp']['header']['raw']['red_mask']) >> $redshift) / ($ThisFileInfo['bmp']['header']['raw']['red_mask'] >> $redshift)) * 255);
|
||||
$green = round(((($pixelvalue & $ThisFileInfo['bmp']['header']['raw']['green_mask']) >> $greenshift) / ($ThisFileInfo['bmp']['header']['raw']['green_mask'] >> $greenshift)) * 255);
|
||||
$blue = round(((($pixelvalue & $ThisFileInfo['bmp']['header']['raw']['blue_mask']) >> $blueshift) / ($ThisFileInfo['bmp']['header']['raw']['blue_mask'] >> $blueshift)) * 255);
|
||||
$ThisFileInfo['bmp']['data'][$row][$col] = (($red << 16) | ($green << 8) | ($blue));
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$ThisFileInfo['error'] .= "\n".'Unknown bits-per-pixel value ('.$ThisFileInfo['bmp']['header']['raw']['bits_per_pixel'].') - cannot read pixel data';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default: // unhandled compression type
|
||||
$ThisFileInfo['error'] .= "\n".'Unknown/unhandled compression type value ('.$ThisFileInfo['bmp']['header']['raw']['compression'].') - cannot decompress pixel data';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function PlotBMP(&$BMPinfo) {
|
||||
$starttime = time();
|
||||
if (!isset($BMPinfo['bmp']['data']) || !is_array($BMPinfo['bmp']['data'])) {
|
||||
echo 'ERROR: no pixel data<BR>';
|
||||
return false;
|
||||
}
|
||||
set_time_limit(round($BMPinfo['resolution_x'] * $BMPinfo['resolution_y'] / 10000));
|
||||
if ($im = ImageCreateTrueColor($BMPinfo['resolution_x'], $BMPinfo['resolution_y'])) {
|
||||
for ($row = 0; $row < $BMPinfo['resolution_y']; $row++) {
|
||||
for ($col = 0; $col < $BMPinfo['resolution_x']; $col++) {
|
||||
if (isset($BMPinfo['bmp']['data'][$row][$col])) {
|
||||
$red = ($BMPinfo['bmp']['data'][$row][$col] & 0x00FF0000) >> 16;
|
||||
$green = ($BMPinfo['bmp']['data'][$row][$col] & 0x0000FF00) >> 8;
|
||||
$blue = ($BMPinfo['bmp']['data'][$row][$col] & 0x000000FF);
|
||||
$pixelcolor = ImageColorAllocate($im, $red, $green, $blue);
|
||||
ImageSetPixel($im, $col, $row, $pixelcolor);
|
||||
} else {
|
||||
//echo 'ERROR: no data for pixel '.$row.' x '.$col.'<BR>';
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (headers_sent()) {
|
||||
echo 'plotted '.($BMPinfo['resolution_x'] * $BMPinfo['resolution_y']).' pixels in '.(time() - $starttime).' seconds<BR>';
|
||||
ImageDestroy($im);
|
||||
exit;
|
||||
} else {
|
||||
header('Content-type: image/png');
|
||||
ImagePNG($im);
|
||||
ImageDestroy($im);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function BMPcompressionWindowsLookup($compressionid) {
|
||||
static $BMPcompressionWindowsLookup = array();
|
||||
if (empty($BMPcompressionWindowsLookup)) {
|
||||
$BMPcompressionWindowsLookup[0] = 'BI_RGB';
|
||||
$BMPcompressionWindowsLookup[1] = 'BI_RLE8';
|
||||
$BMPcompressionWindowsLookup[2] = 'BI_RLE4';
|
||||
$BMPcompressionWindowsLookup[3] = 'BI_BITFIELDS';
|
||||
$BMPcompressionWindowsLookup[4] = 'BI_JPEG';
|
||||
$BMPcompressionWindowsLookup[5] = 'BI_PNG';
|
||||
}
|
||||
return (isset($BMPcompressionWindowsLookup[$compressionid]) ? $BMPcompressionWindowsLookup[$compressionid] : 'invalid');
|
||||
}
|
||||
|
||||
function BMPcompressionOS2Lookup($compressionid) {
|
||||
static $BMPcompressionOS2Lookup = array();
|
||||
if (empty($BMPcompressionOS2Lookup)) {
|
||||
$BMPcompressionOS2Lookup[0] = 'BI_RGB';
|
||||
$BMPcompressionOS2Lookup[1] = 'BI_RLE8';
|
||||
$BMPcompressionOS2Lookup[2] = 'BI_RLE4';
|
||||
$BMPcompressionOS2Lookup[3] = 'Huffman 1D';
|
||||
$BMPcompressionOS2Lookup[4] = 'BI_RLE24';
|
||||
}
|
||||
return (isset($BMPcompressionOS2Lookup[$compressionid]) ? $BMPcompressionOS2Lookup[$compressionid] : 'invalid');
|
||||
}
|
||||
|
||||
?>
|
2763
livesupport/modules/getid3/var/getid3.frames.php
Normal file
2763
livesupport/modules/getid3/var/getid3.frames.php
Normal file
File diff suppressed because it is too large
Load diff
343
livesupport/modules/getid3/var/getid3.iso.php
Normal file
343
livesupport/modules/getid3/var/getid3.iso.php
Normal file
|
@ -0,0 +1,343 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.iso.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function getISOHeaderFilepointer($fd, &$ThisFileInfo) {
|
||||
$ThisFileInfo['fileformat'] = 'iso';
|
||||
|
||||
for ($i = 16; $i <= 19; $i++) {
|
||||
fseek($fd, 2048 * $i, SEEK_SET);
|
||||
$ISOheader = fread($fd, 2048);
|
||||
if (substr($ISOheader, 1, 5) == 'CD001') {
|
||||
switch (ord($ISOheader{0})) {
|
||||
case 1:
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['offset'] = 2048 * $i;
|
||||
ParsePrimaryVolumeDescriptor($ISOheader, $ThisFileInfo);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['offset'] = 2048 * $i;
|
||||
ParseSupplementaryVolumeDescriptor($ISOheader, $ThisFileInfo);
|
||||
break;
|
||||
|
||||
default:
|
||||
// skip
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ParsePathTable($fd, $ThisFileInfo);
|
||||
|
||||
$ThisFileInfo['iso']['files'] = array();
|
||||
foreach ($ThisFileInfo['iso']['path_table']['directories'] as $directorynum => $directorydata) {
|
||||
|
||||
$ThisFileInfo['iso']['directories'][$directorynum] = ParseDirectoryRecord($fd, $directorydata, $ThisFileInfo);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function ParsePrimaryVolumeDescriptor(&$ISOheader, &$ThisFileInfo) {
|
||||
// ISO integer values are stored *BOTH* Little-Endian AND Big-Endian format!!
|
||||
// ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
|
||||
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_descriptor_type'] = LittleEndian2Int(substr($ISOheader, 0, 1));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['standard_identifier'] = substr($ISOheader, 1, 5);
|
||||
if ($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['standard_identifier'] != 'CD001') {
|
||||
$ThisFileInfo['error'] .= "\n".'Expected "CD001" at offset ('.($ThisFileInfo['iso']['primary_volume_descriptor']['offset'] + 1).'), found "'.$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['standard_identifier'].'" instead';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_descriptor_version'] = LittleEndian2Int(substr($ISOheader, 6, 1));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['unused_1'] = substr($ISOheader, 7, 1);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['system_identifier'] = substr($ISOheader, 8, 32);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_identifier'] = substr($ISOheader, 40, 32);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['unused_2'] = substr($ISOheader, 72, 8);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_space_size'] = LittleEndian2Int(substr($ISOheader, 80, 4));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['unused_3'] = substr($ISOheader, 88, 32);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_set_size'] = LittleEndian2Int(substr($ISOheader, 120, 2));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_sequence_number'] = LittleEndian2Int(substr($ISOheader, 124, 2));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['logical_block_size'] = LittleEndian2Int(substr($ISOheader, 128, 2));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_size'] = LittleEndian2Int(substr($ISOheader, 132, 4));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_l_location'] = LittleEndian2Int(substr($ISOheader, 140, 2));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_l_opt_location'] = LittleEndian2Int(substr($ISOheader, 144, 2));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_m_location'] = LittleEndian2Int(substr($ISOheader, 148, 2));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_m_opt_location'] = LittleEndian2Int(substr($ISOheader, 152, 2));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['root_directory_record'] = substr($ISOheader, 156, 34);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_set_identifier'] = substr($ISOheader, 190, 128);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['publisher_identifier'] = substr($ISOheader, 318, 128);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['data_preparer_identifier'] = substr($ISOheader, 446, 128);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['application_identifier'] = substr($ISOheader, 574, 128);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['copyright_file_identifier'] = substr($ISOheader, 702, 37);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['abstract_file_identifier'] = substr($ISOheader, 739, 37);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['bibliographic_file_identifier'] = substr($ISOheader, 776, 37);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_creation_date_time'] = substr($ISOheader, 813, 17);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_modification_date_time'] = substr($ISOheader, 830, 17);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_expiration_date_time'] = substr($ISOheader, 847, 17);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_effective_date_time'] = substr($ISOheader, 864, 17);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['file_structure_version'] = LittleEndian2Int(substr($ISOheader, 881, 1));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['unused_4'] = LittleEndian2Int(substr($ISOheader, 882, 1));
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['application_data'] = substr($ISOheader, 883, 512);
|
||||
//$ThisFileInfo['iso']['primary_volume_descriptor']['raw']['unused_5'] = substr($ISOheader, 1395, 653);
|
||||
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['system_identifier'] = trim($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['system_identifier']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['volume_identifier'] = trim($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_identifier']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['volume_set_identifier'] = trim($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_set_identifier']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['publisher_identifier'] = trim($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['publisher_identifier']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['data_preparer_identifier'] = trim($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['data_preparer_identifier']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['application_identifier'] = trim($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['application_identifier']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['copyright_file_identifier'] = trim($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['copyright_file_identifier']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['abstract_file_identifier'] = trim($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['abstract_file_identifier']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['bibliographic_file_identifier'] = trim($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['bibliographic_file_identifier']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['volume_creation_date_time'] = ISOtimeText2UNIXtime($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_creation_date_time']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['volume_modification_date_time'] = ISOtimeText2UNIXtime($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_modification_date_time']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['volume_expiration_date_time'] = ISOtimeText2UNIXtime($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_expiration_date_time']);
|
||||
$ThisFileInfo['iso']['primary_volume_descriptor']['volume_effective_date_time'] = ISOtimeText2UNIXtime($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_effective_date_time']);
|
||||
|
||||
if (($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_space_size'] * 2048) > $ThisFileInfo['filesize']) {
|
||||
$ThisFileInfo['error'] .= "\n".'Volume Space Size ('.($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['volume_space_size'] * 2048).' bytes) is larger than the file size ('.$ThisFileInfo['filesize'].' bytes) (truncated file?)';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function ParseSupplementaryVolumeDescriptor(&$ISOheader, &$ThisFileInfo) {
|
||||
// ISO integer values are stored Both-Endian format!!
|
||||
// ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
|
||||
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_descriptor_type'] = LittleEndian2Int(substr($ISOheader, 0, 1));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['standard_identifier'] = substr($ISOheader, 1, 5);
|
||||
if ($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['standard_identifier'] != 'CD001') {
|
||||
$ThisFileInfo['error'] .= "\n".'Expected "CD001" at offset ('.($ThisFileInfo['iso']['supplementary_volume_descriptor']['offset'] + 1).'), found "'.$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['standard_identifier'].'" instead';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_descriptor_version'] = LittleEndian2Int(substr($ISOheader, 6, 1));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['unused_1'] = substr($ISOheader, 7, 1);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['system_identifier'] = substr($ISOheader, 8, 32);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_identifier'] = substr($ISOheader, 40, 32);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['unused_2'] = substr($ISOheader, 72, 8);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_space_size'] = LittleEndian2Int(substr($ISOheader, 80, 4));
|
||||
if ($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_space_size'] == 0) {
|
||||
// Supplementary Volume Descriptor not used
|
||||
// unset($ThisFileInfo['iso']['supplementary_volume_descriptor']);
|
||||
// return false;
|
||||
}
|
||||
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['unused_3'] = substr($ISOheader, 88, 32);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_set_size'] = LittleEndian2Int(substr($ISOheader, 120, 2));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_sequence_number'] = LittleEndian2Int(substr($ISOheader, 124, 2));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['logical_block_size'] = LittleEndian2Int(substr($ISOheader, 128, 2));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_size'] = LittleEndian2Int(substr($ISOheader, 132, 4));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'] = LittleEndian2Int(substr($ISOheader, 140, 2));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_l_opt_location'] = LittleEndian2Int(substr($ISOheader, 144, 2));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_m_location'] = LittleEndian2Int(substr($ISOheader, 148, 2));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_m_opt_location'] = LittleEndian2Int(substr($ISOheader, 152, 2));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['root_directory_record'] = substr($ISOheader, 156, 34);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_set_identifier'] = substr($ISOheader, 190, 128);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['publisher_identifier'] = substr($ISOheader, 318, 128);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['data_preparer_identifier'] = substr($ISOheader, 446, 128);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['application_identifier'] = substr($ISOheader, 574, 128);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['copyright_file_identifier'] = substr($ISOheader, 702, 37);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['abstract_file_identifier'] = substr($ISOheader, 739, 37);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['bibliographic_file_identifier'] = substr($ISOheader, 776, 37);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_creation_date_time'] = substr($ISOheader, 813, 17);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_modification_date_time'] = substr($ISOheader, 830, 17);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_expiration_date_time'] = substr($ISOheader, 847, 17);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_effective_date_time'] = substr($ISOheader, 864, 17);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['file_structure_version'] = LittleEndian2Int(substr($ISOheader, 881, 1));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['unused_4'] = LittleEndian2Int(substr($ISOheader, 882, 1));
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['application_data'] = substr($ISOheader, 883, 512);
|
||||
//$ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['unused_5'] = substr($ISOheader, 1395, 653);
|
||||
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['system_identifier'] = trim($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['system_identifier']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['volume_identifier'] = trim($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_identifier']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['volume_set_identifier'] = trim($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_set_identifier']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['publisher_identifier'] = trim($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['publisher_identifier']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['data_preparer_identifier'] = trim($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['data_preparer_identifier']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['application_identifier'] = trim($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['application_identifier']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['copyright_file_identifier'] = trim($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['copyright_file_identifier']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['abstract_file_identifier'] = trim($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['abstract_file_identifier']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['bibliographic_file_identifier'] = trim($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['bibliographic_file_identifier']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['volume_creation_date_time'] = ISOtimeText2UNIXtime($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_creation_date_time']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['volume_modification_date_time'] = ISOtimeText2UNIXtime($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_modification_date_time']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['volume_expiration_date_time'] = ISOtimeText2UNIXtime($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_expiration_date_time']);
|
||||
$ThisFileInfo['iso']['supplementary_volume_descriptor']['volume_effective_date_time'] = ISOtimeText2UNIXtime($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_effective_date_time']);
|
||||
|
||||
if (($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_space_size'] * $ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['logical_block_size']) > $ThisFileInfo['filesize']) {
|
||||
$ThisFileInfo['error'] .= "\n".'Volume Space Size ('.($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['volume_space_size'] * $ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['logical_block_size']).' bytes) is larger than the file size ('.$ThisFileInfo['filesize'].' bytes) (truncated file?)';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function ParsePathTable($fd, &$ThisFileInfo) {
|
||||
if (!isset($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location']) && !isset($ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_l_location'])) {
|
||||
return false;
|
||||
}
|
||||
if (isset($ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'])) {
|
||||
$PathTableLocation = $ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'];
|
||||
$PathTableSize = $ThisFileInfo['iso']['supplementary_volume_descriptor']['raw']['path_table_size'];
|
||||
$TextEncoding = 255; // Big-Endian Unicode
|
||||
} else {
|
||||
$PathTableLocation = $ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_l_location'];
|
||||
$PathTableSize = $ThisFileInfo['iso']['primary_volume_descriptor']['raw']['path_table_size'];
|
||||
$TextEncoding = 0; // ASCII
|
||||
}
|
||||
|
||||
if (($PathTableLocation * 2048) > $ThisFileInfo['filesize']) {
|
||||
$ThisFileInfo['error'] .= "\n".'Path Table Location specifies an offset ('.($PathTableLocation * 2048).') beyond the end-of-file ('.$ThisFileInfo['filesize'].')';
|
||||
return false;
|
||||
}
|
||||
|
||||
$ThisFileInfo['iso']['path_table']['offset'] = $PathTableLocation * 2048;
|
||||
fseek($fd, $ThisFileInfo['iso']['path_table']['offset'], SEEK_SET);
|
||||
$ThisFileInfo['iso']['path_table']['raw'] = fread($fd, $PathTableSize);
|
||||
|
||||
$offset = 0;
|
||||
$pathcounter = 1;
|
||||
while ($offset < $PathTableSize) {
|
||||
$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['length'] = LittleEndian2Int(substr($ThisFileInfo['iso']['path_table']['raw'], $offset, 1));
|
||||
$offset += 1;
|
||||
$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['extended_length'] = LittleEndian2Int(substr($ThisFileInfo['iso']['path_table']['raw'], $offset, 1));
|
||||
$offset += 1;
|
||||
$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['location_logical'] = LittleEndian2Int(substr($ThisFileInfo['iso']['path_table']['raw'], $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['parent_directory'] = LittleEndian2Int(substr($ThisFileInfo['iso']['path_table']['raw'], $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['name'] = substr($ThisFileInfo['iso']['path_table']['raw'], $offset, $ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['length']);
|
||||
$offset += $ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['length'] + ($ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['length'] % 2);
|
||||
|
||||
$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['name_ascii'] = RoughTranslateUnicodeToASCII($ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['name'], $TextEncoding);
|
||||
|
||||
$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['location_bytes'] = $ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['location_logical'] * 2048;
|
||||
if ($pathcounter == 1) {
|
||||
$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['full_path'] = '/';
|
||||
} else {
|
||||
$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['full_path'] = $ThisFileInfo['iso']['path_table']['directories'][$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['parent_directory']]['full_path'].$ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['name_ascii'].'/';
|
||||
}
|
||||
$FullPathArray[] = $ThisFileInfo['iso']['path_table']['directories'][$pathcounter]['full_path'];
|
||||
|
||||
$pathcounter++;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function ParseDirectoryRecord(&$fd, $directorydata, &$ThisFileInfo) {
|
||||
if (isset($ThisFileInfo['iso']['supplementary_volume_descriptor'])) {
|
||||
$TextEncoding = 255; // Big-Endian Unicode
|
||||
} else {
|
||||
$TextEncoding = 0; // ASCII
|
||||
}
|
||||
|
||||
|
||||
fseek($fd, $directorydata['location_bytes'], SEEK_SET);
|
||||
$DirectoryRecordData = fread($fd, 1);
|
||||
|
||||
while (ord($DirectoryRecordData{0}) > 33) {
|
||||
|
||||
$DirectoryRecordData .= fread($fd, ord($DirectoryRecordData{0}) - 1);
|
||||
|
||||
$ThisDirectoryRecord['raw']['length'] = LittleEndian2Int(substr($DirectoryRecordData, 0, 1));
|
||||
$ThisDirectoryRecord['raw']['extended_attribute_length'] = LittleEndian2Int(substr($DirectoryRecordData, 1, 1));
|
||||
$ThisDirectoryRecord['raw']['offset_logical'] = LittleEndian2Int(substr($DirectoryRecordData, 2, 4));
|
||||
$ThisDirectoryRecord['raw']['filesize'] = LittleEndian2Int(substr($DirectoryRecordData, 10, 4));
|
||||
$ThisDirectoryRecord['raw']['recording_date_time'] = substr($DirectoryRecordData, 18, 7);
|
||||
$ThisDirectoryRecord['raw']['file_flags'] = LittleEndian2Int(substr($DirectoryRecordData, 25, 1));
|
||||
$ThisDirectoryRecord['raw']['file_unit_size'] = LittleEndian2Int(substr($DirectoryRecordData, 26, 1));
|
||||
$ThisDirectoryRecord['raw']['interleave_gap_size'] = LittleEndian2Int(substr($DirectoryRecordData, 27, 1));
|
||||
$ThisDirectoryRecord['raw']['volume_sequence_number'] = LittleEndian2Int(substr($DirectoryRecordData, 28, 2));
|
||||
$ThisDirectoryRecord['raw']['file_identifier_length'] = LittleEndian2Int(substr($DirectoryRecordData, 32, 1));
|
||||
$ThisDirectoryRecord['raw']['file_identifier'] = substr($DirectoryRecordData, 33, $ThisDirectoryRecord['raw']['file_identifier_length']);
|
||||
|
||||
$ThisDirectoryRecord['file_identifier_ascii'] = RoughTranslateUnicodeToASCII($ThisDirectoryRecord['raw']['file_identifier'], $TextEncoding);
|
||||
|
||||
$ThisDirectoryRecord['filesize'] = $ThisDirectoryRecord['raw']['filesize'];
|
||||
$ThisDirectoryRecord['offset_bytes'] = $ThisDirectoryRecord['raw']['offset_logical'] * 2048;
|
||||
$ThisDirectoryRecord['file_flags']['hidden'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x01);
|
||||
$ThisDirectoryRecord['file_flags']['directory'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x02);
|
||||
$ThisDirectoryRecord['file_flags']['associated'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x04);
|
||||
$ThisDirectoryRecord['file_flags']['extended'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x08);
|
||||
$ThisDirectoryRecord['file_flags']['permissions'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x10);
|
||||
$ThisDirectoryRecord['file_flags']['multiple'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x80);
|
||||
$ThisDirectoryRecord['recording_timestamp'] = ISOtime2UNIXtime($ThisDirectoryRecord['raw']['recording_date_time']);
|
||||
|
||||
if ($ThisDirectoryRecord['file_flags']['directory']) {
|
||||
$ThisDirectoryRecord['filename'] = $directorydata['full_path'];
|
||||
} else {
|
||||
$ThisDirectoryRecord['filename'] = $directorydata['full_path'].ISOstripFilenameVersion($ThisDirectoryRecord['file_identifier_ascii']);
|
||||
$ThisFileInfo['iso']['files'] = array_merge_clobber($ThisFileInfo['iso']['files'], CreateDeepArray($ThisDirectoryRecord['filename'], '/', $ThisDirectoryRecord['filesize']));
|
||||
}
|
||||
|
||||
$DirectoryRecord[] = $ThisDirectoryRecord;
|
||||
$DirectoryRecordData = fread($fd, 1);
|
||||
}
|
||||
|
||||
return $DirectoryRecord;
|
||||
}
|
||||
|
||||
function ISOstripFilenameVersion($ISOfilename) {
|
||||
// convert 'filename.ext;1' to 'filename.ext'
|
||||
if (!strstr($ISOfilename, ';')) {
|
||||
return $ISOfilename;
|
||||
} else {
|
||||
return substr($ISOfilename, 0, strpos($ISOfilename, ';'));
|
||||
}
|
||||
}
|
||||
|
||||
function ISOtimeText2UNIXtime($ISOtime) {
|
||||
|
||||
$UNIXyear = (int) substr($ISOtime, 0, 4);
|
||||
$UNIXmonth = (int) substr($ISOtime, 4, 2);
|
||||
$UNIXday = (int) substr($ISOtime, 6, 2);
|
||||
$UNIXhour = (int) substr($ISOtime, 8, 2);
|
||||
$UNIXminute = (int) substr($ISOtime, 10, 2);
|
||||
$UNIXsecond = (int) substr($ISOtime, 12, 2);
|
||||
|
||||
if (!$UNIXyear) {
|
||||
return false;
|
||||
}
|
||||
return mktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
|
||||
}
|
||||
|
||||
function ISOtime2UNIXtime($ISOtime) {
|
||||
// Represented by seven bytes:
|
||||
// 1: Number of years since 1900
|
||||
// 2: Month of the year from 1 to 12
|
||||
// 3: Day of the Month from 1 to 31
|
||||
// 4: Hour of the day from 0 to 23
|
||||
// 5: Minute of the hour from 0 to 59
|
||||
// 6: second of the minute from 0 to 59
|
||||
// 7: Offset from Greenwich Mean Time in number of 15 minute intervals from -48 (West) to +52 (East)
|
||||
|
||||
$UNIXyear = ord($ISOtime{0}) + 1900;
|
||||
$UNIXmonth = ord($ISOtime{1});
|
||||
$UNIXday = ord($ISOtime{2});
|
||||
$UNIXhour = ord($ISOtime{3});
|
||||
$UNIXminute = ord($ISOtime{4});
|
||||
$UNIXsecond = ord($ISOtime{5});
|
||||
$GMToffset = TwosCompliment2Decimal(ord($ISOtime{5}));
|
||||
|
||||
return mktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
|
||||
}
|
||||
|
||||
|
||||
?>
|
58
livesupport/modules/getid3/var/getid3.jpg.php
Normal file
58
livesupport/modules/getid3/var/getid3.jpg.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.jpg.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function getJPGHeaderFilepointer(&$fd, &$ThisFileInfo) {
|
||||
$ThisFileInfo['fileformat'] = 'jpg';
|
||||
$ThisFileInfo['video']['dataformat'] = 'jpg';
|
||||
|
||||
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.getimagesize.php');
|
||||
|
||||
list($width, $height, $type) = GetDataImageSize(fread($fd, $ThisFileInfo['filesize']));
|
||||
if ($type == 2) {
|
||||
|
||||
$ThisFileInfo['video']['resolution_x'] = $width;
|
||||
$ThisFileInfo['video']['resolution_y'] = $height;
|
||||
|
||||
if (version_compare(phpversion(), '4.2.0', '>=')) {
|
||||
|
||||
if (function_exists('exif_read_data')) {
|
||||
|
||||
ob_start();
|
||||
$ThisFileInfo['jpg']['exif'] = exif_read_data($ThisFileInfo['filenamepath'], '', true, false);
|
||||
$errors = ob_get_contents();
|
||||
if ($errors) {
|
||||
$ThisFileInfo['warning'] .= "\n".strip_tags($errors);
|
||||
unset($ThisFileInfo['jpg']['exif']);
|
||||
}
|
||||
ob_end_clean();
|
||||
|
||||
} else {
|
||||
|
||||
$ThisFileInfo['error'] .= "\n".'EXIF parsing only available when compiled with --enable-exif (or php_exif.dll enabled for Windows)';
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$ThisFileInfo['error'] .= "\n".'EXIF parsing only available in PHP v4.2.0 and higher (you are using PHP v'.phpversion().') compiled with --enable-exif (or php_exif.dll enabled for Windows)';
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
unset($ThisFileInfo['fileformat']);
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
131
livesupport/modules/getid3/var/getid3.la.php
Normal file
131
livesupport/modules/getid3/var/getid3.la.php
Normal file
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.la.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function getLAHeaderFilepointer(&$fd, &$ThisFileInfo) {
|
||||
$offset = 0;
|
||||
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
|
||||
$rawdata = fread($fd, FREAD_BUFFER_SIZE);
|
||||
|
||||
switch (substr($rawdata, $offset, 4)) {
|
||||
case 'LA02':
|
||||
case 'LA03':
|
||||
$ThisFileInfo['fileformat'] = 'la';
|
||||
$ThisFileInfo['audio']['dataformat'] = 'la';
|
||||
$ThisFileInfo['la']['version_major'] = (int) substr($rawdata, $offset + 2, 1);
|
||||
$ThisFileInfo['la']['version_minor'] = (int) substr($rawdata, $offset + 3, 1);
|
||||
$ThisFileInfo['la']['version'] = (float) $ThisFileInfo['la']['version_major'] + ($ThisFileInfo['la']['version_minor'] / 10);
|
||||
$offset += 4;
|
||||
|
||||
$ThisFileInfo['la']['uncompressed_size'] = LittleEndian2Int(substr($rawdata, $offset, 4));
|
||||
$offset += 4;
|
||||
if ($ThisFileInfo['la']['uncompressed_size'] == 0) {
|
||||
$ThisFileInfo['error'] .= "\n".'Corrupt LA file: uncompressed_size == zero';
|
||||
return false;
|
||||
}
|
||||
|
||||
$WAVEchunk = substr($rawdata, $offset, 4);
|
||||
if ($WAVEchunk !== 'WAVE') {
|
||||
$ThisFileInfo['error'] .= "\n".'Expected "WAVE" ('.PrintHexBytes('WAVE').') at offset '.$offset.', found "'.$WAVEchunk.'" ('.PrintHexBytes($WAVEchunk).') instead.';
|
||||
return false;
|
||||
}
|
||||
$offset += 4;
|
||||
|
||||
$ThisFileInfo['la']['format_size'] = 24;
|
||||
if ($ThisFileInfo['la']['version'] > 0.2) {
|
||||
|
||||
$ThisFileInfo['la']['format_size'] = LittleEndian2Int(substr($rawdata, $offset, 4));
|
||||
$ThisFileInfo['la']['header_size'] = 49 + $ThisFileInfo['la']['format_size'] - 24;
|
||||
$offset += 4;
|
||||
|
||||
} else {
|
||||
|
||||
// version two didn't support additional data blocks
|
||||
$ThisFileInfo['la']['header_size'] = 41;
|
||||
|
||||
}
|
||||
|
||||
$fmt_chunk = substr($rawdata, $offset, 4);
|
||||
if ($fmt_chunk !== 'fmt ') {
|
||||
$ThisFileInfo['error'] .= "\n".'Expected "fmt " ('.PrintHexBytes('fmt ').') at offset '.$offset.', found "'.$fmt_chunk.'" ('.PrintHexBytes($fmt_chunk).') instead.';
|
||||
return false;
|
||||
}
|
||||
$offset += 4;
|
||||
$fmt_size = LittleEndian2Int(substr($rawdata, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
$ThisFileInfo['la']['format_raw'] = LittleEndian2Int(substr($rawdata, $offset, 2));
|
||||
$offset += 2;
|
||||
|
||||
$ThisFileInfo['la']['channels'] = LittleEndian2Int(substr($rawdata, $offset, 2));
|
||||
$offset += 2;
|
||||
if ($ThisFileInfo['la']['channels'] == 0) {
|
||||
$ThisFileInfo['error'] .= "\n".'Corrupt LA file: channels == zero';
|
||||
return false;
|
||||
}
|
||||
|
||||
$ThisFileInfo['la']['sample_rate'] = LittleEndian2Int(substr($rawdata, $offset, 4));
|
||||
$offset += 4;
|
||||
if ($ThisFileInfo['la']['sample_rate'] == 0) {
|
||||
$ThisFileInfo['error'] .= "\n".'Corrupt LA file: sample_rate == zero';
|
||||
return false;
|
||||
}
|
||||
|
||||
$ThisFileInfo['la']['bytes_per_second'] = LittleEndian2Int(substr($rawdata, $offset, 4));
|
||||
$offset += 4;
|
||||
$ThisFileInfo['la']['bytes_per_sample'] = LittleEndian2Int(substr($rawdata, $offset, 2));
|
||||
$offset += 2;
|
||||
$ThisFileInfo['la']['bits_per_sample'] = LittleEndian2Int(substr($rawdata, $offset, 2));
|
||||
$offset += 2;
|
||||
|
||||
$ThisFileInfo['la']['samples'] = LittleEndian2Int(substr($rawdata, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
$ThisFileInfo['la']['seekable'] = (bool) LittleEndian2Int(substr($rawdata, $offset, 1));
|
||||
$offset += 1;
|
||||
|
||||
$ThisFileInfo['la']['original_crc'] = LittleEndian2Int(substr($rawdata, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.riff.php');
|
||||
$ThisFileInfo['la']['codec'] = RIFFwFormatTagLookup($ThisFileInfo['la']['format_raw']);
|
||||
$ThisFileInfo['la']['compression_ratio'] = (float) (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) / $ThisFileInfo['la']['uncompressed_size']);
|
||||
$ThisFileInfo['playtime_seconds'] = (float) ($ThisFileInfo['la']['samples'] / $ThisFileInfo['la']['sample_rate']) / $ThisFileInfo['la']['channels'];
|
||||
if ($ThisFileInfo['playtime_seconds'] == 0) {
|
||||
$ThisFileInfo['error'] .= "\n".'Corrupt LA file: playtime_seconds == zero';
|
||||
return false;
|
||||
}
|
||||
|
||||
// add size of file header to avdataoffset - calc bitrate correctly + MD5 data
|
||||
$ThisFileInfo['avdataoffset'] += $ThisFileInfo['la']['header_size'];
|
||||
|
||||
$ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['playtime_seconds'];
|
||||
$ThisFileInfo['audio']['codec'] = $ThisFileInfo['la']['codec'];
|
||||
$ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['la']['bits_per_sample'];
|
||||
break;
|
||||
|
||||
default:
|
||||
if (substr($rawdata, $offset, 2) == 'LA') {
|
||||
$ThisFileInfo['error'] .= "\n".'This version of getID3() (v'.GETID3VERSION.') doesn\'t support LA version '.substr($rawdata, $offset + 2, 1).'.'.substr($rawdata, $offset + 3, 1).' which this appears to be - check http://getid3.sourceforge.net for updates.';
|
||||
} else {
|
||||
$ThisFileInfo['error'] .= "\n".'Not a LA (Lossless-Audio) file';
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
$ThisFileInfo['audio']['channels'] = $ThisFileInfo['la']['channels'];
|
||||
$ThisFileInfo['audio']['sample_rate'] = (int) $ThisFileInfo['la']['sample_rate'];
|
||||
$ThisFileInfo['audio']['encoder'] = (string) $ThisFileInfo['la']['version'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
104
livesupport/modules/getid3/var/getid3.ogginfo.php
Normal file
104
livesupport/modules/getid3/var/getid3.ogginfo.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.ogginfo.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function OggWrite($filename, $comments) {
|
||||
|
||||
// Uses vorbiscomment(.exe) to write comments, if available.
|
||||
|
||||
if ((bool) ini_get('safe_mode')) {
|
||||
|
||||
echo 'Failed making system call to vorbiscomment.exe - cannot write comments - error returned: PHP running in Safe Mode (backtick operator not available)';
|
||||
return false;
|
||||
|
||||
} else {
|
||||
|
||||
// Prevent user from aborting script
|
||||
$old_abort = ignore_user_abort(true);
|
||||
|
||||
// Create file with new comments
|
||||
$commentsfilename = tempnam('/tmp', 'getID3');
|
||||
if ($fpcomments = fopen($commentsfilename, 'wb')) {
|
||||
|
||||
foreach ($comments as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
$comments[$key] = array($value);
|
||||
}
|
||||
}
|
||||
foreach ($comments as $key => $value) {
|
||||
foreach ($value as $valuekey => $valuevalue) {
|
||||
str_replace("\r", "\n", $valuevalue);
|
||||
if (strstr($valuevalue, "\n")) {
|
||||
unset($comments[$key][$valuekey]);
|
||||
$multilineexploded = explode("\n", $valuevalue);
|
||||
foreach ($multilineexploded as $newcomment) {
|
||||
if (strlen(trim($newcomment)) > 0) {
|
||||
$comments[$key][] = $newcomment;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($comments as $key => $value) {
|
||||
foreach ($value as $commentdata) {
|
||||
fwrite($fpcomments, CleanOggCommentName($key).'='.$commentdata."\n");
|
||||
}
|
||||
}
|
||||
fclose($fpcomments);
|
||||
}
|
||||
|
||||
if (substr(php_uname(), 0, 7) == 'Windows') {
|
||||
|
||||
if (file_exists(GETID3_INCLUDEPATH.'vorbiscomment.exe')) {
|
||||
|
||||
$VorbisCommentError = `vorbiscomment.exe -w -c "$commentsfilename" "$filename"`;
|
||||
|
||||
} else {
|
||||
|
||||
$VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_INCLUDEPATH;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$VorbisCommentError = `vorbiscomment -w -c "$commentsfilename" "$filename" 2>&1`;
|
||||
|
||||
}
|
||||
|
||||
if (!empty($VorbisCommentError)) {
|
||||
|
||||
echo 'Failed making system call to vorbiscomment(.exe) - cannot write comments. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// Remove temporary comments file
|
||||
unlink($commentsfilename);
|
||||
|
||||
// Reset abort setting
|
||||
ignore_user_abort($old_abort);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function CleanOggCommentName($originalcommentname) {
|
||||
// A case-insensitive field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
|
||||
// ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through
|
||||
// 0x7A inclusive (a-z).
|
||||
|
||||
// replace invalid chars with a space, return uppercase text
|
||||
// Thanks Chris Bolt <chris-getid3@bolt.cx> for improving this function
|
||||
return strtoupper(ereg_replace('[^ -<>-}]', ' ', $originalcommentname));
|
||||
|
||||
}
|
||||
|
||||
?>
|
666
livesupport/modules/getid3/var/getid3.php
Normal file
666
livesupport/modules/getid3/var/getid3.php
Normal file
|
@ -0,0 +1,666 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Requires: PHP 4.1.0 (or higher) //
|
||||
// GD <1.6 for GIF and JPEG functions //
|
||||
// GD >=1.6 for PNG and JPEG functions //
|
||||
// GD >=2.0 for BMP display function //
|
||||
// //
|
||||
// Please see getid3.readme.txt for more information //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
// Defines
|
||||
define('GETID3VERSION', '1.6.0');
|
||||
define('FREAD_BUFFER_SIZE', 16384); // number of bytes to read in at once
|
||||
|
||||
// Get base path of getID3()
|
||||
$includedfilepaths = get_included_files();
|
||||
foreach ($includedfilepaths as $key => $val) {
|
||||
if (basename($val) == 'getid3.php') {
|
||||
if (substr(php_uname(), 0, 7) == 'Windows') {
|
||||
define('GETID3_INCLUDEPATH', str_replace('\\', '/', dirname($val)).'/');
|
||||
} else {
|
||||
define('GETID3_INCLUDEPATH', dirname($val).'/');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!defined('GETID3_INCLUDEPATH')) {
|
||||
define('GETID3_INCLUDEPATH', '');
|
||||
}
|
||||
|
||||
|
||||
function GetAllFileInfo($filename, $assumedFormat='', $MD5file=false, $MD5data=false) {
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.functions.php'); // Function library
|
||||
|
||||
$ThisFileInfo['getID3version'] = GETID3VERSION;
|
||||
$ThisFileInfo['fileformat'] = ''; // filled in later
|
||||
$ThisFileInfo['audio']['dataformat'] = ''; // filled in later, unset if not used
|
||||
$ThisFileInfo['video']['dataformat'] = ''; // filled in later, unset if not used
|
||||
$ThisFileInfo['tags'] = array(); // filled in later, unset if not used
|
||||
$ThisFileInfo['error'] = ''; // filled in later, unset if not used
|
||||
$ThisFileInfo['warning'] = ''; // filled in later, unset if not used
|
||||
$ThisFileInfo['exist'] = false;
|
||||
|
||||
if (eregi('^(ht|f)tp://', $filename)) {
|
||||
|
||||
// remote file
|
||||
$ThisFileInfo['filename'] = $filename;
|
||||
$ThisFileInfo['error'] .= "\n".'Remote files are not supported in this version of getID3() - please copy the file locally first';
|
||||
|
||||
} else {
|
||||
|
||||
// local file
|
||||
|
||||
$ThisFileInfo['filename'] = basename($filename);
|
||||
$ThisFileInfo['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
|
||||
$ThisFileInfo['filenamepath'] = $ThisFileInfo['filepath'].'/'.$ThisFileInfo['filename'];
|
||||
ob_start();
|
||||
if ($localfilepointer = fopen($filename, 'rb')) {
|
||||
|
||||
$ThisFileInfo['exist'] = true;
|
||||
|
||||
//$ThisFileInfo['filesize'] = filesize($ThisFileInfo['filenamepath']);
|
||||
// PHP doesn't support integers larger than 31-bit (~2GB)
|
||||
// filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
|
||||
// ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
|
||||
fseek($localfilepointer, 0, SEEK_END);
|
||||
$ThisFileInfo['filesize'] = ftell($localfilepointer);
|
||||
ob_end_clean();
|
||||
if ($ThisFileInfo['filesize'] == 0) {
|
||||
if (filesize($ThisFileInfo['filenamepath']) != 0) {
|
||||
|
||||
unset($ThisFileInfo['filesize']);
|
||||
$ThisFileInfo['error'] .= "\n".'File is most likely larger than 2GB and is not supported by PHP';
|
||||
|
||||
}
|
||||
|
||||
// remove unneeded/meaningless keys
|
||||
CleanUpGetAllMP3info($ThisFileInfo);
|
||||
|
||||
// close & remove local filepointer
|
||||
CloseRemoveFilepointer($localfilepointer);
|
||||
return $ThisFileInfo;
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
$ThisFileInfo['error'] .= "\n".'Error opening file: '.trim(strip_tags(ob_get_contents()));
|
||||
ob_end_clean();
|
||||
|
||||
// remove unneeded/meaningless keys
|
||||
CleanUpGetAllMP3info($ThisFileInfo);
|
||||
|
||||
// close & remove local filepointer
|
||||
CloseRemoveFilepointer($localfilepointer);
|
||||
return $ThisFileInfo;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Initialize avdataoffset and avdataend
|
||||
$ThisFileInfo['avdataoffset'] = 0;
|
||||
$ThisFileInfo['avdataend'] = $ThisFileInfo['filesize'];
|
||||
|
||||
// Handle APE tags
|
||||
HandleAPETag($localfilepointer, $ThisFileInfo);
|
||||
|
||||
rewind($localfilepointer);
|
||||
//$formattest = fread($localfilepointer, 16); // 16 bytes is sufficient for any format except ISO CD-image
|
||||
$formattest = fread($localfilepointer, 32774); // (ISO needs at least 32774 bytes)
|
||||
|
||||
// Handle ID3v2 tag
|
||||
if (substr($formattest, 0, 3) == 'ID3') {
|
||||
HandleID3v2Tag($localfilepointer, $ThisFileInfo);
|
||||
rewind($localfilepointer);
|
||||
fseek($localfilepointer, $ThisFileInfo['avdataoffset'], SEEK_SET);
|
||||
$formattest = fread($localfilepointer, 32774); // (ISO9660 needs at least 32774 bytes)
|
||||
}
|
||||
|
||||
// Handle ID3v1 tags
|
||||
HandleID3v1Tag($localfilepointer, $ThisFileInfo);
|
||||
|
||||
// Nothing-but-tags check
|
||||
if (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) > 0) {
|
||||
|
||||
if ($DeterminedFormat = GetFileFormat($formattest)) {
|
||||
|
||||
// break if ID3/APE tags found on illegal format
|
||||
if (!$DeterminedFormat['allowtags'] && ($ThisFileInfo['avdataoffset'] > 0) && ($ThisFileInfo['avdataend'] != $ThisFileInfo['filesize'])) {
|
||||
$ThisFileInfo['error'] .= "\n".'Illegal ID3 and/or APE tag found on non multimedia file.';
|
||||
break;
|
||||
}
|
||||
|
||||
// set mime type
|
||||
$ThisFileInfo['mime_type'] = $DeterminedFormat['mimetype'];
|
||||
|
||||
// supported format signature pattern detected
|
||||
require_once(GETID3_INCLUDEPATH.$DeterminedFormat['include']);
|
||||
|
||||
switch ($DeterminedFormat['format']) {
|
||||
//case 'midi':
|
||||
// if ($assumedFormat === false) {
|
||||
// // do not parse all MIDI tracks - much faster
|
||||
// getMIDIHeaderFilepointer($localfilepointer, $ThisFileInfo, false);
|
||||
// } else {
|
||||
// getMIDIHeaderFilepointer($localfilepointer, $ThisFileInfo);
|
||||
// }
|
||||
// break;
|
||||
|
||||
//case 'aac':
|
||||
// if (!getAACADIFheaderFilepointer($localfilepointer, $ThisFileInfo)) {
|
||||
// $dummy = $ThisFileInfo;
|
||||
// unset($dummy['error']);
|
||||
// if (getAACADTSheaderFilepointer($localfilepointer, $dummy)) {
|
||||
// $ThisFileInfo = $dummy;
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
|
||||
default:
|
||||
$VariableFunctionName = $DeterminedFormat['function'];
|
||||
$VariableFunctionName($localfilepointer, $ThisFileInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
} elseif ((($assumedFormat == 'mp3') || (($assumedFormat == '') && ((substr($formattest, 0, 3) == 'ID3') || (substr(BigEndian2Bin(substr($formattest, 0, 2)), 0, 11) == '11111111111'))))) {
|
||||
|
||||
// assume AAC-ADTS format
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.aac.php');
|
||||
$dummy = $ThisFileInfo;
|
||||
if (getAACADTSheaderFilepointer($localfilepointer, $dummy)) {
|
||||
|
||||
$ThisFileInfo = $dummy;
|
||||
|
||||
} else {
|
||||
|
||||
// it's not AAC-ADTS format, probably MP3
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.mp3.php');
|
||||
getMP3headerFilepointer($localfilepointer, $ThisFileInfo);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// unknown format, do nothing
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($ThisFileInfo['fileformat'])) {
|
||||
|
||||
// Calculate combined bitrate - audio + video
|
||||
$CombinedBitrate = 0;
|
||||
$CombinedBitrate += (isset($ThisFileInfo['audio']['bitrate']) ? $ThisFileInfo['audio']['bitrate'] : 0);
|
||||
$CombinedBitrate += (isset($ThisFileInfo['video']['bitrate']) ? $ThisFileInfo['video']['bitrate'] : 0);
|
||||
if (($CombinedBitrate > 0) && !isset($ThisFileInfo['bitrate'])) {
|
||||
$ThisFileInfo['bitrate'] = $CombinedBitrate;
|
||||
}
|
||||
|
||||
// Set playtime string
|
||||
if (!empty($ThisFileInfo['playtime_seconds']) && empty($ThisFileInfo['playtime_string'])) {
|
||||
$ThisFileInfo['playtime_string'] = PlaytimeString($ThisFileInfo['playtime_seconds']);
|
||||
}
|
||||
|
||||
if (!empty($ThisFileInfo['audio']['channels'])) {
|
||||
switch ($ThisFileInfo['audio']['channels']) {
|
||||
case 1:
|
||||
$ThisFileInfo['audio']['channelmode'] = 'mono';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$ThisFileInfo['audio']['channelmode'] = 'stereo';
|
||||
break;
|
||||
|
||||
default:
|
||||
// unknown?
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the MD5 hash of the entire file
|
||||
if ($MD5file && empty($ThisFileInfo['md5_file'])) {
|
||||
$ThisFileInfo['md5_file'] = md5_file($filename);
|
||||
}
|
||||
|
||||
// Get the MD5 hash of the audio/video portion of the file
|
||||
// (without ID3/APE/Lyrics3/etc header/footer tags
|
||||
if ($MD5data && empty($ThisFileInfo['md5_data'])) {
|
||||
getMD5data($ThisFileInfo);
|
||||
}
|
||||
|
||||
// return tags data in alphabetical order, without duplicates
|
||||
$ThisFileInfo['tags'] = array_unique($ThisFileInfo['tags']);
|
||||
sort($ThisFileInfo['tags']);
|
||||
|
||||
// remove unneeded/meaningless keys
|
||||
CleanUpGetAllMP3info($ThisFileInfo);
|
||||
|
||||
// close & remove local filepointer
|
||||
CloseRemoveFilepointer($localfilepointer);
|
||||
|
||||
return $ThisFileInfo;
|
||||
}
|
||||
|
||||
|
||||
function CleanUpGetAllMP3info(&$ThisFileInfo) {
|
||||
if (empty($ThisFileInfo['fileformat'])) {
|
||||
// remove meaningless entries from unknown-format files
|
||||
unset($ThisFileInfo['fileformat']);
|
||||
unset($ThisFileInfo['audio']['dataformat']);
|
||||
unset($ThisFileInfo['video']['dataformat']);
|
||||
unset($ThisFileInfo['avdataoffset']);
|
||||
unset($ThisFileInfo['avdataend']);
|
||||
}
|
||||
|
||||
$PotentialKeysToRemove = array('dataformat', 'bitrate_mode');
|
||||
foreach (array('audio', 'video') as $key1) {
|
||||
$RemoveThisKey = true;
|
||||
if (count($ThisFileInfo[$key1]) > count($PotentialKeysToRemove)) {
|
||||
$RemoveThisKey = false;
|
||||
} else {
|
||||
foreach ($PotentialKeysToRemove as $key2) {
|
||||
if (!in_array($key2, $PotentialKeysToRemove)) {
|
||||
$RemoveThisKey = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($RemoveThisKey) {
|
||||
unset($ThisFileInfo[$key1]);
|
||||
}
|
||||
}
|
||||
|
||||
$PotentialKeysToRemove = array('comments', 'error', 'warning', 'audio', 'video');
|
||||
foreach ($PotentialKeysToRemove as $keyname) {
|
||||
if (empty($ThisFileInfo["$keyname"])) {
|
||||
unset($ThisFileInfo["$keyname"]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function CloseRemoveFilepointer(&$filepointer) {
|
||||
if (isset($localfilepointer) && is_resource($localfilepointer) && (get_resource_type($localfilepointer) == 'file')) {
|
||||
fclose($localfilepointer);
|
||||
if (isset($localfilepointer)) {
|
||||
unset($localfilepointer);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function CopyFormatCommentsToRootComments($commentsarray, &$ThisFileInfo, $KeysToCopy=array('title'=>'title', 'artist'=>'artist', 'album'=>'album', 'year'=>'year', 'genre'=>'genre', 'comment'=>'comment', 'track'=>'track'), $ReplaceAll=false, $Append=false) {
|
||||
if ($ReplaceAll) {
|
||||
$ThisFileInfo['comments'] = array();
|
||||
}
|
||||
|
||||
if (!is_array($KeysToCopy)) {
|
||||
$KeysToCopy = array();
|
||||
foreach (array_keys($commentsarray) as $key => $value) {
|
||||
$KeysToCopy[$value] = $value;
|
||||
}
|
||||
}
|
||||
foreach ($KeysToCopy as $FromKey => $ToKey) {
|
||||
$ToKey = strtolower($ToKey);
|
||||
if (!empty($commentsarray["$FromKey"])) {
|
||||
if (is_array($commentsarray["$FromKey"])) {
|
||||
foreach ($commentsarray["$FromKey"] as $CommentArrayValue) {
|
||||
if ((empty($ThisFileInfo['comments']["$ToKey"])) || ($Append && !in_array($CommentArrayValue, $ThisFileInfo['comments']["$ToKey"], false))) {
|
||||
$ThisFileInfo['comments']["$ToKey"][] = $CommentArrayValue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((empty($ThisFileInfo['comments']["$ToKey"])) || ($Append && !in_array($commentsarray["$FromKey"], $ThisFileInfo['comments']["$ToKey"], false))) {
|
||||
$ThisFileInfo['comments']["$ToKey"][] = $commentsarray["$FromKey"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetFileFormat(&$filedata) {
|
||||
// this function will determine the format of a file based on usually
|
||||
// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
|
||||
// and in the case of ISO CD image, 6 bytes offset 32kb from the start
|
||||
// of the file).
|
||||
|
||||
// Array containing information about all supported formats
|
||||
static $format_info = array();
|
||||
if (empty($format_info)) {
|
||||
$format_info = array(
|
||||
|
||||
// Format: <internal name> => array(<regular expression to id file>, <include-file>, <function-to-call>, <allow-id/ape-tags>, <MIME type>)
|
||||
|
||||
|
||||
// Audio formats
|
||||
|
||||
// AAC - audio - Advanced Audio Coding (AAC) - ADIF format
|
||||
'aac' => array('^ADIF', 'getid3.aac.php', 'getAACADIFheaderFilepointer', true, 'application/octet-stream'),
|
||||
|
||||
// AIFF - audio - Audio Interchange File Format (AIFF)
|
||||
//'aiff' => array('^FORM', 'getid3.aiff.php', 'getAIFFHeaderFilepointer', true, 'audio/x-aiff'),
|
||||
|
||||
// FLAC - audio - Free Lossless Audio Codec
|
||||
'flac' => array('^fLaC', 'getid3.flac.php', 'getFLACHeaderFilepointer', true, 'audio/x-flac'),
|
||||
|
||||
// LA - audio - Lossless Audio (LA)
|
||||
'la' => array('^LA0[23]', 'getid3.la.php', 'getLAHeaderFilepointer', true, 'application/octet-stream'),
|
||||
|
||||
// MIDI - audio - MIDI (Musical Instrument Digital Interface)
|
||||
'midi' => array('^MThd', 'getid3.midi.php', 'getMIDIHeaderFilepointer', true, 'audio/midi'),
|
||||
|
||||
// MAC - audio - Monkey's Audio Compressor
|
||||
'mac' => array('^MAC ', 'getid3.monkey.php', 'getMonkeysAudioHeaderFilepointer', true, 'application/octet-stream'),
|
||||
|
||||
// MPC - audio - Musepack / MPEGplus
|
||||
'mpc' => array('^MP\+', 'getid3.mpc.php', 'getMPCHeaderFilepointer', true, 'application/octet-stream'),
|
||||
|
||||
// Ogg - audio - Ogg Vorbis
|
||||
'ogg' => array('^OggS', 'getid3.ogg.php', 'getOggHeaderFilepointer', true, 'application/x-ogg'),
|
||||
|
||||
// VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF)
|
||||
'vqf' => array('^TWIN', 'getid3.vqf.php', 'getVQFHeaderFilepointer', true, 'application/octet-stream'),
|
||||
|
||||
|
||||
// Audio-Video formats
|
||||
|
||||
// ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
|
||||
'asf' => array('^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C', 'getid3.asf.php', 'getASFHeaderFilepointer', true, 'video/x-ms-asf'),
|
||||
|
||||
// RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com)
|
||||
'riff' => array('^(RIFF|SDSS)', 'getid3.riff.php', 'getRIFFHeaderFilepointer', true, 'audio/x-wave'),
|
||||
|
||||
// Real - audio/video - RealAudio, RealVideo
|
||||
'real' => array('^\.RMF', 'getid3.real.php', 'getRealHeaderFilepointer', true, 'audio/x-realaudio'),
|
||||
|
||||
// NSV - audio/video - Nullsoft Streaming Video (NSV)
|
||||
'nsv' => array('^NSV[sf]', 'getid3.nsv.php', 'getNSVHeaderFilepointer', true, 'application/octet-stream'),
|
||||
|
||||
// MPEG - audio/video - MPEG (Moving Pictures Experts Group)
|
||||
'mpeg' => array('^\x00\x00\x01\xBA', 'getid3.mpeg.php', 'getMPEGHeaderFilepointer', true, 'video/mpeg'),
|
||||
|
||||
// QT - audio/video - Quicktime
|
||||
'quicktime' => array('^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)', 'getid3.quicktime.php', 'getQuicktimeHeaderFilepointer', true, 'video/quicktime'),
|
||||
|
||||
|
||||
// Still-Image formats
|
||||
|
||||
// BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
|
||||
'bmp' => array('^BM', 'getid3.bmp.php', 'getBMPHeaderFilepointer', false, 'image/bmp'),
|
||||
|
||||
// GIF - still image - Graphics Interchange Format
|
||||
'gif' => array('^GIF', 'getid3.gif.php', 'getGIFHeaderFilepointer', false, 'image/gif'),
|
||||
|
||||
// JPEG - still image - Joint Photographic Experts Group (JPEG)
|
||||
'jpg' => array('^\xFF\xD8\xFF', 'getid3.jpg.php', 'getJPGHeaderFilepointer', false, 'image/jpg'),
|
||||
|
||||
// PNG - still image - Portable Network Graphics (PNG)
|
||||
'png' => array('^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A', 'getid3.png.php', 'getPNGHeaderFilepointer', false, 'image/png'),
|
||||
|
||||
|
||||
// Data formats
|
||||
|
||||
// EXE - data - EXEcutable program (EXE, COM)
|
||||
//'exe' => array('^MZ', 'getid3.exe.php', 'getEXEHeaderFilepointer', false, 'application/octet-stream'),
|
||||
|
||||
// ISO - data - International Standards Organization (ISO) CD-ROM Image
|
||||
'iso' => array('^.{32769}CD001', 'getid3.iso.php', 'getISOHeaderFilepointer', false, 'application/octet-stream'),
|
||||
|
||||
// RAR - data - RAR compressed data
|
||||
//'rar' => array('^Rar\!', 'getid3.rar.php', 'getRARHeaderFilepointer', false, 'application/octet-stream'),
|
||||
|
||||
// ZIP - data - ZIP compressed data
|
||||
'zip' => array('^PK\x03\x04', 'getid3.zip.php', 'getZIPHeaderFilepointer', false, 'application/zip'),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
// Identify file format - loop through $format_info and detect with reg expr
|
||||
foreach ($format_info as $format_name => $info) {
|
||||
// Using preg_match() instead of ereg() - much faster
|
||||
// The /s switch on preg_match() forces preg_match() NOT to treat
|
||||
// newline (0x0A) characters as special chars but do a binary match
|
||||
if (preg_match('/'.$info[0].'/s', $filedata)) {
|
||||
// Extract information
|
||||
$FormatData['format'] = $format_name;
|
||||
//$FormatData['pattern'] = $info[0];
|
||||
$FormatData['include'] = $info[1];
|
||||
$FormatData['function'] = $info[2];
|
||||
$FormatData['allowtags'] = $info[3];
|
||||
$FormatData['mimetype'] = $info[4];
|
||||
|
||||
return $FormatData;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function HandleAPETag(&$fd, &$ThisFileInfo) {
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.ape.php');
|
||||
getAPEtagFilepointer($fd, $ThisFileInfo);
|
||||
|
||||
if (isset($ThisFileInfo['ape']['header']['raw']['tagsize'])) {
|
||||
|
||||
$ThisFileInfo['avdataend'] -= $ThisFileInfo['ape']['header']['raw']['tagsize'] + 32;
|
||||
|
||||
// APE tags has second highest priority
|
||||
CopyFormatCommentsToRootComments($ThisFileInfo['ape']['comments'], $ThisFileInfo, true, true, true);
|
||||
|
||||
// add tag to array of tags
|
||||
$ThisFileInfo['tags'][] = 'ape';
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function HandleID3v1Tag(&$fd, &$ThisFileInfo) {
|
||||
fseek($fd, (0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - LYRICSEND - [Lyrics3size]
|
||||
$lyrics3_id3v1 = fread($fd, (128 + 9 + 6));
|
||||
$lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size
|
||||
$lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200
|
||||
$id3v1tag = substr($lyrics3_id3v1, 15, 128); // ID3v1
|
||||
|
||||
if ($lyrics3end == 'LYRICSEND') {
|
||||
// Lyrics3 v1 and ID3v1
|
||||
|
||||
$lyrics3size = 5100;
|
||||
$ThisFileInfo['avdataend'] -= $lyrics3size;
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.lyrics3.php');
|
||||
getLyrics3Filepointer($ThisFileInfo, $fd, 0 - 128 - $lyrics3size, 1, $lyrics3size);
|
||||
|
||||
} elseif ($lyrics3end == 'LYRICS200') {
|
||||
// Lyrics3 v2 and ID3v1
|
||||
|
||||
$lyrics3size = $lyrics3lsz + 6 + strlen('LYRICS200'); // LSZ = lyrics + 'LYRICSBEGIN'; add 6-byte size field; add 'LYRICS200'
|
||||
$ThisFileInfo['avdataend'] -= $lyrics3size;
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.lyrics3.php');
|
||||
getLyrics3Filepointer($ThisFileInfo, $fd, -128 - $lyrics3size, 2, $lyrics3size);
|
||||
|
||||
} elseif (substr($lyrics3_id3v1, strlen($lyrics3_id3v1) - 1 - 9, 9) == 'LYRICSEND') {
|
||||
// Lyrics3 v1, no ID3v1 (I think according to Lyrics3 specs there MUST be ID3v1, but just in case :)
|
||||
|
||||
$lyrics3size = 5100;
|
||||
$ThisFileInfo['avdataend'] -= $lyrics3size;
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.lyrics3.php');
|
||||
getLyrics3Filepointer($ThisFileInfo, $fd, 0 - $lyrics3size, 1, $lyrics3size);
|
||||
|
||||
} elseif (substr($lyrics3_id3v1, strlen($lyrics3_id3v1) - 1 - 9, 9) == 'LYRICS200') {
|
||||
// Lyrics3 v2, no ID3v1 (I think according to Lyrics3 specs there MUST be ID3v1, but just in case :)
|
||||
|
||||
$lyrics3size = $lyrics3lsz + 6 + strlen('LYRICS200'); // LSZ = lyrics + 'LYRICSBEGIN'; add 6-byte size field; add 'LYRICS200'
|
||||
$ThisFileInfo['avdataend'] -= $lyrics3size;
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.lyrics3.php');
|
||||
getLyrics3Filepointer($ThisFileInfo, $fd, 0 - $lyrics3size, 2, $lyrics3size);
|
||||
}
|
||||
|
||||
if (substr($id3v1tag, 0, 3) == 'TAG') {
|
||||
$ThisFileInfo['avdataend'] -= 128;
|
||||
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.id3v1.php');
|
||||
getID3v1Filepointer($fd, $ThisFileInfo);
|
||||
|
||||
// Do not change fileformat if already set
|
||||
if (empty($ThisFileInfo['fileformat'])) {
|
||||
$ThisFileInfo['fileformat'] = 'id3';
|
||||
}
|
||||
|
||||
$ThisFileInfo['tags'][] = 'id3v1';
|
||||
|
||||
// ID3v1 has lowest preference. We add if $ThisFileInfo[comments] is empty - this will override empty tags of higher preference, or add comments to root if not already present
|
||||
if (isset($ThisFileInfo['id3v1'])) {
|
||||
CopyFormatCommentsToRootComments($ThisFileInfo['id3v1'], $ThisFileInfo, true, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function HandleID3v2Tag(&$fd, &$ThisFileInfo) {
|
||||
require_once(GETID3_INCLUDEPATH.'getid3.id3v2.php');
|
||||
getID3v2Filepointer($fd, $ThisFileInfo);
|
||||
|
||||
// Tag present
|
||||
if (isset($ThisFileInfo['id3v2']['header'])) {
|
||||
|
||||
// Do not change fileformat if already set
|
||||
if (empty($ThisFileInfo['fileformat'])) {
|
||||
$ThisFileInfo['fileformat'] = 'id3';
|
||||
}
|
||||
|
||||
// Set avdataoffset
|
||||
$ThisFileInfo['avdataoffset'] = $ThisFileInfo['id3v2']['headerlength'];
|
||||
if (isset($ThisFileInfo['id3v2']['footer'])) {
|
||||
$ThisFileInfo['avdataoffset'] += 10;
|
||||
}
|
||||
|
||||
$ThisFileInfo['tags'][] = 'id3v2';
|
||||
|
||||
if (isset($ThisFileInfo['id3v2']['comments'])) {
|
||||
CopyFormatCommentsToRootComments($ThisFileInfo['id3v2']['comments'], $ThisFileInfo, true, false, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getMD5data(&$ThisFileInfo) {
|
||||
|
||||
if (($ThisFileInfo['fileformat'] == 'ogg') && (@$ThisFileInfo['audio']['dataformat'] == 'vorbis')) {
|
||||
|
||||
// We cannot get an identical md5_data value for Ogg files where the comments
|
||||
// span more than 1 Ogg page (compared to the same audio data with smaller
|
||||
// comments) using the normal getID3() method of MD5'ing the data between the
|
||||
// end of the comments and the end of the file (minus any trailing tags),
|
||||
// because the page sequence numbers of the pages that the audio data is on
|
||||
// do not match. Under normal circumstances, where comments are smaller than
|
||||
// the nominal 4-8kB page size, then this is not a problem, but if there are
|
||||
// very large comments, the only way around it is to strip off the comment
|
||||
// tags with vorbiscomment and MD5 that file.
|
||||
// This procedure must be applied to ALL Ogg files, not just the ones with
|
||||
// comments larger than 1 page, because the below method simply MD5's the
|
||||
// whole file with the comments stripped, not just the portion after the
|
||||
// comments block (which is the standard getID3() method.
|
||||
|
||||
// The above-mentioned problem of comments spanning multiple pages and changing
|
||||
// page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
|
||||
// currently vorbiscomment only works on OggVorbis files.
|
||||
|
||||
if ((bool) ini_get('safe_mode')) {
|
||||
|
||||
$ThisFileInfo['warning'] .= "\n".'Failed making system call to vorbiscomment.exe - md5_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)';
|
||||
$ThisFileInfo['md5_data'] = false;
|
||||
|
||||
} else {
|
||||
|
||||
// Prevent user from aborting script
|
||||
$old_abort = ignore_user_abort(true);
|
||||
|
||||
// Create empty file
|
||||
$empty = tempnam('/tmp', 'getID3');
|
||||
touch($empty);
|
||||
|
||||
|
||||
// Use vorbiscomment to make temp file without comments
|
||||
$temp = tempnam('/tmp', 'getID3');
|
||||
$file = $ThisFileInfo['filenamepath'];
|
||||
|
||||
if (substr(php_uname(), 0, 7) == 'Windows') {
|
||||
|
||||
if (file_exists(GETID3_INCLUDEPATH.'vorbiscomment.exe')) {
|
||||
|
||||
$VorbisCommentError = `vorbiscomment.exe -w -c "$empty" "$file" "$temp"`;
|
||||
|
||||
} else {
|
||||
|
||||
$VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_INCLUDEPATH;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$VorbisCommentError = `vorbiscomment -w -c "$empty" "$file" "$temp" 2>&1`;
|
||||
|
||||
}
|
||||
|
||||
if (!empty($VorbisCommentError)) {
|
||||
|
||||
$ThisFileInfo['warning'] .= "\n".'Failed making system call to vorbiscomment(.exe) - md5_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
|
||||
$ThisFileInfo['md5_data'] = false;
|
||||
|
||||
} else {
|
||||
|
||||
// Get md5 value of newly created file
|
||||
$ThisFileInfo['md5_data'] = md5_file($temp);
|
||||
|
||||
}
|
||||
|
||||
// Clean up
|
||||
unlink($empty);
|
||||
unlink($temp);
|
||||
|
||||
// Reset abort setting
|
||||
ignore_user_abort($old_abort);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!empty($ThisFileInfo['avdataoffset']) || (isset($ThisFileInfo['avdataend']) && ($ThisFileInfo['avdataend'] < $ThisFileInfo['filesize']))) {
|
||||
$ThisFileInfo['md5_data'] = md5_data($ThisFileInfo['filenamepath'], $ThisFileInfo['avdataoffset'], $ThisFileInfo['avdataend']);
|
||||
} else {
|
||||
if (empty($ThisFileInfo['md5_file'])) {
|
||||
$ThisFileInfo['md5_file'] = md5_file($ThisFileInfo['filenamepath']);
|
||||
}
|
||||
$ThisFileInfo['md5_data'] = $ThisFileInfo['md5_file'];
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function PoweredBygetID3($string='<BR><HR NOSHADE><DIV STYLE="font-size: 8pt; font-face: sans-serif;">Powered by <A HREF="http://getid3.sourceforge.net" TARGET="_blank"><B>getID3() v<!--GETID3VER--></B><BR>http://getid3.sourceforge.net</A></DIV>') {
|
||||
return str_replace('<!--GETID3VER-->', GETID3VERSION, $string);
|
||||
}
|
||||
|
||||
?>
|
484
livesupport/modules/getid3/var/getid3.png.php
Normal file
484
livesupport/modules/getid3/var/getid3.png.php
Normal file
|
@ -0,0 +1,484 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.png.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function getPNGHeaderFilepointer(&$fd, &$ThisFileInfo) {
|
||||
$ThisFileInfo['fileformat'] = 'png';
|
||||
$ThisFileInfo['video']['dataformat'] = 'png';
|
||||
|
||||
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
|
||||
$PNGfiledata = fread($fd, FREAD_BUFFER_SIZE);
|
||||
$offset = 0;
|
||||
|
||||
$PNGidentifier = substr($PNGfiledata, $offset, 8); // $89 $50 $4E $47 $0D $0A $1A $0A
|
||||
$offset += 8;
|
||||
if ($PNGidentifier != chr(0x89).chr(0x50).chr(0x4E).chr(0x47).chr(0x0D).chr(0x0A).chr(0x1A).chr(0x0A)) {
|
||||
$ThisFileInfo['error'] .= "\n".'First 8 bytes of file ('.PrintHexBytes($PNGidentifier).') did not match expected PNG identifier';
|
||||
unset($ThisFileInfo['fileformat']);
|
||||
return false;
|
||||
}
|
||||
|
||||
while (((ftell($fd) - (strlen($PNGfiledata) - $offset)) < $ThisFileInfo['filesize'])) {
|
||||
$chunk['data_length'] = BigEndian2Int(substr($PNGfiledata, $offset, 4));
|
||||
$offset += 4;
|
||||
while (((strlen($PNGfiledata) - $offset) < ($chunk['data_length'] + 4)) && (ftell($fd) < $ThisFileInfo['filesize'])) {
|
||||
$PNGfiledata .= fread($fd, FREAD_BUFFER_SIZE);
|
||||
}
|
||||
$chunk['type_text'] = substr($PNGfiledata, $offset, 4);
|
||||
$offset += 4;
|
||||
$chunk['type_raw'] = BigEndian2Int($chunk['type_text']);
|
||||
$chunk['data'] = substr($PNGfiledata, $offset, $chunk['data_length']);
|
||||
$offset += $chunk['data_length'];
|
||||
$chunk['crc'] = BigEndian2Int(substr($PNGfiledata, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
$chunk['flags']['ancilliary'] = (bool) ($chunk['type_raw'] & 0x20000000);
|
||||
$chunk['flags']['private'] = (bool) ($chunk['type_raw'] & 0x00200000);
|
||||
$chunk['flags']['reserved'] = (bool) ($chunk['type_raw'] & 0x00002000);
|
||||
$chunk['flags']['safe_to_copy'] = (bool) ($chunk['type_raw'] & 0x00000020);
|
||||
|
||||
switch ($chunk['type_text']) {
|
||||
|
||||
case 'IHDR': // Image Header
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['width'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 4));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['height'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 4, 4));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['raw']['bit_depth'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 8, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['raw']['color_type'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 9, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['raw']['compression_method'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 10, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['raw']['filter_method'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 11, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['raw']['interlace_method'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 12, 1));
|
||||
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compression_method_text'] = PNGcompressionMethodLookup($ThisFileInfo['png'][$chunk['type_text']]['raw']['compression_method']);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['color_type']['palette'] = (bool) ($ThisFileInfo['png'][$chunk['type_text']]['raw']['color_type'] & 0x01);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['color_type']['true_color'] = (bool) ($ThisFileInfo['png'][$chunk['type_text']]['raw']['color_type'] & 0x02);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['color_type']['alpha'] = (bool) ($ThisFileInfo['png'][$chunk['type_text']]['raw']['color_type'] & 0x04);
|
||||
|
||||
$ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['png'][$chunk['type_text']]['width'];
|
||||
$ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['png'][$chunk['type_text']]['height'];
|
||||
break;
|
||||
|
||||
|
||||
case 'PLTE': // Palette
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$paletteoffset = 0;
|
||||
for ($i = 0; $i <= 255; $i++) {
|
||||
//$ThisFileInfo['png'][$chunk['type_text']]['red'][$i] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $paletteoffset++, 1));
|
||||
//$ThisFileInfo['png'][$chunk['type_text']]['green'][$i] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $paletteoffset++, 1));
|
||||
//$ThisFileInfo['png'][$chunk['type_text']]['blue'][$i] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $paletteoffset++, 1));
|
||||
$red = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $paletteoffset++, 1));
|
||||
$green = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $paletteoffset++, 1));
|
||||
$blue = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $paletteoffset++, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$i] = (($red << 16) | ($green << 8) | ($blue));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'tRNS': // Transparency
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
switch ($ThisFileInfo['png']['IHDR']['raw']['color_type']) {
|
||||
case 0:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['transparent_color_gray'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 2));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['transparent_color_red'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 2));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['transparent_color_green'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 2));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['transparent_color_blue'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 2));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for ($i = 0; $i < strlen($ThisFileInfo['png'][$chunk['type_text']]['header']['data']); $i++) {
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['palette_opacity'][$i] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $i, 1));
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case 6:
|
||||
$ThisFileInfo['error'] .= "\n".'Invalid color_type in tRNS chunk: '.$ThisFileInfo['png']['IHDR']['raw']['color_type'];
|
||||
|
||||
default:
|
||||
$ThisFileInfo['warning'] .= "\n".'Unhandled color_type in tRNS chunk: '.$ThisFileInfo['png']['IHDR']['raw']['color_type'];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'gAMA': // Image Gamma
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['gamma'] = BigEndian2Int($ThisFileInfo['png'][$chunk['type_text']]['header']['data']) / 100000;
|
||||
break;
|
||||
|
||||
|
||||
case 'cHRM': // Primary Chromaticities
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['white_x'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 4)) / 100000;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['white_y'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 4, 4)) / 100000;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['red_y'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 8, 4)) / 100000;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['red_y'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 12, 4)) / 100000;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['green_y'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 16, 4)) / 100000;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['green_y'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 20, 4)) / 100000;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['blue_y'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 24, 4)) / 100000;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['blue_y'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 28, 4)) / 100000;
|
||||
break;
|
||||
|
||||
|
||||
case 'sRGB': // Standard RGB Color Space
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['reindering_intent'] = BigEndian2Int($ThisFileInfo['png'][$chunk['type_text']]['header']['data']);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['reindering_intent_text'] = PNGsRGBintentLookup($ThisFileInfo['png'][$chunk['type_text']]['reindering_intent']);
|
||||
break;
|
||||
|
||||
|
||||
case 'iCCP': // Embedded ICC Profile
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
list($profilename, $compressiondata) = explode(chr(0x00), $ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['profile_name'] = $profilename;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compression_method'] = BigEndian2Int(substr($compressiondata, 0, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compression_profile'] = substr($compressiondata, 1);
|
||||
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compression_method_text'] = PNGcompressionMethodLookup($ThisFileInfo['png'][$chunk['type_text']]['compression_method']);
|
||||
break;
|
||||
|
||||
|
||||
case 'tEXt': // Textual Data
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
list($keyword, $text) = explode(chr(0x00), $ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['keyword'] = $keyword;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['text'] = $text;
|
||||
|
||||
$ThisFileInfo['png']['comments'][$ThisFileInfo['png'][$chunk['type_text']]['keyword']][] = $ThisFileInfo['png'][$chunk['type_text']]['text'];
|
||||
break;
|
||||
|
||||
|
||||
case 'zTXt': // Compressed Textual Data
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
list($keyword, $otherdata) = explode(chr(0x00), $ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['keyword'] = $keyword;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compression_method'] = BigEndian2Int(substr($otherdata, 0, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compressed_text'] = substr($otherdata, 1);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compression_method_text'] = PNGcompressionMethodLookup($ThisFileInfo['png'][$chunk['type_text']]['compression_method']);
|
||||
switch ($ThisFileInfo['png'][$chunk['type_text']]['compression_method']) {
|
||||
case 0:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['text'] = gzuncompress($ThisFileInfo['png'][$chunk['type_text']]['compressed_text']);
|
||||
break;
|
||||
|
||||
default:
|
||||
// unknown compression method
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($ThisFileInfo['png'][$chunk['type_text']]['text'])) {
|
||||
$ThisFileInfo['png']['comments'][$ThisFileInfo['png'][$chunk['type_text']]['keyword']][] = $ThisFileInfo['png'][$chunk['type_text']]['text'];
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'iTXt': // International Textual Data
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
list($keyword, $otherdata) = explode(chr(0x00), $ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['keyword'] = $keyword;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compression'] = (bool) BigEndian2Int(substr($otherdata, 0, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compression_method'] = BigEndian2Int(substr($otherdata, 1, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['compression_method_text'] = PNGcompressionMethodLookup($ThisFileInfo['png'][$chunk['type_text']]['compression_method']);
|
||||
list($languagetag, $translatedkeyword, $text) = explode(chr(0x00), substr($otherdata, 2), 3);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['language_tag'] = $languagetag;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['translated_keyword'] = utf8_decode($translatedkeyword);
|
||||
|
||||
if ($ThisFileInfo['png'][$chunk['type_text']]['compression']) {
|
||||
|
||||
switch ($ThisFileInfo['png'][$chunk['type_text']]['compression_method']) {
|
||||
case 0:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['text'] = utf8_decode(gzuncompress($text));
|
||||
break;
|
||||
|
||||
default:
|
||||
// unknown compression method
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['text'] = utf8_decode($text);
|
||||
|
||||
}
|
||||
|
||||
if (isset($ThisFileInfo['png'][$chunk['type_text']]['text'])) {
|
||||
$ThisFileInfo['png']['comments'][$ThisFileInfo['png'][$chunk['type_text']]['keyword']][] = $ThisFileInfo['png'][$chunk['type_text']]['text'];
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'bKGD': // Background Color
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
switch ($ThisFileInfo['png']['IHDR']['raw']['color_type']) {
|
||||
case 0:
|
||||
case 4:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['background_gray'] = BigEndian2Int($ThisFileInfo['png'][$chunk['type_text']]['header']['data']);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 6:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['background_red'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0 * $ThisFileInfo['png']['IHDR']['raw']['bit_depth'], $ThisFileInfo['png']['IHDR']['raw']['bit_depth']));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['background_green'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 1 * $ThisFileInfo['png']['IHDR']['raw']['bit_depth'], $ThisFileInfo['png']['IHDR']['raw']['bit_depth']));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['background_blue'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2 * $ThisFileInfo['png']['IHDR']['raw']['bit_depth'], $ThisFileInfo['png']['IHDR']['raw']['bit_depth']));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['background_index'] = BigEndian2Int($ThisFileInfo['png'][$chunk['type_text']]['header']['data']);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'pHYs': // Physical Pixel Dimensions
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['pixels_per_unit_x'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 4));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['pixels_per_unit_y'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 4, 4));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['unit_specifier'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 8, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['unit'] = PNGpHYsUnitLookup($ThisFileInfo['png'][$chunk['type_text']]['unit_specifier']);
|
||||
break;
|
||||
|
||||
|
||||
case 'sBIT': // Significant Bits
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
switch ($ThisFileInfo['png']['IHDR']['raw']['color_type']) {
|
||||
case 0:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_gray'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 1));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_red'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_green'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 1, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_blue'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2, 1));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_gray'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_alpha'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 1, 1));
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_red'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_green'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 1, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_blue'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['significant_bits_alpha'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 3, 1));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'sPLT': // Suggested Palette
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
list($palettename, $otherdata) = explode(chr(0x00), $ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['palette_name'] = $palettename;
|
||||
$sPLToffset = 0;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bits'] = BigEndian2Int(substr($otherdata, $sPLToffset, 1));
|
||||
$sPLToffset += 1;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bytes'] = $ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bits'] / 8;
|
||||
$paletteCounter = 0;
|
||||
while ($sPLToffset < strlen($otherdata)) {
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['red'][$paletteCounter] = BigEndian2Int(substr($otherdata, $sPLToffset, $ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bytes']));
|
||||
$sPLToffset += $ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bytes'];
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['green'][$paletteCounter] = BigEndian2Int(substr($otherdata, $sPLToffset, $ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bytes']));
|
||||
$sPLToffset += $ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bytes'];
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['blue'][$paletteCounter] = BigEndian2Int(substr($otherdata, $sPLToffset, $ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bytes']));
|
||||
$sPLToffset += $ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bytes'];
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['alpha'][$paletteCounter] = BigEndian2Int(substr($otherdata, $sPLToffset, $ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bytes']));
|
||||
$sPLToffset += $ThisFileInfo['png'][$chunk['type_text']]['sample_depth_bytes'];
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['frequency'][$paletteCounter] = BigEndian2Int(substr($otherdata, $sPLToffset, 2));
|
||||
$sPLToffset += 2;
|
||||
$paletteCounter++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'hIST': // Palette Histogram
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$hISTcounter = 0;
|
||||
while ($hISTcounter < strlen($ThisFileInfo['png'][$chunk['type_text']]['header']['data'])) {
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$hISTcounter] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $hISTcounter / 2, 2));
|
||||
$hISTcounter += 2;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'tIME': // Image Last-Modification Time
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['year'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 2));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['month'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['day'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 3, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['hour'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 4, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['minute'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 5, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['second'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 6, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['unix'] = gmmktime($ThisFileInfo['png'][$chunk['type_text']]['hour'], $ThisFileInfo['png'][$chunk['type_text']]['minute'], $ThisFileInfo['png'][$chunk['type_text']]['second'], $ThisFileInfo['png'][$chunk['type_text']]['month'], $ThisFileInfo['png'][$chunk['type_text']]['day'], $ThisFileInfo['png'][$chunk['type_text']]['year']);
|
||||
break;
|
||||
|
||||
|
||||
case 'oFFs': // Image Offset
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['position_x'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 4), false, true);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['position_y'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 4, 4), false, true);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['unit_specifier'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 8, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['unit'] = PNGoFFsUnitLookup($ThisFileInfo['png'][$chunk['type_text']]['unit_specifier']);
|
||||
break;
|
||||
|
||||
|
||||
case 'pCAL': // Calibration Of Pixel Values
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
list($calibrationname, $otherdata) = explode(chr(0x00), $ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['calibration_name'] = $calibrationname;
|
||||
$pCALoffset = 0;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['original_zero'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $pCALoffset, 4), false, true);
|
||||
$pCALoffset += 4;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['original_max'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $pCALoffset, 4), false, true);
|
||||
$pCALoffset += 4;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['equation_type'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $pCALoffset, 1));
|
||||
$pCALoffset += 1;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['equation_type_text'] = PNGpCALequationTypeLookup($ThisFileInfo['png'][$chunk['type_text']]['equation_type']);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['parameter_count'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $pCALoffset, 1));
|
||||
$pCALoffset += 1;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['parameters'] = explode(chr(0x00), substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], $pCALoffset));
|
||||
break;
|
||||
|
||||
|
||||
case 'sCAL': // Physical Scale Of Image Subject
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['unit_specifier'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['unit'] = PNGsCALUnitLookup($ThisFileInfo['png'][$chunk['type_text']]['unit_specifier']);
|
||||
list($pixelwidth, $pixelheight) = explode(chr(0x00), substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['pixel_width'] = $pixelwidth;
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['pixel_height'] = $pixelheight;
|
||||
break;
|
||||
|
||||
|
||||
case 'gIFg': // GIF Graphic Control Extension
|
||||
$gIFgCounter = 0;
|
||||
if (isset($ThisFileInfo['png'][$chunk['type_text']]) && is_array($ThisFileInfo['png'][$chunk['type_text']])) {
|
||||
$gIFgCounter = count($ThisFileInfo['png'][$chunk['type_text']]);
|
||||
}
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$gIFgCounter]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$gIFgCounter]['disposal_method'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$gIFgCounter]['user_input_flag'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 1, 1));
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$gIFgCounter]['delay_time'] = BigEndian2Int(substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 2, 2));
|
||||
break;
|
||||
|
||||
|
||||
case 'gIFx': // GIF Application Extension
|
||||
$gIFxCounter = 0;
|
||||
if (isset($ThisFileInfo['png'][$chunk['type_text']]) && is_array($ThisFileInfo['png'][$chunk['type_text']])) {
|
||||
$gIFxCounter = count($ThisFileInfo['png'][$chunk['type_text']]);
|
||||
}
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$gIFxCounter]['header'] = $chunk;
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$gIFxCounter]['application_identifier'] = substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 0, 8);
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$gIFxCounter]['authentication_code'] = substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 8, 3);
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$gIFxCounter]['application_data'] = substr($ThisFileInfo['png'][$chunk['type_text']]['header']['data'], 11);
|
||||
break;
|
||||
|
||||
|
||||
case 'IDAT': // Image Data
|
||||
$idatinformationfieldindex = 0;
|
||||
if (isset($ThisFileInfo['png']['IDAT']) && is_array($ThisFileInfo['png']['IDAT'])) {
|
||||
$idatinformationfieldindex = count($ThisFileInfo['png']['IDAT']);
|
||||
}
|
||||
unset($chunk['data']);
|
||||
$ThisFileInfo['png'][$chunk['type_text']][$idatinformationfieldindex]['header'] = $chunk;
|
||||
break;
|
||||
|
||||
|
||||
case 'IEND': // Image Trailer
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
//unset($chunk['data']);
|
||||
$ThisFileInfo['png'][$chunk['type_text']]['header'] = $chunk;
|
||||
$ThisFileInfo['warning'] .= "\n".'Unhandled chunk type: '.$chunk['type_text'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// PNG tags have highest priority
|
||||
if (!empty($ThisFileInfo['png']['comments'])) {
|
||||
CopyFormatCommentsToRootComments($ThisFileInfo['png']['comments'], $ThisFileInfo, true, true, true);
|
||||
|
||||
// add tag to array of tags
|
||||
$ThisFileInfo['tags'][] = 'png';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function PNGsRGBintentLookup($sRGB) {
|
||||
static $PNGsRGBintentLookup = array();
|
||||
if (empty($PNGsRGBintentLookup)) {
|
||||
$PNGsRGBintentLookup[0] = 'Perceptual';
|
||||
$PNGsRGBintentLookup[1] = 'Relative colorimetric';
|
||||
$PNGsRGBintentLookup[2] = 'Saturation';
|
||||
$PNGsRGBintentLookup[3] = 'Absolute colorimetric';
|
||||
}
|
||||
return (isset($PNGsRGBintentLookup[$sRGB]) ? $PNGsRGBintentLookup[$sRGB] : 'invalid');
|
||||
}
|
||||
|
||||
function PNGcompressionMethodLookup($compressionmethod) {
|
||||
static $PNGcompressionMethodLookup = array();
|
||||
if (empty($PNGcompressionMethodLookup)) {
|
||||
$PNGcompressionMethodLookup[0] = 'deflate/inflate';
|
||||
}
|
||||
return (isset($PNGcompressionMethodLookup[$compressionmethod]) ? $PNGcompressionMethodLookup[$compressionmethod] : 'invalid');
|
||||
}
|
||||
|
||||
function PNGpHYsUnitLookup($unitid) {
|
||||
static $PNGpHYsUnitLookup = array();
|
||||
if (empty($PNGpHYsUnitLookup)) {
|
||||
$PNGpHYsUnitLookup[0] = 'unknown';
|
||||
$PNGpHYsUnitLookup[1] = 'meter';
|
||||
}
|
||||
return (isset($PNGpHYsUnitLookup[$unitid]) ? $PNGpHYsUnitLookup[$unitid] : 'invalid');
|
||||
}
|
||||
|
||||
function PNGoFFsUnitLookup($unitid) {
|
||||
static $PNGoFFsUnitLookup = array();
|
||||
if (empty($PNGoFFsUnitLookup)) {
|
||||
$PNGoFFsUnitLookup[0] = 'pixel';
|
||||
$PNGoFFsUnitLookup[1] = 'micrometer';
|
||||
}
|
||||
return (isset($PNGoFFsUnitLookup[$unitid]) ? $PNGoFFsUnitLookup[$unitid] : 'invalid');
|
||||
}
|
||||
|
||||
function PNGpCALequationTypeLookup($equationtype) {
|
||||
static $PNGpCALequationTypeLookup = array();
|
||||
if (empty($PNGpCALequationTypeLookup)) {
|
||||
$PNGpCALequationTypeLookup[0] = 'Linear mapping';
|
||||
$PNGpCALequationTypeLookup[1] = 'Base-e exponential mapping';
|
||||
$PNGpCALequationTypeLookup[2] = 'Arbitrary-base exponential mapping';
|
||||
$PNGpCALequationTypeLookup[3] = 'Hyperbolic mapping';
|
||||
}
|
||||
return (isset($PNGpCALequationTypeLookup[$equationtype]) ? $PNGpCALequationTypeLookup[$equationtype] : 'invalid');
|
||||
}
|
||||
|
||||
function PNGsCALUnitLookup($unitid) {
|
||||
static $PNGsCALUnitLookup = array();
|
||||
if (empty($PNGsCALUnitLookup)) {
|
||||
$PNGsCALUnitLookup[0] = 'meter';
|
||||
$PNGsCALUnitLookup[1] = 'radian';
|
||||
}
|
||||
return (isset($PNGsCALUnitLookup[$unitid]) ? $PNGsCALUnitLookup[$unitid] : 'invalid');
|
||||
}
|
||||
|
||||
?>
|
1938
livesupport/modules/getid3/var/getid3.putid3.php
Normal file
1938
livesupport/modules/getid3/var/getid3.putid3.php
Normal file
File diff suppressed because it is too large
Load diff
1037
livesupport/modules/getid3/var/getid3.quicktime.php
Normal file
1037
livesupport/modules/getid3/var/getid3.quicktime.php
Normal file
File diff suppressed because it is too large
Load diff
21
livesupport/modules/getid3/var/getid3.rar.php
Normal file
21
livesupport/modules/getid3/var/getid3.rar.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.rar.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function getRARHeaderFilepointer(&$fd, &$ThisFileInfo) {
|
||||
|
||||
$ThisFileInfo['fileformat'] = 'rar';
|
||||
|
||||
$ThisFileInfo['error'] .= "\n".'RAR parsing not enabled in this version of getID3()';
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
?>
|
58
livesupport/modules/getid3/var/getid3.rgad.php
Normal file
58
livesupport/modules/getid3/var/getid3.rgad.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.rgad.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function RGADnameLookup($namecode) {
|
||||
static $RGADname = array();
|
||||
if (empty($RGADname)) {
|
||||
$RGADname[0] = 'not set';
|
||||
$RGADname[1] = 'Radio Gain Adjustment';
|
||||
$RGADname[2] = 'Audiophile Gain Adjustment';
|
||||
}
|
||||
|
||||
return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
|
||||
}
|
||||
|
||||
function RGADoriginatorLookup($originatorcode) {
|
||||
static $RGADoriginator = array();
|
||||
if (empty($RGADoriginator)) {
|
||||
$RGADoriginator[0] = 'unspecified';
|
||||
$RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
|
||||
$RGADoriginator[2] = 'set by user';
|
||||
$RGADoriginator[3] = 'determined automatically';
|
||||
}
|
||||
|
||||
return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
|
||||
}
|
||||
|
||||
function RGADadjustmentLookup($rawadjustment, $signbit) {
|
||||
$adjustment = $rawadjustment / 10;
|
||||
if ($signbit == 1) {
|
||||
$adjustment *= -1;
|
||||
}
|
||||
return (float) $adjustment;
|
||||
}
|
||||
|
||||
function RGADgainString($namecode, $originatorcode, $replaygain) {
|
||||
if ($replaygain < 0) {
|
||||
$signbit = '1';
|
||||
} else {
|
||||
$signbit = '0';
|
||||
}
|
||||
$storedreplaygain = round($replaygain * 10);
|
||||
$gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
|
||||
$gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
|
||||
$gainstring .= $signbit;
|
||||
$gainstring .= str_pad(decbin(round($replaygain * 10)), 9, '0', STR_PAD_LEFT);
|
||||
|
||||
return $gainstring;
|
||||
}
|
||||
|
||||
?>
|
144
livesupport/modules/getid3/var/getid3.vqf.php
Normal file
144
livesupport/modules/getid3/var/getid3.vqf.php
Normal file
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <getid3@users.sourceforge.net> //
|
||||
// available at http://getid3.sourceforge.net ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// getid3.vqf.php - part of getID3() //
|
||||
// See getid3.readme.txt for more details //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
function getVQFHeaderFilepointer(&$fd, &$ThisFileInfo) {
|
||||
// based loosely on code from TTwinVQ by Jurgen Faul
|
||||
// jfaul@gmx.de http://jfaul.de/atl
|
||||
|
||||
$ThisFileInfo['fileformat'] = 'vqf';
|
||||
$ThisFileInfo['audio']['dataformat'] = 'vqf';
|
||||
$ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
|
||||
$HasVQFTags = false;
|
||||
|
||||
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
|
||||
$VQFheaderData = fread($fd, 16);
|
||||
|
||||
$offset = 0;
|
||||
$ThisFileInfo['vqf']['raw']['header_tag'] = substr($VQFheaderData, $offset, 4);
|
||||
$offset += 4;
|
||||
$ThisFileInfo['vqf']['raw']['version'] = substr($VQFheaderData, $offset, 8);
|
||||
$offset += 8;
|
||||
$ThisFileInfo['vqf']['raw']['size'] = BigEndian2Int(substr($VQFheaderData, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
while (ftell($fd) < $ThisFileInfo['avdataend']) {
|
||||
|
||||
$ChunkBaseOffset = ftell($fd);
|
||||
$chunkoffset = 0;
|
||||
$ChunkData = fread($fd, 8);
|
||||
$ChunkName = substr($ChunkData, $chunkoffset, 4);
|
||||
if ($ChunkName == 'DATA') {
|
||||
$ThisFileInfo['avdataoffset'] = $ChunkBaseOffset;
|
||||
break;
|
||||
}
|
||||
$chunkoffset += 4;
|
||||
$ChunkSize = BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
|
||||
$chunkoffset += 4;
|
||||
if ($ChunkSize > ($ThisFileInfo['avdataend'] - ftell($fd))) {
|
||||
$ThisFileInfo['error'] .= "\n".'Invalid chunk size ('.$ChunkSize.') for chunk "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
|
||||
break;
|
||||
}
|
||||
$ChunkData .= fread($fd, $ChunkSize);
|
||||
|
||||
switch ($ChunkName) {
|
||||
case 'COMM':
|
||||
$ThisFileInfo['vqf']["$ChunkName"]['channel_mode'] = BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
|
||||
$chunkoffset += 4;
|
||||
$ThisFileInfo['vqf']["$ChunkName"]['bitrate'] = BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
|
||||
$chunkoffset += 4;
|
||||
$ThisFileInfo['vqf']["$ChunkName"]['sample_rate'] = BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
|
||||
$chunkoffset += 4;
|
||||
$ThisFileInfo['vqf']["$ChunkName"]['security_level'] = BigEndian2Int(substr($ChunkData, $chunkoffset, 4));
|
||||
$chunkoffset += 4;
|
||||
|
||||
$ThisFileInfo['audio']['channels'] = $ThisFileInfo['vqf']["$ChunkName"]['channel_mode'] + 1;
|
||||
$ThisFileInfo['audio']['sample_rate'] = VQFchannelFrequencyLookup($ThisFileInfo['vqf']["$ChunkName"]['sample_rate']);
|
||||
$ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['vqf']["$ChunkName"]['bitrate'] * 1000;
|
||||
|
||||
if ($ThisFileInfo['audio']['bitrate'] == 0) {
|
||||
$ThisFileInfo['error'] .= 'Corrupt VQF file: bitrate_audio == zero';
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'NAME':
|
||||
case 'AUTH':
|
||||
case '(c) ':
|
||||
case 'FILE':
|
||||
case 'COMT':
|
||||
case 'ALBM':
|
||||
$HasVQFTags = true;
|
||||
$ThisFileInfo['vqf']['comments'][VQFcommentNiceNameLookup($ChunkName)][] = trim(substr($ChunkData, 8));
|
||||
break;
|
||||
|
||||
case 'DSIZ':
|
||||
$ThisFileInfo['vqf']['DSIZ'] = BigEndian2Int(substr($ChunkData, 8, 4));
|
||||
break;
|
||||
|
||||
default:
|
||||
$ThisFileInfo['warning'] .= "\n".'Unhandled chunk type "'.$ChunkName.'" at offset '.$ChunkBaseOffset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$ThisFileInfo['playtime_seconds'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['audio']['bitrate'];
|
||||
|
||||
if (isset($ThisFileInfo['vqf']['DSIZ']) && (($ThisFileInfo['vqf']['DSIZ'] != ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'] - strlen('DATA'))))) {
|
||||
switch ($ThisFileInfo['vqf']['DSIZ']) {
|
||||
case 0:
|
||||
case 1:
|
||||
$ThisFileInfo['warning'] .= "\n".'Invalid DSIZ value "'.$ThisFileInfo['vqf']['DSIZ'].'". This is known to happen with VQF files encoded by Ahead Nero, and seems to be its way of saying this is TwinVQF v'.($ThisFileInfo['vqf']['DSIZ'] + 1).'.0';
|
||||
$ThisFileInfo['audio']['encoder'] = 'Ahead Nero';
|
||||
break;
|
||||
|
||||
default:
|
||||
$ThisFileInfo['warning'] .= "\n".'Probable corrupted file - should be '.$ThisFileInfo['vqf']['DSIZ'].' bytes, actually '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'] - strlen('DATA'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Any VQF tags present?
|
||||
if ($HasVQFTags) {
|
||||
|
||||
// add tag to array of tags
|
||||
$ThisFileInfo['tags'][] = 'vqf';
|
||||
|
||||
// Yank other comments - VQF highest preference
|
||||
CopyFormatCommentsToRootComments($ThisFileInfo['vqf']['comments'], $ThisFileInfo, true, true, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function VQFchannelFrequencyLookup($frequencyid) {
|
||||
static $VQFchannelFrequencyLookup = array();
|
||||
if (empty($VQFchannelFrequencyLookup)) {
|
||||
$VQFchannelFrequencyLookup[11] = 11025;
|
||||
$VQFchannelFrequencyLookup[22] = 22050;
|
||||
$VQFchannelFrequencyLookup[44] = 44100;
|
||||
}
|
||||
return (isset($VQFchannelFrequencyLookup[$frequencyid]) ? $VQFchannelFrequencyLookup[$frequencyid] : $frequencyid * 1000);
|
||||
}
|
||||
|
||||
function VQFcommentNiceNameLookup($shortname) {
|
||||
static $VQFcommentNiceNameLookup = array();
|
||||
if (empty($VQFcommentNiceNameLookup)) {
|
||||
$VQFcommentNiceNameLookup['NAME'] = 'title';
|
||||
$VQFcommentNiceNameLookup['AUTH'] = 'artist';
|
||||
$VQFcommentNiceNameLookup['(c) '] = 'copyright';
|
||||
$VQFcommentNiceNameLookup['FILE'] = 'filename';
|
||||
$VQFcommentNiceNameLookup['COMT'] = 'comment';
|
||||
$VQFcommentNiceNameLookup['ALBM'] = 'album';
|
||||
}
|
||||
return (isset($VQFcommentNiceNameLookup["$shortname"]) ? $VQFcommentNiceNameLookup["$shortname"] : $shortname);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue