forum_image.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: forum_image.php 32531 2013-02-06 10:15:19Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ') || empty($_GET['aid']) || empty($_GET['size']) || empty($_GET['key'])) {
  9. header('location: '.$_G['siteurl'].'static/image/common/none.gif');
  10. exit;
  11. }
  12. $nocache = !empty($_GET['nocache']) ? 1 : 0;
  13. $daid = intval($_GET['aid']);
  14. $type = !empty($_GET['type']) ? $_GET['type'] : 'fixwr';
  15. list($w, $h) = explode('x', $_GET['size']);
  16. $dw = intval($w);
  17. $dh = intval($h);
  18. $thumbfile = 'image/'.helper_attach::makethumbpath($daid, $dw, $dh);$attachurl = helper_attach::attachpreurl();
  19. if(!$nocache) {
  20. if(file_exists($_G['setting']['attachdir'].$thumbfile)) {
  21. dheader('location: '.$attachurl.$thumbfile);
  22. }
  23. }
  24. define('NOROBOT', TRUE);
  25. $id = !empty($_GET['atid']) ? $_GET['atid'] : $daid;
  26. if(dsign($id.'|'.$dw.'|'.$dh) != $_GET['key']) {
  27. dheader('location: '.$_G['siteurl'].'static/image/common/none.gif');
  28. }
  29. if($attach = C::t('forum_attachment_n')->fetch('aid:'.$daid, $daid, array(1, -1))) {
  30. if(!$dw && !$dh && $attach['tid'] != $id) {
  31. dheader('location: '.$_G['siteurl'].'static/image/common/none.gif');
  32. }
  33. dheader('Expires: '.gmdate('D, d M Y H:i:s', TIMESTAMP + 3600).' GMT');
  34. if($attach['remote']) {
  35. $filename = $_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment'];
  36. } else {
  37. $filename = $_G['setting']['attachdir'].'forum/'.$attach['attachment'];
  38. }
  39. require_once libfile('class/image');
  40. $img = new image;
  41. if($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
  42. if($nocache) {
  43. dheader('Content-Type: image');
  44. @readfile($_G['setting']['attachdir'].$thumbfile);
  45. @unlink($_G['setting']['attachdir'].$thumbfile);
  46. } else {
  47. dheader('location: '.$attachurl.$thumbfile);
  48. }
  49. } else {
  50. dheader('Content-Type: image');
  51. @readfile($filename);
  52. }
  53. }
  54. ?>