pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

pastebin private pastebin - collaborative debugging tool What's a private pastebin?

Posted by lordV on Sat 6th Dec 20:16
download | new post

  1. <?php
  2.     /*
  3.         Generate watermarked images on the fly
  4.         and output as a jpg
  5.         Requires imagemagick libraries to be installed
  6.         Author paul@mrvallis.co.uk
  7.         Thanks to frymaster@127001.org for the idea!
  8.         inputs:
  9.             GET path        path to image
  10.             GET image       image filename
  11.         outputs:
  12.             watermarked image (jpg)
  13.     */
  14.  
  15.     $composite = "/usr/bin/composite";                              //path to composite binary
  16.     $fullpath = "/var/www/vhosts/mrvallis.co.uk/httpdocs/";         //full path to location of this file
  17.     $watermarked = "images/watermarked/";                           //location to store watermarked images
  18.  
  19.     if(isset($_GET['image']) && isset($_GET['path']))
  20.     {
  21.         $location = $_GET['image'];
  22.         $path = $fullpath . $_GET['path'];
  23.  
  24.         $pattern = "/" . ".*\.jpg$" . "/i";
  25.         if (preg_match($pattern, $location))
  26.         {
  27.             if(file_exists($path.$location) && file_exists($fullpath.$watermarked.$location))
  28.             {
  29.                 header('Content-Type: image/jpeg');
  30.                 header('Location: ' . $watermarked . $location);
  31.                 die();
  32.             }
  33.             elseif (file_exists($path . $location))
  34.             {
  35.                 $command = $composite . ' -gravity center ' . $fullpath.$watermarked . 'watermark.png ' . $path.$location . ' ' . $fullpath.$watermarked.$location;
  36.                 exec($command);
  37.                 header('Content-Type: image/jpeg');
  38.                 header('Location: ' . $watermarked . $location);
  39.             }
  40.             else
  41.             {
  42.                 die();
  43.             }
  44.         }
  45.         else
  46.         {
  47.             die();
  48.         }
  49.     }
  50.     else
  51.     {
  52.         die();
  53.     }
  54. ?>

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings