$fn = ew_UploadPathEx(TRUE, @$_GET["path"]) . $obj->Value; if (file_exists($fn)) { $pathinfo = pathinfo($fn); $ext = strtolower($pathinfo['extension']); if (in_array($ext, explode(',', EW_IMAGE_ALLOWED_FILE_EXT))) { $size = getimagesize($fn); if ($size) { header("Content-type: {$size['mime']}"); } echo ew_ResizeFileToBinary($fn, $width, $height, $quality); } } } else { // If not IE, get the content type if (strpos(ew_ServerVar("HTTP_USER_AGENT"), "MSIE") === FALSE) { $tmpfname = tempnam(ew_TmpFolder(), 'tmp'); $handle = fopen($tmpfname, "w"); fwrite($handle, $obj->Value); fclose($handle); $size = getimagesize($tmpfname); if ($size) { header("Content-type: {$size['mime']}"); } @unlink($tmpfname); } if ($resize) { $obj->Resize($width, $height, $quality); } echo $obj->Value; exit; }
function ew_ResizeBinary(&$filedata, &$width, &$height, $quality = EW_THUMBNAIL_DEFAULT_QUALITY, $plugins = array()) { global $EW_THUMBNAIL_CLASS, $EW_RESIZE_OPTIONS; if ($width <= 0 && $height <= 0) { return FALSE; } $f = tempnam(ew_TmpFolder(), "tmp"); $handle = @fopen($f, 'wb'); if ($handle) { fwrite($handle, $filedata); fclose($handle); } $format = ""; if (file_exists($f) && filesize($f) > 0) { // temp file created $info = @getimagesize($f); @unlink($f); if (!$info || !in_array($info[2], array(1, 2, 3))) { // not gif/jpg/png return FALSE; } elseif ($info[2] == 1) { $format = "GIF"; } elseif ($info[2] == 2) { $format = "JPG"; } elseif ($info[2] == 3) { $format = "PNG"; } } else { // temp file not created if (substr($filedata, 0, 6) == "GIF87a" || substr($filedata, 0, 6) == "GIF89a") { $format = "GIF"; } elseif (substr($filedata, 0, 4) == "����" && substr($filedata, 6, 5) == "JFIF") { $format = "JPG"; } elseif (substr($filedata, 0, 8) == "�PNG\r\n\n") { $format = "PNG"; } else { return FALSE; } } $thumb = new $EW_THUMBNAIL_CLASS($filedata, $EW_RESIZE_OPTIONS + array("isDataStream" => TRUE, "format" => $format), $plugins); return $thumb->resizeEx($filedata, $width, $height); }
function SaveToSession() { $sSessionID = $this->getSessionID(); $_SESSION[$sSessionID . "_Action"] = $this->Action; $_SESSION[$sSessionID . "_FileSize"] = $this->FileSize; $_SESSION[$sSessionID . "_FileName"] = $this->FileName; $_SESSION[$sSessionID . "_ContentType"] = $this->ContentType; $_SESSION[$sSessionID . "_ImageWidth"] = $this->ImageWidth; $_SESSION[$sSessionID . "_ImageHeight"] = $this->ImageHeight; $path = pathinfo($this->FileName); $ext = @$path['extension']; if ($ext == '') { $ext = 'tmp'; } $f = tempnam(ew_TmpFolder(), 'tmp') . '.' . $ext; if (!is_null($this->Value)) { if (rename($this->Value, $this->Value . '.' . $ext)) { $this->Value .= '.' . $ext; } elseif (move_uploaded_file($this->Value, $f)) { $this->Value = $f; } } $_SESSION[$sSessionID . "_Value"] = $this->Value; }