Dynadot โ€” .com Registration $8.99

WILL PAY for a little help please.

Spaceship Spaceship
Watch
Impact
109
Hey all,
Well i'm in need of a little help.
I'll give whoever can fix this $20 if it works. (PayPal).

Here's my situation:

I am using phpThumb on my image hosting site picuploader.com which works nice.

BUT I cannot use the cache setting... The cache setting saves the thumbnailed image so that it doesnt have to be processed again and again (saves about 90% CPU usage!!!). BUT my problem is that this will not work on forums etc and in html code because it uses a php header redirect to access the cached file. ie
if image1.jpg has been cached, going to http://www.domain.com/thumb/image1.jpg will redirect to http://www.domain.com/cachedthumbnail/image1.jpg

That is done using php...

So obviously when posting on a forum etc the image will not show, because it does not process the php header redirect...

I have thought about using the htaccess to do this but i dont think it will work...

PLEASE can someone fix that OR give me links to another thumbnail system other than phpthumb...

$20 as long as it works lol.

Thankyou all in advance, anyone who tries to help and fails will get some NP$ anyway, so theres nothing to lose :P.

Kindest Regards, Rhett.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
write a very simple separate php page, that you can call lets say showthumb.php
in this showimage, the thumb is taken from GET, i.e. linking to any thumb should be to showthumb.php?thumb=name.jpg instead of /thumb/name.jpg
this way, since it's a separate file, headers can be changed and the other image fetched if it is existant.
so, in summary:
1- put the image checking code in a different php file
2- tweak it to take the image name from $_GET['thumb']
2- linking to a thumb is now done through showthumb.php?image=name.jpg
good luck
 
0
•••
legend2 said:
write a very simple separate php page, that you can call lets say showthumb.php
in this showimage, the thumb is taken from GET, i.e. linking to any thumb should be to showthumb.php?thumb=name.jpg instead of /thumb/name.jpg
this way, since it's a separate file, headers can be changed and the other image fetched if it is existant.
so, in summary:
1- put the image checking code in a different php file
2- tweak it to take the image name from $_GET['thumb']
2- linking to a thumb is now done through showthumb.php?image=name.jpg
good luck
Hey legend2,
I know what you are saying, I definately would've done something like you were saying BUT... the problem is, i cannot use this code on a forum to show an image as it will not allow the tags:
PHP:
[img]http://www.domain.com/showthumb.php?thumb=sdfsfsdf.jpg[/img]
Forums won't allow that unfortunately :(

Currently the thumb is processed by http://www.domain.com/phpthumb.php?image=asdasd.jpg but i have edited htaccess so that http://www.domain.com/thumbs/asdasd.jpg instead, no tags so that means forums will allow this.

Thankyou muchly for your try :D NP$ donated!

Keep sugesting people :)

Kindest Regards, Rhett.
 
Last edited:
0
•••
Try this, I posted it in another thread a few days ago and it worked fine. Just note this isnt my code, I found it a while ago when I was searching for one as well

PHP:
function image_createthumb($src,$dest,$maxWidth,$maxHeight,  $quality) { 
        if (file_exists($src)  && isset($dest)) { 
            // path info 
            $destInfo  = pathInfo($dest); 
             
            // image src size 
            $srcSize   = getImageSize($src); 
                
            // image dest size $destSize[0] = width, $destSize[1] = height 
            $srcRatio  = $srcSize[0]/$srcSize[1]; // width/height ratio 
            $destRatio = $maxWidth/$maxHeight; 
            if ($destRatio > $srcRatio) { 
                $destSize[1] = $maxHeight; 
                $destSize[0] = $maxHeight*$srcRatio; 
            } 
            else { 
                $destSize[0] = $maxWidth; 
                $destSize[1] = $maxWidth/$srcRatio; 
            } 
             
            // path rectification 
            if ($destInfo['extension'] == "gif") { 
                $dest = substr_replace($dest, 'jpg', -3); 
            } 
             
            // true color image, with anti-aliasing 
            $destImage = imagecreatetruecolor($destSize[0],$destSize[1]); 
            imageantialias($destImage,true); 
             
            // src image 
            switch ($srcSize[2]) { 
                case 1: //GIF 
                $srcImage = imagecreatefromgif($src); 
                break; 
                 
                case 2: //JPEG 
                $srcImage = imagecreatefromjpeg($src); 
                break; 
                 
                case 3: //PNG 
                $srcImage = imagecreatefrompng($src); 
                break; 
                 
                default: 
                return false; 
                break; 
            } 
             
            // resampling 
            imagecopyresampled($destImage, $srcImage, 0, 0, 0, 0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]); 
             
            // generating image 
            switch ($srcSize[2]) { 
                case 1: 
                case 2: 
                imagejpeg($destImage,$dest,$quality); 
                break; 
                 
                case 3: 
                imagepng($destImage,$dest); 
                break; 
            } 
            return true; 
        } 
        else { 
            return false; 
        } 
    }
 
0
•••
Hey gamex,
Unfortunately I don't think that code is going to help in my case :). It doesn't do what is needed. afaik that is a completely new thumbnail creator, which will not fix my problem... I'm looking perhaps for a simple phpThuumb hack for it or a htaccess hack or something of that sort (Don't know much about htaccess so I don't know i that can be done).

Anyways NP$ doated for trying, thanks anyways!

Kindest Regards, Rhett.
 
0
•••
Ahh, sorry about that. Thats what I get for reading the post to quickly!!! If I think of anything, ill let you know!
 
0
•••
0
•••
0
•••
1.jpg
 
0
•••
0
•••
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
</head>

