Leeching Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JohnDigweed
Forum Newbie
Posts: 18
Joined: Sun Mar 28, 2004 6:24 pm
Location: root/user/hell

Leeching Question

Post by JohnDigweed »

Hi,

I am hiding the URL of images using GD Library. Is there a way so that the picture will not be shown unless the URL of the site is my site?

Like lets say I would use <img src="http://www.mysite.com/stuff.php">

Stuff.php contains the image made in php

Now, mr. someone from leecher.com likes my image, looks at the img src. He uses <img src="http://www.mysite.com/stuff.php">
even though his web site is http://www.leecher.com. Is there a way to protect it so the script does not show?

Could I use this code?

Code: Select all

<?
$domaincheck = $_SERVER&#1111;'HTTP_REFERER']
$mydomain = "http://www.mysite.com";

if($domaincheck == $mydomain)&#123;
    echo 'You may download files. ';
&#125; else &#123;
    echo 'Sorry, you may not download any files. ';
&#125;

?>
Another question, will the 'if' command recognize http://www.mysite.com/links.php, since I only set it to http://www.mysite.com?

Thanks.
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

I'm pretty sure that if they link to the .php page, the image will show. However, you may also be able to use some regex with the URL to make sure that the server it is being shown on is, indeed, yours.
JohnDigweed
Forum Newbie
Posts: 18
Joined: Sun Mar 28, 2004 6:24 pm
Location: root/user/hell

Post by JohnDigweed »

Is there another way limit the showing of stuff.php as an image, then?

Also, could you lead me to where regex is?

Thanks.
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

I tend to use perl regular expressions more often, you can find these at http://us4.php.net/pcre (tutorials at http://gnosis.cx/publish/programming/re ... sions.html)
Image Image
Post Reply