phpThumb shows me "usage" example even though I've supplied the correct input
phpThumb is a PHP library that converts large images to image thumbnails and caches the result. It takes such a syntax: http://domain.com/phpThumb.php?src=/images/image.jpg
However in my web application I'm following a strict MVC architecture, so I changed the syntax to this: http://domain.com/thumb/images%2Fimage.jpg/width/height
However now the output image is now complaining
Usage: /workspace/urs/index.php?src=/path/and/filename.jpg
Even though I've checked the $_GET dump and it reads:
array(1) {
["src"]=>
string(42) "/workspace/urs/images/portfolio/shoopm.jpg"
}
This is the code that runs up to the error (in my web application):
// If getting a thumbnail
if($qa[0] == "thumb")
{
if(!isset($qa[1]) || !isset($qa[2]) || !isset($qa[3]))
die("Bad thumb request. Needs 3 parameters!");
开发者_StackOverflow中文版 unset($_GET["q"]);
$_GET["src"] = $qa[1];
$_GET["w"] = $qa[2];
$_GET["h"] = $qa[3];
include("phpThumb/phpThumb.php");
exit();
}
Now, what I'm fearing is that phpThumb checks the actual URL, and not just the $_GET parameters... It's hard to confirm since the source contains thousands and thousands of lines of code and I haven't a clue where to start.
Thanks for any helpful replies
Judging from reading some of the source, it looks like it tries to do it's own PATH_INFO
parsing. You can prevent this by either changing the disable_pathinfo_parsing
config variable, or setting $_SERVER['PATH_INFO']
to null.
This may be important because the "Usage: ..." error happens only when the src
attribute of the $phpThumb
object is empty. It populates this attribute by looking for it in $_GET
, and it does some pretty serious $_GET['src']
manipulation when it tries to process PATH_INFO
.
In the alternative, you might want to try just using it's own native PATH_INFO
-based URLs instead of your own, just to avoid the futzing.
I had a similar issue when working on a windows system.
My src paths had a mix of forward /
and back \
slashes in the so I was converting them all o PHP's DIRECTORY_SEPARATOR
constant (a backslash in windows).
When I converted them all to a forward slash it just worked
精彩评论