1 : #!/bin/wel¶
2 : ¶
3 : /* file: download.wel¶
4 : ¶
5 : 게시판 파일 다운 프로그램 (author: 서광현)¶
6 : ¶
7 : Copyright (c) 2001/03/25 by Wesoft¶
8 : All Rights Reserved.¶
9 : */¶
10 : ¶
11 : timeout(0);¶
12 : htmlquery("GET");¶
13 : send_cookie= "NO";¶
14 : break_on= 0;¶
15 : if(include("include/board.inc")!=OK) return;¶
16 : ¶
17 : no= val(no);¶
18 : if(no<1)¶
19 : {¶
20 : MSG1= "자료번호 오류";¶
21 : MSG2= "자료 번호가 없거나 잘못되었습니다." ~ BACK_BUTTON;¶
22 : formdump(message_form);¶
23 : return disconnect();¶
24 : }¶
25 : ¶
26 : qstr= "select attfile,fileseq from " ~ mytable ~ " where selno=" ~ no;¶
27 : if( (rt=mysql_getrecord(qstr,"")) < 1 )¶
28 : {¶
29 : if(rt==0)¶
30 : {¶
31 : MSG1= "자료가 없습니다!";¶
32 : MSG2= no ~ "번의 게시물이 삭제되었거나 없습니다!" ~ BACK_BUTTON;¶
33 : formdump(message_form);¶
34 : }¶
35 : return disconnect();¶
36 : }¶
37 : if(attfile!="")¶
38 : {¶
39 : if(fileseq>0) seq= fileseq ~ "-"; else seq= "";¶
40 : download_file= "upload/" ~ db ~ "/" ~ seq ~ attfile; // 저장된 실제 파일명¶
41 : }¶
42 : if(attfile=="" || !fexist(download_file))¶
43 : {¶
44 : MSG1= "다운 로드 오류";¶
45 : MSG2= no ~ "번 게시물은 업로드된 파일이 없습니다!" ~ BACK_BUTTON;¶
46 : formdump(message_form);¶
47 : return disconnect();¶
48 : }¶
49 : ¶
50 : qstr= "update " ~ mytable ~ " set downcnt=downcnt+1 where selno=" ~ no;¶
51 : mysql_query(mysql, qstr); // 다운 횟수 증가¶
52 : ¶
53 : header("Content-type: application/octet-stream");¶
54 : header("Content-disposition: filename="~attfile);¶
55 : header("Pragma: no-cache\nExpires: 0");¶
56 : fdump(download_file); // 파일 출력¶
57 : return disconnect();¶
|