100 or $op < 1) { $op=85; } $he=($wi/4)*3; @mysql_pconnect ("localhost", "coronel_user", "coronet"); @mysql_select_db ("coronel_photo"); /* $s=$_GET["s"]; $query = "select * from servers where id='$s'"; $result = mysql_query($query); $row = mysql_fetch_array($result); */ $query2 = "select * from ph_list where id='".$_GET["gal"]."'"; $result2 = mysql_query($query2); $row2 = mysql_fetch_array($result2); $query = "select * from servers where id=".$row2[server_id]; $result = mysql_query($query); $row = mysql_fetch_array($result); $s=$row2[server_id]; $dir=$row2["dirname"]; $owner=$row2["owner_id"]; $query2 = "select * from ph_".$row2["id"]." where id='".$_GET["photo"]."'"; $result2 = mysql_query($query2); $row2 = mysql_fetch_array($result2); $photo=$row2["fname"]; if ($s != "") { if (!file_exists($_SERVER['DOCUMENT_ROOT']."/photo/cache/".$s)) { mkdir($_SERVER['DOCUMENT_ROOT']."/photo/cache/".$s); } if (!file_exists($_SERVER['DOCUMENT_ROOT']."/photo/cache/".$s."/".$_GET["gal"])) { mkdir($_SERVER['DOCUMENT_ROOT']."/photo/cache/".$s."/".$_GET["gal"]); } } $photoCacheName=$_SERVER['DOCUMENT_ROOT']."/photo/cache/".$s."/".$_GET["gal"]."/".$_GET["photo"]."s".$wi; if ($_GET["op"] != "" and $_GET["op"] < 100 and $_GET["op"] > 1) { $photoCacheName .= "q".$op; } if ($_GET["e"]) { $photoCacheName .= "exif"; } $photoCacheName .= ".jpg"; if ($s != "0") { $url = "http://". $row["path"] . $dir ."/"; } else { $url = "../local/". $dir ."/"; } $handle = @file ($url . $photo .".jpg"); //Indus variant. To be removed. if (!$handle) { $handle = @file ($url . $photo .".JPG"); $bigext=1; } //-Indus if (!$handle) { print "ERROR! NO SUCH PHOTO!"; die; } if ($bigext) $source = $url . $photo .".JPG"; else $source = $url . $photo .".jpg"; $ex=$_GET["e"]; if (!$ex and $wi != 1) //Proceed as usually { if (!file_exists($photoCacheName)) { resizeimg($source, $wi, $he, $photoCacheName, "cache", $op, $owner); header('content-type: image/jpeg'); print file_get_contents($photoCacheName); } else { //resizeimg($source, $wi, $he, '', "view", $op, $owner); header('content-type: image/jpeg'); print file_get_contents($photoCacheName); } } else if ($wi == "1") //showing original { //inserting logotype if ($owner == 0) { $size_img = getimagesize($source); $dest_img = imagecreatefromjpeg($source); //$dest_img = imagecreatetruecolor($size_img[0], $size_img[1]); // imagefill($dest_img, 0, 0, 0xFFFFFF); $size_logo = getimagesize($_SERVER['DOCUMENT_ROOT']."/photo/logo.png"); $src_logo = imagecreatefrompng($_SERVER['DOCUMENT_ROOT']."/photo/logo.png"); if ($size_img[0] > $size_img[1]) { $logo_w = $size_img[0] * 0.2; $logo_h = $logo_w / ($size_logo[0]/$size_logo[1]); } else { $logo_h = $size_img[1] * 0.15; $logo_w = $logo_h / ($size_logo[1]/$size_logo[0]); } $logo_fin = @imagecreatetruecolor($logo_w, $logo_h); $colourBlack = @imagecolorallocate($logo_fin, 0, 0, 0); @imagecolortransparent($logo_fin, $colourBlack); $logo_dest0 = $size_img[0]-$logo_w; $logo_dest1 = $size_img[1]-$logo_h+3; @imagecopyresampled($logo_fin , $src_logo, 0, 0, 0, 0, $logo_w, $logo_h, $size_logo[0], $size_logo[1]); @imagecopymerge ($dest_img, $logo_fin, $logo_dest0, $logo_dest1, 0, 0, $logo_w, $logo_h, 100 ); } //logotype inserted header('content-type: image/jpeg'); if ($owner != 0) print file_get_contents($source); else { if (!file_exists($photoCacheName)) { imagejpeg($dest_img, $photoCacheName, 95); } imagejpeg($dest_img, NULL, 95); } } else // EXIF-diplaying module { if (!file_exists($photoCacheName)) { ob_start(); $input_jpeg = new PelJpeg($source); $exif = $input_jpeg->getExif(); resizeimg($source, $wi, $he, "", "view", $op, $owner); $ourimage=ob_get_contents(); ob_end_clean(); $resized = ImageCreateFromString($ourimage); $new_img = new PelJpeg($resized); if ($exif != null) $new_img->setExif($exif); echo $new_img->getBytes(); $cachewrite = fopen($photoCacheName, 'w'); fwrite($cachewrite, $new_img->getBytes()); fclose($cachewrite); } else { header('content-type: image/jpeg'); print file_get_contents($photoCacheName); } } ?>