0

I want to hide file links generated by php function in source code. I know its impossible to hide source code but i think there should be a way to hide php generated links in php code.

Here is the part of my code which used to generate links.

<?php foreach($tracks as $track){ ?>
<tr class="track" 
data-track_order="<?php echo $track['menu_order']; ?>
"data-track_src=" <?php echo $track['audio_file']; ?>">

OUTPUT IN SOURCE

<tr class="track" data-track_order="2"  data-track_src="http://domain.com/spins.mp3">

Is there any way in javascipt or in php vulnerability to make this hidden in source?

Well, From the above code, i tried so many encryptions methods but none of them worked. I need any solution to make it hidden in source.

6
  • What is it that you want to hide? Commented Nov 17, 2013 at 13:52
  • Well, I do not want anyone to grab my audio files from source code so it needed to be hidden. Its not pointless, its harder even dailymotion doing the same. Commented Nov 17, 2013 at 13:55
  • Did you try to obfuscate the code instead of hiding it? Supposing you want to prevent people from understanding your code, that approach might be useful. This is a very cool example in Javascript: kahusecurity.com/2011/… Commented Nov 17, 2013 at 13:56
  • Use .htaccess with headers. Plus you can use a DB. Google "force download php" Commented Nov 17, 2013 at 14:01
  • Or there is any way to stop users to downlaod files? Commented Nov 17, 2013 at 14:12

3 Answers 3

2

There are ways to try to get around this topic BUT the browser NEEDS to see the plain html code in order to render the webpage. Because of this current methods can be easily circumnavigated and they client will still be able to get hold of the link. So you can never fully stop the client getting your links BUT you can make it harder for them to get at it by using some techniques like javascript Obfuscation.

Sign up to request clarification or add additional context in comments.

2 Comments

Well, If this is no way to hide it from source then how youtube and other media sites are hiding them? You can find the youtube video location and link to download in source? Ofcource NO. You can"t find the link to youtube video in source.
@user2997826 they are embedding a flash player from another webpage and passing variables to it which are obfuscated. If you had enough time and patience you could eventually decode it but its obfuscated well which makes it very difficult to decode and it looks jibberish to most people
0

I presume that you want to hide the location so that people can't just retrieve the file without going through your site?

Instead of serving the file directly, have a php file serve the file. This file can then check that you are logged into the system, or have a time limited auth key that was generated from the page, whatever you think may limit the ability to copy and paste the link.

If the client accessing the file doesn't pass the checks, you serve them an authorisation failure header instead of the file contents.

1 Comment

This make some sence. Its impossible to hide source, I can stop them to download a file. yes system login check will surly work. Thanks this really helps alot :)
0

What is the purpose of hiding the link? To stop people from being able to see the file location, or to stop anything other than your application from accessing the MP3's?

You can program the link into your JavaScript and obfuscate it which will make it hard for the end user to see the link but ultimately its impossible to complete hide it if you are sending the end user to that page.

If you want to simply stop people from accessing the MP3 location(s) you might be better off looking at putting a .htaccess / mod rewite on the directory that they are residing in, or, have a single .php page to load in the MP3's that will authenticate the referrer and/or server IP address before loading the required file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.