本文整理匯總了PHP中getid3_lib::sha1_file方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::sha1_file方法的具體用法?PHP getid3_lib::sha1_file怎麽用?PHP getid3_lib::sha1_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::sha1_file方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getHashdata
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;
}
示例2: die
}
if (isset($_REQUEST['filename'])) {
if (!file_exists($_REQUEST['filename']) || !is_file($_REQUEST['filename'])) {
die(getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-8', $_REQUEST['filename'] . ' does not exist'));
}
$starttime = getmicrotime();
//$getID3->setOption(array(
// 'option_md5_data' => $AutoGetHashes,
// 'option_sha1_data' => $AutoGetHashes,
//));
$ThisFileInfo = $getID3->analyze($_REQUEST['filename']);
$AutoGetHashes = (bool) (@$ThisFileInfo['filesize'] > 0 && $ThisFileInfo['filesize'] < 50 * 1048576);
// auto-get md5_data, md5_file, sha1_data, sha1_file if filesize < 50MB, and NOT zero (which may indicate a file>2GB)
if ($AutoGetHashes) {
$ThisFileInfo['md5_file'] = getid3_lib::md5_file($_REQUEST['filename']);
$ThisFileInfo['sha1_file'] = getid3_lib::sha1_file($_REQUEST['filename']);
}
getid3_lib::CopyTagsToComments($ThisFileInfo);
$listdirectory = dirname(getid3_lib::SafeStripSlashes($_REQUEST['filename']));
$listdirectory = realpath($listdirectory);
// get rid of /../../ references
if (GETID3_OS_ISWINDOWS) {
// this mostly just gives a consistant look to Windows and *nix filesystems
// (windows uses \ as directory seperator, *nix uses /)
$listdirectory = str_replace('\\', '/', $listdirectory . '/');
}
if (strstr($_REQUEST['filename'], 'http://') || strstr($_REQUEST['filename'], 'ftp://')) {
echo '<i>Cannot browse remote filesystems</i><br>';
} else {
echo 'Browse: <a href="' . $_SERVER['PHP_SELF'] . '?listdirectory=' . urlencode($listdirectory) . '">' . getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-8', $listdirectory) . '</a><br>';
}