[PHP] Download Manager Support

Discussion in 'Programming' started by jags2ooo, Sep 15, 2008.

  1. #1
    In need of a php programmer to fix up a download script too support Pause and Resume from download Managers such as FlashGET.

    Currently if someone pauses then resumes a download they end up with a different amount of bytes causing the file to be corrupted.

    pm me with how much $ you would like to solve this problem.

    Example of the download code

    
    <?
    $time = time();
    $mysql = mysql_connect("zzzzz:3306","zzzz","]zzzz");
    mysql_select_db("zzz_zzzz", $mysql);
    include("../mine-types.php");
    $pass = mysql_fetch_array(mysql_query("SELECT MD5(CONCAT(MD5('{$_SERVER['PHP_AUTH_PW']}'), salt)) as enteredpass, password FROM user WHERE  username = '{$_GET['user']}'"),MYSQL_ASSOC);
    
    
    if (!isset($_SERVER['PHP_AUTH_USER']) ||
         ($pass['enteredpass'] !=$pass['password'])) {
         
        authenticate();
        
    }
    
    	$t = mysql_fetch_array(mysql_query("SELECT * FROM `adl_tickets` WHERE `code` = '{$_GET['code']}' LIMIT 1"),MYSQL_ASSOC);
    
    	if ($t['time'] >= $time-(60*60*24*7*2)){	
    	
    		$db = mysql_fetch_array(mysql_query("SELECT * FROM adl_files WHERE id= '{$_GET['id']}'  LIMIT 1"),MYSQL_ASSOC);
    								
    		$updatedls = mysql_query("INSERT INTO adl_downloads (filename, filesize, username, timestamp) VALUES ('{$db['filename']}','{$db['filesize']}','{$_GET['user']}','{$time}')");
    		$insertdownloads = mysql_query("update adl_files set download_count = ( download_count + 1 ) WHERE id = '{$_GET['id']}' LIMIT 1");
    		
    		$size = $db['filesize'];
    		$mtype=$type[$db['extension']];
    		header('Expires: 0');
    		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    		header("Content-Type: $mtype");
    		header("Accept-Ranges: bytes");
    		header( "Content-Disposition: filename='".$db['filename']."';" );
    		header( 'Content-Disposition: attachment; filename="'.$db['filename'].'"');
    		header("Content-transfer-encoding: binary");
    						
    		if(isset($_SERVER['HTTP_RANGE'])){		
    		
    			list($a, $range) = explode("=",$_SERVER['HTTP_RANGE']);
    			str_replace($range, "-", $range);
    			$size2 = $size-1;
    			$new_length = $size-$range;
    			header("HTTP/1.1 206 Partial Content");
    			header("Content-Length: $new_length");
    			header("Content-Range: bytes $range$size2/$size");
    		
    		}else{
    		
    			header("Content-Length: ".$size);
    			
    		}
    		    
    		readfile("zzzzz/".$db['series']."/".$db['filename']);
        
    	}else{
    	
    		$deleteticket = mysql_query("DELECT FROM adl_tickets WHERE code= '{$_GET['code']}'  LIMIT 1");
    		echo "Sorry, your ticket has expired go back and try to download again. 
    	}
    	
    	
    	function authenticate() {
        header('WWW-Authenticate: Basic realm="zzzz"');
        header('HTTP/1.0 401 Unauthorized');
        echo "You must enter a valid login ID and password to access this resource\n";
        exit;
    }
     
    
    ?>
    
    PHP:
     
    jags2ooo, Sep 15, 2008 IP
  2. Shoro

    Shoro Peon

    Messages:
    143
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Shoro, Sep 15, 2008 IP