zembereck / timthumb

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

Can't get timthumb to fetch images from any local location. #315

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I've been testing this on my live site and my test bed, same issue.

If i configure wordpress to use my local ip (192.168.0.2) as hostname or any 
domain name i will not get an image output.

But if i set wordpress to "localhost" timthumb works perfectly.

I have tested to 

if(! defined('ALLOW_ALL_EXTERNAL_SITES') )  define ('ALLOW_ALL_EXTERNAL_SITES', 
true);  

Without any difference (duh it's not an external issue, only internal.)

What is the expected output? What do you see instead?

Expected thumbnail output, i get error message:

The following error(s) occured:

    * Could not find the internal image you specified.

Query String : src=http://192.168.0.2/imagehost/thumb-102.jpg&w=120&h=120
TimThumb version : 2.8.5

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

2.8.5 of timthumb windowsxp and windows 2003 both tested, same result.

Please provide any additional information below.

Timthumb will only grab images from domains outside my own, if hosted on the 
same domain i get "Could not find the internal image you specified."

Any help would be appreciated.

Original issue reported on code.google.com by jonny_er...@bredband.net on 8 Jan 2012 at 6:34

GoogleCodeExporter commented 9 years ago
More updates from debugging: looks like the local path supplied is bad.

[Sun Jan 08 19:36:42 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.000115 : 0.000000]: Starting new request from 192.168.0.2 to 
/wp-content/themes/inove/timthumb.php?src=http://192.168.0.2/imagehost/thumb-90.
jpg&w=120&h=120, referer: http://192.168.0.2/45/testpost/

If changed to "localhost"

[Sun Jan 08 19:39:45 2012] [error] [client 127.0.0.1] TimThumb Debug line 1102 
[0.056767 : 0.000170]: Image processed succesfully. Serving from cache, 
referer: http://localhost/45/testpost/

Any ideas?

Original comment by jonny_er...@bredband.net on 8 Jan 2012 at 7:06

GoogleCodeExporter commented 9 years ago
Found the issue, however not sure how to solve it, more debuggging

[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.000123 : 0.000000]: Starting new request from 192.168.0.2 to 
/wp-content/themes/inove/timthumb.php?src=http://192.168.0.2/imagehost/thumb-102
.jpg&w=120&h=120
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.000428 : 0.000290]: DOCUMENT_ROOT is not set. This is probably windows. 
Starting search 1.
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.000477 : 0.000045]: Generated docRoot using SCRIPT_FILENAME and 
PHP_SELF as: D:/Root
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.000583 : 0.000103]: Doc root is: D:/Root
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.000819 : 0.000233]: Salt is: 1326050879-0
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.001350 : 0.000529]: cleanCache() called
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.001670 : 0.000317]: Cache was cleaned less than 86400 seconds ago so no 
cleaning needed.
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.001989 : 0.000315]: Is a request for an internal file: 
/imagehost/thumb-102.jpg
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.002291 : 0.000302]: Trying file as: 
D:/Root/wp-content/themes/inove/timthumb.php/imagehost/thumb-102.jpg
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.002549 : 0.000253]: Could not find the local image: 
[Sun Jan 08 20:34:52 2012] [error] [client 192.168.0.2] TimThumb Debug line 
1102 [0.002592 : 0.000039]: Adding error message: Could not find the internal 
image you specified.

As you can see timthumb tries to look for the image in d:/root/imagehost/ 
however the image is served via htaccess that rewrites the original url so the 
image is not locally stored on the same location as when served over web.

Snipped from htaccess in /root/imagehost/

RewriteRule ^thumb-(.*).jpg$ view-image.html?img=$1&w=180&h=180 [QSA]
RewriteRule ^showpic-(.*)/(.*)$ view-pic.html?img=$1 [QSA]
RewriteRule ^download-(.*)/(.*)$ view-pic-original.html?img=$1&dl=1 [QSA]
RewriteRule ^showoriginal-(.*)/(.*)$ view-pic-original.html?img=$1 [QSA]

So my guess is that i want to disable timthumb from looking on this as a local 
storage and attempt to access it over the web instead?

How can this be done? 

Thanks guys.

Original comment by jonny_er...@bredband.net on 8 Jan 2012 at 7:38

