How to protect media file.

Discussion in 'PHP' started by huyhoa, Jun 19, 2007.

  1. #1
    I have a music site that i host my own music at a share hosting. But, i had been hide link, some newbie cant view but some one still can see and can get all link in folder by using Flashget or IDM.
    I cant use hot link, becoz if use, my music site cant play music. Please help me, limit connect from 1 Ip so, i thinks, i only give 1 Ip about 1 or 2 connect to my music host site. So, they cant use IDM or Flash get. And do you have any idea please help me and give me a code that limit the connecttion to my music host?
     
    huyhoa, Jun 19, 2007 IP
  2. php_daemon

    php_daemon Active Member

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    95
    #2
    Step 1. Use .htaccess to protect the directory of your media files

    Step 2. Create a script to deliver the media files to the user. In this script, you can limit the access per IP. See readfile
     
    php_daemon, Jun 20, 2007 IP
  3. huyhoa

    huyhoa Active Member

    Messages:
    214
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    can you tell me more about this?
    How can i limit the access per IP?
    And can you tell me more about: Step 1. Use .htaccess to protect the directory of your media files
    or can you please tell me where i can learn more about this?
    I have aready read http://php.net/readfile but i cant found anything
     
    huyhoa, Jun 20, 2007 IP
  4. kaisellgren

    kaisellgren Well-Known Member

    Messages:
    472
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Hi huyhoa,

    You can do this more easily. In your web server, you have a document root, htdocs, www, or something like that. You insert your files there, but this time you insert your protected media in root of your server, not in www or htdocs folder. When you are using the media file, just use PHP to handle the file.

    For example opening a zip file:
    $handle = fopen('../file.zip');
    PHP:
     
    kaisellgren, Jun 20, 2007 IP
  5. huyhoa

    huyhoa Active Member

    Messages:
    214
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    with mod rewrite, can i limit the connection to mysite at 1 time,1 ip?
    How can i do that? Please help
     
    huyhoa, Jul 2, 2007 IP