本文整理匯總了PHP中phpthumb_functions::md5_file_safe方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpthumb_functions::md5_file_safe方法的具體用法?PHP phpthumb_functions::md5_file_safe怎麽用?PHP phpthumb_functions::md5_file_safe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpthumb_functions
的用法示例。
在下文中一共展示了phpthumb_functions::md5_file_safe方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: md5
}
}
}
}
if (!@$_SERVER['PATH_INFO'] && !@$_SERVER['QUERY_STRING']) {
$phpThumb->ErrorImage('phpThumb() v' . $phpThumb->phpthumb_version . '<br><a href="http://phpthumb.sourceforge.net">http://phpthumb.sourceforge.net</a><br><br>ERROR: no parameters specified');
}
if (@$_GET['src'] && isset($_GET['md5s']) && empty($_GET['md5s'])) {
if (preg_match('/^(f|ht)tps?\\:\\/\\//i', $_GET['src'])) {
if ($rawImageData = phpthumb_functions::SafeURLread($_GET['src'], $error, $phpThumb->config_http_fopen_timeout, $phpThumb->config_http_follow_redirect)) {
$md5s = md5($rawImageData);
}
} else {
$SourceFilename = $phpThumb->ResolveFilenameToAbsolute($_GET['src']);
if (is_readable($SourceFilename)) {
$md5s = phpthumb_functions::md5_file_safe($SourceFilename);
} else {
$phpThumb->ErrorImage('ERROR: "' . $SourceFilename . '" cannot be read');
}
}
if (@$_SERVER['HTTP_REFERER']) {
$phpThumb->ErrorImage('&md5s=' . $md5s);
} else {
die('&md5s=' . $md5s);
}
}
if (!empty($PHPTHUMB_CONFIG)) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$keyname = 'config_' . $key;
$phpThumb->setParameter($keyname, $value);
if (!preg_match('/password/i', $key)) {
示例2: SourceImageToGD
function SourceImageToGD()
{
if (is_resource($this->gdimg_source)) {
$this->source_width = ImageSX($this->gdimg_source);
$this->source_height = ImageSY($this->gdimg_source);
$this->DebugMessage('skipping SourceImageToGD() because $this->gdimg_source is already a resource (' . $this->source_width . 'x' . $this->source_height . ')', __FILE__, __LINE__);
return true;
}
$this->DebugMessage('starting SourceImageToGD()', __FILE__, __LINE__);
if ($this->config_prefer_imagemagick) {
if (empty($this->sourceFilename) && !empty($this->rawImageData)) {
$this->DebugMessage('Copying raw image data to temp file and trying again with ImageMagick', __FILE__, __LINE__);
if ($tempnam = $this->phpThumb_tempnam()) {
if (file_put_contents($tempnam, $this->rawImageData)) {
$this->sourceFilename = $tempnam;
if ($this->ImageMagickThumbnailToGD()) {
// excellent, we have a thumbnailed source image
$this->DebugMessage('ImageMagickThumbnailToGD() succeeded', __FILE__, __LINE__);
} else {
$this->DebugMessage('ImageMagickThumbnailToGD() failed', __FILE__, __LINE__);
}
} else {
$this->DebugMessage('failed to put $this->rawImageData into temp file "' . $tempnam . '"', __FILE__, __LINE__);
}
} else {
$this->DebugMessage('failed to generate temp file name', __FILE__, __LINE__);
}
}
}
if (!$this->gdimg_source && $this->rawImageData) {
if ($this->SourceImageIsTooLarge($this->source_width, $this->source_height)) {
$memory_get_usage = function_exists('memory_get_usage') ? memory_get_usage() : 0;
return $this->ErrorImage('Source image is too large (' . $this->source_width . 'x' . $this->source_height . ' = ' . number_format($this->source_width * $this->source_height / 1000000, 1) . 'Mpx, max=' . number_format($this->config_max_source_pixels / 1000000, 1) . 'Mpx) for GD creation (either install ImageMagick or increase PHP memory_limit to at least ' . ceil(($memory_get_usage + 5 * $this->source_width * $this->source_height) / 1048576) . 'M).');
}
if ($this->md5s && $this->md5s != md5($this->rawImageData)) {
return $this->ErrorImage('$this->md5s != md5($this->rawImageData)' . "\n" . '"' . $this->md5s . '" != ' . "\n" . '"' . md5($this->rawImageData) . '"');
}
//if ($this->issafemode) {
// return $this->ErrorImage('Cannot generate thumbnails from raw image data when PHP SAFE_MODE enabled');
//}
$this->gdimg_source = $this->ImageCreateFromStringReplacement($this->rawImageData);
if (!$this->gdimg_source) {
if (substr($this->rawImageData, 0, 2) === 'BM') {
$this->getimagesizeinfo[2] = 6;
// BMP
} elseif (substr($this->rawImageData, 0, 4) === 'II' . "*") {
$this->getimagesizeinfo[2] = 7;
// TIFF (littlendian)
} elseif (substr($this->rawImageData, 0, 4) === 'MM' . "*") {
$this->getimagesizeinfo[2] = 8;
// TIFF (bigendian)
}
$this->DebugMessage('SourceImageToGD.ImageCreateFromStringReplacement() failed with unknown image type "' . substr($this->rawImageData, 0, 4) . '" (' . phpthumb_functions::HexCharDisplay(substr($this->rawImageData, 0, 4)) . ')', __FILE__, __LINE__);
// return $this->ErrorImage('Unknown image type identified by "'.substr($this->rawImageData, 0, 4).'" ('.phpthumb_functions::HexCharDisplay(substr($this->rawImageData, 0, 4)).') in SourceImageToGD()['.__LINE__.']');
}
} elseif (!$this->gdimg_source && $this->sourceFilename) {
if ($this->md5s && $this->md5s != phpthumb_functions::md5_file_safe($this->sourceFilename)) {
return $this->ErrorImage('$this->md5s != md5(sourceFilename)' . "\n" . '"' . $this->md5s . '" != ' . "\n" . '"' . phpthumb_functions::md5_file_safe($this->sourceFilename) . '"');
}
switch (@$this->getimagesizeinfo[2]) {
case 1:
case 3:
// GIF or PNG input file may have transparency
$this->is_alpha = true;
break;
}
if (!$this->SourceImageIsTooLarge($this->source_width, $this->source_height)) {
$this->gdimg_source = $this->ImageCreateFromFilename($this->sourceFilename);
}
}
while (true) {
if ($this->gdimg_source) {
$this->DebugMessage('Not using EXIF thumbnail data because $this->gdimg_source is already set', __FILE__, __LINE__);
break;
}
if (!$this->exif_thumbnail_data) {
$this->DebugMessage('Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty', __FILE__, __LINE__);
break;
}
if (ini_get('safe_mode')) {
if (!$this->SourceImageIsTooLarge($this->source_width, $this->source_height)) {
$this->DebugMessage('Using EXIF thumbnail data because source image too large and safe_mode enabled', __FILE__, __LINE__);
$this->aoe = true;
} else {
break;
}
} else {
if (!$this->config_use_exif_thumbnail_for_speed) {
$this->DebugMessage('Not using EXIF thumbnail data because $this->config_use_exif_thumbnail_for_speed is FALSE', __FILE__, __LINE__);
break;
}
if ($this->thumbnailCropX != 0 || $this->thumbnailCropY != 0) {
$this->DebugMessage('Not using EXIF thumbnail data because source cropping is enabled (' . $this->thumbnailCropX . ',' . $this->thumbnailCropY . ')', __FILE__, __LINE__);
break;
}
if ($this->w > $this->exif_thumbnail_width || $this->h > $this->exif_thumbnail_height) {
$this->DebugMessage('Not using EXIF thumbnail data because EXIF thumbnail is too small (' . $this->exif_thumbnail_width . 'x' . $this->exif_thumbnail_height . ' vs ' . $this->w . 'x' . $this->h . ')', __FILE__, __LINE__);
break;
}
$source_ar = $this->source_width / $this->source_height;
//.........這裏部分代碼省略.........
示例3: SourceImageToGD
function SourceImageToGD()
{
if (is_resource($this->gdimg_source)) {
$this->DebugMessage('skipping SourceImageToGD() because $this->gdimg_source is already a resource', __FILE__, __LINE__);
return true;
}
$this->DebugMessage('starting SourceImageToGD()', __FILE__, __LINE__);
while (true) {
if (!$this->config_use_exif_thumbnail_for_speed) {
$this->DebugMessage('Not using EXIF thumbnail data because $this->config_use_exif_thumbnail_for_speed is FALSE', __FILE__, __LINE__);
break;
}
if (!$this->exif_thumbnail_data) {
$this->DebugMessage('Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty', __FILE__, __LINE__);
break;
}
if ($this->thumbnailCropX != 0 || $this->thumbnailCropY != 0) {
$this->DebugMessage('Not using EXIF thumbnail data because source cropping is enabled (' . $this->thumbnailCropX . ',' . $this->thumbnailCropY . ')', __FILE__, __LINE__);
break;
}
if ($this->w > $this->exif_thumbnail_width || $this->h > $this->exif_thumbnail_height) {
$this->DebugMessage('Not using EXIF thumbnail data because EXIF thumbnail is too small (' . $this->exif_thumbnail_width . 'x' . $this->exif_thumbnail_height . ' vs ' . $this->w . 'x' . $this->h . ')', __FILE__, __LINE__);
break;
}
$source_ar = $this->source_width / $this->source_height;
$exif_ar = $this->exif_thumbnail_width / $this->exif_thumbnail_height;
if (number_format($source_ar, 2) != number_format($exif_ar, 2)) {
$this->DebugMessage('not using EXIF thumbnail because $source_ar != $exif_ar (' . $source_ar . ' != ' . $exif_ar . ')', __FILE__, __LINE__);
}
// EXIF thumbnail exists, and is equal to or larger than destination thumbnail, and will be use as source image
$this->DebugMessage('Trying to use EXIF thumbnail as source image', __FILE__, __LINE__);
if ($gdimg_exif_temp = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false)) {
$this->DebugMessage('Successfully using EXIF thumbnail as source image', __FILE__, __LINE__);
$this->gdimg_source = $gdimg_exif_temp;
$this->source_width = $this->exif_thumbnail_width;
$this->source_height = $this->exif_thumbnail_height;
$this->thumbnailCropW = $this->source_width;
$this->thumbnailCropH = $this->source_height;
return true;
} else {
$this->DebugMessage('$this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false) failed', __FILE__, __LINE__);
}
break;
}
if (!$this->gdimg_source) {
// try to create GD image source directly via GD, if possible,
// rather than buffering to memory and creating with ImageCreateFromString
$ImageCreateWasAttempted = false;
$ImageCreateFromFunction = array(1 => 'ImageCreateFromGIF', 2 => 'ImageCreateFromJPEG', 3 => 'ImageCreateFromPNG', 15 => 'ImageCreateFromWBMP');
switch (@$this->getimagesizeinfo[2]) {
case 1:
// GIF
// GIF
case 2:
// JPEG
// JPEG
case 3:
// PNG
// PNG
case 15:
// WBMP
if ($this->md5s && $this->md5s != phpthumb_functions::md5_file_safe($this->sourceFilename)) {
return $this->ErrorImage('$this->md5s != md5($this->rawImageData)' . "\n" . '"' . $this->md5s . '" != ' . "\n" . '"' . phpthumb_functions::md5_file_safe($this->sourceFilename) . '"');
}
$ImageCreateFromFunctionName = $ImageCreateFromFunction[$this->getimagesizeinfo[2]];
if (function_exists($ImageCreateFromFunctionName)) {
$this->DebugMessage('Calling ' . $ImageCreateFromFunctionName . '(' . $this->sourceFilename . ')', __FILE__, __LINE__);
$ImageCreateWasAttempted = true;
$this->gdimg_source = @$ImageCreateFromFunctionName($this->sourceFilename);
switch ($this->getimagesizeinfo[2]) {
case 1:
case 3:
// GIF or PNG input file may have transparency
$this->is_alpha = true;
break;
}
} else {
$this->DebugMessage('NOT calling ' . $ImageCreateFromFunctionName . '(' . $this->sourceFilename . ') because !function_exists(' . $ImageCreateFromFunctionName . ')', __FILE__, __LINE__);
}
break;
case 4:
// SWF
// SWF
case 5:
// PSD
// PSD
case 6:
// BMP
// BMP
case 7:
// TIFF (LE)
// TIFF (LE)
case 8:
// TIFF (BE)
// TIFF (BE)
case 9:
// JPC
// JPC
case 10:
// JP2
//.........這裏部分代碼省略.........
示例4: ob_end_flush
if (!file_exists(dirname(__FILE__) . '/phpthumb.functions.php') || !(include_once dirname(__FILE__) . '/phpthumb.functions.php')) {
ob_end_flush();
die('(phpthumb.config.php) failed to include_once(phpthumb.functions.php) - realpath="' . realpath(dirname(__FILE__) . '/phpthumb.functions.php') . '"');
}
ob_end_clean();
// START USER CONFIGURATION SECTION:
// * DocumentRoot configuration
// phpthumb() depends on $_SERVER['DOCUMENT_ROOT'] to resolve path/filenames. This value is almost always correct,
// but has been known to be broken on rare occasion. This value allows you to override the default value.
// Do not modify from the default value of $_SERVER['DOCUMENT_ROOT'] unless you are having problems.
//$PHPTHUMB_CONFIG['document_root'] = '/home/httpd/httpdocs';
//$PHPTHUMB_CONFIG['document_root'] = 'c:\\webroot\\example.com\\www';
//echo @$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'].' = '.phpthumb_functions::md5_file_safe(@$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']).'<br>';
//echo realpath('.').'/'.basename($_SERVER['PHP_SELF']).' = '.phpthumb_functions::md5_file_safe(realpath('.').'/'.basename($_SERVER['PHP_SELF'])).'<br>';
//exit;
$PHPTHUMB_CONFIG['document_root'] = @$_SERVER['DOCUMENT_ROOT'] && file_exists(@$_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']) && @phpthumb_functions::md5_file_safe(@$_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']) == @phpthumb_functions::md5_file_safe(realpath('.') . '/' . basename($_SERVER['PHP_SELF'])) ? $_SERVER['DOCUMENT_ROOT'] : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace('\\', '/', realpath('.')));
// * Cache directory configuration (choose only one of these - leave the other lines commented-out):
// Note: this directory must be writable (usually chmod 777 is neccesary) for caching to work.
// If the directory is not writable no error will be generated but caching will be disabled.
$PHPTHUMB_CONFIG['cache_directory'] = dirname(__FILE__) . '/cache/';
// set the cache directory relative to the phpthumb() installation
// $PHPTHUMB_CONFIG['cache_directory'] = $PHPTHUMB_CONFIG['document_root'].'/cache/'; // set the cache directory to an absolute directory for all source images
// $PHPTHUMB_CONFIG['cache_directory'] = './cache/'; // set the cache directory relative to the source image - must start with '.' (will not work to cache URL- or database-sourced images, please use an absolute directory name)
// $PHPTHUMB_CONFIG['cache_directory'] = null; // disable thumbnail caching (not recommended)
$PHPTHUMB_CONFIG['cache_disable_warning'] = false;
// If [cache_directory] is non-existant or not writable, and [cache_disable_warning] is false, an error image will be generated warning to either set the cache directory or disable the warning (to avoid people not knowing about the cache)
// * Cache culling: phpthumb can automatically limit the contents of the cache directory
// based on last-access date and/or number of files and/or total filesize.
$PHPTHUMB_CONFIG['cache_maxage'] = null;
// never delete cached thumbnails based on last-access time
//$PHPTHUMB_CONFIG['cache_maxage'] = 86400 * 30; // delete cached thumbnails that haven't been accessed in more than [30 days] (value is maximum time since last access in seconds to avoid deletion)
示例5: SourceImageToGD
function SourceImageToGD()
{
if (is_resource($this->gdimg_source)) {
$this->source_width = ImageSX($this->gdimg_source);
$this->source_height = ImageSY($this->gdimg_source);
$this->DebugMessage('skipping SourceImageToGD() because $this->gdimg_source is already a resource (' . $this->source_width . 'x' . $this->source_height . ')', __FILE__, __LINE__);
return true;
}
$this->DebugMessage('starting SourceImageToGD()', __FILE__, __LINE__);
while (true) {
if (!$this->exif_thumbnail_data) {
$this->DebugMessage('Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty', __FILE__, __LINE__);
break;
}
if (ini_get('safe_mode')) {
if ($this->config_max_source_pixels > 0 && $this->source_width * $this->source_height > $this->config_max_source_pixels) {
$this->DebugMessage('Using EXIF thumbnail data because source image too large and safe_mode enabled', __FILE__, __LINE__);
$this->aoe = true;
} else {
break;
}
} else {
if (!$this->config_use_exif_thumbnail_for_speed) {
$this->DebugMessage('Not using EXIF thumbnail data because $this->config_use_exif_thumbnail_for_speed is FALSE', __FILE__, __LINE__);
break;
}
if ($this->thumbnailCropX != 0 || $this->thumbnailCropY != 0) {
$this->DebugMessage('Not using EXIF thumbnail data because source cropping is enabled (' . $this->thumbnailCropX . ',' . $this->thumbnailCropY . ')', __FILE__, __LINE__);
break;
}
if ($this->w > $this->exif_thumbnail_width || $this->h > $this->exif_thumbnail_height) {
$this->DebugMessage('Not using EXIF thumbnail data because EXIF thumbnail is too small (' . $this->exif_thumbnail_width . 'x' . $this->exif_thumbnail_height . ' vs ' . $this->w . 'x' . $this->h . ')', __FILE__, __LINE__);
break;
}
$source_ar = $this->source_width / $this->source_height;
$exif_ar = $this->exif_thumbnail_width / $this->exif_thumbnail_height;
if (number_format($source_ar, 2) != number_format($exif_ar, 2)) {
$this->DebugMessage('not using EXIF thumbnail because $source_ar != $exif_ar (' . $source_ar . ' != ' . $exif_ar . ')', __FILE__, __LINE__);
break;
}
}
// EXIF thumbnail exists, and is equal to or larger than destination thumbnail, and will be use as source image
$this->DebugMessage('Trying to use EXIF thumbnail as source image', __FILE__, __LINE__);
if ($gdimg_exif_temp = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false)) {
$this->DebugMessage('Successfully using EXIF thumbnail as source image', __FILE__, __LINE__);
$this->gdimg_source = $gdimg_exif_temp;
$this->source_width = $this->exif_thumbnail_width;
$this->source_height = $this->exif_thumbnail_height;
$this->thumbnailCropW = $this->source_width;
$this->thumbnailCropH = $this->source_height;
return true;
} else {
$this->DebugMessage('$this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false) failed', __FILE__, __LINE__);
}
break;
}
if (!$this->gdimg_source) {
if ($this->md5s && $this->md5s != phpthumb_functions::md5_file_safe($this->sourceFilename)) {
return $this->ErrorImage('$this->md5s != md5($rawimagedata)' . "\n" . '"' . $this->md5s . '" != ' . "\n" . '"' . phpthumb_functions::md5_file_safe($this->sourceFilename) . '"');
}
switch (@$this->getimagesizeinfo[2]) {
case 1:
case 3:
// GIF or PNG input file may have transparency
$this->is_alpha = true;
break;
}
//$this->gdimg_source = $this->ImageCreateFromFilename($this->sourceFilename, $this->rawImageData);
$this->gdimg_source = $this->ImageCreateFromFilename($this->sourceFilename);
//if ($this->md5s && ($this->md5s != md5($this->rawImageData))) {
// return $this->ErrorImage('$this->md5s != md5($this->rawImageData)'."\n".'"'.$this->md5s.'" != '."\n".'"'.md5($this->rawImageData).'"');
//}
if (!$this->gdimg_source) {
$this->DebugMessage('$this->gdimg_source is still empty', __FILE__, __LINE__);
if ($this->ImageMagickThumbnailToGD()) {
// excellent, we have a thumbnailed source image
$this->DebugMessage('ImageMagickThumbnailToGD() succeeded', __FILE__, __LINE__);
} else {
$this->DebugMessage('ImageMagickThumbnailToGD() failed', __FILE__, __LINE__);
$imageHeader = '';
$gd_info = gd_info();
$GDreadSupport = false;
//switch (substr($this->rawImageData, 0, 3)) {
// case 'GIF':
// $imageHeader = 'Content-Type: image/gif';
// $GDreadSupport = (bool) @$gd_info['GIF Read Support'];
// break;
// case "\xFF\xD8\xFF":
// $imageHeader = 'Content-Type: image/jpeg';
// $GDreadSupport = (bool) @$gd_info['JPG Support'];
// break;
// case "\x89".'PN':
// $imageHeader = 'Content-Type: image/png';
// $GDreadSupport = (bool) @$gd_info['PNG Support'];
// break;
//}
switch (@$this->getimagesizeinfo[2]) {
case 1:
$imageHeader = 'Content-Type: image/gif';
$GDreadSupport = (bool) @$gd_info['GIF Read Support'];
//.........這裏部分代碼省略.........