basic addition to php
I just need to add the following code to this page above where the image is drawn: I need to add <a href:javascript:history.go(-1) but I'm not sure where it goes - can any one help? here is the code for the page
<?php
require_once("config.php");
// path being dynamically requested
if(!empty($_REQUEST['src'])) {
if(file_exists(stripslashes(PATH.$_REQUEST['src'])))
$src = urldecode(stripslashes(PATH.$_REQUEST['src']));
else
$src = null;
// extra validation
$src = stristr($src, '..') ? null : $src;
}
// see if we're working with a thumbnail or not
$size = !empty($_REQUEST['size']) && $_REQUEST['size'] == 'full' ? $_REQUEST['size'] : null;
// draw watermarked & thumbnail images
function draw_image($src) {
global $size;
list($width, $height, $type, $attr) = getimagesize($src);
$img = imagecreatefromstring(file_get_contents($src));
if($size == 'full') {
$red = imagecolorallocate($img, 0xFF, 0x00, 0x00);
imagestring($img, 5, 3, 3, WATERMARK, $red);
} else {
$lowest = min(THMBWIDTH / $width, THMBHEIGHT / $height);
if($lowest < 1) {
$smallwidth = floor($lowest*$width);
$smallheight = floor($lowest*$height);
$tmp = imagecreatetruecolor($smallwidth, $smallheight);
imagecopyresized($tmp, $img, 0, 0, 0, 0, $smallwidth, $smallheight, $width, $height);
imagedestroy($img);
$img = $tmp;
}
}
switch($type) {
case 1:
header("Content-type: image/gif");
imagegif($img);
break;
case 2:
header('Content-Type: image/jpeg');
imagejpeg($img, '', 100);
break;
case 3:
header("Content-type: image/png");
imagepng($img);
break;
}
imagedestroy($img);
}
if(!empty($src)) {
draw_image($src);
} else {
header("Content-type: image/png");
$img = imagecreatetruecolor(THMBWIDTH, THMBHEIGHT);
$black = imagecolorallocate($img, 0x00, 0x00, 0x00);
$white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
imagestring($img, 5, 3, 3, "NO IMAGE", $white);
imagepng($img);
imagedestroy($img);
}
?>
thanks
Adam
|