Selling Downloads

de.monkeyz

New Member
Messages
35
Reaction score
0
Points
0
I want to try and sell my friends own music which he was full rights to on my site, and I've been told that it won't violate the TOS, I was wondering if people knew how to restrict acces to these files unless someone has bought them, I am using php to write all of the script. Any help is greatly appreiated and I'll give you rep if you want.
 
Last edited:

Azuremyst

Banned
Messages
81
Reaction score
0
Points
0
Redistributing music in any way violates the composer's copyright law, as such, being illegal without permission of the artist.
 

de.monkeyz

New Member
Messages
35
Reaction score
0
Points
0
He's giving me explicit permission to sell it, and it will be pretty much his own site, and its all composed, edited and performed by him, so I dont have any legal issues.
 
Last edited:

Jake

Developer
Contributors
Messages
4,057
Reaction score
5
Points
0
Redistributing music in any way violates the composer's copyright law, as such, being illegal without permission of the artist.

Gotta finish reading posts buddy :)

Well there should be a marketplace type script around here, I know I have seen one before I'll have a quick look.

Its pretty simple, the person pays for it using say paypal and then their account gets access to download the song that they paid for. Although for a paypal version without SSL im not sure you'd be able to sell real-time... Like you'd have to update peoples accounts manually.

Another option would be make cds and just sell the cds... could be possible. I have never really tried something like that though sorry, mostly tossing out ideas.
 
Last edited:

de.monkeyz

New Member
Messages
35
Reaction score
0
Points
0
Thanks for the help, I'm looking for info on another site that provides downloads in a similar way and asking how they do it. Hopefully I'll get some info soon.
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Personally, I would recommend storing the files in a db with the content in a Blob field(you'd have to decide on the appropriate size). Make sure the file's mime type, and name(what you want the client to save it as, including the extension) are stored with it, as well as a unique ID, of course. Then, you might want to have another page where all of a user's confirmed purchases are listed with links to download them.

Allowing users to download files through php is quite easy. First, you'd want to query the db to make sure the ID of the file they're requesting exists, as well as ensure that they're authorized to download it. Then, assuming the download is valid, send the right headers along with the file's content to the client.

So you might have something like this: (I hope I didn't screw up anywhere)

PHP:
<?php
//download.php

if (!empty($_GET['id'])) {
    //connect to the db, get the user's id, etc

    $id = intval($_GET['id']);
    
    $sql = "SELECT *, LENGTH(content) AS size
        FROM downloads
        WHERE id = $id";
    $file = mysql_query($sql);
    if (!$file) {
        die('Something went wrong with the query');
    }
    
    $file = mysql_fetch_array($file);
    if (empty($file)) {
        die('The file doesn\'t exist');
    }
    
    $sql = "SELECT id
        FROM download_auth
        WHERE user_id = $user_id
        AND file_id = $id";
    $auth = mysql_query($sql);
    if (!$auth) {
        die('Something went wrong with the query');
    }
    
    $auth = mysql_fetch_array($auth);
    if (empty($auth)) {
        die('You are not allowed to download this file');
    }
    
    header("Content-type: {$file['type']}");
    header("Content-length: {$file['size']}");
    header("Content-Disposition: attachment; filename={$file['name']}");
    print $file['content'];
    
}
else {
    die('No id was given');
}
?>
Alternatively, you could put the files in a protected folder, with mysql storing the file's path/name instead of its content, and then readfile() it after the headers. But I personally believe storing them in the db is the better option.
 

de.monkeyz

New Member
Messages
35
Reaction score
0
Points
0
Thanks very much, I was thinking about sotring files in a database, but I had no idea about the blob datatype. This should be very helpful. Thanks again.
 

Azuremyst

Banned
Messages
81
Reaction score
0
Points
0
Gotta finish reading posts buddy :)

Well there should be a marketplace type script around here, I know I have seen one before I'll have a quick look.

Its pretty simple, the person pays for it using say paypal and then their account gets access to download the song that they paid for. Although for a paypal version without SSL im not sure you'd be able to sell real-time... Like you'd have to update peoples accounts manually.

Another option would be make cds and just sell the cds... could be possible. I have never really tried something like that though sorry, mostly tossing out ideas.

Sorry, he was not very clear on whether or not his friend actually made the music in the first post.
 
Top