<body>
<img src="http://www.dgzy.be/1.jpg" width="94" height="84" border="0" alt="">
<img src="http://www.dgzy.be/2.jpg" width="94" height="84" border="0" alt="">
</body>
</html>
1.jpg was redirected to 2.jpg , do u mean this?
Code:
RedirectMatch /1.jpg$ http://www.dgzy.be/2.gif

And will
PHP:
[im g]http://www.dgzy.be/1.jpg[/img]
works?
 
Last edited:
0
•••
0
•••
Hello FULFREE!
I think what you are trying to do is create a htaccess that checks to see whether or not the thumbnail exists or not, and if it does, it redirects to it...

Good thinking, but let me post the code which phpThumb uses to check for a thumbnail and then redirect and let me know if it will work or if you can do something to make it work. I will definately donate NP$ later for you!

PHP:
function RedirectToCachedFile() {
	global $phpThumb, $PHPTHUMB_CONFIG;

	$nice_cachefile = str_replace($phpThumb->osslash, '/', $phpThumb->cache_filename);
	$nice_docroot   = str_replace($phpThumb->osslash, '/', rtrim($PHPTHUMB_CONFIG['document_root'], '/\\'));

	$parsed_url = @parse_url(@$_SERVER['HTTP_REFERER']);

	$nModified  = filemtime($phpThumb->cache_filename);

	if ($phpThumb->config_nooffsitelink_enabled && @$_SERVER['HTTP_REFERER'] && !in_array(@$parsed_url['host'], $phpThumb->config_nooffsitelink_valid_domains)) {

		$phpThumb->DebugMessage('Would have used cached (image/'.$phpThumb->thumbnailFormat.') file "'.$phpThumb->cache_filename.'" (Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT), but skipping because $_SERVER[HTTP_REFERER] ('.@$_SERVER['HTTP_REFERER'].') is not in $phpThumb->config_nooffsitelink_valid_domains ('.implode(';', $phpThumb->config_nooffsitelink_valid_domains).')', __FILE__, __LINE__);

	} elseif ($phpThumb->phpThumbDebug) {

		$phpThumb->DebugMessage('Would have used cached file, but skipping due to phpThumbDebug', __FILE__, __LINE__);
		$phpThumb->DebugMessage('* Would have sent headers (1): Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT', __FILE__, __LINE__);
		if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
			$phpThumb->DebugMessage('* Would have sent headers (2): Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]), __FILE__, __LINE__);
		}
		if (ereg('^'.preg_quote($nice_docroot).'(.*)$', $nice_cachefile, $matches)) {
			$phpThumb->DebugMessage('* Would have sent headers (3): Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1])), __FILE__, __LINE__);
		} else {
			$phpThumb->DebugMessage('* Would have sent data: readfile('.$phpThumb->cache_filename.')', __FILE__, __LINE__);
		}

	} else {

		if (headers_sent()) {
			$phpThumb->ErrorImage('Headers already sent ('.basename(__FILE__).' line '.__LINE__.')');
			exit;
		}
		SendSaveAsFileHeaderIfNeeded();

		header('Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT');
		if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] && ($nModified == strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) && @$_SERVER['SERVER_PROTOCOL']) {
			header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified');
			exit;
		}

		if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
			header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]));
		}
		if (ereg('^'.preg_quote($nice_docroot).'(.*)$', $nice_cachefile, $matches)) {
			header('Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1])));
		} else {
			@readfile($phpThumb->cache_filename);
		}
		exit;

	}
	return true;
}

// check to see if file already exists in cache, and output it with no processing if it does
$phpThumb->SetCacheFilename();
if (is_file($phpThumb->cache_filename)) {
	RedirectToCachedFile();
} else {
	$phpThumb->DebugMessage('Cached file "'.$phpThumb->cache_filename.'" does not exist, processing as normal', __FILE__, __LINE__);
}

Thankyou!

I donated some NP$ for your work so far, and if you can get this baby to work for me you'll certainly get $20 unless someone else gets it first :D.

Thanks!
Kind Regards, Rhett.
 
0
•••
Please hold off on this now, i think i may have a solution.
I will keep you posted :).
Thankyou!
 
0
•••
Billy, why don't you use symbolic links? you would execute shell_exec("ln -s target source"); where source is source image and target is target image. you would use this whenever a thumb that doesn't exist is created. so now you link the /thumb/image.jpg to /cachedthumb/image.jpg
so whenever a request to an existing file is received, the link is actually fetching the cahced thumb.
 
0
•••
This is all beyond me lol, seems a solution can't be found.
I think what your saying legend2 is that that will check for an existing thumbnail and use the data from the existing one if it exists OR SOMETHING... but the thumbnail created is a completely diferent filename to the one uploaded, so i would hav no idea what image name to check for. NP$ donated though.

This now closed people, no more NP$ will be donated.

But you can help me out at: http://namepros.com/showthread.php?t=141642

Thanks for your help anyways, Regards, Rhett.
 
0
•••
Thanks billy, just to clarify.
if you try to access http://www.domain.com/thumbs/image1.jpg , image1.jpg is actually an actual symbolic link ON the server (not the real image, think of that as a shortcut on windows systems), and this symbolic link is to the actual file in /cachethumb/image823.jpg
but whenever the request is to http://www.domain.com/thumbs/image1.jpg , no actual redirection is done on the site, it's the server itself that will be looking to what this link is.

good luck on the other thread:)
 
0
•••
YaaaY i got it working, thanks everyone for yout help, i had to use a different script, AND as well as that i figured out ther was someting wrong with the cpanel account, deleted it and recreated and now purs like a kiten lol

Thanks once again.

Kindest Regards, Rhett.
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back