Hiding the link of source file for mp3

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • codexxx
    New Member
    • Jun 2007
    • 18

    Hiding the link of source file for mp3

    Hi All,

    I am working on a social networking site.And there is a option for playing mp3
    musics. But now there is a problem. The link of that file is visible when someone goes through source of that page from view source. I want some ways to hide that path so that link cant be used as direct downloading option.

    Thanks and regards
    codexxx
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Codexxx.

    On the page that contains the link to the MP3 file, send a token to the User's session and add it to the MP3 link:

    [code=php]
    <?php
    $_SESSION['mp3token'] = uniqid('name_of _mp3_file_hashe d_with_username ');
    ?>

    <a href="/path/to/mp3.php?fileid= 12345&amp;token =<?php echo $_SESSION['mp3token'] ?>">mp3 file!</a>
    [/code]

    In mp3.php:
    [code=php]
    if( $_GET['token'] == $_SESSION['mp3token'] )
    {
    header('Content-type: audio/mpeg');
    readfile('.../' . getMP3Filename( $_GET['fileid']));
    }

    unset($_SESSION['mp3token']);
    [/code]

    You could alternatively store the token in a database. The download link is only valid if the User provides a matching token, which he can only do by visiting the page on your site.

    Comment

    Working...