GoogleCodeExporter commented 9 years ago
solved removed line 229 : remove $this->src = 
preg_replace('/https?:\/\/(?:www\.)?' . $this->myHost . '/i', '',$this->src);

Original comment by jonny_er...@bredband.net on 8 Jan 2012 at 11:07

GoogleCodeExporter commented 9 years ago
I had the same problem. TimThumb 2.8.5 on CentOS.
I tried and did not work:
removed line 229: remove $ this-> src = preg_replace ('/ https?: \ / \ / (?: 
www \.)?'. $ this-> myhost. '/ i','', $ this-> src);

I solved reversing 
http://code.google.com/p/timthumb/source/diff?spec=svn192&r=192&format=side&path
=/trunk/timthumb.php

This link has is my solution: 
http://git.atp.usp.br/wordpress.git/commitdiff/5a78fe0083321da8d71f97be66dafda20
4f174e9?hp=fd0754f3b884c30a3cd538651314db43b52674e7

Original comment by helbert...@gmail.com on 11 Jan 2012 at 1:13

GoogleCodeExporter commented 9 years ago
Confirmed that helbert's solution above resolved the issue for me.

Original comment by muppsy...@gmail.com on 10 Apr 2012 at 8:20

GoogleCodeExporter commented 9 years ago
im set ALLOW_ALL_EXTERNAL_SITES=true and comment line 229:  remove $this->src = 
preg_replace('/https?:\/\/(?:www\.)?' . $this->myHost . '/i', '',$this->src); 
then it's work :D

Original comment by arzen...@gmail.com on 20 May 2012 at 5:25

GoogleCodeExporter commented 9 years ago
arzen's solution worked for me on both 2.8.10 and 2.8.3

Original comment by mserie...@gmail.com on 14 Jun 2012 at 1:51

GoogleCodeExporter commented 9 years ago
I am have a similar issue but removing line 229 did not fix it for me. I am 
getting "Could not find the internal image you specified." 

Here is the link and you can view the network tab to see that when ever it 
accesses the timthumb it gets a error 400. 
http://50.87.32.81/~ectjaxco/

Any help would be greatly appreciated.

Original comment by RJVentr...@gmail.com on 19 Jun 2012 at 4:13

GoogleCodeExporter commented 9 years ago
THANK YOU SO MUCH.  After maybe 8 hours of troubleshooting, commenting out \

        //$this->src = preg_replace('/https?:\/\/(?:www\.)?' . $this->myHost . '/i', '', $this->src);

workd for me.  This was line 212 for my timthumb code.

Thank you.

Running a wordpress multiuser site.

Original comment by jacobrac...@gmail.com on 27 Jun 2012 at 3:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
after spending a lot of time working on it, finally i brought my timthumb.php 
in workgin condition and of course you should also. So you can grab fixed 
version of timthumb.php from attachment of this comment or just look below!

Thanks you guys!

Original comment by bhosalem...@gmail.com on 11 Jul 2012 at 9:17

Attachments:

GoogleCodeExporter commented 9 years ago
Perfect

Original comment by polf...@gmail.com on 12 Aug 2012 at 10:50

GoogleCodeExporter commented 9 years ago
@Comment11
This doesn't work for Xampp using a local directory as the source. If I change 
the source to http://localhost/path/to/image/image.png, it will work.

Original comment by NinjaDan9 on 15 Aug 2012 at 4:48

GoogleCodeExporter commented 9 years ago
THANK YOU SO MUCH, ITS REALLY WORDKED, I SET ALLOW_ALL_EXTERNAL_SITES = TRUE 
AND COMMENT THE LINE , MENTIONED ABOVE AND IT WORKS FOR ME.

GREAT.

Original comment by amanprit...@gmail.com on 6 Sep 2012 at 10:41

GoogleCodeExporter commented 9 years ago
Danke nach 4 Tagen dann hier die richtige Lösung gefunden 

Original comment by adultblo...@gmail.com on 9 Dec 2012 at 10:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thank you very much #11 - that solved it for me as well!

Original comment by adina.li...@gmail.com on 9 Feb 2013 at 10:04

