⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getid3.php

📁 CMS系统 提供学习研究修改最好了 比流行的一些CMS简单 但是更容易理解 是帮助你学习PHPCMS系统的好东东哦
💻 PHP
📖 第 1 页 / 共 3 页
字号:
							'pattern'   => '^SZ\x0A\x04',							'group'     => 'archive',							'module'    => 'szip',							'mime_type' => 'application/octet-stream',							'fail_id3'  => 'ERROR',							'fail_ape'  => 'ERROR',						  ),				// ZIP  - data        - ZIP compressed data				'zip'  => array(							'pattern'   => '^PK\x03\x04',							'group'     => 'archive',							'module'    => 'zip',							'mime_type' => 'application/zip',							'fail_id3'  => 'ERROR',							'fail_ape'  => 'ERROR',						  )			);		}		return $format_info;	}	function GetFileFormat(&$filedata, $filename='') {		// this function will determine the format of a file based on usually		// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,		// and in the case of ISO CD image, 6 bytes offset 32kb from the start		// of the file).		// Identify file format - loop through $format_info and detect with reg expr		foreach ($this->GetFileFormatArray() as $format_name => $info) {			// Using preg_match() instead of ereg() - much faster			// The /s switch on preg_match() forces preg_match() NOT to treat			// newline (0x0A) characters as special chars but do a binary match			if (preg_match('/'.$info['pattern'].'/s', $filedata)) {				$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';				return $info;			}		}		// Too many mp3 encoders on the market put gabage in front of mpeg files		// use assume format on these if format detection failed		if (preg_match('/\.mp[123a]$/i', $filename)) {			$GetFileFormatArray = $this->GetFileFormatArray();			$info = $GetFileFormatArray['mp3'];			$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';			return $info;		}		return false;	}	// converts array to $encoding charset from $this->encoding	function CharConvert(&$array, $encoding) {		// identical encoding - end here		if ($encoding == $this->encoding) {			return;		}		// loop thru array		foreach ($array as $key => $value) {			// go recursive			if (is_array($value)) {				$this->CharConvert($array[$key], $encoding);			}			// convert string			elseif (is_string($value)) {				$array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));			}		}	}	function HandleAllTags() {		// key name => array (tag name, character encoding)		static $tags;		if (empty($tags)) {			$tags = array(				'asf'       => array('asf'           , 'UTF-16LE'),				'midi'      => array('midi'          , 'ISO-8859-1'),				'nsv'       => array('nsv'           , 'ISO-8859-1'),				'ogg'       => array('vorbiscomment' , 'UTF-8'),				'png'       => array('png'           , 'UTF-8'),				'tiff'      => array('tiff'          , 'ISO-8859-1'),				'quicktime' => array('quicktime'     , 'ISO-8859-1'),				'real'      => array('real'          , 'ISO-8859-1'),				'vqf'       => array('vqf'           , 'ISO-8859-1'),				'zip'       => array('zip'           , 'ISO-8859-1'),				'riff'      => array('riff'          , 'ISO-8859-1'),				'lyrics3'   => array('lyrics3'       , 'ISO-8859-1'),				'id3v1'     => array('id3v1'         , $this->encoding_id3v1),				'id3v2'     => array('id3v2'         , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8				'ape'       => array('ape'           , 'UTF-8')			);		}		// loop thru comments array		foreach ($tags as $comment_name => $tagname_encoding_array) {			list($tag_name, $encoding) = $tagname_encoding_array;			// fill in default encoding type if not already present			if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {				$this->info[$comment_name]['encoding'] = $encoding;			}			// copy comments if key name set			if (!empty($this->info[$comment_name]['comments'])) {				foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {					foreach ($valuearray as $key => $value) {						if (strlen(trim($value)) > 0) {							$this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; // do not trim!! Unicode characters will get mangled if trailing nulls are removed!						}					}				}				if (!isset($this->info['tags'][$tag_name])) {					// comments are set but contain nothing but empty strings, so skip					continue;				}				if ($this->option_tags_html) {					foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {						foreach ($valuearray as $key => $value) {							if (is_string($value)) {								//$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);								$this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $encoding));							} else {								$this->info['tags_html'][$tag_name][$tag_key][$key] = $value;							}						}					}				}				$this->CharConvert($this->info['tags'][$tag_name], $encoding);           // only copy gets converted!			}		}		return true;	}	function getHashdata($algorithm) {		switch ($algorithm) {			case 'md5':			case 'sha1':				break;			default:				return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');				break;		}		if ((@$this->info['fileformat'] == 'ogg') && (@$this->info['audio']['dataformat'] == 'vorbis')) {			// We cannot get an identical md5_data value for Ogg files where the comments			// span more than 1 Ogg page (compared to the same audio data with smaller			// comments) using the normal getID3() method of MD5'ing the data between the			// end of the comments and the end of the file (minus any trailing tags),			// because the page sequence numbers of the pages that the audio data is on			// do not match. Under normal circumstances, where comments are smaller than			// the nominal 4-8kB page size, then this is not a problem, but if there are			// very large comments, the only way around it is to strip off the comment			// tags with vorbiscomment and MD5 that file.			// This procedure must be applied to ALL Ogg files, not just the ones with			// comments larger than 1 page, because the below method simply MD5's the			// whole file with the comments stripped, not just the portion after the			// comments block (which is the standard getID3() method.			// The above-mentioned problem of comments spanning multiple pages and changing			// page sequence numbers likely happens for OggSpeex and OggFLAC as well, but			// currently vorbiscomment only works on OggVorbis files.			if ((bool) ini_get('safe_mode')) {				$this->info['warning'][] = 'Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)';				$this->info[$algorithm.'_data']  = false;			} else {				// Prevent user from aborting script				$old_abort = ignore_user_abort(true);				// Create empty file				$empty = tempnam('*', 'getID3');				touch($empty);				// Use vorbiscomment to make temp file without comments				$temp = tempnam('*', 'getID3');				$file = $this->info['filenamepath'];				if (GETID3_OS_ISWINDOWS) {					if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {						$commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';						$VorbisCommentError = `$commandline`;					} else {						$VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;					}				} else {					$commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1';					$VorbisCommentError = `$commandline`;				}				if (!empty($VorbisCommentError)) {					$this->info['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;					$this->info[$algorithm.'_data']  = false;				} else {					// Get hash of newly created file					switch ($algorithm) {						case 'md5':							$this->info[$algorithm.'_data'] = getid3_lib::md5_file($temp);							break;						case 'sha1':							$this->info[$algorithm.'_data'] = getid3_lib::sha1_file($temp);							break;					}				}				// Clean up				unlink($empty);				unlink($temp);				// Reset abort setting				ignore_user_abort($old_abort);			}		} else {			if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {				// get hash from part of file				$this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);			} else {				// get hash from whole file				switch ($algorithm) {					case 'md5':						$this->info[$algorithm.'_data'] = getid3_lib::md5_file($this->info['filenamepath']);						break;					case 'sha1':						$this->info[$algorithm.'_data'] = getid3_lib::sha1_file($this->info['filenamepath']);						break;				}			}		}		return true;	}	function ChannelsBitratePlaytimeCalculations() {		// set channelmode on audio		if (@$this->info['audio']['channels'] == '1') {			$this->info['audio']['channelmode'] = 'mono';		} elseif (@$this->info['audio']['channels'] == '2') {			$this->info['audio']['channelmode'] = 'stereo';		}		// Calculate combined bitrate - audio + video		$CombinedBitrate  = 0;		$CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);		$CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);		if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {			$this->info['bitrate'] = $CombinedBitrate;		}		//if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {		//	// for example, VBR MPEG video files cannot determine video bitrate:		//	// should not set overall bitrate and playtime from audio bitrate only		//	unset($this->info['bitrate']);		//}		if (!isset($this->info['playtime_seconds']) && !empty($this->info['bitrate'])) {			$this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];		}		// Set playtime string		if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {			$this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);		}	}	function CalculateCompressionRatioVideo() {		if (empty($this->info['video'])) {			return false;		}		if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {			return false;		}		if (empty($this->info['video']['bits_per_sample'])) {			return false;		}		switch ($this->info['video']['dataformat']) {			case 'bmp':			case 'gif':			case 'jpeg':			case 'jpg':			case 'png':			case 'tiff':				$FrameRate = 1;				$PlaytimeSeconds = 1;				$BitrateCompressed = $this->info['filesize'] * 8;				break;			default:				if (!empty($this->info['video']['frame_rate'])) {					$FrameRate = $this->info['video']['frame_rate'];				} else {					return false;				}				if (!empty($this->info['playtime_seconds'])) {					$PlaytimeSeconds = $this->info['playtime_seconds'];				} else {					return false;				}				if (!empty($this->info['video']['bitrate'])) {					$BitrateCompressed = $this->info['video']['bitrate'];				} else {					return false;				}				break;		}		$BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;		$this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;		return true;	}	function CalculateCompressionRatioAudio() {		if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate'])) {			return false;		}		$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));		if (!empty($this->info['audio']['streams'])) {			foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {				if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {					$this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));				}			}		}		return true;	}	function CalculateReplayGain() {		if (isset($this->info['replay_gain'])) {			$this->info['replay_gain']['reference_volume'] = 89;			if (isset($this->info['replay_gain']['track']['adjustment'])) {				$this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];			}			if (isset($this->info['replay_gain']['album']['adjustment'])) {				$this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];			}			if (isset($this->info['replay_gain']['track']['peak'])) {				$this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);			}			if (isset($this->info['replay_gain']['album']['peak'])) {				$this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);			}		}		return true;	}	function ProcessAudioStreams() {		if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {			if (!isset($this->info['audio']['streams'])) {				foreach ($this->info['audio'] as $key => $value) {					if ($key != 'streams') {						$this->info['audio']['streams'][0][$key] = $value;					}				}			}		}		return true;	}}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -