0

I am using a little PHP script on my site called timthumb.php. The script crops and resizes images on the fly and creates a folder called cache in the same location as the script where it stores the new images.

Is it possible somehow in PHP to write a line of code in another file which can replace the line of code in timthumb.php where the 'cache' folder location is defined?

I've had a look in timthumb.php and on line 40 is the following:

if(! defined('FILE_CACHE_DIRECTORY')) define ('FILE_CACHE_DIRECTORY', './cache');

I've experimented with changing the last part ./cache to for example ../../../uploads and this works fine. My only reservation with doing this is it'll be lost if/when timthumb.php is next updated, so I wondering if there might be another solution.

Sorry if this is a dumb question. I am new to PHP.

air4x
  • 5,618
  • 1
  • 23
  • 36
user18577
  • 643
  • 3
  • 9
  • 21
  • 1
    offtopic, but just a heads up: timthunb has a [vulnerability](http://markmaunder.com/2011/08/19/wordpress-security-please-delete-old-themes-and-plugins/) – Prasanth Oct 30 '12 at 10:51

1 Answers1

3

In the script that loads timthumb.php add the following line before the call to include.

define ('FILE_CACHE_DIRECTORY', './cache')

and change ./cache to wherever you want your cache to be.

Explanation: The script checks if the constant FILE_CACHE_DIRECTORY was defined by you, if not it will use the default value (./cache).

clentfort
  • 2,454
  • 17
  • 19