Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../ID3
File: getid3.lib.php
return false;
[1500] Fix | Delete
}
[1501] Fix | Delete
$GetDataImageSize['height'] = $GetDataImageSize[0];
[1502] Fix | Delete
$GetDataImageSize['width'] = $GetDataImageSize[1];
[1503] Fix | Delete
return $GetDataImageSize;
[1504] Fix | Delete
}
[1505] Fix | Delete
static $tempdir = '';
[1506] Fix | Delete
if (empty($tempdir)) {
[1507] Fix | Delete
if (function_exists('sys_get_temp_dir')) {
[1508] Fix | Delete
$tempdir = sys_get_temp_dir(); // https://github.com/JamesHeinrich/getID3/issues/52
[1509] Fix | Delete
}
[1510] Fix | Delete
[1511] Fix | Delete
// yes this is ugly, feel free to suggest a better way
[1512] Fix | Delete
if (include_once(dirname(__FILE__).'/getid3.php')) {
[1513] Fix | Delete
$getid3_temp = new getID3();
[1514] Fix | Delete
if ($getid3_temp_tempdir = $getid3_temp->tempdir) {
[1515] Fix | Delete
$tempdir = $getid3_temp_tempdir;
[1516] Fix | Delete
}
[1517] Fix | Delete
unset($getid3_temp, $getid3_temp_tempdir);
[1518] Fix | Delete
}
[1519] Fix | Delete
}
[1520] Fix | Delete
$GetDataImageSize = false;
[1521] Fix | Delete
if ($tempfilename = tempnam($tempdir, 'gI3')) {
[1522] Fix | Delete
if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) {
[1523] Fix | Delete
fwrite($tmp, $imgData);
[1524] Fix | Delete
fclose($tmp);
[1525] Fix | Delete
$GetDataImageSize = @getimagesize($tempfilename, $imageinfo);
[1526] Fix | Delete
if (($GetDataImageSize === false) || !isset($GetDataImageSize[0]) || !isset($GetDataImageSize[1])) {
[1527] Fix | Delete
return false;
[1528] Fix | Delete
}
[1529] Fix | Delete
$GetDataImageSize['height'] = $GetDataImageSize[0];
[1530] Fix | Delete
$GetDataImageSize['width'] = $GetDataImageSize[1];
[1531] Fix | Delete
}
[1532] Fix | Delete
unlink($tempfilename);
[1533] Fix | Delete
}
[1534] Fix | Delete
return $GetDataImageSize;
[1535] Fix | Delete
}
[1536] Fix | Delete
[1537] Fix | Delete
/**
[1538] Fix | Delete
* @param string $mime_type
[1539] Fix | Delete
*
[1540] Fix | Delete
* @return string
[1541] Fix | Delete
*/
[1542] Fix | Delete
public static function ImageExtFromMime($mime_type) {
[1543] Fix | Delete
// temporary way, works OK for now, but should be reworked in the future
[1544] Fix | Delete
return str_replace(array('image/', 'x-', 'jpeg'), array('', '', 'jpg'), $mime_type);
[1545] Fix | Delete
}
[1546] Fix | Delete
[1547] Fix | Delete
/**
[1548] Fix | Delete
* @param array $ThisFileInfo
[1549] Fix | Delete
* @param bool $option_tags_html default true (just as in the main getID3 class)
[1550] Fix | Delete
*
[1551] Fix | Delete
* @return bool
[1552] Fix | Delete
*/
[1553] Fix | Delete
public static function CopyTagsToComments(&$ThisFileInfo, $option_tags_html=true) {
[1554] Fix | Delete
// Copy all entries from ['tags'] into common ['comments']
[1555] Fix | Delete
if (!empty($ThisFileInfo['tags'])) {
[1556] Fix | Delete
[1557] Fix | Delete
// Some tag types can only support limited character sets and may contain data in non-standard encoding (usually ID3v1)
[1558] Fix | Delete
// and/or poorly-transliterated tag values that are also in tag formats that do support full-range character sets
[1559] Fix | Delete
// To make the output more user-friendly, process the potentially-problematic tag formats last to enhance the chance that
[1560] Fix | Delete
// the first entries in [comments] are the most correct and the "bad" ones (if any) come later.
[1561] Fix | Delete
// https://github.com/JamesHeinrich/getID3/issues/338
[1562] Fix | Delete
$processLastTagTypes = array('id3v1','riff');
[1563] Fix | Delete
foreach ($processLastTagTypes as $processLastTagType) {
[1564] Fix | Delete
if (isset($ThisFileInfo['tags'][$processLastTagType])) {
[1565] Fix | Delete
// bubble ID3v1 to the end, if present to aid in detecting bad ID3v1 encodings
[1566] Fix | Delete
$temp = $ThisFileInfo['tags'][$processLastTagType];
[1567] Fix | Delete
unset($ThisFileInfo['tags'][$processLastTagType]);
[1568] Fix | Delete
$ThisFileInfo['tags'][$processLastTagType] = $temp;
[1569] Fix | Delete
unset($temp);
[1570] Fix | Delete
}
[1571] Fix | Delete
}
[1572] Fix | Delete
foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
[1573] Fix | Delete
foreach ($tagarray as $tagname => $tagdata) {
[1574] Fix | Delete
foreach ($tagdata as $key => $value) {
[1575] Fix | Delete
if (!empty($value)) {
[1576] Fix | Delete
if (empty($ThisFileInfo['comments'][$tagname])) {
[1577] Fix | Delete
[1578] Fix | Delete
// fall through and append value
[1579] Fix | Delete
[1580] Fix | Delete
} elseif ($tagtype == 'id3v1') {
[1581] Fix | Delete
[1582] Fix | Delete
$newvaluelength = strlen(trim($value));
[1583] Fix | Delete
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
[1584] Fix | Delete
$oldvaluelength = strlen(trim($existingvalue));
[1585] Fix | Delete
if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) {
[1586] Fix | Delete
// new value is identical but shorter-than (or equal-length to) one already in comments - skip
[1587] Fix | Delete
break 2;
[1588] Fix | Delete
}
[1589] Fix | Delete
[1590] Fix | Delete
if (function_exists('mb_convert_encoding')) {
[1591] Fix | Delete
if (trim($value) == trim(substr(mb_convert_encoding($existingvalue, $ThisFileInfo['id3v1']['encoding'], $ThisFileInfo['encoding']), 0, 30))) {
[1592] Fix | Delete
// value stored in ID3v1 appears to be probably the multibyte value transliterated (badly) into ISO-8859-1 in ID3v1.
[1593] Fix | Delete
// As an example, Foobar2000 will do this if you tag a file with Chinese or Arabic or Cyrillic or something that doesn't fit into ISO-8859-1 the ID3v1 will consist of mostly "?" characters, one per multibyte unrepresentable character
[1594] Fix | Delete
break 2;
[1595] Fix | Delete
}
[1596] Fix | Delete
}
[1597] Fix | Delete
}
[1598] Fix | Delete
[1599] Fix | Delete
} elseif (!is_array($value)) {
[1600] Fix | Delete
[1601] Fix | Delete
$newvaluelength = strlen(trim($value));
[1602] Fix | Delete
$newvaluelengthMB = mb_strlen(trim($value));
[1603] Fix | Delete
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
[1604] Fix | Delete
$oldvaluelength = strlen(trim($existingvalue));
[1605] Fix | Delete
$oldvaluelengthMB = mb_strlen(trim($existingvalue));
[1606] Fix | Delete
if (($newvaluelengthMB == $oldvaluelengthMB) && ($existingvalue == getid3_lib::iconv_fallback('UTF-8', 'ASCII', $value))) {
[1607] Fix | Delete
// https://github.com/JamesHeinrich/getID3/issues/338
[1608] Fix | Delete
// check for tags containing extended characters that may have been forced into limited-character storage (e.g. UTF8 values into ASCII)
[1609] Fix | Delete
// which will usually display unrepresentable characters as "?"
[1610] Fix | Delete
$ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
[1611] Fix | Delete
break;
[1612] Fix | Delete
}
[1613] Fix | Delete
if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
[1614] Fix | Delete
$ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
[1615] Fix | Delete
break;
[1616] Fix | Delete
}
[1617] Fix | Delete
}
[1618] Fix | Delete
[1619] Fix | Delete
}
[1620] Fix | Delete
if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
[1621] Fix | Delete
$value = (is_string($value) ? trim($value) : $value);
[1622] Fix | Delete
if (!is_int($key) && !ctype_digit($key)) {
[1623] Fix | Delete
$ThisFileInfo['comments'][$tagname][$key] = $value;
[1624] Fix | Delete
} else {
[1625] Fix | Delete
if (!isset($ThisFileInfo['comments'][$tagname])) {
[1626] Fix | Delete
$ThisFileInfo['comments'][$tagname] = array($value);
[1627] Fix | Delete
} else {
[1628] Fix | Delete
$ThisFileInfo['comments'][$tagname][] = $value;
[1629] Fix | Delete
}
[1630] Fix | Delete
}
[1631] Fix | Delete
}
[1632] Fix | Delete
}
[1633] Fix | Delete
}
[1634] Fix | Delete
}
[1635] Fix | Delete
}
[1636] Fix | Delete
[1637] Fix | Delete
// attempt to standardize spelling of returned keys
[1638] Fix | Delete
if (!empty($ThisFileInfo['comments'])) {
[1639] Fix | Delete
$StandardizeFieldNames = array(
[1640] Fix | Delete
'tracknumber' => 'track_number',
[1641] Fix | Delete
'track' => 'track_number',
[1642] Fix | Delete
);
[1643] Fix | Delete
foreach ($StandardizeFieldNames as $badkey => $goodkey) {
[1644] Fix | Delete
if (array_key_exists($badkey, $ThisFileInfo['comments']) && !array_key_exists($goodkey, $ThisFileInfo['comments'])) {
[1645] Fix | Delete
$ThisFileInfo['comments'][$goodkey] = $ThisFileInfo['comments'][$badkey];
[1646] Fix | Delete
unset($ThisFileInfo['comments'][$badkey]);
[1647] Fix | Delete
}
[1648] Fix | Delete
}
[1649] Fix | Delete
}
[1650] Fix | Delete
[1651] Fix | Delete
if ($option_tags_html) {
[1652] Fix | Delete
// Copy ['comments'] to ['comments_html']
[1653] Fix | Delete
if (!empty($ThisFileInfo['comments'])) {
[1654] Fix | Delete
foreach ($ThisFileInfo['comments'] as $field => $values) {
[1655] Fix | Delete
if ($field == 'picture') {
[1656] Fix | Delete
// pictures can take up a lot of space, and we don't need multiple copies of them
[1657] Fix | Delete
// let there be a single copy in [comments][picture], and not elsewhere
[1658] Fix | Delete
continue;
[1659] Fix | Delete
}
[1660] Fix | Delete
foreach ($values as $index => $value) {
[1661] Fix | Delete
if (is_array($value)) {
[1662] Fix | Delete
$ThisFileInfo['comments_html'][$field][$index] = $value;
[1663] Fix | Delete
} else {
[1664] Fix | Delete
$ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
[1665] Fix | Delete
}
[1666] Fix | Delete
}
[1667] Fix | Delete
}
[1668] Fix | Delete
}
[1669] Fix | Delete
}
[1670] Fix | Delete
[1671] Fix | Delete
}
[1672] Fix | Delete
return true;
[1673] Fix | Delete
}
[1674] Fix | Delete
[1675] Fix | Delete
/**
[1676] Fix | Delete
* @param string $key
[1677] Fix | Delete
* @param int $begin
[1678] Fix | Delete
* @param int $end
[1679] Fix | Delete
* @param string $file
[1680] Fix | Delete
* @param string $name
[1681] Fix | Delete
*
[1682] Fix | Delete
* @return string
[1683] Fix | Delete
*/
[1684] Fix | Delete
public static function EmbeddedLookup($key, $begin, $end, $file, $name) {
[1685] Fix | Delete
[1686] Fix | Delete
// Cached
[1687] Fix | Delete
static $cache;
[1688] Fix | Delete
if (isset($cache[$file][$name])) {
[1689] Fix | Delete
return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
[1690] Fix | Delete
}
[1691] Fix | Delete
[1692] Fix | Delete
// Init
[1693] Fix | Delete
$keylength = strlen($key);
[1694] Fix | Delete
$line_count = $end - $begin - 7;
[1695] Fix | Delete
[1696] Fix | Delete
// Open php file
[1697] Fix | Delete
$fp = fopen($file, 'r');
[1698] Fix | Delete
[1699] Fix | Delete
// Discard $begin lines
[1700] Fix | Delete
for ($i = 0; $i < ($begin + 3); $i++) {
[1701] Fix | Delete
fgets($fp, 1024);
[1702] Fix | Delete
}
[1703] Fix | Delete
[1704] Fix | Delete
// Loop thru line
[1705] Fix | Delete
while (0 < $line_count--) {
[1706] Fix | Delete
[1707] Fix | Delete
// Read line
[1708] Fix | Delete
$line = ltrim(fgets($fp, 1024), "\t ");
[1709] Fix | Delete
[1710] Fix | Delete
// METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
[1711] Fix | Delete
//$keycheck = substr($line, 0, $keylength);
[1712] Fix | Delete
//if ($key == $keycheck) {
[1713] Fix | Delete
// $cache[$file][$name][$keycheck] = substr($line, $keylength + 1);
[1714] Fix | Delete
// break;
[1715] Fix | Delete
//}
[1716] Fix | Delete
[1717] Fix | Delete
// METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
[1718] Fix | Delete
//$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
[1719] Fix | Delete
$explodedLine = explode("\t", $line, 2);
[1720] Fix | Delete
$ThisKey = (isset($explodedLine[0]) ? $explodedLine[0] : '');
[1721] Fix | Delete
$ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : '');
[1722] Fix | Delete
$cache[$file][$name][$ThisKey] = trim($ThisValue);
[1723] Fix | Delete
}
[1724] Fix | Delete
[1725] Fix | Delete
// Close and return
[1726] Fix | Delete
fclose($fp);
[1727] Fix | Delete
return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
[1728] Fix | Delete
}
[1729] Fix | Delete
[1730] Fix | Delete
/**
[1731] Fix | Delete
* @param string $filename
[1732] Fix | Delete
* @param string $sourcefile
[1733] Fix | Delete
* @param bool $DieOnFailure
[1734] Fix | Delete
*
[1735] Fix | Delete
* @return bool
[1736] Fix | Delete
* @throws Exception
[1737] Fix | Delete
*/
[1738] Fix | Delete
public static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
[1739] Fix | Delete
global $GETID3_ERRORARRAY;
[1740] Fix | Delete
[1741] Fix | Delete
if (file_exists($filename)) {
[1742] Fix | Delete
if (include_once($filename)) {
[1743] Fix | Delete
return true;
[1744] Fix | Delete
} else {
[1745] Fix | Delete
$diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
[1746] Fix | Delete
}
[1747] Fix | Delete
} else {
[1748] Fix | Delete
$diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
[1749] Fix | Delete
}
[1750] Fix | Delete
if ($DieOnFailure) {
[1751] Fix | Delete
throw new Exception($diemessage);
[1752] Fix | Delete
} else {
[1753] Fix | Delete
$GETID3_ERRORARRAY[] = $diemessage;
[1754] Fix | Delete
}
[1755] Fix | Delete
return false;
[1756] Fix | Delete
}
[1757] Fix | Delete
[1758] Fix | Delete
/**
[1759] Fix | Delete
* @param string $string
[1760] Fix | Delete
*
[1761] Fix | Delete
* @return string
[1762] Fix | Delete
*/
[1763] Fix | Delete
public static function trimNullByte($string) {
[1764] Fix | Delete
return trim($string, "\x00");
[1765] Fix | Delete
}
[1766] Fix | Delete
[1767] Fix | Delete
/**
[1768] Fix | Delete
* @param string $path
[1769] Fix | Delete
*
[1770] Fix | Delete
* @return float|bool
[1771] Fix | Delete
*/
[1772] Fix | Delete
public static function getFileSizeSyscall($path) {
[1773] Fix | Delete
$commandline = null;
[1774] Fix | Delete
$filesize = false;
[1775] Fix | Delete
[1776] Fix | Delete
if (GETID3_OS_ISWINDOWS) {
[1777] Fix | Delete
if (class_exists('COM')) { // From PHP 5.3.15 and 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini:
[1778] Fix | Delete
$filesystem = new COM('Scripting.FileSystemObject');
[1779] Fix | Delete
$file = $filesystem->GetFile($path);
[1780] Fix | Delete
$filesize = $file->Size();
[1781] Fix | Delete
unset($filesystem, $file);
[1782] Fix | Delete
} else {
[1783] Fix | Delete
$commandline = 'for %I in ('.escapeshellarg($path).') do @echo %~zI';
[1784] Fix | Delete
}
[1785] Fix | Delete
} else {
[1786] Fix | Delete
$commandline = 'ls -l '.escapeshellarg($path).' | awk \'{print $5}\'';
[1787] Fix | Delete
}
[1788] Fix | Delete
if (isset($commandline)) {
[1789] Fix | Delete
$output = trim(`$commandline`);
[1790] Fix | Delete
if (ctype_digit($output)) {
[1791] Fix | Delete
$filesize = (float) $output;
[1792] Fix | Delete
}
[1793] Fix | Delete
}
[1794] Fix | Delete
return $filesize;
[1795] Fix | Delete
}
[1796] Fix | Delete
[1797] Fix | Delete
/**
[1798] Fix | Delete
* @param string $filename
[1799] Fix | Delete
*
[1800] Fix | Delete
* @return string|false
[1801] Fix | Delete
*/
[1802] Fix | Delete
public static function truepath($filename) {
[1803] Fix | Delete
// 2017-11-08: this could use some improvement, patches welcome
[1804] Fix | Delete
if (preg_match('#^(\\\\\\\\|//)[a-z0-9]#i', $filename, $matches)) {
[1805] Fix | Delete
// PHP's built-in realpath function does not work on UNC Windows shares
[1806] Fix | Delete
$goodpath = array();
[1807] Fix | Delete
foreach (explode('/', str_replace('\\', '/', $filename)) as $part) {
[1808] Fix | Delete
if ($part == '.') {
[1809] Fix | Delete
continue;
[1810] Fix | Delete
}
[1811] Fix | Delete
if ($part == '..') {
[1812] Fix | Delete
if (count($goodpath)) {
[1813] Fix | Delete
array_pop($goodpath);
[1814] Fix | Delete
} else {
[1815] Fix | Delete
// cannot step above this level, already at top level
[1816] Fix | Delete
return false;
[1817] Fix | Delete
}
[1818] Fix | Delete
} else {
[1819] Fix | Delete
$goodpath[] = $part;
[1820] Fix | Delete
}
[1821] Fix | Delete
}
[1822] Fix | Delete
return implode(DIRECTORY_SEPARATOR, $goodpath);
[1823] Fix | Delete
}
[1824] Fix | Delete
return realpath($filename);
[1825] Fix | Delete
}
[1826] Fix | Delete
[1827] Fix | Delete
/**
[1828] Fix | Delete
* Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268)
[1829] Fix | Delete
*
[1830] Fix | Delete
* @param string $path A path.
[1831] Fix | Delete
* @param string $suffix If the name component ends in suffix this will also be cut off.
[1832] Fix | Delete
*
[1833] Fix | Delete
* @return string
[1834] Fix | Delete
*/
[1835] Fix | Delete
public static function mb_basename($path, $suffix = '') {
[1836] Fix | Delete
$splited = preg_split('#/#', rtrim($path, '/ '));
[1837] Fix | Delete
return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
[1838] Fix | Delete
}
[1839] Fix | Delete
[1840] Fix | Delete
}
[1841] Fix | Delete
[1842] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function