Jump to content

i need help with a file i don't want downloaded


andrew_U

Recommended Posts

so i contacted a band with permission to play their song on my website.

they said i can use it, but it cannot be downloaded.

so i uploaded the .mp3 file i wanted to use and set the permissions so it could not be downloaded.

but now the file will not play, because of the permissions change.

i want to be able to use this simple script:

 

<embed src="http://undignifiedconference.com/xxxxxxxx.mp3" autostart="true" 

loop="true"></embed>

 

to play a music file "grabbed" by php is this possible?

i am not that familiar with php and the code i tried to use was file_get_contents.

 

 

Link to comment
Share on other sites

sorry i forgot to include what i did to the file_get_contents

script, i think i tried this:

 

<php?

$filename = ['xxxxxxx.mp3'];
$flags = ['FILE_TEXT'];
$context = ['NULL'];
$offset = ['0']
$maxlen = ['999999999']

string file_get_contents ( string $filename [, int $flags [, resource $context [, int $offset [, int $maxlen ]]]] )

help cuz i don't really know what i am doing haha

Link to comment
Share on other sites

The problem lays with the permissions, the webserver doesn't have the rights to read the .mp3.

 

What I would do, in your situation; I would move the .mp3 ABOVE the webtree. so this means that if you have a webserver that has path like this: c:/server/www/yoursite/index.php ( or linux /var/www/yoursite/index.php ) or something, and everything you put into www folder be available for anyone to read from all around the internet. Now you move the .mp3 to the c:/server/ folder which is above the webtree and thus not available to ppl on the internet, but still readable and playable by the webserver.

 

Then just embed it with relative path, like src='../../../file.mp3'...

Link to comment
Share on other sites

It doesn't matter. If they can hear it then they've probably got it cached, aka downloaded. You could always throw it into a flash jukebox... but even that is cached. I'm sure when they say 'cannot be downloaded' they probably mean have a link on your website for a download.

 

I think the flash jukebox is the best option.

Link to comment
Share on other sites

I would include a ajax script that users cant access, and include it to the page where you want to play your song. The ajax would send vars to a PHP file that echos the filename, the filename of the mp3 should be hashed or renamed to something impossible to guess. Then the Ajax would put the filename into a <div></div> tag, which users cant see with view page source. You should also super rename the php file too, if someone gets lucky(like winning the lottery lucky).....

 

this is my method to be safe..

 

PHP FILE

 

<?php

// AJAX VARS POST METHOD

  $activate = $_POST['act'];

if($activate == '1'){

  
// echo impossible filename to guess

}

?>

 

 

The OBJECT response text would change the div tag's innerHTML to the filename, or something like

 


function getXMLHttpObject(){

var r;

  if(window.XMLHttpRequest){
  
   r = new XMLHttpRequest();
      }else if(window.ActiveXObject){
  
   r = new ActiveXObject('Microsoft.XMLHTTP');
  
    }else{

	 alert('Please enable Javascript');

	 }

	 return r;
}

var obj = getXMLHttpObject();

  function getSong(){


     
    obj.send('POST','ksdjk3j4lk23j4lk3jlkrjelkfjkfjlksdfjr923r23r3jr.php', true);
    obj.onreadystatechange = handleSong;
    obj.send('act=1');

}

function handleSong(){
if(obj.readyState == 4 && obj.status == 200){

var response = obj.responseText;

if(response){

     document.getElementById('divSONG').innerHTML = '<embed src="http://undignifiedconference.com/'+response+'" autostart="true" loop="true"></embed>'; // 

    }
  }
}

 

 

 

 

 

 

HTML

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script scr="ajaxScript.php"></script>
</head>
<body>
<div id="divSONG"></div>
</body>
</html>

Link to comment
Share on other sites

EDIT HTML:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script scr="ajaxScript.php"></script>
</head>
<body onload="getSong();">>
<div id="divSONG"></div>
</body 
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.