jperezmedina / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

Images Not Appearing On Windows Server #277

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I was getting an error that the script couldn't find the internal image.

I tracked the issue down to line 837...

if(stripos($real, $this->docRoot) === 0){

the realpath function in window gives the path as c:\path\image.jpg but the 
docRoot is set as c:/path/image.jpg

I put the line...

$real = str_replace( "\\" , "/" , $real);

before the if statement and bingo!

Original issue reported on code.google.com by danc...@gmail.com on 26 Oct 2011 at 6:33

GoogleCodeExporter commented 8 years ago
Updating a WordPress theme to run version 2.8.2 (currently running 2.8 which 
works) and it wasn't working, no cached images saved to the cache folder on my 
develepment PC.

Appears I had the same issue (the fix worked) on a Localhost development server 
(using Wampserver) running under Windows Vista.

Not tested on a live site yet.

David

Original comment by regionbe...@seo-gold.com on 27 Oct 2011 at 1:31

GoogleCodeExporter commented 8 years ago
where do i have to put the line: $real = str_replace( "\\" , "/" , $real);  ?

i've tried this but it didn't worked... :/

    //Try src under docRoot
        if(file_exists ($this->docRoot . '/' . $src)) {
            $this->debug(3, "Found file as " . $this->docRoot . '/' . $src);
            $real = realpath($this->docRoot . '/' . $src);

            if(stripos($real, $realDocRoot) === 0){

                return $real;
                $real = str_replace( "\\" , "/" , $real);
            } else {
                $this->debug(1, "Security block: The file specified occurs outside the document root.");
                //allow search to continue
            }
        }

Original comment by michelem...@gmail.com on 28 Nov 2011 at 10:32

GoogleCodeExporter commented 8 years ago
//Try src under docRoot
if(file_exists ($this->docRoot . '/' . $src)) {
    $this->debug(3, "Found file as " . $this->docRoot . '/' . $src);
    $real = realpath($this->docRoot . '/' . $src);
    $real = str_replace( "\\" , "/" , $real);
    if(stripos($real, $this->docRoot) === 0){
        return $real;
    } else {
        $this->debug(1, "Security block: The file specified occurs outside the document root.");
        //allow search to continue
    }
}

Original comment by danc...@gmail.com on 28 Nov 2011 at 10:39

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have just done fix for timthumb v 8.9 :

Just put this below two line on line #863 :
-----------------------------------------------------------------
$arr_docroot_path = explode("/wp-content/",$_SERVER["SCRIPT_FILENAME"]);
$this->docRoot = $arr_docroot_path[0];
-------------------------------------------------------------------

if(file_exists ($this->docRoot . '/' . $src)) { #863

It will fix the issue.

Find the attached fixed version of file.

Original comment by kumar.sh...@gmail.com on 2 Mar 2012 at 7:29

Attachments:

GoogleCodeExporter commented 8 years ago
The script is not a WordPress plugin so adding fixes specific to WordPress will 
not help everyone with this issue I am afraid.

Original comment by BinaryMoon on 5 Mar 2012 at 7:29

GoogleCodeExporter commented 8 years ago

Original comment by BinaryMoon on 3 Dec 2012 at 10:23

GoogleCodeExporter commented 8 years ago
I know my original fix works for non WordPress sites. Not tested with WordPress.

Original comment by danc...@gmail.com on 4 Dec 2012 at 8:22

GoogleCodeExporter commented 8 years ago
I have fixed this problem. After years of no solution I decided to take it upon 
myself. The attached file will work on Windows systems the same as it will work 
on Unix systems.

Less than 20 lines of code added for the fix, so execution times are unaffected.

Enjoy :)
- Dan

Original comment by mardan...@gmail.com on 5 Aug 2015 at 9:28

Attachments: