Changeset 41196 for trunk/src/wp-includes/ID3/getid3.lib.php
- Timestamp:
- 07/31/2017 07:49:31 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/getid3.lib.php
r32979 r41196 294 294 } 295 295 296 public static function LittleEndian2Bin($byteword) { 297 return self::BigEndian2Bin(strrev($byteword)); 298 } 296 299 297 300 public static function BigEndian2Bin($byteword) { … … 413 416 } 414 417 return $newarray; 418 } 419 420 public static function flipped_array_merge_noclobber($array1, $array2) { 421 if (!is_array($array1) || !is_array($array2)) { 422 return false; 423 } 424 # naturally, this only works non-recursively 425 $newarray = array_flip($array1); 426 foreach (array_flip($array2) as $key => $val) { 427 if (!isset($newarray[$key])) { 428 $newarray[$key] = count($newarray); 429 } 430 } 431 return array_flip($newarray); 415 432 } 416 433 … … 947 964 } 948 965 966 // mb_convert_encoding() availble 967 if (function_exists('mb_convert_encoding')) { 968 if ($converted_string = @mb_convert_encoding($string, $out_charset, $in_charset)) { 969 switch ($out_charset) { 970 case 'ISO-8859-1': 971 $converted_string = rtrim($converted_string, "\x00"); 972 break; 973 } 974 return $converted_string; 975 } 976 return $string; 977 } 949 978 // iconv() availble 950 if (function_exists('iconv')) {979 else if (function_exists('iconv')) { 951 980 if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) { 952 981 switch ($out_charset) { … … 964 993 965 994 966 // iconv() notavailable995 // neither mb_convert_encoding or iconv() is available 967 996 static $ConversionFunctionList = array(); 968 997 if (empty($ConversionFunctionList)) { … … 986 1015 return self::$ConversionFunction($string); 987 1016 } 988 throw new Exception('PHP does not ha veiconv() support - cannot convert from '.$in_charset.' to '.$out_charset);1017 throw new Exception('PHP does not has mb_convert_encoding() or iconv() support - cannot convert from '.$in_charset.' to '.$out_charset); 989 1018 } 990 1019 … … 1007 1036 $HTMLstring = ''; 1008 1037 1009 switch ( $charset) {1038 switch (strtolower($charset)) { 1010 1039 case '1251': 1011 1040 case '1252': … … 1014 1043 case '936': 1015 1044 case '950': 1016 case ' BIG5':1017 case ' BIG5-HKSCS':1045 case 'big5': 1046 case 'big5-hkscs': 1018 1047 case 'cp1251': 1019 1048 case 'cp1252': 1020 1049 case 'cp866': 1021 case ' EUC-JP':1022 case ' EUCJP':1023 case ' GB2312':1050 case 'euc-jp': 1051 case 'eucjp': 1052 case 'gb2312': 1024 1053 case 'ibm866': 1025 case ' ISO-8859-1':1026 case ' ISO-8859-15':1027 case ' ISO8859-1':1028 case ' ISO8859-15':1029 case ' KOI8-R':1054 case 'iso-8859-1': 1055 case 'iso-8859-15': 1056 case 'iso8859-1': 1057 case 'iso8859-15': 1058 case 'koi8-r': 1030 1059 case 'koi8-ru': 1031 1060 case 'koi8r': 1032 case ' Shift_JIS':1033 case ' SJIS':1061 case 'shift_jis': 1062 case 'sjis': 1034 1063 case 'win-1251': 1035 case ' Windows-1251':1036 case ' Windows-1252':1064 case 'windows-1251': 1065 case 'windows-1252': 1037 1066 $HTMLstring = htmlentities($string, ENT_COMPAT, $charset); 1038 1067 break; 1039 1068 1040 case ' UTF-8':1069 case 'utf-8': 1041 1070 $strlen = strlen($string); 1042 1071 for ($i = 0; $i < $strlen; $i++) { … … 1066 1095 break; 1067 1096 1068 case ' UTF-16LE':1097 case 'utf-16le': 1069 1098 for ($i = 0; $i < strlen($string); $i += 2) { 1070 1099 $charval = self::LittleEndian2Int(substr($string, $i, 2)); … … 1077 1106 break; 1078 1107 1079 case ' UTF-16BE':1108 case 'utf-16be': 1080 1109 for ($i = 0; $i < strlen($string); $i += 2) { 1081 1110 $charval = self::BigEndian2Int(substr($string, $i, 2)); … … 1154 1183 static $tempdir = ''; 1155 1184 if (empty($tempdir)) { 1185 if (function_exists('sys_get_temp_dir')) { 1186 $tempdir = sys_get_temp_dir(); // https://github.com/JamesHeinrich/getID3/issues/52 1187 } 1188 1156 1189 // yes this is ugly, feel free to suggest a better way 1157 require_once(dirname(__FILE__).'/getid3.php'); 1158 $getid3_temp = new getID3(); 1159 $tempdir = $getid3_temp->tempdir; 1160 unset($getid3_temp); 1190 if (include_once(dirname(__FILE__).'/getid3.php')) { 1191 if ($getid3_temp = new getID3()) { 1192 if ($getid3_temp_tempdir = $getid3_temp->tempdir) { 1193 $tempdir = $getid3_temp_tempdir; 1194 } 1195 unset($getid3_temp, $getid3_temp_tempdir); 1196 } 1197 } 1161 1198 } 1162 1199 $GetDataImageSize = false; … … 1166 1203 fclose($tmp); 1167 1204 $GetDataImageSize = @getimagesize($tempfilename, $imageinfo); 1205 if (($GetDataImageSize === false) || !isset($GetDataImageSize[0]) || !isset($GetDataImageSize[1])) { 1206 return false; 1207 } 1168 1208 $GetDataImageSize['height'] = $GetDataImageSize[0]; 1169 1209 $GetDataImageSize['width'] = $GetDataImageSize[1]; … … 1238 1278 if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) { 1239 1279 $value = (is_string($value) ? trim($value) : $value); 1240 if (!is_ numeric($key)) {1280 if (!is_int($key) && !ctype_digit($key)) { 1241 1281 $ThisFileInfo['comments'][$tagname][$key] = $value; 1242 1282 } else { 1243 $ThisFileInfo['comments'][$tagname][] = $value; 1283 if (isset($ThisFileInfo['comments'][$tagname])) { 1284 $ThisFileInfo['comments'][$tagname] = array($value); 1285 } else { 1286 $ThisFileInfo['comments'][$tagname][] = $value; 1287 } 1244 1288 } 1245 1289 } 1246 1290 } 1247 1291 } 1292 } 1293 } 1294 1295 // attempt to standardize spelling of returned keys 1296 $StandardizeFieldNames = array( 1297 'tracknumber' => 'track_number', 1298 'track' => 'track_number', 1299 ); 1300 foreach ($StandardizeFieldNames as $badkey => $goodkey) { 1301 if (array_key_exists($badkey, $ThisFileInfo['comments']) && !array_key_exists($goodkey, $ThisFileInfo['comments'])) { 1302 $ThisFileInfo['comments'][$goodkey] = $ThisFileInfo['comments'][$badkey]; 1303 unset($ThisFileInfo['comments'][$badkey]); 1248 1304 } 1249 1305 }
Note: See TracChangeset
for help on using the changeset viewer.