= 1) // 회원이상 다운로드가 가능하다면 { // 다운로드 포인트가 음수이고 회원의 포인트가 0 이거나 작다면 if ($member['mb_point'] + $board['bo_download_point'] < 0) alert('보유하신 포인트('.number_format($member['mb_point']).')가 없거나 모자라서 다운로드('.number_format($board['bo_download_point']).')가 불가합니다.\\n\\n포인트를 적립하신 후 다시 다운로드 해 주십시오.'); // 게시물당 한번만 차감하도록 수정 insert_point($member['mb_id'], $board['bo_download_point'], "{$board['bo_subject']} $wr_id 파일 다운로드", $bo_table, $wr_id, "다운로드"); } set_session($ss_name, TRUE); } // 이미 다운로드 받은 파일인지를 검사한 후 다운로드 카운트 증가 ( SIR 그누위즈 님 코드 제안 ) $ss_name = 'ss_down_'.$bo_table.'_'.$wr_id.'_'.$no; if (!get_session($ss_name)) { // 다운로드 카운트 증가 $sql = " update {$g5['board_file_table']} set bf_download = bf_download + 1 where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$no' "; sql_query($sql); // 다운로드 카운트를 증가시키고 세션을 생성 $_SESSION[$ss_name] = true; } $g5['title'] = '다운로드 > '.conv_subject($write['wr_subject'], 255); //파일명에 한글이 있는 경우 /* if(preg_match("/[\xA1-\xFE][\xA1-\xFE]/", $file['bf_source'])){ // 2015.09.02 날짜의 파이어폭스에서 인코딩된 문자 그대로 출력되는 문제가 발생됨, 2018.12.11 날짜의 파이어폭스에서는 해당 현상이 없으므로 해당 코드를 사용 안합니다. $original = iconv('utf-8', 'euc-kr', $file['bf_source']); // SIR 잉끼님 제안코드 } else { $original = urlencode($file['bf_source']); } */ //$original = urlencode($file['bf_source']); $original = rawurlencode($file['bf_source']); @include_once($board_skin_path.'/download.tail.skin.php'); run_event('download_file_header', $file, $file_exist_check); 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 if (preg_match("/Firefox/i", $_SERVER['HTTP_USER_AGENT'])){ header("content-type: file/unknown"); header("content-length: ".filesize($filepath)); //header("content-disposition: attachment; filename=\"".basename($file['bf_source'])."\""); header("content-disposition: attachment; filename=\"".$original."\""); header("content-description: php generated data"); } 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($fp, round($download_rate * 1024)); flush(); usleep(1000); } fclose ($fp); flush();