config_document_root没有phpthumb.config.php文件的phpthumb错误

时间:2013-10-10 13:35:51

标签: php phpthumb

我收到重复目录的错误

[09-Oct-2013 07:51:31] PHP Warning:  getimagesize(/home3/username/public_html/mywebsite//mywebsite/assets/content/images/slideshow/slider1.jpg) [<a href='function.getimagesize'>function.getimagesize</a>]: failed to open stream: No such file or directory in /home3/username/public_html/mywebsite/core/model/phpthumb/phpthumb.class.php on line 1312
[09-Oct-2013 07:51:31] PHP Warning:  file_get_contents(/home3/username/public_html/mywebsite//mywebsite/assets/content/images/slideshow/slider1.jpg) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in /home3/username/public_html/mywebsite/core/model/phpthumb/phpthumb.class.php on line 3210

正如您所看到的,config_document_root导致一个目录过高而public_html/mywebsite//mywebsite/assets只放在public_html/mywebsite/assets 我想解决这个问题,以便它正常工作

第1312行:

$getimagesize = GetImageSize($this->sourceFilename);

第3210行:

$rawimagedata = file_get_contents($filename);
        if (empty($rawimagedata)) {
            $this->DebugMessage('cannot fopen('.$filename.')', __FILE__, __LINE__);
        }
        if ($rawimagedata) {
            $this->DebugMessage('attempting ImageCreateFromStringReplacement($rawimagedata ('.strlen($rawimagedata).' bytes), true)', __FILE__, __LINE__);
            $gd_image = $this->ImageCreateFromStringReplacement($rawimagedata, true);
        }
    }
    return $gd_image;
}

PHP代码设置这个东西,我没有phpthumb.config.php文件所以我怀疑这是在这个文件中设置phpthumb.class.php

<?php
   ob_start();
       if (!include_once(dirname(__FILE__).'/phpthumb.functions.php')) {
    ob_end_flush();
die('failed to include_once("'.realpath(dirname(__FILE__).'/phpthumb.functions.php').'")');
}
ob_end_clean();

