Edit File by line
/home/barbar84/www/wp-inclu.../ID3
File: getid3.php
// pictures can take up a lot of space, and we don't need multiple copies of them; let there be a single copy in [comments][picture], and not elsewhere
[1500] Fix | Delete
unset($this->info[$comment_name]['comments'][$tag_key]);
[1501] Fix | Delete
}
[1502] Fix | Delete
}
[1503] Fix | Delete
[1504] Fix | Delete
if (!isset($this->info['tags'][$tag_name])) {
[1505] Fix | Delete
// comments are set but contain nothing but empty strings, so skip
[1506] Fix | Delete
continue;
[1507] Fix | Delete
}
[1508] Fix | Delete
[1509] Fix | Delete
$this->CharConvert($this->info['tags'][$tag_name], $this->info[$comment_name]['encoding']); // only copy gets converted!
[1510] Fix | Delete
[1511] Fix | Delete
if ($this->option_tags_html) {
[1512] Fix | Delete
foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
[1513] Fix | Delete
if ($tag_key == 'picture') {
[1514] Fix | Delete
// Do not to try to convert binary picture data to HTML
[1515] Fix | Delete
// https://github.com/JamesHeinrich/getID3/issues/178
[1516] Fix | Delete
continue;
[1517] Fix | Delete
}
[1518] Fix | Delete
$this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $this->info[$comment_name]['encoding']);
[1519] Fix | Delete
}
[1520] Fix | Delete
}
[1521] Fix | Delete
[1522] Fix | Delete
}
[1523] Fix | Delete
[1524] Fix | Delete
}
[1525] Fix | Delete
[1526] Fix | Delete
// pictures can take up a lot of space, and we don't need multiple copies of them; let there be a single copy in [comments][picture], and not elsewhere
[1527] Fix | Delete
if (!empty($this->info['tags'])) {
[1528] Fix | Delete
$unset_keys = array('tags', 'tags_html');
[1529] Fix | Delete
foreach ($this->info['tags'] as $tagtype => $tagarray) {
[1530] Fix | Delete
foreach ($tagarray as $tagname => $tagdata) {
[1531] Fix | Delete
if ($tagname == 'picture') {
[1532] Fix | Delete
foreach ($tagdata as $key => $tagarray) {
[1533] Fix | Delete
$this->info['comments']['picture'][] = $tagarray;
[1534] Fix | Delete
if (isset($tagarray['data']) && isset($tagarray['image_mime'])) {
[1535] Fix | Delete
if (isset($this->info['tags'][$tagtype][$tagname][$key])) {
[1536] Fix | Delete
unset($this->info['tags'][$tagtype][$tagname][$key]);
[1537] Fix | Delete
}
[1538] Fix | Delete
if (isset($this->info['tags_html'][$tagtype][$tagname][$key])) {
[1539] Fix | Delete
unset($this->info['tags_html'][$tagtype][$tagname][$key]);
[1540] Fix | Delete
}
[1541] Fix | Delete
}
[1542] Fix | Delete
}
[1543] Fix | Delete
}
[1544] Fix | Delete
}
[1545] Fix | Delete
foreach ($unset_keys as $unset_key) {
[1546] Fix | Delete
// remove possible empty keys from (e.g. [tags][id3v2][picture])
[1547] Fix | Delete
if (empty($this->info[$unset_key][$tagtype]['picture'])) {
[1548] Fix | Delete
unset($this->info[$unset_key][$tagtype]['picture']);
[1549] Fix | Delete
}
[1550] Fix | Delete
if (empty($this->info[$unset_key][$tagtype])) {
[1551] Fix | Delete
unset($this->info[$unset_key][$tagtype]);
[1552] Fix | Delete
}
[1553] Fix | Delete
if (empty($this->info[$unset_key])) {
[1554] Fix | Delete
unset($this->info[$unset_key]);
[1555] Fix | Delete
}
[1556] Fix | Delete
}
[1557] Fix | Delete
// remove duplicate copy of picture data from (e.g. [id3v2][comments][picture])
[1558] Fix | Delete
if (isset($this->info[$tagtype]['comments']['picture'])) {
[1559] Fix | Delete
unset($this->info[$tagtype]['comments']['picture']);
[1560] Fix | Delete
}
[1561] Fix | Delete
if (empty($this->info[$tagtype]['comments'])) {
[1562] Fix | Delete
unset($this->info[$tagtype]['comments']);
[1563] Fix | Delete
}
[1564] Fix | Delete
if (empty($this->info[$tagtype])) {
[1565] Fix | Delete
unset($this->info[$tagtype]);
[1566] Fix | Delete
}
[1567] Fix | Delete
}
[1568] Fix | Delete
}
[1569] Fix | Delete
return true;
[1570] Fix | Delete
}
[1571] Fix | Delete
[1572] Fix | Delete
/**
[1573] Fix | Delete
* Calls getid3_lib::CopyTagsToComments() but passes in the option_tags_html setting from this instance of getID3
[1574] Fix | Delete
*
[1575] Fix | Delete
* @param array $ThisFileInfo
[1576] Fix | Delete
*
[1577] Fix | Delete
* @return bool
[1578] Fix | Delete
*/
[1579] Fix | Delete
public function CopyTagsToComments(&$ThisFileInfo) {
[1580] Fix | Delete
return getid3_lib::CopyTagsToComments($ThisFileInfo, $this->option_tags_html);
[1581] Fix | Delete
}
[1582] Fix | Delete
[1583] Fix | Delete
/**
[1584] Fix | Delete
* @param string $algorithm
[1585] Fix | Delete
*
[1586] Fix | Delete
* @return array|bool
[1587] Fix | Delete
*/
[1588] Fix | Delete
public function getHashdata($algorithm) {
[1589] Fix | Delete
switch ($algorithm) {
[1590] Fix | Delete
case 'md5':
[1591] Fix | Delete
case 'sha1':
[1592] Fix | Delete
break;
[1593] Fix | Delete
[1594] Fix | Delete
default:
[1595] Fix | Delete
return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
[1596] Fix | Delete
}
[1597] Fix | Delete
[1598] Fix | Delete
if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) {
[1599] Fix | Delete
[1600] Fix | Delete
// We cannot get an identical md5_data value for Ogg files where the comments
[1601] Fix | Delete
// span more than 1 Ogg page (compared to the same audio data with smaller
[1602] Fix | Delete
// comments) using the normal getID3() method of MD5'ing the data between the
[1603] Fix | Delete
// end of the comments and the end of the file (minus any trailing tags),
[1604] Fix | Delete
// because the page sequence numbers of the pages that the audio data is on
[1605] Fix | Delete
// do not match. Under normal circumstances, where comments are smaller than
[1606] Fix | Delete
// the nominal 4-8kB page size, then this is not a problem, but if there are
[1607] Fix | Delete
// very large comments, the only way around it is to strip off the comment
[1608] Fix | Delete
// tags with vorbiscomment and MD5 that file.
[1609] Fix | Delete
// This procedure must be applied to ALL Ogg files, not just the ones with
[1610] Fix | Delete
// comments larger than 1 page, because the below method simply MD5's the
[1611] Fix | Delete
// whole file with the comments stripped, not just the portion after the
[1612] Fix | Delete
// comments block (which is the standard getID3() method.
[1613] Fix | Delete
[1614] Fix | Delete
// The above-mentioned problem of comments spanning multiple pages and changing
[1615] Fix | Delete
// page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
[1616] Fix | Delete
// currently vorbiscomment only works on OggVorbis files.
[1617] Fix | Delete
[1618] Fix | Delete
// phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved
[1619] Fix | Delete
if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
[1620] Fix | Delete
[1621] Fix | Delete
$this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)');
[1622] Fix | Delete
$this->info[$algorithm.'_data'] = false;
[1623] Fix | Delete
[1624] Fix | Delete
} else {
[1625] Fix | Delete
[1626] Fix | Delete
// Prevent user from aborting script
[1627] Fix | Delete
$old_abort = ignore_user_abort(true);
[1628] Fix | Delete
[1629] Fix | Delete
// Create empty file
[1630] Fix | Delete
$empty = tempnam(GETID3_TEMP_DIR, 'getID3');
[1631] Fix | Delete
touch($empty);
[1632] Fix | Delete
[1633] Fix | Delete
// Use vorbiscomment to make temp file without comments
[1634] Fix | Delete
$temp = tempnam(GETID3_TEMP_DIR, 'getID3');
[1635] Fix | Delete
$file = $this->info['filenamepath'];
[1636] Fix | Delete
[1637] Fix | Delete
if (GETID3_OS_ISWINDOWS) {
[1638] Fix | Delete
[1639] Fix | Delete
if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
[1640] Fix | Delete
[1641] Fix | Delete
$commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';
[1642] Fix | Delete
$VorbisCommentError = `$commandline`;
[1643] Fix | Delete
[1644] Fix | Delete
} else {
[1645] Fix | Delete
[1646] Fix | Delete
$VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
[1647] Fix | Delete
[1648] Fix | Delete
}
[1649] Fix | Delete
[1650] Fix | Delete
} else {
[1651] Fix | Delete
[1652] Fix | Delete
$commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
[1653] Fix | Delete
$VorbisCommentError = `$commandline`;
[1654] Fix | Delete
[1655] Fix | Delete
}
[1656] Fix | Delete
[1657] Fix | Delete
if (!empty($VorbisCommentError)) {
[1658] Fix | Delete
[1659] Fix | Delete
$this->warning('Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_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);
[1660] Fix | Delete
$this->info[$algorithm.'_data'] = false;
[1661] Fix | Delete
[1662] Fix | Delete
} else {
[1663] Fix | Delete
[1664] Fix | Delete
// Get hash of newly created file
[1665] Fix | Delete
switch ($algorithm) {
[1666] Fix | Delete
case 'md5':
[1667] Fix | Delete
$this->info[$algorithm.'_data'] = md5_file($temp);
[1668] Fix | Delete
break;
[1669] Fix | Delete
[1670] Fix | Delete
case 'sha1':
[1671] Fix | Delete
$this->info[$algorithm.'_data'] = sha1_file($temp);
[1672] Fix | Delete
break;
[1673] Fix | Delete
}
[1674] Fix | Delete
}
[1675] Fix | Delete
[1676] Fix | Delete
// Clean up
[1677] Fix | Delete
unlink($empty);
[1678] Fix | Delete
unlink($temp);
[1679] Fix | Delete
[1680] Fix | Delete
// Reset abort setting
[1681] Fix | Delete
ignore_user_abort($old_abort);
[1682] Fix | Delete
[1683] Fix | Delete
}
[1684] Fix | Delete
[1685] Fix | Delete
} else {
[1686] Fix | Delete
[1687] Fix | Delete
if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
[1688] Fix | Delete
[1689] Fix | Delete
// get hash from part of file
[1690] Fix | Delete
$this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
[1691] Fix | Delete
[1692] Fix | Delete
} else {
[1693] Fix | Delete
[1694] Fix | Delete
// get hash from whole file
[1695] Fix | Delete
switch ($algorithm) {
[1696] Fix | Delete
case 'md5':
[1697] Fix | Delete
$this->info[$algorithm.'_data'] = md5_file($this->info['filenamepath']);
[1698] Fix | Delete
break;
[1699] Fix | Delete
[1700] Fix | Delete
case 'sha1':
[1701] Fix | Delete
$this->info[$algorithm.'_data'] = sha1_file($this->info['filenamepath']);
[1702] Fix | Delete
break;
[1703] Fix | Delete
}
[1704] Fix | Delete
}
[1705] Fix | Delete
[1706] Fix | Delete
}
[1707] Fix | Delete
return true;
[1708] Fix | Delete
}
[1709] Fix | Delete
[1710] Fix | Delete
public function ChannelsBitratePlaytimeCalculations() {
[1711] Fix | Delete
[1712] Fix | Delete
// set channelmode on audio
[1713] Fix | Delete
if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
[1714] Fix | Delete
// ignore
[1715] Fix | Delete
} elseif ($this->info['audio']['channels'] == 1) {
[1716] Fix | Delete
$this->info['audio']['channelmode'] = 'mono';
[1717] Fix | Delete
} elseif ($this->info['audio']['channels'] == 2) {
[1718] Fix | Delete
$this->info['audio']['channelmode'] = 'stereo';
[1719] Fix | Delete
}
[1720] Fix | Delete
[1721] Fix | Delete
// Calculate combined bitrate - audio + video
[1722] Fix | Delete
$CombinedBitrate = 0;
[1723] Fix | Delete
$CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
[1724] Fix | Delete
$CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
[1725] Fix | Delete
if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
[1726] Fix | Delete
$this->info['bitrate'] = $CombinedBitrate;
[1727] Fix | Delete
}
[1728] Fix | Delete
//if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {
[1729] Fix | Delete
// // for example, VBR MPEG video files cannot determine video bitrate:
[1730] Fix | Delete
// // should not set overall bitrate and playtime from audio bitrate only
[1731] Fix | Delete
// unset($this->info['bitrate']);
[1732] Fix | Delete
//}
[1733] Fix | Delete
[1734] Fix | Delete
// video bitrate undetermined, but calculable
[1735] Fix | Delete
if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && (!isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) {
[1736] Fix | Delete
// if video bitrate not set
[1737] Fix | Delete
if (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] > 0) && ($this->info['audio']['bitrate'] == $this->info['bitrate'])) {
[1738] Fix | Delete
// AND if audio bitrate is set to same as overall bitrate
[1739] Fix | Delete
if (isset($this->info['playtime_seconds']) && ($this->info['playtime_seconds'] > 0)) {
[1740] Fix | Delete
// AND if playtime is set
[1741] Fix | Delete
if (isset($this->info['avdataend']) && isset($this->info['avdataoffset'])) {
[1742] Fix | Delete
// AND if AV data offset start/end is known
[1743] Fix | Delete
// THEN we can calculate the video bitrate
[1744] Fix | Delete
$this->info['bitrate'] = round((($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds']);
[1745] Fix | Delete
$this->info['video']['bitrate'] = $this->info['bitrate'] - $this->info['audio']['bitrate'];
[1746] Fix | Delete
}
[1747] Fix | Delete
}
[1748] Fix | Delete
}
[1749] Fix | Delete
}
[1750] Fix | Delete
[1751] Fix | Delete
if ((!isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && !empty($this->info['bitrate'])) {
[1752] Fix | Delete
$this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
[1753] Fix | Delete
}
[1754] Fix | Delete
[1755] Fix | Delete
if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) {
[1756] Fix | Delete
$this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds'];
[1757] Fix | Delete
}
[1758] Fix | Delete
if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) {
[1759] Fix | Delete
if (isset($this->info['audio']['dataformat']) && empty($this->info['video']['resolution_x'])) {
[1760] Fix | Delete
// audio only
[1761] Fix | Delete
$this->info['audio']['bitrate'] = $this->info['bitrate'];
[1762] Fix | Delete
} elseif (isset($this->info['video']['resolution_x']) && empty($this->info['audio']['dataformat'])) {
[1763] Fix | Delete
// video only
[1764] Fix | Delete
$this->info['video']['bitrate'] = $this->info['bitrate'];
[1765] Fix | Delete
}
[1766] Fix | Delete
}
[1767] Fix | Delete
[1768] Fix | Delete
// Set playtime string
[1769] Fix | Delete
if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
[1770] Fix | Delete
$this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
[1771] Fix | Delete
}
[1772] Fix | Delete
}
[1773] Fix | Delete
[1774] Fix | Delete
/**
[1775] Fix | Delete
* @return bool
[1776] Fix | Delete
*/
[1777] Fix | Delete
public function CalculateCompressionRatioVideo() {
[1778] Fix | Delete
if (empty($this->info['video'])) {
[1779] Fix | Delete
return false;
[1780] Fix | Delete
}
[1781] Fix | Delete
if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
[1782] Fix | Delete
return false;
[1783] Fix | Delete
}
[1784] Fix | Delete
if (empty($this->info['video']['bits_per_sample'])) {
[1785] Fix | Delete
return false;
[1786] Fix | Delete
}
[1787] Fix | Delete
[1788] Fix | Delete
switch ($this->info['video']['dataformat']) {
[1789] Fix | Delete
case 'bmp':
[1790] Fix | Delete
case 'gif':
[1791] Fix | Delete
case 'jpeg':
[1792] Fix | Delete
case 'jpg':
[1793] Fix | Delete
case 'png':
[1794] Fix | Delete
case 'tiff':
[1795] Fix | Delete
$FrameRate = 1;
[1796] Fix | Delete
$PlaytimeSeconds = 1;
[1797] Fix | Delete
$BitrateCompressed = $this->info['filesize'] * 8;
[1798] Fix | Delete
break;
[1799] Fix | Delete
[1800] Fix | Delete
default:
[1801] Fix | Delete
if (!empty($this->info['video']['frame_rate'])) {
[1802] Fix | Delete
$FrameRate = $this->info['video']['frame_rate'];
[1803] Fix | Delete
} else {
[1804] Fix | Delete
return false;
[1805] Fix | Delete
}
[1806] Fix | Delete
if (!empty($this->info['playtime_seconds'])) {
[1807] Fix | Delete
$PlaytimeSeconds = $this->info['playtime_seconds'];
[1808] Fix | Delete
} else {
[1809] Fix | Delete
return false;
[1810] Fix | Delete
}
[1811] Fix | Delete
if (!empty($this->info['video']['bitrate'])) {
[1812] Fix | Delete
$BitrateCompressed = $this->info['video']['bitrate'];
[1813] Fix | Delete
} else {
[1814] Fix | Delete
return false;
[1815] Fix | Delete
}
[1816] Fix | Delete
break;
[1817] Fix | Delete
}
[1818] Fix | Delete
$BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
[1819] Fix | Delete
[1820] Fix | Delete
$this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
[1821] Fix | Delete
return true;
[1822] Fix | Delete
}
[1823] Fix | Delete
[1824] Fix | Delete
/**
[1825] Fix | Delete
* @return bool
[1826] Fix | Delete
*/
[1827] Fix | Delete
public function CalculateCompressionRatioAudio() {
[1828] Fix | Delete
if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || !is_numeric($this->info['audio']['sample_rate'])) {
[1829] Fix | Delete
return false;
[1830] Fix | Delete
}
[1831] Fix | Delete
$this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
[1832] Fix | Delete
[1833] Fix | Delete
if (!empty($this->info['audio']['streams'])) {
[1834] Fix | Delete
foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
[1835] Fix | Delete
if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
[1836] Fix | Delete
$this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
[1837] Fix | Delete
}
[1838] Fix | Delete
}
[1839] Fix | Delete
}
[1840] Fix | Delete
return true;
[1841] Fix | Delete
}
[1842] Fix | Delete
[1843] Fix | Delete
/**
[1844] Fix | Delete
* @return bool
[1845] Fix | Delete
*/
[1846] Fix | Delete
public function CalculateReplayGain() {
[1847] Fix | Delete
if (isset($this->info['replay_gain'])) {
[1848] Fix | Delete
if (!isset($this->info['replay_gain']['reference_volume'])) {
[1849] Fix | Delete
$this->info['replay_gain']['reference_volume'] = 89.0;
[1850] Fix | Delete
}
[1851] Fix | Delete
if (isset($this->info['replay_gain']['track']['adjustment'])) {
[1852] Fix | Delete
$this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
[1853] Fix | Delete
}
[1854] Fix | Delete
if (isset($this->info['replay_gain']['album']['adjustment'])) {
[1855] Fix | Delete
$this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
[1856] Fix | Delete
}
[1857] Fix | Delete
[1858] Fix | Delete
if (isset($this->info['replay_gain']['track']['peak'])) {
[1859] Fix | Delete
$this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
[1860] Fix | Delete
}
[1861] Fix | Delete
if (isset($this->info['replay_gain']['album']['peak'])) {
[1862] Fix | Delete
$this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
[1863] Fix | Delete
}
[1864] Fix | Delete
}
[1865] Fix | Delete
return true;
[1866] Fix | Delete
}
[1867] Fix | Delete
[1868] Fix | Delete
/**
[1869] Fix | Delete
* @return bool
[1870] Fix | Delete
*/
[1871] Fix | Delete
public function ProcessAudioStreams() {
[1872] Fix | Delete
if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
[1873] Fix | Delete
if (!isset($this->info['audio']['streams'])) {
[1874] Fix | Delete
foreach ($this->info['audio'] as $key => $value) {
[1875] Fix | Delete
if ($key != 'streams') {
[1876] Fix | Delete
$this->info['audio']['streams'][0][$key] = $value;
[1877] Fix | Delete
}
[1878] Fix | Delete
}
[1879] Fix | Delete
}
[1880] Fix | Delete
}
[1881] Fix | Delete
return true;
[1882] Fix | Delete
}
[1883] Fix | Delete
[1884] Fix | Delete
/**
[1885] Fix | Delete
* @return string|bool
[1886] Fix | Delete
*/
[1887] Fix | Delete
public function getid3_tempnam() {
[1888] Fix | Delete
return tempnam($this->tempdir, 'gI3');
[1889] Fix | Delete
}
[1890] Fix | Delete
[1891] Fix | Delete
/**
[1892] Fix | Delete
* @param string $name
[1893] Fix | Delete
*
[1894] Fix | Delete
* @return bool
[1895] Fix | Delete
*
[1896] Fix | Delete
* @throws getid3_exception
[1897] Fix | Delete
*/
[1898] Fix | Delete
public function include_module($name) {
[1899] Fix | Delete
//if (!file_exists($this->include_path.'module.'.$name.'.php')) {
[1900] Fix | Delete
if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
[1901] Fix | Delete
throw new getid3_exception('Required module.'.$name.'.php is missing.');
[1902] Fix | Delete
}
[1903] Fix | Delete
include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php');
[1904] Fix | Delete
return true;
[1905] Fix | Delete
}
[1906] Fix | Delete
[1907] Fix | Delete
/**
[1908] Fix | Delete
* @param string $filename
[1909] Fix | Delete
*
[1910] Fix | Delete
* @return bool
[1911] Fix | Delete
*/
[1912] Fix | Delete
public static function is_writable ($filename) {
[1913] Fix | Delete
$ret = is_writable($filename);
[1914] Fix | Delete
if (!$ret) {
[1915] Fix | Delete
$perms = fileperms($filename);
[1916] Fix | Delete
$ret = ($perms & 0x0080) || ($perms & 0x0010) || ($perms & 0x0002);
[1917] Fix | Delete
}
[1918] Fix | Delete
return $ret;
[1919] Fix | Delete
}
[1920] Fix | Delete
[1921] Fix | Delete
}
[1922] Fix | Delete
[1923] Fix | Delete
[1924] Fix | Delete
abstract class getid3_handler
[1925] Fix | Delete
{
[1926] Fix | Delete
[1927] Fix | Delete
/**
[1928] Fix | Delete
* @var getID3
[1929] Fix | Delete
*/
[1930] Fix | Delete
protected $getid3; // pointer
[1931] Fix | Delete
[1932] Fix | Delete
/**
[1933] Fix | Delete
* Analyzing filepointer or string.
[1934] Fix | Delete
*
[1935] Fix | Delete
* @var bool
[1936] Fix | Delete
*/
[1937] Fix | Delete
protected $data_string_flag = false;
[1938] Fix | Delete
[1939] Fix | Delete
/**
[1940] Fix | Delete
* String to analyze.
[1941] Fix | Delete
*
[1942] Fix | Delete
* @var string
[1943] Fix | Delete
*/
[1944] Fix | Delete
protected $data_string = '';
[1945] Fix | Delete
[1946] Fix | Delete
/**
[1947] Fix | Delete
* Seek position in string.
[1948] Fix | Delete
*
[1949] Fix | Delete
* @var int
[1950] Fix | Delete
*/
[1951] Fix | Delete
protected $data_string_position = 0;
[1952] Fix | Delete
[1953] Fix | Delete
/**
[1954] Fix | Delete
* String length.
[1955] Fix | Delete
*
[1956] Fix | Delete
* @var int
[1957] Fix | Delete
*/
[1958] Fix | Delete
protected $data_string_length = 0;
[1959] Fix | Delete
[1960] Fix | Delete
/**
[1961] Fix | Delete
* @var string
[1962] Fix | Delete
*/
[1963] Fix | Delete
private $dependency_to;
[1964] Fix | Delete
[1965] Fix | Delete
/**
[1966] Fix | Delete
* getid3_handler constructor.
[1967] Fix | Delete
*
[1968] Fix | Delete
* @param getID3 $getid3
[1969] Fix | Delete
* @param string $call_module
[1970] Fix | Delete
*/
[1971] Fix | Delete
public function __construct(getID3 $getid3, $call_module=null) {
[1972] Fix | Delete
$this->getid3 = $getid3;
[1973] Fix | Delete
[1974] Fix | Delete
if ($call_module) {
[1975] Fix | Delete
$this->dependency_to = str_replace('getid3_', '', $call_module);
[1976] Fix | Delete
}
[1977] Fix | Delete
}
[1978] Fix | Delete
[1979] Fix | Delete
/**
[1980] Fix | Delete
* Analyze from file pointer.
[1981] Fix | Delete
*
[1982] Fix | Delete
* @return bool
[1983] Fix | Delete
*/
[1984] Fix | Delete
abstract public function Analyze();
[1985] Fix | Delete
[1986] Fix | Delete
/**
[1987] Fix | Delete
* Analyze from string instead.
[1988] Fix | Delete
*
[1989] Fix | Delete
* @param string $string
[1990] Fix | Delete
*/
[1991] Fix | Delete
public function AnalyzeString($string) {
[1992] Fix | Delete
// Enter string mode
[1993] Fix | Delete
$this->setStringMode($string);
[1994] Fix | Delete
[1995] Fix | Delete
// Save info
[1996] Fix | Delete
$saved_avdataoffset = $this->getid3->info['avdataoffset'];
[1997] Fix | Delete
$saved_avdataend = $this->getid3->info['avdataend'];
[1998] Fix | Delete
$saved_filesize = (isset($this->getid3->info['filesize']) ? $this->getid3->info['filesize'] : null); // may be not set if called as dependency without openfile() call
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function