thumbnail.php 902 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Image thumbnail view
  4. *
  5. * @author Cash Costello
  6. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
  7. */
  8. $guid = (int) get_input('guid');
  9. $size = get_input('size');
  10. $image = get_entity($guid);
  11. if (!$image) {
  12. forward(REFERER);
  13. }
  14. if ($size == 'master') {
  15. $contents = $image->getImage();
  16. } else {
  17. $contents = $image->getThumbnail($size);
  18. }
  19. if (!$contents) {
  20. forward("mod/tidypics/graphics/image_error_$size");
  21. }
  22. // expires every 14 days
  23. $expires = 14 * 60*60*24;
  24. // overwrite header caused by php session code so images can be cached
  25. $mime = $image->getMimeType();
  26. header("Content-Type: $mime");
  27. header("Content-Length: " . strlen($contents));
  28. header("Cache-Control: public", true);
  29. header("Pragma: public", true);
  30. header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);
  31. // Return the thumbnail and exit
  32. echo $contents;
  33. exit;