jperezmedina / timthumb

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

Image not found. realpath() in PHP 5.3.5 for Windows returns blank. Bug fix is attached. #281

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Install timthumb.php on a PHP 5.3.5 installation for Windows
2. Run timthumb.php?src=myimage.png
3. "Could not find the internal image you specified"

What is the expected output? What do you see instead?
Expected input: display the image
What I see instead: 
A TimThumb error has occured
The following error(s) occured:

    Could not find the internal image you specified.

What version of the product are you using? On what operating system?
TimThumb version : 2.8.2

Please provide any additional information below.

The root cause is this:
Line 834: $real = realpath($base . $src);
Line 835: if(stripos($real, $this->docRoot) === 0){ 

In XAMMP 1.7.4 on Windows running PHP 5.3.5, the realpath method returns a path 
with backslash separated, instead of forward slashes. $this->docRoot is 
forward-slashed, so the stripos does not return 0 (it returs FALSE).

The fix is:

Line 835: if(stripos(preg_replace("/\\\/", "/", $real), $this->docRoot) === 0) {

This solved the issue in my machine.

Original issue reported on code.google.com by ardee.a...@gmail.com on 30 Oct 2011 at 4:10

GoogleCodeExporter commented 8 years ago
I am still having this issue with the changes
http://tv.burkina24.com/wp-content/themes/b24tv/scripts/timthumb.php?src=http://
tv.burkina24.com/files/2011/10/missburkinagroup2.jpg&h=45&w=60&zc=1

Original comment by filsduf...@gmail.com on 30 Oct 2011 at 4:19

GoogleCodeExporter commented 8 years ago
So am I 
http://dev.condiffphotography.com/wp-content/themes/photo-theme/image-processor/
?src=http://dev.condiffphotography.com/wp-content/uploads/2011/10/B033.jpg&h=543
&w=1799

Original comment by austin.c...@gmail.com on 31 Oct 2011 at 5:12

GoogleCodeExporter commented 8 years ago
i've that issue in version 2.8.3 too :/

http://www.ufficiocreativo.com/site/wp-content/themes/miworks/timthumb.php?src=h
ttp://www.ufficiocreativo.com/site/wp-content/uploads/2011/11/test.jpg&h=154&w=1
92&zc=1

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

GoogleCodeExporter commented 8 years ago
I fixed it replacing

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

with

Line 835: if(stripos($real, $this->docRoot) == false){ 

Hope this helps...

Original comment by bolado.c...@gmail.com on 6 Dec 2011 at 7:20

GoogleCodeExporter commented 8 years ago
sorry, the line is the 847, not 835

Original comment by bolado.c...@gmail.com on 6 Dec 2011 at 7:21

GoogleCodeExporter commented 8 years ago
I had this issue, bolado's fix worked for me.

Original comment by twar...@gmail.com on 6 Dec 2011 at 7:46

GoogleCodeExporter commented 8 years ago
I had this issue and BOLADO's fixed worked for me too:

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

SHOULD BE

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

Original comment by toddsant...@gmail.com on 7 Dec 2011 at 11:16

GoogleCodeExporter commented 8 years ago
Thanks for this. I've added it to the trunk.

Original comment by BinaryMoon on 8 Dec 2011 at 9:31

GoogleCodeExporter commented 8 years ago
Thank you, this fixed my issue, as well. 

Original comment by lukehe...@gmail.com on 21 Feb 2012 at 3:59

GoogleCodeExporter commented 8 years ago
I was using 2.8.5 version and above fix didn't work for me.
After a bit of hacking I fixed it by replacing line #817

$docRoot = @$_SERVER['DOCUMENT_ROOT'];

with this one:

$docRoot=dirname(dirname($_SERVER['SCRIPT_FILENAME']));

Hope it helps.

Original comment by st...@finethemes.com on 28 Feb 2012 at 8:28

GoogleCodeExporter commented 8 years ago
I was using 2.8.3 version and still having this issue.

http://pastebin.com/1pHfFMPu

Any help would be appreciated

Original comment by paulgcra...@gmail.com on 1 Mar 2012 at 2:52

GoogleCodeExporter commented 8 years ago
you need to update to the latest version before posting bug requests. TimThumb 
is currently on 2.8.9 and a number of bugs have been fixed.

Original comment by BinaryMoon on 1 Mar 2012 at 8:18

GoogleCodeExporter commented 8 years ago
Doesn't work for me. Im using 2.8.10 :(

Original comment by tienduon...@gmail.com on 3 Apr 2012 at 7:24

GoogleCodeExporter commented 8 years ago
I have the same problem, I'm usin 2.8.10 and tested on previous version,

http://www.popgeo.com/TEST/

Best Regards 
Rafal

Original comment by raf...@gmail.com on 4 Apr 2012 at 8:17

GoogleCodeExporter commented 8 years ago
THANK YOU VERY MUCH!! it worked :)

Original comment by novak...@gmail.com on 3 May 2012 at 10:15

GoogleCodeExporter commented 8 years ago
On my system the $_SERVER['DOCUMENT_ROOT'] was not giving the right path
After some hard debugging timthumb.php I fixed the issue using a 
timthumb-config.php config containing the line:

$_SERVER['DOCUMENT_ROOT'] = '/path/to/wordpress/home/directory/';

replace /path/to/wordpress/home/directory/ to your absolute wordpress root 
(commonly something like /var/www/... etc.)

Original comment by i...@ijsselkade.com on 17 Jun 2012 at 9:47

GoogleCodeExporter commented 8 years ago
Where should the timthumb-config.php be placed?

Original comment by kvanrepp...@gmail.com on 17 Oct 2012 at 3:02

GoogleCodeExporter commented 8 years ago
Thank you very much to the author of comment 16! It works for me 
(Version 2.8.11). 

The timthumb-config.php should be placed in the same place that timthumb.php.

Original comment by sdane...@gmail.com on 4 Dec 2012 at 5:59

GoogleCodeExporter commented 8 years ago
Same problem but still cant fix it. Version 2.8.11

Tried to make a timthumb-config.php but not sure if I used the correct 
/path/to/wordpress/home/directory/
Using Justhost 
In File manager I can see /home5/moonskoh/public_html/ as the folder I 
installed Wordpress into.  is this the path I need to use or should anything 
come before /home5 ?

( Apologies for the probably dumb newbie question, dont know anything about 
this really. )

Original comment by ian.kohc...@gmail.com on 17 Dec 2012 at 1:16

GoogleCodeExporter commented 8 years ago
Same problem here: 
http://wilhelmkoetzler.com.br/novosite/wp-content/themes/photoartist-parent/fram
ework/timthumb/timthumb.php

Original comment by one...@gmail.com on 16 Jan 2013 at 7:36

GoogleCodeExporter commented 8 years ago
I have the same issue
2.8.11

Here is what I see in firebug
TIMTHUMBURL?w=460&h=280&src=http://localhost/wp351_incipience/wp-content/uploads
/2012/07/img4.jpg

any solution ? file attached. 

Original comment by olen2...@gmail.com on 1 Feb 2013 at 3:36

Attachments:

GoogleCodeExporter commented 8 years ago
My problem is solved. It lied in the timthumb-config.php NOT in the 
timthumb.php itself.

Original comment by one...@gmail.com on 1 Feb 2013 at 4:05

GoogleCodeExporter commented 8 years ago
Could somebody attach the timthumb.config.php pelase?

Original comment by robertoc...@gmail.com on 5 Mar 2013 at 1:19

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I fix it with adding following command to the top of timthumb-config.php file

$_SERVER['DOCUMENT_ROOT'] = dirname( __FILE__ );

If you get this error at only localhost you can use like that also.

if($_SERVER["HTTP_HOST"] == 'localhost'){
$_SERVER['DOCUMENT_ROOT'] = dirname( __FILE__ );
}

Original comment by deniz2...@gmail.com on 4 Apr 2013 at 9:35