Jump to content

Download System?


reyna12

Recommended Posts

What i want

I have an mp3 file, only available for logged in users, but i want to make it so that it is downloadable, only by logged in users so that the link cannot be passed around, is this hard to do?

Also would need to add something to the member system that alerts if the user has logged in from several ip addresses, is there something available for this?

Thanks for any advice
Link to comment
Share on other sites

For your system for downloading, I would suggest storing all files in a database.  I don't mena the actual files themselves, but the links to those files.  Also, give the songs a specific ID.  Have a variable that must be equal to true, such as a logged_in SESSION variable on the download page itself.  The download page will check that they are logged in, run the id for the song to be downloaded, and secretly redirect to that link stored in the database.

For the IP address part, why not just make a variable in the member's db that is called logged or something that is a simple int.  If it is 1, they are logged in, if it is 0, they are not.  If it is set to 0, the user can still login, but once it is 1, they cannot log in again until logged back out.
Link to comment
Share on other sites

The mp3 itself will be created by me so no issues with copyright etc...


I'd never thought of that, that script won't do it (or i am failing to understand it) but it could be a link "Download" but it wouldnt actually show the url to the file.

I am guessing that, that script might be part of it but how would i go about actually setting teh file to download?
Link to comment
Share on other sites

Make a link to the download page (which people have to be logged in to view) and put it on that page to forward to the file hidden in a hidden directory so that people cant find it.

As it is in the php code the location does not show up on the source, and as far as I am aware, it just says downloading from www.site.com when you download it, and does not say the actual path to the file so people shouldn't be able to easilly find it.
Link to comment
Share on other sites

Now what i have the problem with is, it worked before putting it into the member system  :D

It does show the register options when trying to access it when not logged in, but when you are it keeps saying downloading download.php then error, cannot download download.php rather than the file.

[code=php:0]
<?
session_start();
include('./config.php');
if(!check_login($username, $password))
{
$title = "Guest Page";
$msg = "<h2>Welcome Guest</h2>
<p>Hi there.  I see that you're a guest to this site, in order to get the best experience out of ". SITE_NAME .", you must be registered.  Registering is totally free and requires only a few minutes of your time, we promise!  If you're interested, you can register <a href='login.php?do=reg'>here</a>.</p><p>If you're not a guest, and simply haven't logged in, you may log in <a href='login.php'>here</a>.";
}
else {
if ( !isset ( $_GET['file'] ) )
{
header ( 'HTTP/1.0 404 Not Found' );
die ( 'File not found.' );
}

$File = $_GET['file'];
$Directory = '/home/designht/public_html/dan/1/2/d/';

$File = $Directory . preg_replace ( '#([^\w\d_\-\. ])#', '', $File );

if ( !is_file ( $File ) )
{
header ( 'HTTP/1.0 404 Not Found' );
die ( 'File not found: ' . $File );
}

header ( 'HTTP/1.1 200 OK' );
header ( 'Date: ' . date ( 'D M j G:i:s T Y' ) );
header ( 'Last-Modified: ' . date ( 'D M j G:i:s T Y' ) );
header ( 'Content-Type: application/force-download' );
header ( 'Content-Lenght: ' . (string) ( filesize ( $File ) ) );
header ( 'Content-Transfer-Encoding: Binary' );
header ( 'Content-Disposition: attachment;filename=' . basename ( $File ) );
readfile ( $File );
}
?>

<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<?php echo $msg, $footer; ?>
</body>
</html>[/code]
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.