ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); include ("include/init.php"); include ("include/imageUtil.php"); $id = (int)$_GET['id']; $type = $_GET['type']; $w = g_get("w"); $h = g_get("h"); $percent = g_get("percent"); $constrain = g_get("constrain"); $crop = g_get("crop"); if(!$id) die(); if(empty($type)){ $type = "big"; } if ($type == 'resize') { // echo "resize"; $sql = "SELECT image_big FROM product_images WHERE id = $id"; $result = $db->Execute($sql); if($result === false) die("failed - $sql"); if($result->RecordCount()) { $photo_array = $result->getRows(); $photo = $photo_array[0]; header('Content-Type: image/jpeg'); header('Content-Disposition: attachment; filename="product_image_big_'.$id.'.jpg"'); $img = new Image($photo['image_big'], true); echo $img->getUpdatedImage($w, $h, $percent, $constrain, $crop); } } elseif ($type == 'small') { $sql = "SELECT image_tiny FROM product_images WHERE id = $id"; $result = $db->Execute($sql); if($result === false) die("failed - $sql"); if($result->RecordCount()) { $photo_array = $result->getRows(); $photo = $photo_array[0]; header('Content-Type: image/jpeg'); header('Content-Disposition: attachment; filename="product_image_tiny_'.$id.'.jpg"'); echo($photo['image_tiny']); } else { header('Content-Type: image/gif'); $fp = fopen('../img/no_photo.gif', 'rb'); fpassthru($fp); fclose($fp); } }elseif ($type == 'medium'){ $sql = "SELECT image_thumbnail FROM product_images WHERE id = $id"; $result = $db->Execute($sql); if($result === false) die("failed - $sql"); if($result->RecordCount()) { $photo_array = $result->getRows(); $photo = $photo_array[0]; header('Content-Type: image/jpeg'); header('Content-Disposition: attachment; filename="product_image_thmb_'.$id.'.jpg"'); echo($photo['image_thumbnail']); } else { header('Content-Type: image/gif'); $fp = fopen('../img/no_photo.gif', 'rb'); fpassthru($fp); fclose($fp); } }else { if(empty($_GET['fullHtml'])){ $sql = "SELECT image_big FROM product_images WHERE id = $id"; $result = $db->Execute($sql); if($result === false) die("failed - $sql"); if($result->RecordCount()) { $photo_array = $result->getRows(); $photo = $photo_array[0]; header('Content-Type: image/jpeg'); header('Content-Disposition: attachment; filename="product_image_big_'.$id.'.jpg"'); echo($photo['image_big']); } } else { echo '
'; } } ?>