Jump to content

[SOLVED] Stopping Hotlink with Picture Rename - Possible?


Jerzxu

Recommended Posts

I came up with an idea for stopping hotlinking, but I am not sure if it is possible.

 

See with fileupload I devised the way of encrypting the filename so that it isn't possible to just randomly guess the image. (you could but it would be by extreme chance)

Then it would move it with just that name and no extension so it isn't viewable. 

 

Problem I ran into was that the browser doesn't know how to read the image seeing as it doesn't have an extension.

Is there a possible way to make it so the web browser would know that it was an image using php codes, without making the files name also include a extension?

 

Here's the basics of what's happening with the code:

 

File upload -> Checks to see if its acceptable file type -> Generates a random number and adds it into the middle of the filename -> Encrypts new filename -> Moves to the images folder.

 

So the file went from: image.jpg -> ima9328342734ge.jpg -> 8a5cd29fa948465792a084cff17a162e

 

So in essence I am asking is it possible to make that file viewable without adding the extension onto the filename at the end?

Link to comment
Share on other sites

if you have access to your cpanel you should be able to deal with hotlinking from there.

 

an alternative is to store your pictures in a database and have a script retrieve the info and use the gd library to create and post a picture on the fly. 

Posting a picture in a database. I was wondering about that actually. Does it actually post the picture itself into the database or just the link to the picture?

Link to comment
Share on other sites

you store the data that makes up the picture as a string.  Well in reality, you'd be storing it as type blob.  Then you retrieve that string and make a loop to build it back up, pixel by pixel.

 

edit:

 

or well, I guess you could store it as a file. I mean, if you make a blob or longblob type column and use the target file as the value, that should work, too.

Link to comment
Share on other sites

you store the data that makes up the picture as a string.  Well in reality, you'd be storing it as type blob.  Then you retrieve that string and make a loop to build it back up, pixel by pixel.

 

edit:

 

or well, I guess you could store it as a file. I mean, if you make a blob or longblob type column and use the target file as the value, that should work, too.

Okay, that makes sense.

Thanks for the help

Link to comment
Share on other sites

you store the data that makes up the picture as a string.  Well in reality, you'd be storing it as type blob.  Then you retrieve that string and make a loop to build it back up, pixel by pixel.

 

edit:

 

or well, I guess you could store it as a file. I mean, if you make a blob or longblob type column and use the target file as the value, that should work, too.

 

Update: (Just some tidbits of info.)

 

I was looking at a tutorial on how to insert images into a database and got it successfully running. Except I ran into some problems resizing it etc.

I got frustrated and was about to go back to normal way just uploading etc. and realized this line of code when displaying an image from the database:

 

header("content-type: text/jpeg");

 

After some messing around with changing the file extensions etc. around I actually got my way of viewing to work.

 

So now it will display a file with no file extension, or with a .somemadeupextension regardless. And the way I did it makes it quite difficult to copy without using printscreen.

 

And that's all she wrote.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.