GoogleCodeExporter commented 9 years ago
I have try all ways to solve my site problem but it's stil not working, please 
check it and give me a solutions=> 
http://www.friendinfotech.com/demo/wpmobileshop/
and when I login in admin panel of this site I can see images properly it's not 
showing when I logout or visit from another browser.

Thanks...

Original comment by Tapas...@gmail.com on 12 Feb 2013 at 7:19

GoogleCodeExporter commented 9 years ago
I have try all ways, but no one does not work...
I work in localhost (ZendCore)...

TimThumb version : 2.8.11

Original comment by Abdukha...@gmail.com on 16 Apr 2013 at 1:52

GoogleCodeExporter commented 9 years ago
I have been having the following on the front page of my site. 
"A TimThumb error has occured
The following error(s) occured:
    No image specified
Query String :
TimThumb version : 2.8.11"

I've tried the patch, made changes in TimThumb.php to no avail. I have the 
"Connections" plugin which uses the timthumb as well. Anyone has any 
suggestions? Can I revert back to the old version? and how?
Thanks in Advance,
Foaad

Original comment by foaad.ha...@gmail.com on 16 Apr 2013 at 8:51

GoogleCodeExporter commented 9 years ago
Just an addition. The error is the only thing shown on the home page of the 
site. Sometimes it brings a garbled version of the front page.
http://jimclickbpn.com/
Thanks,
Foaad

Original comment by foaad.ha...@gmail.com on 16 Apr 2013 at 10:34

GoogleCodeExporter commented 9 years ago
Thanks... it works for me..

Original comment by sidiquep...@gmail.com on 7 Apr 2014 at 6:12

GoogleCodeExporter commented 9 years ago
I have error
A TimThumb error has occured

The following error(s) occured:
An error occured fetching image.

Query String : 
src=http://cam4dl.com/wp-content/uploads/2013/11/719daee9ed52947f0d6e760fe35.jpg
&h=240&w=300&zc=1
TimThumb version : 2.8.10
website: http://gametonghop.vn

Original comment by phamxuan...@gmail.com on 25 Apr 2014 at 6:47

GoogleCodeExporter commented 9 years ago
#4 helbert Solution worked for me.
Comment the below line
    $this->src = preg_replace('/https?:\/\/(?:www\.)?' . $this->myHost . '/i', '', $this->src);

Running: xampp on localhost.

Original comment by wer...@gmail.com on 12 Jul 2014 at 7:15

GoogleCodeExporter commented 9 years ago
For WP sites using domain mapping in subdomain mode, simply open timthumb.php 
and change line 215

FROM:
$this->myHost = preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST']); 
TO:
$this->myHost = preg_replace('/^www\./i', '', 
'yoursubdomain.yourwordpressmultisite.com');

Original comment by dezio1...@gmail.com on 6 Aug 2014 at 9:19

GoogleCodeExporter commented 9 years ago
I have been having the same problem since I migrating from one hosting to 
another hosting since last 2 weeks, been asking help from the hosting company 
which is not helpful at all, today just try follow #6Arzen method, it worked 
perfectly, tested I have to follow both methods together, it will not work for 
me just with 1 of the method only. BTW I am using timthumb.php 2.8

These are what i did exactly; 

I removed the whole following 2 lines:
        }
        if(preg_match('/https?:\/\/(?:www\.)?' . $this->myHost . '(?:$|\/)/i', $this->src)){
            $this->src = preg_replace('/https?:\/\/(?:www\.)?' . $this->myHost . '/i', '', $this->src);

And change the word false to TRUE on following line:

if(! defined('ALLOW_ALL_EXTERNAL_SITES') )  define ('ALLOW_ALL_EXTERNAL_SITES', 
TRUE);      // Less secure.

Thank You Very to all of you.

Original comment by chris.fi...@gmail.com on 18 Dec 2014 at 8:09

GoogleCodeExporter commented 9 years ago
I tried all above. Its not working for me(

Have error:
 GET http://192.168.20.128/wp-content/themes/Shuttershot/timthumb.php?src=http:/….20.128/wp-content/uploads/2014/12/Photo3029-1024x492.jpg&h=200&w=470&zc=1 400 (Bad Request)

Please help.

Original comment by yuriypel...@gmail.com on 27 Dec 2014 at 2:38