Thread: Major Additions - DownloadsII
View Single Post
  #2412  
Old 03-07-2008, 03:38 PM
Kingster Kingster is offline
 
Join Date: Jan 2005
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

RS_Jelle, I'd like to provide you some basic code for supporting resumes when downloading...

Keep in mind, I have't converted this as of yet to plug in to the downloads.php but I'm definitely getting ready to, if you choose not to in your next version. I'm dealing with big files (UT3 maps and mods), hitting 20-30M easy, so I need this.

Still looking for RSS support out of your mod, but, I'll not look to solve that if you're working on it. If it's on the "to-do" list with no active work toward it, let me know, and I'll pull something together for that.

Lastly, if you want me to just shut the hell up, let me know.

Here goes for supporting resuming downloads...
PHP Code:
    //  Begin writing headers
    
header("Cache-Control:");
    
header("Cache-Control: public");
    
header("Content-Type: $ctype");
 
    
$filespaces str_replace("_"" "$filename);
    
// if your filename contains underscores, replace them with spaces
 
    
$header='Content-Disposition: attachment; filename='.$filespaces;
    
header($header);
    
header("Accept-Ranges: bytes");
   
    
$size filesize($file); 
    
//  check if http_range is sent by browser (or download manager) 
    
if(isset($_SERVER['HTTP_RANGE'])) {
        
// if yes, download missing part    
 
        
$seek_range substr($_SERVER['HTTP_RANGE'] , 6);
        
$range explode'-'$seek_range);
        if(
$range[0] > 0) { $seek_start intval($range[0]); }
        if(
$range[1] > 0) { $seek_end  =  intval($range[1]); }
          
        
header("HTTP/1.1 206 Partial Content");
        
header("Content-Length: " . ($seek_end $seek_start 1));
        
header("Content-Range: bytes $seek_start-$seek_end/$size");
    } else {
        
header("Content-Range: bytes 0-$seek_end/$size");
        
header("Content-Length: $size");
    } 
    
//open the file
    
$fp fopen("$file","rb");
   
    
//seek to start of missing part 
    
fseek($fp,$seek_start);
 
    
//start buffered download
    
while(!feof($fp)) {  
        
//reset time limit for big files
        
set_time_limit(0);    
        print(
fread($fp,1024*$speed));
        
flush();
        
sleep(1);
    } 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01091 seconds
  • Memory Usage 1,795KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete