36    public static function PrintHexBytes($string, $hex = 
true, $spaces = 
true,
 
   37                                         $htmlencoding = 
'UTF-8')
 
   40        for ($i = 0; $i < strlen($string); $i++) {
 
   42                $returnstring .= str_pad(dechex(ord($string{$i})), 2, 
'0',
 
   45                $returnstring .= 
' ' . (preg_match(
"#[\x20-\x7E]#", $string{$i}) ? $string{$i} : 
'ยค');
 
   51        if (!empty($htmlencoding)) {
 
   52            if ($htmlencoding === 
true) {
 
   53                $htmlencoding = 
'UTF-8'; 
 
   55            $returnstring = htmlentities($returnstring, ENT_QUOTES,
 
   67    public static function trunc($floatnumber)
 
   71        if ($floatnumber >= 1) {
 
   72            $truncatednumber = floor($floatnumber);
 
   73        } elseif ($floatnumber <= -1) {
 
   74            $truncatednumber = ceil($floatnumber);
 
   78        if (self::intValueSupported($truncatednumber)) {
 
   79            $truncatednumber = (int) $truncatednumber;
 
   82        return $truncatednumber;
 
   91    public static function safe_inc(&$variable, $increment = 1)
 
   93        if (isset($variable)) {
 
   94            $variable += $increment;
 
   96            $variable = $increment;
 
  110        $floatnum = (float) $floatnum;
 
  113        if (self::trunc($floatnum) == $floatnum) {
 
  115            if (self::intValueSupported($floatnum)) {
 
  117                $floatnum = (int) $floatnum;
 
  133        static $hasINT64 = 
null;
 
  134        if ($hasINT64 === 
null) { 
 
  135            $hasINT64 = is_int(pow(2, 31)); 
 
  136            if (!$hasINT64 && !
defined(
'PHP_INT_MIN')) {
 
  137                define(
'PHP_INT_MIN', ~PHP_INT_MAX);
 
  141        if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) {
 
  155        list($numerator, $denominator) = explode(
'/', $fraction);
 
  157        return $numerator / ($denominator ? $denominator : 1);
 
  169                                                      strlen($binarynumerator)));
 
  171        return ($numerator / $denominator);
 
  183        if (strpos($binarypointnumber, 
'.') === 
false) {
 
  184            $binarypointnumber = 
'0.' . $binarypointnumber;
 
  185        } elseif ($binarypointnumber{0} == 
'.') {
 
  186            $binarypointnumber = 
'0' . $binarypointnumber;
 
  189        while (($binarypointnumber{0} != 
'1') || (substr($binarypointnumber, 1,
 
  191            if (substr($binarypointnumber, 1, 1) == 
'.') {
 
  193                $binarypointnumber = substr($binarypointnumber, 2, 1) . 
'.' . substr($binarypointnumber,
 
  196                $pointpos = strpos($binarypointnumber, 
'.');
 
  197                $exponent += ($pointpos - 1);
 
  198                $binarypointnumber = str_replace(
'.', 
'', $binarypointnumber);
 
  199                $binarypointnumber = $binarypointnumber{0} . 
'.' . substr($binarypointnumber,
 
  203        $binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2),
 
  204                                            $maxbits + 2, 
'0', STR_PAD_RIGHT);
 
  206        return array(
'normalized' => $binarypointnumber, 
'exponent' => (
int) $exponent);
 
  219        $floatpart = abs($floatvalue - $intpart);
 
  220        $pointbitstring = 
'';
 
  221        while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
 
  223            $pointbitstring .= (string) self::trunc($floatpart);
 
  226        $binarypointnumber = decbin($intpart) . 
'.' . $pointbitstring;
 
  228        return $binarypointnumber;
 
  255        if ($floatvalue >= 0) {
 
  262        $biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary[
'exponent']; 
 
  263        $exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits,
 
  265        $fractionbitstring = str_pad(substr($normalizedbinary[
'normalized'], 2),
 
  266                                            $fractionbits, 
'0', STR_PAD_RIGHT);
 
  296        $signbit = $bitword{0};
 
  298        switch (strlen($byteword) * 8) {
 
  312                $exponentstring = substr($bitword, 1, 15);
 
  313                $isnormalized = intval($bitword{16});
 
  314                $fractionstring = substr($bitword, 17, 63);
 
  315                $exponent = pow(2, self::Bin2Dec($exponentstring) - 16383);
 
  317                $floatvalue = $exponent * $fraction;
 
  318                if ($signbit == 
'1') {
 
  329        $exponentstring = substr($bitword, 1, $exponentbits);
 
  330        $fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
 
  334        if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
 
  337        } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
 
  338            if ($signbit == 
'1') {
 
  339                $floatvalue = 
'-infinity';
 
  341                $floatvalue = 
'+infinity';
 
  343        } elseif (($exponent == 0) && ($fraction == 0)) {
 
  344            if ($signbit == 
'1') {
 
  349            $floatvalue = ($signbit ? 0 : -0);
 
  350        } elseif (($exponent == 0) && ($fraction != 0)) {
 
  353            if ($signbit == 
'1') {
 
  356        } elseif ($exponent != 0) {
 
  358            if ($signbit == 
'1') {
 
  363        return (
float) $floatvalue;
 
  378        $bytewordlen = strlen($byteword);
 
  379        if ($bytewordlen == 0) {
 
  382        for ($i = 0; $i < $bytewordlen; $i++) {
 
  385                $intvalue += (ord($byteword{$i}) & 0x7F) * pow(2,
 
  386                                                               ($bytewordlen - 1 - $i) * 7);
 
  388                $intvalue += ord($byteword{$i}) * pow(256,
 
  389                                                      ($bytewordlen - 1 - $i));
 
  392        if ($signed && !$synchsafe) {
 
  394            if ($bytewordlen <= PHP_INT_SIZE) {
 
  395                $signMaskBit = 0x80 << (8 * ($bytewordlen - 1));
 
  396                if ($intvalue & $signMaskBit) {
 
  397                    $intvalue = 0 - ($intvalue & ($signMaskBit - 1));
 
  400                throw new DefaultException(
'ERROR: Cannot have signed integers larger than ' . (8 * PHP_INT_SIZE) . 
'-bits (' . strlen($byteword) . 
') in self::BigEndian2Int()');
 
  426        $bytewordlen = strlen($byteword);
 
  427        for ($i = 0; $i < $bytewordlen; $i++) {
 
  428            $binvalue .= str_pad(decbin(ord($byteword{$i})), 8, 
'0',
 
  445                                            $synchsafe = 
false, $signed = 
false)
 
  448            throw new DefaultException(
'ERROR: self::BigEndian2String() does not support negative numbers');
 
  450        $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
 
  453            if ($minbytes > PHP_INT_SIZE) {
 
  454                throw new DefaultException(
'ERROR: Cannot have signed integers larger than ' . (8 * PHP_INT_SIZE) . 
'-bits in self::BigEndian2String()');
 
  456            $number = $number & (0x80 << (8 * ($minbytes - 1)));
 
  458        while ($number != 0) {
 
  459            $quotient = ($number / ($maskbyte + 1));
 
  460            $intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)) . $intstring;
 
  461            $number = floor($quotient);
 
  464        return str_pad($intstring, $minbytes, 
"\x00", STR_PAD_LEFT);
 
  474        while ($number >= 256) {
 
  475            $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
 
  476            $number = floor($number / 256);
 
  480        for ($i = 0; $i < count($bytes); $i++) {
 
  481            $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]),
 
  484                                                                                          STR_PAD_LEFT)) . $binstring;
 
  496    public static function Bin2Dec($binstring, $signed = 
false)
 
  500            if ($binstring{0} == 
'1') {
 
  503            $binstring = substr($binstring, 1);
 
  506        for ($i = 0; $i < strlen($binstring); $i++) {
 
  507            $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1,
 
  523        $binstringreversed = strrev($binstring);
 
  524        for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
 
  525            $string = chr(self::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))) . $string;
 
  542        while ($number > 0) {
 
  544                $intstring = $intstring . chr($number & 127);
 
  547                $intstring = $intstring . chr($number & 255);
 
  552        return str_pad($intstring, $minbytes, 
"\x00", STR_PAD_RIGHT);
 
  565        if (!is_array($array1) || !is_array($array2)) {
 
  569        foreach ($array2 as $key => $val) {
 
  570            if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
 
  574                $newarray[$key] = $val;
 
  589        if (!is_array($array1) || !is_array($array2)) {
 
  593        foreach ($array2 as $key => $val) {
 
  594            if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
 
  597            } elseif (!isset($newarray[$key])) {
 
  598                $newarray[$key] = $val;
 
  613        foreach ($theArray as $key => $value) {
 
  614            if (is_array($value)) {
 
  633            for ($i = 0; $i < $numextensions; $i++) {
 
  634                $offset = strpos($reversedfilename, 
'.', $offset + 1);
 
  635                if ($offset === 
false) {
 
  640            return strrev(substr($reversedfilename, 0, $offset));
 
  653        $sign = (($seconds < 0) ? 
'-' : 
'');
 
  654        $seconds = round(abs($seconds));
 
  655        $H = (int) floor($seconds / 3600);
 
  656        $M = (int) floor(($seconds - (3600 * $H) ) / 60);
 
  657        $S = (int) round($seconds - (3600 * $H) - (60 * $M));
 
  659        return $sign . ($H ? $H . 
':' : 
'') . ($H ? str_pad($M, 2, 
'0',
 
  660                                                            STR_PAD_LEFT) : intval($M)) . 
':' . str_pad($S,
 
  685        return self::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (self::BigEndian2Int(substr($rawdata,
 
  698        return self::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (self::BigEndian2Int(substr($rawdata,
 
  713        return self::Bin2Dec(substr($binarystring, 0, 2)) + (float) (self::Bin2Dec(substr($binarystring,
 
  734        while ($ArrayPath && ($ArrayPath{0} == $Separator)) {
 
  735            $ArrayPath = substr($ArrayPath, 1);
 
  737        if (($pos = strpos($ArrayPath, $Separator)) !== 
false) {
 
  743            $ReturnedArray[$ArrayPath] = $Value;
 
  746        return $ReturnedArray;
 
  755    public static function array_max($arraydata, $returnkey = 
false)
 
  759        foreach ($arraydata as $key => $value) {
 
  760            if (!is_array($value)) {
 
  761                if ($value > $maxvalue) {
 
  768        return ($returnkey ? $maxkey : $maxvalue);
 
  777    public static function array_min($arraydata, $returnkey = 
false)
 
  781        foreach ($arraydata as $key => $value) {
 
  782            if (!is_array($value)) {
 
  783                if ($value > $minvalue) {
 
  790        return ($returnkey ? $minkey : $minvalue);
 
  800        if (function_exists(
'simplexml_load_string')) {
 
  801            if (function_exists(
'get_object_vars')) {
 
  802                $XMLobject = simplexml_load_string($XMLstring);
 
  818        if (!is_object($XMLobject) && !is_array($XMLobject)) {
 
  821        $XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject);
 
  822        foreach ($XMLarray as $key => $value) {
 
  843        static $tempdir = 
'';
 
  844        if (!self::intValueSupported($end)) {
 
  847        switch ($algorithm) {
 
  849                $hash_function = 
'md5_file';
 
  850                $unix_call = 
'md5sum';
 
  851                $windows_call = 
'md5sum.exe';
 
  856                $hash_function = 
'sha1_file';
 
  857                $unix_call = 
'sha1sum';
 
  858                $windows_call = 
'sha1sum.exe';
 
  863                throw new DefaultException(
'Invalid algorithm (' . $algorithm . 
') in self::hash_data()');
 
  866        $size = $end - $offset;
 
  872                if ($algorithm == 
'sha1') {
 
  876                $RequiredFiles = array(
'cygwin1.dll', 
'head.exe', 
'tail.exe', $windows_call);
 
  877                foreach ($RequiredFiles as $required_file) {
 
  890                $commandline = 
'head -c' . $end . 
' ' . escapeshellarg(
$file) . 
' | ';
 
  891                $commandline .= 
'tail -c' . 
$size . 
' | ';
 
  892                $commandline .= $unix_call;
 
  894            if (preg_match(
'#(1|ON)#i', ini_get(
'safe_mode'))) {
 
  899            return substr(`$commandline`, 0, $hash_length);
 
  902        if (empty($tempdir)) {
 
  905            $tempdir = $getid3_temp->tempdir;
 
  909        if (($data_filename = tempnam($tempdir, 
'gI3')) === 
false) {
 
  920            $result = $hash_function($data_filename);
 
  922            throw new DefaultException(
'self::CopyFileParts() failed in getid_lib::hash_data(): ' . $e->getMessage());
 
  924        unlink($data_filename);
 
  941        if (!self::intValueSupported($offset + $length)) {
 
  942            throw new DefaultException(
'cannot copy file portion, it extends beyond the ' . round(PHP_INT_MAX / 1073741824) . 
'GB limit');
 
  944        if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source,
 
  946            if (($fp_dest = fopen($filename_dest, 
'wb'))) {
 
  947                if (fseek($fp_src, $offset, SEEK_SET) == 0) {
 
  948                    $byteslefttowrite = $length;
 
  949                    while (($byteslefttowrite > 0) && ($buffer = fread($fp_src,
 
  950                                                                       min($byteslefttowrite,
 
  952                        $byteswritten = fwrite($fp_dest, $buffer,
 
  954                        $byteslefttowrite -= $byteswritten;
 
  959                    throw new DefaultException(
'failed to seek to offset ' . $offset . 
' in ' . $filename_source);
 
  963                throw new DefaultException(
'failed to create file for writing ' . $filename_dest);
 
  967            throw new DefaultException(
'failed to open file for reading ' . $filename_source);
 
  980        if ($charval < 128) {
 
  982            $newcharstring = chr($charval);
 
  983        } elseif ($charval < 2048) {
 
  985            $newcharstring = chr(($charval >> 6) | 0xC0);
 
  986            $newcharstring .= chr(($charval & 0x3F) | 0x80);
 
  987        } elseif ($charval < 65536) {
 
  989            $newcharstring = chr(($charval >> 12) | 0xE0);
 
  990            $newcharstring .= chr(($charval >> 6) | 0xC0);
 
  991            $newcharstring .= chr(($charval & 0x3F) | 0x80);
 
  994            $newcharstring = chr(($charval >> 18) | 0xF0);
 
  995            $newcharstring .= chr(($charval >> 12) | 0xC0);
 
  996            $newcharstring .= chr(($charval >> 6) | 0xC0);
 
  997            $newcharstring .= chr(($charval & 0x3F) | 0x80);
 
 1000        return $newcharstring;
 
 1012        if (function_exists(
'utf8_encode')) {
 
 1013            return utf8_encode($string);
 
 1016        $newcharstring = 
'';
 
 1018            $newcharstring .= 
"\xEF\xBB\xBF";
 
 1020        for ($i = 0; $i < strlen($string); $i++) {
 
 1021            $charval = ord($string{$i});
 
 1025        return $newcharstring;
 
 1037        $newcharstring = 
'';
 
 1039            $newcharstring .= 
"\xFE\xFF";
 
 1041        for ($i = 0; $i < strlen($string); $i++) {
 
 1042            $newcharstring .= 
"\x00" . $string{$i};
 
 1045        return $newcharstring;
 
 1057        $newcharstring = 
'';
 
 1059            $newcharstring .= 
"\xFF\xFE";
 
 1061        for ($i = 0; $i < strlen($string); $i++) {
 
 1062            $newcharstring .= $string{$i} . 
"\x00";
 
 1065        return $newcharstring;
 
 1087        if (function_exists(
'utf8_decode')) {
 
 1088            return utf8_decode($string);
 
 1091        $newcharstring = 
'';
 
 1093        $stringlength = strlen($string);
 
 1094        while ($offset < $stringlength) {
 
 1095            if ((ord($string{$offset}) | 0x07) == 0xF7) {
 
 1097                $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
 
 1098                    ((ord($string{($offset + 1)}) & 0x3F) << 12) &
 
 1099                    ((ord($string{($offset + 2)}) & 0x3F) << 6) &
 
 1100                    (ord($string{($offset + 3)}) & 0x3F);
 
 1102            } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
 
 1104                $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
 
 1105                    ((ord($string{($offset + 1)}) & 0x3F) << 6) &
 
 1106                    (ord($string{($offset + 2)}) & 0x3F);
 
 1108            } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
 
 1110                $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
 
 1111                    (ord($string{($offset + 1)}) & 0x3F);
 
 1113            } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
 
 1115                $charval = ord($string{$offset});
 
 1122            if ($charval !== 
false) {
 
 1123                $newcharstring .= (($charval < 256) ? chr($charval) : 
'?');
 
 1127        return $newcharstring;
 
 1140        $newcharstring = 
'';
 
 1142            $newcharstring .= 
"\xFE\xFF";
 
 1145        $stringlength = strlen($string);
 
 1146        while ($offset < $stringlength) {
 
 1147            if ((ord($string{$offset}) | 0x07) == 0xF7) {
 
 1149                $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
 
 1150                    ((ord($string{($offset + 1)}) & 0x3F) << 12) &
 
 1151                    ((ord($string{($offset + 2)}) & 0x3F) << 6) &
 
 1152                    (ord($string{($offset + 3)}) & 0x3F);
 
 1154            } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
 
 1156                $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
 
 1157                    ((ord($string{($offset + 1)}) & 0x3F) << 6) &
 
 1158                    (ord($string{($offset + 2)}) & 0x3F);
 
 1160            } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
 
 1162                $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
 
 1163                    (ord($string{($offset + 1)}) & 0x3F);
 
 1165            } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
 
 1167                $charval = ord($string{$offset});
 
 1174            if ($charval !== 
false) {
 
 1175                $newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval,
 
 1180        return $newcharstring;
 
 1192        $newcharstring = 
'';
 
 1194            $newcharstring .= 
"\xFF\xFE";
 
 1197        $stringlength = strlen($string);
 
 1198        while ($offset < $stringlength) {
 
 1199            if ((ord($string{$offset}) | 0x07) == 0xF7) {
 
 1201                $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
 
 1202                    ((ord($string{($offset + 1)}) & 0x3F) << 12) &
 
 1203                    ((ord($string{($offset + 2)}) & 0x3F) << 6) &
 
 1204                    (ord($string{($offset + 3)}) & 0x3F);
 
 1206            } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
 
 1208                $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
 
 1209                    ((ord($string{($offset + 1)}) & 0x3F) << 6) &
 
 1210                    (ord($string{($offset + 2)}) & 0x3F);
 
 1212            } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
 
 1214                $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
 
 1215                    (ord($string{($offset + 1)}) & 0x3F);
 
 1217            } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
 
 1219                $charval = ord($string{$offset});
 
 1226            if ($charval !== 
false) {
 
 1227                $newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval,
 
 1232        return $newcharstring;
 
 1254        if (substr($string, 0, 2) == 
"\xFE\xFF") {
 
 1256            $string = substr($string, 2);
 
 1258        $newcharstring = 
'';
 
 1259        for ($i = 0; $i < strlen($string); $i += 2) {
 
 1264        return $newcharstring;
 
 1275        if (substr($string, 0, 2) == 
"\xFF\xFE") {
 
 1277            $string = substr($string, 2);
 
 1279        $newcharstring = 
'';
 
 1280        for ($i = 0; $i < strlen($string); $i += 2) {
 
 1285        return $newcharstring;
 
 1296        if (substr($string, 0, 2) == 
"\xFE\xFF") {
 
 1298            $string = substr($string, 2);
 
 1300        $newcharstring = 
'';
 
 1301        for ($i = 0; $i < strlen($string); $i += 2) {
 
 1303            $newcharstring .= (($charval < 256) ? chr($charval) : 
'?');
 
 1306        return $newcharstring;
 
 1317        if (substr($string, 0, 2) == 
"\xFF\xFE") {
 
 1319            $string = substr($string, 2);
 
 1321        $newcharstring = 
'';
 
 1322        for ($i = 0; $i < strlen($string); $i += 2) {
 
 1324            $newcharstring .= (($charval < 256) ? chr($charval) : 
'?');
 
 1327        return $newcharstring;
 
 1338        $bom = substr($string, 0, 2);
 
 1339        if ($bom == 
"\xFE\xFF") {
 
 1341        } elseif ($bom == 
"\xFF\xFE") {
 
 1356        $bom = substr($string, 0, 2);
 
 1357        if ($bom == 
"\xFE\xFF") {
 
 1359        } elseif ($bom == 
"\xFF\xFE") {
 
 1378        if ($in_charset == $out_charset) {
 
 1383        if (function_exists(
'iconv')) {
 
 1384            if ($converted_string = @iconv($in_charset,
 
 1385                                           $out_charset . 
'//TRANSLIT', $string)) {
 
 1386                switch ($out_charset) {
 
 1388                        $converted_string = rtrim($converted_string, 
"\x00");
 
 1392                return $converted_string;
 
 1402        static $ConversionFunctionList = array();
 
 1403        if (empty($ConversionFunctionList)) {
 
 1404            $ConversionFunctionList[
'ISO-8859-1'][
'UTF-8'] = 
'iconv_fallback_iso88591_utf8';
 
 1405            $ConversionFunctionList[
'ISO-8859-1'][
'UTF-16'] = 
'iconv_fallback_iso88591_utf16';
 
 1406            $ConversionFunctionList[
'ISO-8859-1'][
'UTF-16BE'] = 
'iconv_fallback_iso88591_utf16be';
 
 1407            $ConversionFunctionList[
'ISO-8859-1'][
'UTF-16LE'] = 
'iconv_fallback_iso88591_utf16le';
 
 1408            $ConversionFunctionList[
'UTF-8'][
'ISO-8859-1'] = 
'iconv_fallback_utf8_iso88591';
 
 1409            $ConversionFunctionList[
'UTF-8'][
'UTF-16'] = 
'iconv_fallback_utf8_utf16';
 
 1410            $ConversionFunctionList[
'UTF-8'][
'UTF-16BE'] = 
'iconv_fallback_utf8_utf16be';
 
 1411            $ConversionFunctionList[
'UTF-8'][
'UTF-16LE'] = 
'iconv_fallback_utf8_utf16le';
 
 1412            $ConversionFunctionList[
'UTF-16'][
'ISO-8859-1'] = 
'iconv_fallback_utf16_iso88591';
 
 1413            $ConversionFunctionList[
'UTF-16'][
'UTF-8'] = 
'iconv_fallback_utf16_utf8';
 
 1414            $ConversionFunctionList[
'UTF-16LE'][
'ISO-8859-1'] = 
'iconv_fallback_utf16le_iso88591';
 
 1415            $ConversionFunctionList[
'UTF-16LE'][
'UTF-8'] = 
'iconv_fallback_utf16le_utf8';
 
 1416            $ConversionFunctionList[
'UTF-16BE'][
'ISO-8859-1'] = 
'iconv_fallback_utf16be_iso88591';
 
 1417            $ConversionFunctionList[
'UTF-16BE'][
'UTF-8'] = 
'iconv_fallback_utf16be_utf8';
 
 1419        if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
 
 1420            $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
 
 1422            return self::$ConversionFunction($string);
 
 1424        throw new DefaultException(
'PHP does not have iconv() support - cannot convert from ' . $in_charset . 
' to ' . $out_charset);
 
 1434                                                    $charset = 
'ISO-8859-1')
 
 1436        $string = (string) $string; 
 
 1465            case 'Windows-1251':
 
 1466            case 'Windows-1252':
 
 1467                $HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
 
 1471                $strlen = strlen($string);
 
 1472                for ($i = 0; $i < $strlen; $i++) {
 
 1473                    $char_ord_val = ord($string{$i});
 
 1475                    if ($char_ord_val < 0x80) {
 
 1476                        $charval = $char_ord_val;
 
 1477                    } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i + 3 < $strlen) {
 
 1478                        $charval = (($char_ord_val & 0x07) << 18);
 
 1479                        $charval += ((ord($string{++$i}) & 0x3F) << 12);
 
 1480                        $charval += ((ord($string{++$i}) & 0x3F) << 6);
 
 1481                        $charval += (ord($string{++$i}) & 0x3F);
 
 1482                    } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i + 2 < $strlen) {
 
 1483                        $charval = (($char_ord_val & 0x0F) << 12);
 
 1484                        $charval += ((ord($string{++$i}) & 0x3F) << 6);
 
 1485                        $charval += (ord($string{++$i}) & 0x3F);
 
 1486                    } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i + 1 < $strlen) {
 
 1487                        $charval = (($char_ord_val & 0x1F) << 6);
 
 1488                        $charval += (ord($string{++$i}) & 0x3F);
 
 1490                    if (($charval >= 32) && ($charval <= 127)) {
 
 1491                        $HTMLstring .= htmlentities(chr($charval));
 
 1493                        $HTMLstring .= 
'&#' . $charval . 
';';
 
 1499                for ($i = 0; $i < strlen($string); $i += 2) {
 
 1501                    if (($charval >= 32) && ($charval <= 127)) {
 
 1502                        $HTMLstring .= chr($charval);
 
 1504                        $HTMLstring .= 
'&#' . $charval . 
';';
 
 1510                for ($i = 0; $i < strlen($string); $i += 2) {
 
 1512                    if (($charval >= 32) && ($charval <= 127)) {
 
 1513                        $HTMLstring .= chr($charval);
 
 1515                        $HTMLstring .= 
'&#' . $charval . 
';';
 
 1521                $HTMLstring = 
'ERROR: Character set "' . $charset . 
'" not supported in MultiByteCharString2HTML()';
 
 1536        static $RGADname = array();
 
 1537        if (empty($RGADname)) {
 
 1538            $RGADname[0] = 
'not set';
 
 1539            $RGADname[1] = 
'Track Gain Adjustment';
 
 1540            $RGADname[2] = 
'Album Gain Adjustment';
 
 1543        return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : 
'');
 
 1554        static $RGADoriginator = array();
 
 1555        if (empty($RGADoriginator)) {
 
 1556            $RGADoriginator[0] = 
'unspecified';
 
 1557            $RGADoriginator[1] = 
'pre-set by artist/producer/mastering engineer';
 
 1558            $RGADoriginator[2] = 
'set by user';
 
 1559            $RGADoriginator[3] = 
'determined automatically';
 
 1562        return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : 
'');
 
 1573        $adjustment = $rawadjustment / 10;
 
 1574        if ($signbit == 1) {
 
 1578        return (
float) $adjustment;
 
 1591        if ($replaygain < 0) {
 
 1596        $storedreplaygain = intval(round($replaygain * 10));
 
 1597        $gainstring = str_pad(decbin($namecode), 3, 
'0', STR_PAD_LEFT);
 
 1598        $gainstring .= str_pad(decbin($originatorcode), 3, 
'0', STR_PAD_LEFT);
 
 1599        $gainstring .= $signbit;
 
 1600        $gainstring .= str_pad(decbin($storedreplaygain), 9, 
'0', STR_PAD_LEFT);
 
 1612        return 20 * log10($amplitude);
 
 1624        static $tempdir = 
'';
 
 1625        if (empty($tempdir)) {
 
 1628            $tempdir = $getid3_temp->tempdir;
 
 1629            unset($getid3_temp);
 
 1631        $GetDataImageSize = 
false;
 
 1632        if ($tempfilename = tempnam($tempdir, 
'gI3')) {
 
 1633            if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename,
 
 1635                fwrite($tmp, $imgData);
 
 1637                $GetDataImageSize = @GetImageSize($tempfilename, $imageinfo);
 
 1639            unlink($tempfilename);
 
 1642        return $GetDataImageSize;
 
 1653        static $ImageTypesLookup = array();
 
 1654        if (empty($ImageTypesLookup)) {
 
 1655            $ImageTypesLookup[1] = 
'gif';
 
 1656            $ImageTypesLookup[2] = 
'jpeg';
 
 1657            $ImageTypesLookup[3] = 
'png';
 
 1658            $ImageTypesLookup[4] = 
'swf';
 
 1659            $ImageTypesLookup[5] = 
'psd';
 
 1660            $ImageTypesLookup[6] = 
'bmp';
 
 1661            $ImageTypesLookup[7] = 
'tiff (little-endian)';
 
 1662            $ImageTypesLookup[8] = 
'tiff (big-endian)';
 
 1663            $ImageTypesLookup[9] = 
'jpc';
 
 1664            $ImageTypesLookup[10] = 
'jp2';
 
 1665            $ImageTypesLookup[11] = 
'jpx';
 
 1666            $ImageTypesLookup[12] = 
'jb2';
 
 1667            $ImageTypesLookup[13] = 
'swc';
 
 1668            $ImageTypesLookup[14] = 
'iff';
 
 1671        return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : 
'');
 
 1683        if (!empty($ThisFileInfo[
'tags'])) {
 
 1684            foreach ($ThisFileInfo[
'tags'] as $tagtype => $tagarray) {
 
 1685                foreach ($tagarray as $tagname => $tagdata) {
 
 1686                    foreach ($tagdata as $key => $value) {
 
 1687                        if (!empty($value)) {
 
 1688                            if (empty($ThisFileInfo[
'comments'][$tagname])) {
 
 1691                            } elseif ($tagtype == 
'id3v1') {
 
 1693                                $newvaluelength = strlen(trim($value));
 
 1694                                foreach ($ThisFileInfo[
'comments'][$tagname] as $existingkey => $existingvalue) {
 
 1695                                    $oldvaluelength = strlen(trim($existingvalue));
 
 1696                                    if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue,
 
 1698                                                                                        $newvaluelength) == trim($value))) {
 
 1703                            } elseif (!is_array($value)) {
 
 1705                                $newvaluelength = strlen(trim($value));
 
 1706                                foreach ($ThisFileInfo[
'comments'][$tagname] as $existingkey => $existingvalue) {
 
 1707                                    $oldvaluelength = strlen(trim($existingvalue));
 
 1708                                    if (($newvaluelength > $oldvaluelength) && (substr(trim($value),
 
 1710                                                                                            strlen($existingvalue)) == $existingvalue)) {
 
 1711                                        $ThisFileInfo[
'comments'][$tagname][$existingkey] = trim($value);
 
 1716                            if (is_array($value) || empty($ThisFileInfo[
'comments'][$tagname]) || !in_array(trim($value),
 
 1717                                                                                                                 $ThisFileInfo[
'comments'][$tagname])) {
 
 1718                                $value = (is_string($value) ? trim($value) : $value);
 
 1719                                $ThisFileInfo[
'comments'][$tagname][] = $value;
 
 1727            foreach ($ThisFileInfo[
'comments'] as $field => $values) {
 
 1728                if ($field == 
'picture') {
 
 1733                foreach ($values as $index => $value) {
 
 1734                    if (is_array($value)) {
 
 1735                        $ThisFileInfo[
'comments_html'][$field][$index] = $value;
 
 1737                        $ThisFileInfo[
'comments_html'][$field][$index] = str_replace(
'�',
 
 1739                                                                                     self::MultiByteCharString2HTML($value,
 
 1740                                                                                                                    $ThisFileInfo[
'encoding']));
 
 1764        if (isset($cache[
$file][$name])) {
 
 1765            return (isset($cache[
$file][$name][$key]) ? $cache[
$file][$name][$key] : 
'');
 
 1769        $keylength = strlen($key);
 
 1770        $line_count = $end - $begin - 7;
 
 1773        $fp = fopen(
$file, 
'r');
 
 1776        for ($i = 0; $i < ($begin + 3); $i++) {
 
 1781        while (0 < $line_count--) {
 
 1784            $line = ltrim(fgets($fp, 1024), 
"\t ");
 
 1794            $explodedLine = explode(
"\t", $line, 2);
 
 1795            $ThisKey = (isset($explodedLine[0]) ? $explodedLine[0] : 
'');
 
 1796            $ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : 
'');
 
 1797            $cache[
$file][$name][$ThisKey] = trim($ThisValue);
 
 1803        return (isset($cache[
$file][$name][$key]) ? $cache[
$file][$name][$key] : 
'');
 
 1813        return trim($string, 
"\x00");
 
 1823    public static function toCamelCase($origin, $cahrToReplace = 
'_', $capitaliseFirstChar = 
false)
 
 1825        if ($capitaliseFirstChar) {
 
 1826            $origin = ucfirst($origin);
 
 1828        $func = create_function(
'$c', 
'return strtoupper($c[1]);');
 
 1830        return preg_replace_callback(
'/' . $cahrToReplace . 
'([a-z])/', $func, $origin);
 
An exception for terminatinating execution or to throw for unit testing.
GetId3() by James Heinrich info@getid3.org //.
static environmentIsWindows()
static getHelperAppsDir()
GetId3() by James Heinrich info@getid3.org //.
static safe_inc(&$variable, $increment=1)
static CopyFileParts($filename_source, $filename_dest, $offset, $length)
static Bin2Dec($binstring, $signed=false)
static Float2BinaryDecimal($floatvalue)
static array_merge_clobber($array1, $array2)
static toCamelCase($origin, $cahrToReplace='_', $capitaliseFirstChar=false)
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
static iconv_fallback_utf16le_iso88591($string)
UTF-16LE => ISO-8859-1.
static FixedPoint16_16($rawdata)
static RGADoriginatorLookup($originatorcode)
@staticvar array $RGADoriginator
static Bin2String($binstring)
static iconv_fallback_utf16_iso88591($string)
UTF-16 (BOM) => ISO-8859-1.
static DecimalizeFraction($fraction)
static iconv_fallback_utf8_utf16le($string, $bom=false)
UTF-8 => UTF-16LE.
static iconv_fallback_utf16le_utf8($string)
UTF-16LE => UTF-8.
static iconv_fallback_iso88591_utf16le($string, $bom=false)
ISO-8859-1 => UTF-16LE.
static LittleEndian2Float($byteword)
static intValueSupported($num)
@staticvar null $hasINT64
static iconv_fallback_iso88591_utf16($string)
ISO-8859-1 => UTF-16LE (BOM)
static Float2String($floatvalue, $bits)
static trimNullByte($string)
static iconv_fallback_iso88591_utf16be($string, $bom=false)
ISO-8859-1 => UTF-16BE.
static trunc($floatnumber)
static SimpleXMLelement2array($XMLobject)
static iconv_fallback_iso88591_utf8($string, $bom=false)
ISO-8859-1 => UTF-8.
static RGADamplitude2dB($amplitude)
static iconv_fallback_utf16be_iso88591($string)
UTF-16BE => ISO-8859-1.
static array_min($arraydata, $returnkey=false)
static ImageTypesLookup($imagetypeid)
@staticvar array $ImageTypesLookup
static iconv_fallback_utf16be_utf8($string)
UTF-16BE => UTF-8.
static iconv_fallback($in_charset, $out_charset, $string)
@staticvar array $ConversionFunctionList
static LittleEndian2String($number, $minbytes=1, $synchsafe=false)
static EmbeddedLookup($key, $begin, $end, $file, $name)
@staticvar type $cache
static XML2array($XMLstring)
static fileextension($filename, $numextensions=1)
static DecimalBinary2Float($binarynumerator)
static iconv_fallback_utf8_utf16($string)
UTF-8 => UTF-16LE (BOM)
static array_max($arraydata, $returnkey=false)
static iconv_fallback_utf8_iso88591($string)
UTF-8 => ISO-8859-1.
static array_merge_noclobber($array1, $array2)
static hash_data($file, $offset, $end, $algorithm)
self::md5_data() - returns md5sum for a file from startuing position to absolute end position
static RGADgainString($namecode, $originatorcode, $replaygain)
static BigEndian2Float($byteword)
ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic.
static ksort_recursive(&$theArray)
static PlaytimeString($seconds)
static LittleEndian2Int($byteword, $signed=false)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
static MultiByteCharString2HTML($string, $charset='ISO-8859-1')
static CreateDeepArray($ArrayPath, $Separator, $Value)
static RGADadjustmentLookup($rawadjustment, $signbit)
static iconv_fallback_utf8_utf16be($string, $bom=false)
UTF-8 => UTF-16BE.
static iconv_fallback_int_utf8($charval)
static FixedPoint2_30($rawdata)
static BigEndian2Bin($byteword)
static CastAsInt($floatnum)
static GetDataImageSize($imgData, &$imageinfo)
@staticvar string $tempdir
static RGADnameLookup($namecode)
@staticvar array $RGADname
static NormalizeBinaryPoint($binarypointnumber, $maxbits=52)
static BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false)
static CopyTagsToComments(&$ThisFileInfo)
static FixedPoint8_8($rawdata)
static iconv_fallback_utf16_utf8($string)
UTF-16 (BOM) => UTF-8.
static DateMac2Unix($macdate)
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file