WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

getID3::getHashdata() public WP 1.0

Это метод класса: getID3{}

Хуков нет.

Возвращает

Массив/true/false.

Использование

$getID3 = new getID3();
$getID3->getHashdata( $algorithm );
$algorithm(строка) (обязательный)

Код getID3::getHashdata() WP 5.5.1

wp-includes/ID3/getid3.php
<?php
public function getHashdata($algorithm) {
	switch ($algorithm) {
		case 'md5':
		case 'sha1':
			break;

		default:
			return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
	}

	if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($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.

		// phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved
		if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {

			$this->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_TEMP_DIR, 'getID3');
			touch($empty);

			// Use vorbiscomment to make temp file without comments
			$temp = tempnam(GETID3_TEMP_DIR, '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 '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
				$VorbisCommentError = `$commandline`;

			}

			if (!empty($VorbisCommentError)) {

				$this->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'] = md5_file($temp);
						break;

					case 'sha1':
						$this->info[$algorithm.'_data'] = 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'] = md5_file($this->info['filenamepath']);
					break;

				case 'sha1':
					$this->info[$algorithm.'_data'] = sha1_file($this->info['filenamepath']);
					break;
			}
		}

	}
	return true;
}