Jump to content

Php Download System


ColdEdge

Recommended Posts

Hi, I need a download system, with this features.Dosen't display where the download is comming from..If user add's ?dl=45 in the end of something.php?dl=45 then the download of file set to 45 will beginDosen't display original file name instead it shows ?dl=# Dosen't show this in opera ringo.mysite.com <-- where file is comming...If you can't help with ?dl=45 then I need a simple download script that is not MySQL Driven it only checks if user is logged in or not, and hides where the file is comming from and whats its original name is.-Thank You!

Link to comment
Share on other sites

This code does everything you want. It completely hides the original location through the use of a proxy-type mechanism, it looks up the dl querystring variable in a locally generated array (no DB!), the filename becomes the dl number with the extension appended onto it (e.g. downlode.ogg -> 45.ogg), and since all data is passed through the script no hint of the original location gets through. Note - you need the FileInfo extension for the MIME type determination.

<?php$dl = (int) $_GET['dl']; //get the QS varif (empty($_SESSION['user-logged-in'])) die('Not logged in"); //dies if user is not logged in (session-based auth.)$files = array( //List of files and there dl numbers in array form	1 => "file1.exe",	5 => "anotherfile.ppt",	45 => "downlode.ogg");if (!array_key_exists($dl)) die("File doesn't exist"); //Check for valid dl number$qpath = "downloads/{$files[$dl]}"; //qualified path to downloads$finfo = new finfo(FILEINFO_MIME, "/usr/share/misc/magic"); //Determine MIME type, library needed$mime = $finfo->file($qpath);$finfo->close();header("content-type: $mime"); //Set MIME type$ext = array_pop(explode(".", $files[$dl])); //Get extension to append to random file nameheader("Content-Disposition: attachment; filename=\"$dl.$ext\""); //Sends filename as the dl numberreadfile("$qpath"); //Send data through?>

Link to comment
Share on other sites

its mostly .RAR or .ZIP files arent they all ready in cPanel MINE settings? so basicly this is already in my MINE settings...application/zip <- ZIPapplication/x-rar-compressed <- RARand could you help me with a login script? like this one http://www.zymic.com/forum/index.php?showtopic=4034i need something like that login system to work with my script and to be able to use this...

<?phprequire 'db_connect.php';// require our database connection// which also contains the check_login.php// script. We have $logged_in for use.if ($logged_in == 0) {	?><html><head><title>Member Profile</title></head><body>Im sorry, but you must be logged in to view this page!</body></html><?php}else {  ?> <-- seperates 2 pages member only and non-member ^^<html><head><title>Member Profile</title></head><body>Welcome to the members only section!!!</body></html>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...