Jerzxu Posted June 25, 2008 Share Posted June 25, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/111784-solved-stopping-hotlink-with-picture-rename-possible/ Share on other sites More sharing options...
.josh Posted June 25, 2008 Share Posted June 25, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/111784-solved-stopping-hotlink-with-picture-rename-possible/#findComment-573876 Share on other sites More sharing options...
Jerzxu Posted June 25, 2008 Author Share Posted June 25, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/111784-solved-stopping-hotlink-with-picture-rename-possible/#findComment-573877 Share on other sites More sharing options...
.josh Posted June 25, 2008 Share Posted June 25, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/111784-solved-stopping-hotlink-with-picture-rename-possible/#findComment-573885 Share on other sites More sharing options...
Jerzxu Posted June 25, 2008 Author Share Posted June 25, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/111784-solved-stopping-hotlink-with-picture-rename-possible/#findComment-573891 Share on other sites More sharing options...
Jerzxu Posted June 27, 2008 Author Share Posted June 27, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/111784-solved-stopping-hotlink-with-picture-rename-possible/#findComment-575614 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.