Anyone know PHP?
So I'm trying to make a basic script that will use an .htaccess file for a folder so that if someone tries to open a .gif, .jpg, .jpeg, file from that folder, it goes to a PHP file that makes watermarks...
So I have this as my .htacess file: AddHandler watermarked .jpg AddHandler watermarked .jpeg AddHandler watermarked .gif AddHandler watermarked .png Action watermarked /test/wrapper.php And this is my wrapper.php file: <?php phpinfo(); die(); $watermark = "watermark.png"; $image = $_SERVER["PATH_TRANSLATED"]; if (empty($image)) die(); if (!file_exists($image)) { header("404 Not Found"); echo "File Not Found."; die(); ** $outputType = getFileType($image); watermark($image, $watermark, $outputType); /** Outputs the image $source with $watermark in the lower right corner. @param $source the source image @param $watermark the watermark to apply @param $outputType the type to output as (png, jpg, gif, etc.) defaults to the image type of $source if left blank */ function watermark($source, $watermark, $outputType="") { $sourceType = getFileType($source); $watermarkType = getFileType($watermark); if (empty($outputType)) $outputType = $sourceType; header("Content-type:image/$outputType"); // Derive function names $createSource = "ImageCreateFrom".strtoupper($sourceType); $showImage = "Image".strtoupper($outputType); $createWatermark = "ImageCreateFrom".strtoupper($watermarkType); // Load original and watermark to memory $output = $createSource($source); $logo = $createWatermark($watermark); ImageAlphaBlending($output, true); // Find proper coordinates so watermark will be in the lower right corner $x = ImageSX($output) - ImageSX($logo); $y = ImageSY($output) - ImageSY($logo); // Display ImageCopy($output, $logo, $x, $y, 0, 0, ImageSX($logo), ImageSY($logo)); $showImage($output); // Purge ImageDestroy($output); ImageDestroy($logo); ** function getFileType($string) { $type = strtolower(eregi_replace("^(.*)\.","",$string)); if ($type == "jpg") $type = "jpeg"; return $type; ** But this is what happens when I try linking: http://www.meissenation.com/test/sailboat.jpg :confused: Anyone that knows PHP, can ya direct me as to what's going wrong? (Yeah, I know it's a red x... that's the problem.) |
ahaha, gotta it. Now to make it so these **** unknown users can't hotlink my funny images off my site! :D
http://www.meissenation.com/test/test/thomas.jpg http://www.meissenation.com/test/thomas.jpg |
I'm lost.
|
Originally Posted by MeenZ28
I'm lost.
He's making it so "meissenation.com" show's up on any picture's that are hotlinked off his site. |
hmm Im with grant
|
glad its working for you...
|
Yeah, Chad got it. I looked at the web statistics of my site and noticed that like 20+ people were hotlinking images off my site and posting it on other forums and stuff, so I decided to take care of that!
|
All times are GMT -4. The time now is 08:26 AM. |
© 2024 MH Sub I, LLC dba Internet Brands