PageRenderTime 32ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/ewbv6.php

https://github.com/fredd-for/emaus_tesoreria
PHP | 69 lines | 61 code | 4 blank | 4 comment | 17 complexity | e8eac40767b1b66babad8c79a80c17ab MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. session_start(); // Initialize session data
  3. ob_start(); // Turn on output buffering
  4. ?>
  5. <?php include "ewcfg6.php" ?>
  6. <?php include "ewmysql6.php" ?>
  7. <?php include "phpfn6.php" ?>
  8. <?php
  9. // Get resize parameters
  10. $resize = (@$_GET["resize"] <> "");
  11. $width = (@$_GET["width"] <> "") ? $_GET["width"] : 0;
  12. $height = (@$_GET["height"] <> "") ? $_GET["height"] : 0;
  13. if (@$_GET["width"] == "" && @$_GET["height"] == "") {
  14. $width = EW_THUMBNAIL_DEFAULT_WIDTH;
  15. $height = EW_THUMBNAIL_DEFAULT_HEIGHT;
  16. }
  17. $quality = (@$_GET["quality"] <> "") ? $_GET["quality"] : EW_THUMBNAIL_DEFAULT_QUALITY;
  18. // Resize image from physical file
  19. if (@$_GET["fn"] <> "") {
  20. $fn = ew_StripSlashes($_GET["fn"]);
  21. $fn = str_replace("\0", "", $fn);
  22. if (file_exists($fn)) {
  23. $pathinfo = pathinfo($fn);
  24. $ext = strtolower($pathinfo['extension']);
  25. if (in_array($ext, explode(',', EW_IMAGE_ALLOWED_FILE_EXT))) {
  26. $size = getimagesize($fn);
  27. if ($size)
  28. header("Content-type: {$size['mime']}");
  29. echo ew_ResizeFileToBinary($fn, $width, $height, $quality);
  30. }
  31. }
  32. exit();
  33. } else { // Display image from Session
  34. if (@$_GET["tbl"] <> "") {
  35. $tbl = $_GET["tbl"];
  36. } else {
  37. exit();
  38. }
  39. if (@$_GET["fld"] <> "") {
  40. $fld = $_GET["fld"];
  41. } else {
  42. exit();
  43. }
  44. // Get blob field
  45. $obj = new cUpload($tbl, $fld);
  46. $obj->RestoreFromSession();
  47. if (is_null($obj->Value))
  48. exit();
  49. // If not IE, get the content type
  50. if (strpos(ew_ServerVar("HTTP_USER_AGENT"), "MSIE") === FALSE) {
  51. $tmpfname = tempnam(ew_TmpFolder(), 'tmp');
  52. $handle = fopen($tmpfname, "w");
  53. fwrite($handle, $obj->Value);
  54. fclose($handle);
  55. $size = getimagesize($tmpfname);
  56. if ($size)
  57. header("Content-type: {$size['mime']}");
  58. @unlink($tmpfname);
  59. }
  60. if ($resize)
  61. $obj->Resize($width, $height, $quality);
  62. echo $obj->Value;
  63. exit();
  64. }
  65. ?>