Basic PHP document management system, including automatic detection of corporate logos in letters
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?PHP
  2. /******************************************************************************\
  3. thumb.php: Generate thumbnail image of specified file.
  4. Copyright (C) 2004-2007 Chris 'MD87' Smith
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. |******************************************************************************|
  17. Usage:
  18. <img src="thumb.php?file_name.png"...>
  19. <img src="thumb.php?directory/file.jpg"...>
  20. <img src="thumb.php?http://www.example.com/file.jpg"...>
  21. \******************************************************************************/
  22. header('Cache-control: public');
  23. $image = $_SERVER['QUERY_STRING'];
  24. if (!file_exists($image)) {
  25. /* TODO: Output error image. */
  26. die();
  27. }
  28. if (file_exists('.thumbs/prog-' . md5($image))) {
  29. $mtime = filemtime('.thumbs/prog-' . md5($image));
  30. if ($mtime >= filemtime($image)) {
  31. header('Content-type: image/jpeg');
  32. readfile('.thumbs/prog-' . md5($image));
  33. exit;
  34. }
  35. }
  36. /* TODO: Optimise. */
  37. if (($imi = @imagecreatefromjpeg($image)) === FALSE) {
  38. if (($imi = @imagecreatefrompng($image)) === FALSE) {
  39. if (($imi = @imagecreatefromgif($image)) === FALSE) {
  40. /* TODO: Output error image. */
  41. die();
  42. }
  43. }
  44. }
  45. header('Content-type: image/jpeg');
  46. imageinterlace($imi, true);
  47. imagejpeg($imi, '.thumbs/prog-' . md5($image), 100);
  48. imagejpeg($imi, false, 100);
  49. ?>