<?php session_start(); if ($_GET['pic']) { $img = new img('upload/' . $_GET['pic']); $img->resize(); $img->show(); } class img { var $image = ''; var $temp = ''; function img($sourceFile) { if (file_exists($sourceFile)) { $this->image = ImageCreateFromJPEG($sourceFile); } else { $this->errorHandler(); } return; } function resize($width = 400, $height = 400, $aspectradio = true) { $o_wd = imagesx($this->image); $o_ht = imagesy($this->image); if (isset($aspectradio) && $aspectradio) { $w = round($o_wd * $height / $o_ht); $h = round($o_ht * $width / $o_wd); if ($height - $h < $width - $w) { $width =& $w; } else {
// get image name $filename = DIR_IMG_MAIN . $i[2] . $i[6]; // keep aspect ratio $keep = !empty($i[5]) ? false : true; $image = new img($filename, $i[7]); $image->resize($i[3], $i[4], !empty($i[5]) ? false : true); $image->store(DIR_RESIZED . $i[0]); $image->show(); unset($image); } elseif (preg_match(WATERMARK, $request_uri, $i)) { // get image name $filename = DIR_CUR . 'images' . DIR_SEP . $i[2] . '.jpg'; $image = new img($filename); $image->watermark(DIR_CUR . 'images' . DIR_SEP . 'config' . DIR_SEP . 'watermark.png', 10, 10); $image->store(DIR_WM . $i[0]); $image->show(); unset($image); } elseif (preg_match('/\\/([^\\/]+).html$/i', $request_uri, $i)) { $parsed =& $i[1]; header("HTTP/1.0 200 OK"); require_once DIR_CUR . 'index.php'; } elseif (preg_match('/error.tester$/i', $request_uri)) { header("HTTP/1.0 200 OK"); echo 'ok'; exit; } else { header("HTTP/1.0 404 Not Found"); ?> <html><head><title>Document Not Found</title></head> <body><h1>Document Not found</h1> <hr>