本文整理汇总了PHP中getID3::GetFileFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP getID3::GetFileFormat方法的具体用法?PHP getID3::GetFileFormat怎么用?PHP getID3::GetFileFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类getID3
的用法示例。
在下文中一共展示了getID3::GetFileFormat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetMIMEtype
function GetMIMEtype($filename)
{
// include getID3() library (can be in a different directory if full path is specified)
require_once '../getid3/getid3.php';
// Initialize getID3 engine
$getID3 = new getID3();
$DeterminedMIMEtype = '';
if ($fp = fopen($filename, 'rb')) {
$ThisFileInfo = array('avdataoffset' => 0, 'avdataend' => 0);
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.tag.id3v2.php', __FILE__, true);
$tag = new getid3_id3v2($fp, $ThisFileInfo);
fseek($fp, $ThisFileInfo['avdataoffset'], SEEK_SET);
$formattest = fread($fp, 16);
// 16 bytes is sufficient for any format except ISO CD-image
fclose($fp);
$DeterminedFormatInfo = $getID3->GetFileFormat($formattest);
$DeterminedMIMEtype = $DeterminedFormatInfo['mime_type'];
}
return $DeterminedMIMEtype;
}
示例2: GetMIMEtype
function GetMIMEtype($filename)
{
$filename = realpath($filename);
if (!file_exists($filename)) {
echo 'File does not exist: "' . htmlentities($filename) . '"<br>';
return '';
} elseif (!is_readable($filename)) {
echo 'File is not readable: "' . htmlentities($filename) . '"<br>';
return '';
}
// include getID3() library (can be in a different directory if full path is specified)
require_once '../getid3/getid3.php';
// Initialize getID3 engine
$getID3 = new getID3();
$DeterminedMIMEtype = '';
if ($fp = fopen($filename, 'rb')) {
$getID3->openfile($filename);
if (empty($getID3->info['error'])) {
// ID3v2 is the only tag format that might be prepended in front of files, and it's non-trivial to skip, easier just to parse it and know where to skip to
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.tag.id3v2.php', __FILE__, true);
$getid3_id3v2 = new getid3_id3v2($getID3);
$getid3_id3v2->Analyze();
fseek($fp, $getID3->info['avdataoffset'], SEEK_SET);
$formattest = fread($fp, 16);
// 16 bytes is sufficient for any format except ISO CD-image
fclose($fp);
$DeterminedFormatInfo = $getID3->GetFileFormat($formattest);
$DeterminedMIMEtype = $DeterminedFormatInfo['mime_type'];
} else {
echo 'Failed to getID3->openfile "' . htmlentities($filename) . '"<br>';
}
} else {
echo 'Failed to fopen "' . htmlentities($filename) . '"<br>';
}
return $DeterminedMIMEtype;
}
示例3: explode
//.........这里部分代码省略.........
while (true) {
if ($idx >= $xlen) {
break;
}
$si1 = ord(substr($buff, $fpointer + $idx++, 1));
$si2 = ord(substr($buff, $fpointer + $idx++, 1));
if ($si1 == 0x41 && $si2 == 0x70) {
$w_xsublen = substr($buff, $fpointer + $idx, 2);
$xsublen = getid3_lib::LittleEndian2Int($w_xsublen);
$idx += 2;
$arr_xsubfield[] = substr($buff, $fpointer + $idx, $xsublen);
$idx += $xsublen;
} else {
break;
}
}
$fpointer += $xlen;
}
// bit 3 - FLG.FNAME
//+=========================================+
//|...original file name, zero-terminated...|
//+=========================================+
// GZIP files may have only one file, with no filename, so assume original filename is current filename without .gz
$thisThisFileInfo['filename'] = preg_replace('{.gz$}i', '', $ThisFileInfo['filename']);
if ($thisThisFileInfo['flags']['filename']) {
while (true) {
if (ord($buff[$fpointer]) == 0) {
$fpointer++;
break;
}
$thisThisFileInfo['filename'] .= $buff[$fpointer];
$fpointer++;
}
}
// bit 4 - FLG.FCOMMENT
//+===================================+
//|...file comment, zero-terminated...|
//+===================================+
if ($thisThisFileInfo['flags']['comment']) {
while (true) {
if (ord($buff[$fpointer]) == 0) {
$fpointer++;
break;
}
$thisThisFileInfo['comment'] .= $buff[$fpointer];
$fpointer++;
}
}
// bit 1 - FLG.FHCRC
//+---+---+
//| CRC16 |
//+---+---+
if ($thisThisFileInfo['flags']['crc16']) {
$w_crc = substr($buff, $fpointer, 2);
$thisThisFileInfo['crc16'] = getid3_lib::LittleEndian2Int($w_crc);
$fpointer += 2;
}
// bit 0 - FLG.FTEXT
//if ($thisThisFileInfo['raw']['flags'] & 0x01) {
// Ignored...
//}
// bits 5, 6, 7 - reserved
$thisThisFileInfo['crc32'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 8, 4));
$thisThisFileInfo['filesize'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 4));
$ThisFileInfo['gzip']['files'] = getid3_lib::array_merge_clobber($ThisFileInfo['gzip']['files'], getid3_lib::CreateDeepArray($thisThisFileInfo['filename'], '/', $thisThisFileInfo['filesize']));
if ($this->option_gzip_parse_contents) {
// Try to inflate GZip
$csize = 0;
$inflated = '';
$chkcrc32 = '';
if (function_exists('gzinflate')) {
$cdata = substr($buff, $fpointer);
$cdata = substr($cdata, 0, strlen($cdata) - 8);
$csize = strlen($cdata);
$inflated = gzinflate($cdata);
// Calculate CRC32 for inflated content
$thisThisFileInfo['crc32_valid'] = (bool) (sprintf('%u', crc32($inflated)) == $thisThisFileInfo['crc32']);
// determine format
$formattest = substr($inflated, 0, 32774);
$newgetID3 = new getID3();
$determined_format = $newgetID3->GetFileFormat($formattest);
unset($newgetID3);
// file format is determined
switch (@$determined_format['module']) {
case 'tar':
// view TAR-file info
if (file_exists(GETID3_INCLUDEPATH . $determined_format['include']) && @(include_once GETID3_INCLUDEPATH . $determined_format['include'])) {
getid3_tar::read_tar($inflated, $ThisFileInfo['gzip']['member_header'][$idx]);
}
break;
case '':
default:
// unknown or unhandled format
break;
}
}
}
}
return true;
}
示例4: getID3Mime
/**
*
* @access public
* @return
**/
public function getID3Mime()
{
$mime = NULL;
$filename = realpath($this->file_src_pathname);
if (!file_exists($filename)) {
$this->error = 'File does not exist: "' . htmlentities($filename);
return false;
} elseif (!is_readable($filename)) {
$this->error = 'File is not readable: "' . htmlentities($filename);
return false;
}
require_once CAT_PATH . '/modules/lib_getid3/getid3/getid3.php';
$getID3 = new getID3();
if ($fp = fopen($filename, 'rb')) {
$getID3->openfile($filename);
if (empty($getID3->info['error'])) {
// ID3v2 is the only tag format that might be prepended in front of files, and it's non-trivial to skip, easier just to parse it and know where to skip to
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.tag.id3v2.php', __FILE__, true);
$getid3_id3v2 = new getid3_id3v2($getID3);
$getid3_id3v2->Analyze();
fseek($fp, $getID3->info['avdataoffset'], SEEK_SET);
$formattest = fread($fp, 16);
// 16 bytes is sufficient for any format except ISO CD-image
fclose($fp);
$DeterminedFormatInfo = $getID3->GetFileFormat($formattest);
$mime = $DeterminedFormatInfo['mime_type'];
} else {
$this->error = 'Failed to getID3->openfile "' . htmlentities($filename);
}
} else {
$this->error = 'Failed to fopen "' . htmlentities($filename);
}
$this->log()->logDebug('MIME type detected as [' . $mime . '] by getID3 library');
return $mime;
}
示例5: mime_getid3
public function mime_getid3($path)
{
$determined_mime_type = false;
if (file_exists(MODPATH . 'getid3/getid3/getid3.php')) {
// include getID3() library (can be in a different directory if full path is specified)
require_once MODPATH . 'getid3/getid3/getid3.php';
// Initialize getID3 engine
$get_id3 = new getID3();
if ($fp = fopen($path, 'rb')) {
$this_file_info = array('avdataoffset' => 0, 'avdataend' => 0);
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.tag.id3v2.php', __FILE__, true);
$tag = new getid3_id3v2($fp, $this_file_info);
fseek($fp, $this_file_info['avdataoffset'], SEEK_SET);
$formattest = fread($fp, 16);
// 16 bytes is sufficient for any format except ISO CD-image
fclose($fp);
$determined_format_info = $get_id3->GetFileFormat($formattest);
$determined_mime_type = ($mime = $determined_format_info['mime_type']) ? $mime : FALSE;
}
}
return $determined_mime_type;
}
示例6: getMime
/**
* Get file mime type
*
* @param string $filename The file name
*
* @return string The MIME type
*/
public function getMime($filename)
{
require_once SRPATH_LIBRARY . '/media/getid3/getid3.php';
// Initialize getID3 engine
$getID3 = new getID3();
$determinedMimeType = '';
if ($fp = fopen($filename, 'rb')) {
$thisFileInfo = array('avdataoffset' => 0, 'avdataend' => 0);
getid3_lib::IncludeDependency(SRPATH_LIBRARY . '/media/getid3/module.tag.id3v2.php', __FILE__, true);
$tag = new getid3_id3v2($fp, $thisFileInfo);
fseek($fp, $thisFileInfo['avdataoffset'], SEEK_SET);
$formattest = fread($fp, 16);
// 16 bytes is sufficient for any format except ISO CD-image
fclose($fp);
$determinedFormatInfo = $getID3->GetFileFormat($formattest);
$determinedMimeType = $determinedFormatInfo['mime_type'];
}
return $determinedMimeType;
}