Chit Chat For all general off topic chat on GTcars.

Anyone know PHP?

Thread Tools
 
Search this Thread
 
Old 02-03-2005, 11:09 PM
  #1  
GTcars - Post God !
Thread Starter
 
meissen's Avatar
 
Join Date: Sep 2003
Location: Macomb, Michigan
Posts: 6,032
Rep Power: 877
meissen has a spectacular aura aboutmeissen has a spectacular aura aboutmeissen has a spectacular aura about
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:




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.)
meissen is offline  
Old 02-04-2005, 06:36 AM
  #2  
GTcars - Post God !
Thread Starter
 
meissen's Avatar
 
Join Date: Sep 2003
Location: Macomb, Michigan
Posts: 6,032
Rep Power: 877
meissen has a spectacular aura aboutmeissen has a spectacular aura aboutmeissen has a spectacular aura about
ahaha, gotta it. Now to make it so these **** unknown users can't hotlink my funny images off my site!


meissen is offline  
Old 02-04-2005, 11:59 AM
  #3  
GTcars - Post God !
 
MeenZ28's Avatar
 
Join Date: Feb 2003
Location: so. cali
Posts: 6,012
Rep Power: 896
MeenZ28 has a spectacular aura aboutMeenZ28 has a spectacular aura aboutMeenZ28 has a spectacular aura about
I'm lost.
MeenZ28 is offline  
Old 02-04-2005, 06:25 PM
  #4  
GTcars - Post God !
iTrader: (1)
 
Mike Jones's Avatar
 
Join Date: Jan 2002
Posts: 13,249
Rep Power: 0
Mike Jones street rep is low. keep goingMike Jones street rep is low. keep goingMike Jones street rep is low. keep goingMike Jones street rep is low. keep goingMike Jones street rep is low. keep goingMike Jones street rep is low. keep goingMike Jones street rep is low. keep going
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.
Mike Jones is offline  
Old 02-04-2005, 08:28 PM
  #5  
I Love Triangle Cheese!!
 
97z2801ss's Avatar
 
Join Date: Aug 2003
Location: Z ya around
Posts: 12,007
Rep Power: 0
97z2801ss should buy a rope to hang!97z2801ss should buy a rope to hang!97z2801ss should buy a rope to hang!97z2801ss should buy a rope to hang!97z2801ss should buy a rope to hang!97z2801ss should buy a rope to hang!97z2801ss should buy a rope to hang!
hmm Im with grant
97z2801ss is offline  
Old 02-04-2005, 11:35 PM
  #6  
Post Wench
 
camaro94's Avatar
 
Join Date: Jun 2003
Location: Nemacolin, PA
Posts: 10,392
Rep Power: 971
camaro94 street rep is low. keep going
glad its working for you...
camaro94 is offline  
Old 02-04-2005, 11:50 PM
  #7  
GTcars - Post God !
Thread Starter
 
meissen's Avatar
 
Join Date: Sep 2003
Location: Macomb, Michigan
Posts: 6,032
Rep Power: 877
meissen has a spectacular aura aboutmeissen has a spectacular aura aboutmeissen has a spectacular aura about
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!
meissen is offline  
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
mz.pasillas_o7_27_07
honda / acura
0
11-08-2008 09:47 PM
kuba
Chit Chat
46
09-27-2005 11:20 AM
meissen
Chit Chat
3
09-12-2005 04:03 PM
p51mustang
Honda Mailing List
0
06-20-2005 06:37 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 


Quick Reply: Anyone know PHP?



All times are GMT -4. The time now is 04:22 PM.

Page generated in 0.09052 seconds with 16 queries