/home/mjc1/public_html/j3demo/adm/board_download.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
$no_login 
"Y";
$dir ".";
include_once(
$dir."/_common.php");

$bbsinfo bbs_info($b_table);

$sql "select * from $table_name where idx = '{$idx}' ";
$board_info sql_fetch($sql,$connect_j3);

$sql "select * from shop_bbs_file where b_table = '{$b_table}' and b_idx = '{$idx}' and b_no = '{$b_no}' ";
$file_info sql_fetch($sql,$connect_j3);

$filepath "{$j3_data_path}/bbs/{$b_table}/{$file_info['b_filename']}";
$original iconv("utf-8","euckr",$file_info['b_oriname']);

if(
$_SESSION['id_code']==''){
    if(
$bbsinfo['b_dload_lv']>1){
        
$cinfo customer_info_get($id_ccode); 
        if(
$bbsinfo['b_dload_lv']>$cinfo['mb_lv']){
            
alert('다운로드 권한이 없습니다.'); exit;
        }
    }
}

if(
preg_match("/msie/i"$_SERVER['HTTP_USER_AGENT']) && preg_match("/5\.5/"$_SERVER['HTTP_USER_AGENT'])) {
    
header("content-type: doesn/matter");
    
header("content-length: ".filesize("$filepath"));
    
header("content-disposition: attachment; filename=\"$original\"");
    
header("content-transfer-encoding: binary");
} else {
    
header("content-type: file/unknown");
    
header("content-length: ".filesize("$filepath"));
    
header("content-disposition: attachment; filename=\"$original\"");
    
header("content-description: php generated data");
}
header("pragma: no-cache");
header("expires: 0");
flush();

$fp fopen($filepath'rb');

// 4.00 대체
// 서버부하를 줄이려면 print 나 echo 또는 while 문을 이용한 방법보다는 이방법이...
//if (!fpassthru($fp)) {
//    fclose($fp);
//}

$download_rate 10;

while(!
feof($fp)) {
    
//echo fread($fp, 100*1024);
    /*
    echo fread($fp, 100*1024);
    flush();
    */

    
print fread($fpround($download_rate 1024));
    
flush();
    
usleep(1000);
}
fclose ($fp);
flush();
?>