Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
69
rated 0 times [  70] [ 1]  / answers: 1 / hits: 17833  / 12 Years ago, fri, december 7, 2012, 12:00:00

I want to give a free download to my web visitor but I will hide the download link until they click the facebook like button. After they like it then jquery will make the button active and add 'href' attribute to the tag, contains path to the file, so then user will be able to click the link and download the file.



The problem is, user will be able to see the path easily when viewing source of the html in their browser.
Is there any easy way in php (I put the javascript codes inside on PHP file) to make a the path is harder to read?



It's fine when people will be able to deobfuscate it. I just want to make it harder to read for non advance user, so then people will consider to like the link instead of finding a way to deobfuscate the code.



Thank you


More From » php

 Answers
14

The only way to really do this properly is, of course, for the button press to make a round-trip to the server to retrieve the URL, via ajax or whatever.



But if you don't want to do that, and just want to obscure it, there are plenty of options. Base-64 encoding, for instance, has good support both in PHP and JavaScript, so you could encode the path on the PHP side (with base64_encode) and decode on JavaScript once the button is pressed (using any of several solutions discussed here on Stack Overflow).


[#81547] Thursday, December 6, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mathewb

Total Points: 535
Total Questions: 95
Total Answers: 96

Location: British Indian Ocean Territory
Member since Fri, Oct 15, 2021
3 Years ago
;