Open GoogleCodeExporter opened 8 years ago
temporary fix is to set $_SERVER['DOCUMENT_ROOT'] to the correct doc root --
however the bug still applies re misleading error message being output
Original comment by stewart....@gmail.com
on 19 Aug 2011 at 3:18
looking in the Apache config and also PHP.ini it seems that the document root
is not set and defaults to "/htdocs" -- becuase I'm using mass virtual hosting
with a VirtualDocumentRoot.
See here for the same kind of problem: http://stackoverflow.com/q/390276
Original comment by stewart....@gmail.com
on 19 Aug 2011 at 3:28
I guess the solution might be to set the $_SERVER['DOCUMENT_ROOT'] to an empty
string or FALSE so that the alternate method of finding the docroot is used...
Original comment by stewart....@gmail.com
on 19 Aug 2011 at 3:29
Nope.
Turns out to fix I had to set it as such:
$_SERVER['DOCUMENT_ROOT'] = '/var/www/' . $_SERVER['SERVER_NAME'] . '/html';
because in my Apache config I have:
VirtualDocumentRoot /var/www/%0/html
Original comment by stewart....@gmail.com
on 19 Aug 2011 at 3:35
I have a similar problem: http://code.google.com/p/timthumb/issues/detail?id=240
Original comment by tosz...@gmail.com
on 20 Aug 2011 at 11:02
Yeah I still had the same problem even with that fix, so I added the following
to the top of my timthumb.php (I develop in Windows and my staging server is
Linux):
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$_SERVER['DOCUMENT_ROOT'] = 'C:\www\\' . $_SERVER['SERVER_NAME'] . '\html';
} else {
$_SERVER['DOCUMENT_ROOT'] = '/var/www/' . $_SERVER['SERVER_NAME'] . '/html';
}
Perhaps an optional variable where users could set their document root would be
handy (assuming it's not set correctly or my case where you're using a mass
virtual hosting Apache config).
Original comment by stewart....@gmail.com
on 31 Aug 2011 at 9:19
The script now allows a custom settings file to be loaded. Just create a file
called timthumb-config.php and add your settings to it. As such I would
override the document_root there.
Original comment by BinaryMoon
on 1 Sep 2011 at 12:18
Excellent! :) Thanks!
Original comment by stewart....@gmail.com
on 1 Sep 2011 at 2:45
Sometimes it's just a simple fix: Replace line 879 with the following:
$img = $_SERVER['DOCUMENT_ROOT'] . "/$src";
if (file_exists($img)) { return $img; } else { return false; }
That fixed it for me...
Original comment by der.kunstler
on 16 Nov 2011 at 5:33
nice fix there der. Worked for me to
Original comment by sjp...@gmail.com
on 6 Dec 2011 at 9:10
Unfortunately there's still a piece to fix, what do you think happens here if
DOCUMENT_ROOT is '/' ?
// account for Windows directory structure
if (strstr($_SERVER['SCRIPT_FILENAME'],':')) {
$sub_directories = explode('\\', str_replace($this->docRoot, '', $_SERVER['SCRIPT_FILENAME']));
} else {
$sub_directories = explode('/', str_replace($this->docRoot, '', $_SERVER['SCRIPT_FILENAME']));
}
Yeah, it will remove slashes from the the whole path! So insted of getting
images/full/cupcakes.jpg you'll have imagesfull/cupcakes.jpg which will
obviously fail.
Only the first occurence should be replaced.
Original comment by a.sav...@webgreen.it
on 18 Oct 2012 at 9:06
There is a quickfix for this issue.
Somewere inside the class constructor (around/close to line 225?), you will
find this piece of code:
if(preg_match('/https?:\/\/(?:www\.)?' . $this->myHost . '(?:$|\/)/i',
$this->src)){
$this->src = preg_replace('/https?:\/\/(?:www\.)?' . $this->myHost . '/i', '', $this->src);
}
Comment these three lines and the script will assume the image as an external
resource, just make sure you give it the full address and your php.ini allows
external resources and everything works just great.
if you intend to give it the partial url and the script can't seem to find the
image, goto line 810? inside calcDocRoot func, and after:
$docRoot = @$_SERVER['DOCUMENT_ROOT'];
insert the used document root (under linux will be something similar to):
$docRoot = '/home/{user_name}/public_html/{index_dir}/';
where
user_name = your user name in the system (maybe account name inside an online
server); and
index_dir = directory where your index file is located (might not be needed if
located in public_html)
Original comment by fabioe...@gmail.com
on 5 Dec 2013 at 11:50
Original issue reported on code.google.com by
stewart....@gmail.com
on 19 Aug 2011 at 3:17