k

게시판 리스트에 다운로드 링크 만들기

유재민님이 요청으로 만들었습니다.

bbs/gblist.php파일 3번째 줄에 아래 소스추가
include "./lib/file.lib.php";

185번째 줄부터 189번째 줄 까지 아래와 같이 수정

원본-----------------------------------------------------------------------------------------
for ($k=1; $k<=$cfg[file_count]; $k++) {
&nbsp; &nbsp; &nbsp; &nbsp;if (@preg_match($cfg[image_extension], $row["wr_file".$k])) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$list[$i]["file_image".$k] = "./data/file/$bo_table/" . $row["wr_file".$k];
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
원본 끝--------------------------------------------------------------------------------------

수정-----------------------------------------------------------------------------------------
&nbsp;for ($k=1; $k<=$cfg[file_count]; $k++) {
&nbsp; &nbsp;$wr_file = $row["wr_file".$k];
&nbsp; &nbsp;if ($wr_file) {
&nbsp; &nbsp; &nbsp; &nbsp;if (!(preg_match($cfg[image_extension], $wr_file) || preg_match($cfg[flash_extension], $wr_file) || preg_match($cfg[movie_extension], $wr_file))) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$file[$i]["file_href".$k] = "./?doc=$cfg[bbs_dir]/gbdownload.php&$qstr&wr_id=$row[wr_id]&index=$k";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$file[$i]["download".$k] = $row["wr_file".$k."_download"];
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$file[$i]["size".$k] = get_filesize("./data/file/$bo_table/$wr_file");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$file[$i]["source".$k] = $row["wr_file".$k."_source"];
&nbsp; &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp; &nbsp;if (@preg_match($cfg[image_extension], $row["wr_file".$k])) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$list[$i]["file_image".$k] = "./data/file/$bo_table/" . $row["wr_file".$k];
&nbsp; &nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp;}
수정 끝--------------------------------------------------------------------------------------

그리고 gblist.skin.php 파일에 아래소스 추가하면 게시판 리스트에서 바로 다운로드가 가능합니다..^^
bbs/skin/board/gblist.skin.php

<?if ($file[$i][source1]) {?><a href='<?=$file[$i][file_href1]?>'> 파일1 : <?=$file[$i][source1]?> <?=$file[$i][size1]?></a> 다운로드 : <?=$file[$i][download1]?><?}?>
<?if ($file[$i][source2]) {?><a href='<?=$file[$i][file_href2]?>'> 파일2 : <?=$file[$i][source2]?> <?=$file[$i][size2]?></a> 다운로드 : <?=$file[$i][download2]?><?}?>
|

댓글 9개

좋은 팁이네요~ (y)
JJ.Mando
22년 전
ㅋㅋ멋지군요....
gbdownload.php파일의 아래 부분을 주석 처리하고 해보세요..^^

// 다른곳에서 링크 거는것을 방지하기 위한 코드
//if ("$bo_table|$wr_id" != $HTTP_SESSION_VARS[ss_view]) { alert("값을 제대로 넘겨주세요."); }
22년 전
제경우는 한번 다운받았던 파일은 리스트에서도 다운이 받아지구요.. 그렇지 않은것은 값을 제대로 넣어라고 나와요 ^^;
22년 전
아.. 맞군요 ^^; 못봤어요 저부분은..

근데 역시나 '값을 제대로 넣어주세요' 라는 메세지가 ^^;
조기 위에 보면 3번째 줄 부분을 수정 안해나보군요..^^
22년 전
가자님의 테스트게시판역시.. 설정값을 제대로 넘기라는 메세지가..
22년 전
Fatal error: Call to undefined function: get_filesize() in /home/eric/public_html/drive/bbs/gblist.php on line 191

안되네요 ^^;
$file[$i]["size".$k] = get_filesize("./data/file/$bo_table/$wr_file"); <-- 191번째줄입니다.

어떻게 된건지..
22년 전
정말로 감사합니다.
^______________^/ 언제 술이라도 한잔..
댓글을 작성하시려면 로그인이 필요합니다. 로그인

그누3 팁자료실

+
제목 글쓴이 날짜 조회
22년 전 조회 3,274
22년 전 조회 3,143
22년 전 조회 2,180
22년 전 조회 2,049
22년 전 조회 1,940
22년 전 조회 3,434
22년 전 조회 2,122
22년 전 조회 2,614
22년 전 조회 2,459
22년 전 조회 2,902
22년 전 조회 5,083
22년 전 조회 2,847
22년 전 조회 2,903
22년 전 조회 1,857
22년 전 조회 2,773
22년 전 조회 2,452
22년 전 조회 1,803
22년 전 조회 2,345
22년 전 조회 1,729
천풍
22년 전 조회 1,679
🐛 버그신고