scotty2026 Posted March 28, 2008 Share Posted March 28, 2008 I was wondering how to encrypt links using php? I have a few links to images etc that I don't want others hotlinking to. For example Myspace used msplink to encrypt their links. Is something similar with php? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/ Share on other sites More sharing options...
ucffool Posted March 28, 2008 Share Posted March 28, 2008 Can't you simply use mod_rewrite to stop people from hotlinking? Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-503473 Share on other sites More sharing options...
Psycho Posted March 28, 2008 Share Posted March 28, 2008 Heres a page with code to prevent hotlinking: http://www.safalra.com/programming/php/prevent-hotlinking/ Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-503474 Share on other sites More sharing options...
scotty2026 Posted March 28, 2008 Author Share Posted March 28, 2008 Hello. I am very new at programming with php. So I am not familiar with mod_rewrite ucffool. I looked at the tutorial you provided mjdamato. However, I am interested in just encrypting the link and not the actual file location. Is there a way to encrypt just the link? Edit: ps. the links I am wanting to encrypt are on a phpbb forum. Not sure if this will make a difference. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-503483 Share on other sites More sharing options...
Psycho Posted March 29, 2008 Share Posted March 29, 2008 msplink is not used to prevent hot-linking it is used for tracking purposes. Even if you did encrypt the URL how would that prevent hot-linking, the person could hot-link using the encrypted URL. To prevent hotlinking you can use either the mod-rewrite or another function like the one I posted. They work the same way - prevent access to your images from pages outside your domain. But, they are very flexible in that you can replace the image with a substitute or allow access for some domains and not others, etc. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-503689 Share on other sites More sharing options...
mkoga Posted March 29, 2008 Share Posted March 29, 2008 I think I understand what you're going for here. If you want to just encrypt the link, you just need to find a two-way encryption algorithm. I've used mcrypt in the past, it works just fine. So for instance http://www.example.com/images/encryptedlink, just decrypt "encryptedlink" and use that to determine what image to serve and check to see if the request is coming from your domain. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-503834 Share on other sites More sharing options...
Psycho Posted March 29, 2008 Share Posted March 29, 2008 I think I understand what you're going for here. If you want to just encrypt the link, you just need to find a two-way encryption algorithm. I've used mcrypt in the past, it works just fine. So for instance http://www.example.com/images/encryptedlink, just decrypt "encryptedlink" and use that to determine what image to serve and check to see if the request is coming from your domain. That's all well and good, but the encryption does nothing to prevent hot-linking. It is only process of checking the request URL that will prevent hot-linking. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-504317 Share on other sites More sharing options...
scotty2026 Posted March 29, 2008 Author Share Posted March 29, 2008 I think I understand what you're going for here. If you want to just encrypt the link, you just need to find a two-way encryption algorithm. I've used mcrypt in the past, it works just fine. So for instance http://www.example.com/images/encryptedlink, just decrypt "encryptedlink" and use that to determine what image to serve and check to see if the request is coming from your domain. You hit the nail on the head mkoga! Yes all I want to do is encrypt the link. I guess I was miss leading by saying to prevent hotlinking. That is not my main concern. My main concern is to encrypt just the link. For example if the link was "http://www.example.com/link" I would like to encrypt it to a random string like "AjhilI866Nloiu-98dDlkMTjd07". Is this possible with the two-way algorithm? And is it safe in the sense that no one could get the decryption algorthim? Are there examples of this algorithm? Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-504328 Share on other sites More sharing options...
Psycho Posted March 29, 2008 Share Posted March 29, 2008 You know I changed my sig recently because of problems such as this. I was wondering how to encrypt links using php? I have a few links to images etc that I don't want others hotlinking to. For example Myspace used msplink to encrypt their links. Is something similar with php? The purpose (i.e. "want") in your post was to prevent hot-linking. Why on earth would you even say that if that wasn't what you wanted? I changed my sig recently exactly because of this type problem. Take the time to ask a proper question and you will typically get the solution needed on the first or second response instead of wasting everybody's time. Anyway, yes you can use an encryption algorithym. Although it would be helpful if you stated the purpose for needing this as it may determine the best solution. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-504340 Share on other sites More sharing options...
scotty2026 Posted March 30, 2008 Author Share Posted March 30, 2008 The purpose (i.e. "want") in your post was to prevent hot-linking. Why on earth would you even say that if that wasn't what you wanted? I changed my sig recently exactly because of this type problem. Take the time to ask a proper question and you will typically get the solution needed on the first or second response instead of wasting everybody's time. Anyway, yes you can use an encryption algorithym. Although it would be helpful if you stated the purpose for needing this as it may determine the best solution. Geez mjdamato. Sorry I didn't know of an algorithm that would do this. The best way for me to describe my problem was with hotlinking. I am not a "guru" like yourself. If it bothers you that others don't know how to ask a question properly because they are not as technically advanced as yourself, then why do you bother to hang around here? Seems like there are a lot of people in my shoes if you were forced to change your sig. But I guess that there will naturally be less tech savy people in a help forum?? Now that I know there are such algorithms out there let me rephrase my question for you... I was wondering how to encrypt links using php? I have a few links to images etc that I don't want others seeing the original link of. For example Myspace used msplink to encrypt their links. Is something similar with php? I under stand that there are algorithms that do this. Can someone help me with it or is there a tutorial for it somewhere? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-504355 Share on other sites More sharing options...
Psycho Posted March 30, 2008 Share Posted March 30, 2008 I don't expect anyone to be a "guru", but I do expect them to take the time to ask a question properly when asking for help. If I was paying for support I might not be very dilligent in my preparation, but when it is free I make sure to at least do some due dillegence beforehand. If I don't know how to properly state something I will make it clear. If you don't know/understand the technical terms for what you need then just explain them in plain English. And, now that you've stated what you REALLY want to accomplish - it is clear that encrypting is not needed. How To: Hide The Real Url Of Your Images - using php http://www.trap17.com/index.php/how-hide-real-url-images_t24561.html Note: This will not protect your images for content robbers. I'd still be interested in knowing why you think you need to do this. It doesn't stop anyone from hot-linking and it doesn't protect your images in any way. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-504397 Share on other sites More sharing options...
doni49 Posted March 30, 2008 Share Posted March 30, 2008 If you want to stop hot-linking of images, I think you could store a special variable in the page (never seen by at the html level so the visitor will never know about it. Then set the img source to a php script. If the PHP script sees this variable, then show the image. If the variable is NOT present, then show an image that just says something like "copyrighted image-hotlinking not permitted". EDIT: I must've misread the latest messages in this thread and just realized that the OP does NOT want to prevent hot-linking. I don't get the purpose of the encryption then. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-504411 Share on other sites More sharing options...
scotty2026 Posted March 30, 2008 Author Share Posted March 30, 2008 Thanks for the link mjdamato. doni49, that sounds very interesting. Is there a tutorial about that? Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505096 Share on other sites More sharing options...
doni49 Posted March 31, 2008 Share Posted March 31, 2008 Not that I've seen but lemme see what I can put together. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505256 Share on other sites More sharing options...
scotty2026 Posted March 31, 2008 Author Share Posted March 31, 2008 Not that I've seen but lemme see what I can put together. Thank you! I look forward to your reply! Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505314 Share on other sites More sharing options...
redarrow Posted March 31, 2008 Share Posted March 31, 2008 Ok come on programmers, you no why the user wants to use a hash for his links, the current user is learning php that why. For example if the current user design a uploading image page and the image had the users id at the end, then he/her be worried, Also he might also creted folders with usernames, And we all no that hacking/cracking is huge now due to real world hackers having the abilty to publish there own books and distubute to the public.... dont go on about a user not being able to exspress his explinations ok hot harsh programmers. Also i can not spell properly as i am blind programmer sorry pros...... I was wondering how to encrypt links using php? I have a few links to images etc that I don't want others hotlinking to. For example Myspace used msplink to encrypt their links. Is something similar with php? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505333 Share on other sites More sharing options...
Psycho Posted March 31, 2008 Share Posted March 31, 2008 doni49, that sounds very interesting. Is there a tutorial about that? Look at the page I linked to. In the comments below the tutorial there are examples with that exact functionality. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505344 Share on other sites More sharing options...
Psycho Posted March 31, 2008 Share Posted March 31, 2008 Ok come on programmers, you no why the user wants to use a hash for his links, the current user is learning php that why. For example if the current user design a uploading image page and the image had the users id at the end, then he/her be worried, Also he might also creted folders with usernames, And we all no that hacking/cracking is huge now due to real world hackers having the abilty to publish there own books and distubute to the public.... dont go on about a user not being able to exspress his explinations ok hot harsh programmers. Also i can not spell properly as i am blind programmer sorry pros...... Sorry, RedArrow, but I don't see it that way. The OP ask the wrong question because, according to his own admision, he is not "tech savy". In such a situation asking a person to clarify the reason for their need is appropriate as they may be asking for something for the wrong reasons. in the first post the OP said he wanted to prevet hot-linking, then later he said that is not what he wanted, then in reply #12 he is asking for that functionality again. There are legitimate reasons for encrypting a link, as you already stated, but I don't know that those have anything to do with what the OP is needed. If he was to state what he needs, and why, an appropriate solution could have been had without going to two pages in this thread. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505346 Share on other sites More sharing options...
scotty2026 Posted March 31, 2008 Author Share Posted March 31, 2008 This thread is starting to make me laugh! Ok, since everyone wants to know so bad what I am doing...let me explain my site. I have a phpbb (version 3, mjdamato) which I post images/videos/etc that I find around the internet. I am interested in encrypting the original URLs to the content so that people trying to copy me can't see where exactly I am finding my content. Recently I have been running in to problems with copy cats. I thought that maybe encrypting the links would help solve this problem. Hope this clears up the confusion and I hope we can all move on from the fact that I did not know how to originally ask the question. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505351 Share on other sites More sharing options...
Psycho Posted March 31, 2008 Share Posted March 31, 2008 I am interested in encrypting the original URLs to the content so that people trying to copy me can't see where exactly I am finding my content. If you are hot-linking to that content, then encrypting the link does make sense. If you are copying the content to your server, then encrypting does not make sense. Recently I have been running in to problems with copy cats. I thought that maybe encrypting the links would help solve this problem. So you have people copying the content that you are stealing? Encrypting the link will do nothing to prevent that. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505703 Share on other sites More sharing options...
scotty2026 Posted March 31, 2008 Author Share Posted March 31, 2008 Stealing? Who said anything about stealing? Have you been to a site such as youtube? They offer embed codes. They want you to embed their videos. It is not stealing. I simply want to encrypt the url so that people continue to use my site and not the copy cats. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505708 Share on other sites More sharing options...
Psycho Posted March 31, 2008 Share Posted March 31, 2008 From YouTube's TOS B. You agree not to alter or modify any part of the Website, including but not limited to YouTube's Embeddable Player or any of its related technologies. Modifying the URL to a YouTube video would violate this TOS. It looks to me like you are trying to display content on your website that you did not create and are not even giving proper credit to those who did. Sounds like plagiarism to me. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505809 Share on other sites More sharing options...
scotty2026 Posted March 31, 2008 Author Share Posted March 31, 2008 This has gone way off topic. I do not plan to alter the content/player etc. I just want to encrypt the URL so that others will have to "work" to find the videos as well. I am doing all the work finding the videos/images etc and then the copy cats just take the links. I don't care if they post the same videos but I would like them to have to spend the time finding them also. I am done arguing about this because it seems that you, mjdamato, are more interested in bickering. Unfortunately you are the only one really replying here. I will go elsewhere for help. Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505867 Share on other sites More sharing options...
Psycho Posted March 31, 2008 Share Posted March 31, 2008 Well, as I already stated, the only reason this has gone on so long is that you never properly stated what you needed. Not stating that you were trying to encrypt links to an external source was a big oversight. You might be able to do that with images by reading the content of the image and writing that to the page. But, I can't think of any way to do that with a youtube video. And, jsut for the record the TOS stated that you could not modify "any part of the website". I would consider the URLs to be included in that. It may not be a violation of the letter of the requirement, but I'd consider it a violoation of the intent. Besides, this is all pretty pointless with YouTube videos since clicking on the video while it's playing will open up YouTube to that contents page. Doh! Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505918 Share on other sites More sharing options...
elite_prodigy Posted March 31, 2008 Share Posted March 31, 2008 Hello. I am very new at programming with php. So I am not familiar with mod_rewrite ucffool. I looked at the tutorial you provided mjdamato. However, I am interested in just encrypting the link and not the actual file location. Is there a way to encrypt just the link? Edit: ps. the links I am wanting to encrypt are on a phpbb forum. Not sure if this will make a difference. Try asking about this in these places, they are best suited to help you with phpBB, and there may be a MOD written for it already: 2.x.x -OR- 2.x.x 3.0.x Gold -OR- 3.0.x Gold Quote Link to comment https://forums.phpfreaks.com/topic/98380-link-encrypting/#findComment-505957 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.