class phpthumb {

// public:
// START PARAMETERS (for object mode and phpThumb.php)
// See phpthumb.readme.txt for descriptions of what each of these values are
public $src  = null;     // SouRCe filename
public $new  = null;     // NEW image (phpThumb.php only)
public $w    = null;     // Width
public $h    = null;     // Height
public $wp   = null;     // Width  (Portrait Images Only)
public $hp   = null;     // Height (Portrait Images Only)
public $wl   = null;     // Width  (Landscape Images Only)
public $hl   = null;     // Height (Landscape Images Only)
public $ws   = null;     // Width  (Square Images Only)
public $hs   = null;     // Height (Square Images Only)
public $f    = null;     // output image Format
public $q    = 75;       // jpeg output Quality
public $sx   = null;     // Source crop top-left X position
public $sy   = null;     // Source crop top-left Y position
public $sw   = null;     // Source crop Width
public $sh   = null;     // Source crop Height
public $zc   = null;     // Zoom Crop
public $bc   = null;     // Border Color
public $bg   = null;     // BackGround color
public $fltr = array();  // FiLTeRs
public $goto = null;     // GO TO url after processing
public $err  = null;     // default ERRor image filename
public $xto  = null;     // extract eXif Thumbnail Only
public $ra   = null;     // Rotate by Angle
public $ar   = null;     // Auto Rotate
public $aoe  = null;     // Allow Output Enlargement
public $far  = null;     // Fixed Aspect Ratio
public $iar  = null;     // Ignore Aspect Ratio
public $maxb = null;     // MAXimum Bytes
public $down = null;     // DOWNload thumbnail filename
public $md5s = null;     // MD5 hash of Source image
public $sfn  = 0;        // Source Frame Number
public $dpi  = 150;      // Dots Per Inch for vector source formats
public $sia  = null;     // Save Image As filename

public $file = null;     // >>>deprecated, DO NOT USE, will be removed in future versions<<<

public $phpThumbDebug = null;
// END PARAMETERS


// public:
// START CONFIGURATION OPTIONS (for object mode only)
// See phpThumb.config.php for descriptions of what each of these settings do

// * Directory Configuration
public $config_cache_directory                      = null;
public $config_cache_directory_depth                = 0;
public $config_cache_disable_warning                = true;
public $config_cache_source_enabled                 = false;
public $config_cache_source_directory               = null;
public $config_temp_directory                       = null;
public $config_document_root                        = null;

// * Default output configuration:
public $config_output_format                        = 'jpeg';
public $config_output_maxwidth                      = 0;
public $config_output_maxheight                     = 0;
public $config_output_interlace                     = true;

// * Error message configuration
public $config_error_image_width                    = 400;
public $config_error_image_height                   = 100;
public $config_error_message_image_default          = '';
public $config_error_bgcolor                        = 'CCCCFF';
public $config_error_textcolor                      = 'FF0000';
public $config_error_fontsize                       = 1;
public $config_error_die_on_error                   = false;
public $config_error_silent_die_on_error            = false;
public $config_error_die_on_source_failure          = true;

// * Anti-Hotlink Configuration:
public $config_nohotlink_enabled                    = true;
public $config_nohotlink_valid_domains              = array();
public $config_nohotlink_erase_image                = true;
public $config_nohotlink_text_message               = 'Off-server thumbnailing is not allowed';
// * Off-server Linking Configuration:
public $config_nooffsitelink_enabled                = false;
public $config_nooffsitelink_valid_domains          = array();
public $config_nooffsitelink_require_refer          = false;
public $config_nooffsitelink_erase_image            = true;
public $config_nooffsitelink_watermark_src          = '';
public $config_nooffsitelink_text_message           = 'Off-server linking is not allowed';

// * Border & Background default colors
public $config_border_hexcolor                      = '000000';
public $config_background_hexcolor                  = 'FFFFFF';

// * TrueType Fonts
public $config_ttf_directory                        = './fonts';

public $config_max_source_pixels                    = null;
public $config_use_exif_thumbnail_for_speed         = false;
public $allow_local_http_src                        = false;

public $config_imagemagick_path                     = null;
public $config_prefer_imagemagick                   = true;
public $config_imagemagick_use_thumbnail            = true;

public $config_cache_maxage                         = null;
public $config_cache_maxsize                        = null;
public $config_cache_maxfiles                       = null;
public $config_cache_source_filemtime_ignore_local  = false;
public $config_cache_source_filemtime_ignore_remote = true;
public $config_cache_default_only_suffix            = false;
public $config_cache_force_passthru                 = true;
public $config_cache_prefix                         = '';    // default value set in the constructor below

// * MySQL
public $config_mysql_query                          = null;
public $config_mysql_hostname                       = null;
public $config_mysql_username                       = null;
public $config_mysql_password                       = null;
public $config_mysql_database                       = null;

// * Security
public $config_high_security_enabled                = false;
public $config_high_security_password               = null;
public $config_disable_debug                        = false;
public $config_allow_src_above_docroot              = false;
public $config_allow_src_above_phpthumb             = true;
public $config_allow_parameter_file                 = false;
public $config_allow_parameter_goto                 = false;

// * HTTP fopen
public $config_http_fopen_timeout                   = 10;
public $config_http_follow_redirect                 = true;

// * Compatability
public $config_disable_pathinfo_parsing             = false;
public $config_disable_imagecopyresampled           = false;
public $config_disable_onlycreateable_passthru      = false;

public $config_http_user_agent                      = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7';

// END CONFIGURATION OPTIONS


// public: error messages (read-only; persistant)
public $debugmessages = array();
public $debugtiming   = array();
public $fatalerror    = null;


// private: (should not be modified directly)
public $thumbnailQuality = 75;
public $thumbnailFormat  = null;

public $sourceFilename   = null;
public $rawImageData     = null;
public $IMresizedData    = null;
public $outputImageData  = null;

public $useRawIMoutput   = false;

public $gdimg_output     = null;
public $gdimg_source     = null;

public $getimagesizeinfo = null;

public $source_width  = null;
public $source_height = null;

public $thumbnailCropX = null;
public $thumbnailCropY = null;
public $thumbnailCropW = null;
public $thumbnailCropH = null;

public $exif_thumbnail_width  = null;
public $exif_thumbnail_height = null;
public $exif_thumbnail_type   = null;
public $exif_thumbnail_data   = null;
public $exif_raw_data         = null;

public $thumbnail_width        = null;
public $thumbnail_height       = null;
public $thumbnail_image_width  = null;
public $thumbnail_image_height = null;

public $cache_filename         = null;

public $AlphaCapableFormats = array('png', 'ico', 'gif');
public $is_alpha = false;

public $iswindows = null;

public $phpthumb_version = '1.7.9-200712090829';

//////////////////////////////////////////////////////////////////////

// public: constructor
function __construct() {
    $this->DebugTimingMessage('phpThumb() constructor', __FILE__, __LINE__);
    $this->DebugMessage('phpThumb() v'.$this->phpthumb_version, __FILE__, __LINE__);
    $this->config_max_source_pixels = round(max(intval(ini_get('memory_limit')), intval(get_cfg_var('memory_limit'))) * 1048576 * 0.20); // 20% of memory_limit
    $this->iswindows = (bool) (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN');
    $this->config_document_root = (@$_SERVER['DOCUMENT_ROOT'] ? $_SERVER['DOCUMENT_ROOT'] : $this->config_document_root);
    $this->config_cache_prefix = 'phpThumb_cache_'.@$_SERVER['SERVER_NAME'];

    $php_sapi_name = strtolower(function_exists('php_sapi_name') ? php_sapi_name() : '');
    if ($php_sapi_name == 'cli') {
        $this->config_allow_src_above_docroot = true;
    }
}

// public:
function setSourceFilename($sourceFilename) {
    //$this->resetObject();
    //$this->rawImageData   = null;
    $this->sourceFilename = $sourceFilename;
    $this->src            = $sourceFilename;
    if (is_null($this->config_output_format)) {
        $sourceFileExtension = strtolower(substr(strrchr($sourceFilename, '.'), 1));
        if (preg_match('/^[a-z]{3,4}$/', $sourceFileExtension)) {
            $this->config_output_format = $sourceFileExtension;
            $this->DebugMessage('setSourceFilename('.$sourceFilename.') set $this->config_output_format to "'.$sourceFileExtension.'"', __FILE__, __LINE__);
        } else {
            $this->DebugMessage('setSourceFilename('.$sourceFilename.') did NOT set $this->config_output_format to "'.$sourceFileExtension.'" because it did not seem like an appropriate image format', __FILE__, __LINE__);
        }
    }
    $this->DebugMessage('setSourceFilename('.$sourceFilename.') set $this->sourceFilename to "'.$this->sourceFilename.'"', __FILE__, __LINE__);
    return true;
}

// public:
function setSourceData($rawImageData, $sourceFilename='') {
    //$this->resetObject();
    //$this->sourceFilename = null;
    $this->rawImageData   = $rawImageData;
    $this->DebugMessage('setSourceData() setting $this->rawImageData ('.strlen($this->rawImageData).' bytes; magic="'.substr($this->rawImageData, 0, 4).'" ('.phpthumb_functions::HexCharDisplay(substr($this->rawImageData, 0, 4)).'))', __FILE__, __LINE__);
    if ($this->config_cache_source_enabled) {
        $sourceFilename = ($sourceFilename ? $sourceFilename : md5($rawImageData));
        if (!is_dir($this->config_cache_source_directory)) {
            $this->ErrorImage('$this->config_cache_source_directory ('.$this->config_cache_source_directory.') is not a directory');
        } elseif (!@is_writable($this->config_cache_source_directory)) {
            $this->ErrorImage('$this->config_cache_source_directory ('.$this->config_cache_source_directory.') is not writable');
        }
        $this->DebugMessage('setSourceData() attempting to save source image to "'.$this->config_cache_source_directory.DIRECTORY_SEPARATOR.urlencode($sourceFilename).'"', __FILE__, __LINE__);
        if ($fp = @fopen($this->config_cache_source_directory.DIRECTORY_SEPARATOR.urlencode($sourceFilename), 'wb')) {
            fwrite($fp, $rawImageData);
            fclose($fp);
        } elseif (!$this->phpThumbDebug) {
            $this->ErrorImage('setSourceData() failed to write to source cache ('.$this->config_cache_source_directory.DIRECTORY_SEPARATOR.urlencode($sourceFilename).')');
        }
    }
    return true;
}

0 个答案:

没有答案