Chit Chat For all general off topic chat on GTcars.

Anyone know PHP?

Thread Tools
 
Search this Thread
 
Old Feb 3, 2005 | 11:09 PM
  #1  
meissen's Avatar
Thread Starter
GTcars - Post God !
 
Joined: Sep 2003
Posts: 6,032
From: Macomb, Michigan
Rep Power: 947
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.)
Old Feb 4, 2005 | 06:36 AM
  #2  
meissen's Avatar
Thread Starter
GTcars - Post God !
 
Joined: Sep 2003
Posts: 6,032
From: Macomb, Michigan
Rep Power: 947
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!


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

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



All times are GMT -4. The time now is 08:44 AM.

Page generated in 1.15476 seconds with 7 queries