0

I'm trying to deploy my PHP website in Godaddy Windows shared hosting with IIS7. My site using phpThumb library to generate thumb images.

But the thumb images are not displayed, I got:

Usage: /########/filename.jpg read Usage comments for detail

When I check phpThumb.demo.check.php, the red error occur at cache write test as below

D: / Hosting / ########### / cache / 6 / 67 / 67c / 67c4 / phpThumb_cache_########__raw67c44e91c46b79493d95da579a7fef28_par52b4fbd9e2256843fcdbe9d1f35f2875.jpeg
directory does NOT exist (before EnsureDirectoryExists())
directory does NOT exist (after EnsureDirectoryExists())
write test FAILED

The directory D: / Hosting / ########### / cache already exists and already changed as writable from godaddy file manager.

But I note both "cache directory" and "temp directory" check result is "exists/readable/writable".

Why does phpThumb give "write test FAILED" although cache directory is exists/readable/writable ? And when I check cache folder, CacheStart.txt file is created.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
zawmn83
  • 809
  • 1
  • 9
  • 18

1 Answers1

0

For Godaddy windows share hosting, I did below changes and working for me. There may be other better solution but I just try quick change to work for me.

at phpthumb.functions.php //it will fix creating sub folders in cache dir, optional without it cache will not generate

static function EnsureDirectoryExists($dirname) {
    $dirname = str_replace('/', DIRECTORY_SEPARATOR, $dirname);  //added for godaddy
    $directory_elements = explode(DIRECTORY_SEPARATOR, $dirname);
    $startoffset = 5;  //added for godaddy

    /*  comment for godaddy
    $startoffset = (!$directory_elements[0] ? 2 : 1);  // unix with leading "/" then start with 2nd element; Windows with leading "c:\" then start with 1st element
    $open_basedirs = preg_split('#[;:]#', ini_get('open_basedir'));
    foreach ($open_basedirs as $key => $open_basedir) {
        if (preg_match('#^'.preg_quote($open_basedir).'#', $dirname) && (strlen($dirname) > strlen($open_basedir))) {
            $startoffset = count(explode(DIRECTORY_SEPARATOR, $open_basedir));
            break;
        }
    }
    */
    $i = $startoffset;
    .....

at phpthumb.class.php //it is required, without it sourcefilepath got wrong

function ResolveFilenameToAbsolute($filename) {
    ....
    if ($this->iswindows) {
        //$AbsoluteFilename = preg_replace('#^'.preg_quote(realpath($this->config_document_root)).'#i', realpath($this->config_document_root), $AbsoluteFilename);
        $AbsoluteFilename = str_replace(DIRECTORY_SEPARATOR, '/', $AbsoluteFilename);
    .....
zawmn83
  • 809
  • 1
  • 9
  • 18