게시판 엑셀다운로드 (2018-07-10 수정) 정보
게시판 엑셀다운로드 (2018-07-10 수정)관련링크
본문
막장코더( w3holic ) 님이 올려주신 내용을 조금 정리해보았습니다.
원본 : http://sir.co.kr/g4_skin/81864
참고 : http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=92624
변경된내용
①. excel.php 설정을 변경하지 않아도 가능하도록 변경했습니다.
②. 디비설정을 그누의 dbconfig.php 와 연동되도록 변경했습니다.
1. 그누보드4 / skin / board / basic / _common.php 생성
<?php
include_once "../../../common.php";
?>
2. 그누보드4 / skin / board / basic / list.skin.php 적절한 위치에 아래 코드 추가
<?php if ($admin_href) { ?><a href='<?php echo $board_skin_path; ?>/excel.php?bo_table=<?php echo $bo_table; ?>' target='_blank'>Excel</a><?php } ?>
3. 그누보드4 / skin / board / basic / excel.php 파일 생성
<?php
if (!$is_admin) {
alert("관리자만 접근 가능합니다.");
exit;
}
$excel_down = $g4['table_prefix'] . $_GET['bo_table']; //엑셀 다운로드 테이블
$wr_id = $id = $_GET['wr_id'];
include_once "_common.php";
//@mysql_query("SET CHARACTER SET utf8"); // 한글깨지면 주석해지
if ($ms =="excel"){
$g4[title] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=상품구매.xls" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="power"){
$g4[title] = "파워포인트 문서 다운로드";
header( "Content-type: application/vnd.ms-powerpoint" );
header( "Content-Disposition: attachment; filename=상품구매.ppt" );
// header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="word"){
$g4[title] = "워드 문서 다운로드";
header( "Content-type: application/vnd.ms-word" );
header( "Content-Disposition: attachment; filename=상품구매.doc" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="memo"){
$g4[title] = "메모 문서 다운로드";
header( "Content-type: application/vnd.ms-notepad" );
header( "Content-Disposition: attachment; filename=상품구매.txt" );
} else {
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=상품구매.xls" );
}
header( "Content-Description: PHP4 Generated Data" );
// 원글 + 코멘트 다운로드
$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} "));
$result=sql_query("select * from {$excel_down} order by wr_datetime desc");
// 원글만 다운로드 (코멘트 제외) , 2013-10-21 추가
//$temp=sql_fetch_array(mysql_query("select count(*) from {$excel_down} where wr_is_comment = '0' and wr_content = '{$wr_id}' "));
//$result=sql_query("select * from {$excel_down} where wr_is_comment = '0' and wr_content = '{$wr_id}' order by wr_datetime desc");
$number=$temp[0];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.txt {mso-number-format:'\@'}
</style>
</head>
<body>
<table>
<tr>
<td>번호</td>
<td>제목</td>
<td>아이디</td>
<td>이름</td>
<td>작성일</td>
<td>필드1</td>
<td>필드2</td>
<td>필드3</td>
<td>필드4</td>
<td>필드5</td>
<td>필드6</td>
<td>필드7</td>
<td>필드8</td>
<td>필드9</td>
<td>필드10</td>
</tr>
<?php
while($data=sql_fetch_array($result)) {
echo "
<tr>
<td>{$number}</td>
<td>{$data['wr_subject']}</td>
<td>{$data['mb_id']}</td>
<td>{$data['wr_name']}</td>
<td class='txt'>{$data['wr_datetime']}</td>
<td class='txt'>{$data['wr_1']}</td>
<td class='txt'>{$data['wr_2']}</td>
<td class='txt'>{$data['wr_3']}</td>
<td class='txt'>{$data['wr_4']}</td>
<td class='txt'>{$data['wr_5']}</td>
<td class='txt'>{$data['wr_6']}</td>
<td class='txt'>{$data['wr_7']}</td>
<td class='txt'>{$data['wr_8']}</td>
<td class='txt'>{$data['wr_9']}</td>
<td class='txt'>{$data['wr_10']}</td>
</tr>
";
$number--;
}
?>
</table>
</body>
</html>
원본 : http://sir.co.kr/g4_skin/81864
참고 : http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=92624
변경된내용
①. excel.php 설정을 변경하지 않아도 가능하도록 변경했습니다.
②. 디비설정을 그누의 dbconfig.php 와 연동되도록 변경했습니다.
1. 그누보드4 / skin / board / basic / _common.php 생성
<?php
include_once "../../../common.php";
?>
2. 그누보드4 / skin / board / basic / list.skin.php 적절한 위치에 아래 코드 추가
<?php if ($admin_href) { ?><a href='<?php echo $board_skin_path; ?>/excel.php?bo_table=<?php echo $bo_table; ?>' target='_blank'>Excel</a><?php } ?>
3. 그누보드4 / skin / board / basic / excel.php 파일 생성
<?php
if (!$is_admin) {
alert("관리자만 접근 가능합니다.");
exit;
}
$excel_down = $g4['table_prefix'] . $_GET['bo_table']; //엑셀 다운로드 테이블
$wr_id = $id = $_GET['wr_id'];
include_once "_common.php";
//@mysql_query("SET CHARACTER SET utf8"); // 한글깨지면 주석해지
if ($ms =="excel"){
$g4[title] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=상품구매.xls" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="power"){
$g4[title] = "파워포인트 문서 다운로드";
header( "Content-type: application/vnd.ms-powerpoint" );
header( "Content-Disposition: attachment; filename=상품구매.ppt" );
// header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="word"){
$g4[title] = "워드 문서 다운로드";
header( "Content-type: application/vnd.ms-word" );
header( "Content-Disposition: attachment; filename=상품구매.doc" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="memo"){
$g4[title] = "메모 문서 다운로드";
header( "Content-type: application/vnd.ms-notepad" );
header( "Content-Disposition: attachment; filename=상품구매.txt" );
} else {
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=상품구매.xls" );
}
header( "Content-Description: PHP4 Generated Data" );
// 원글 + 코멘트 다운로드
$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} "));
$result=sql_query("select * from {$excel_down} order by wr_datetime desc");
// 원글만 다운로드 (코멘트 제외) , 2013-10-21 추가
//$temp=sql_fetch_array(mysql_query("select count(*) from {$excel_down} where wr_is_comment = '0' and wr_content = '{$wr_id}' "));
//$result=sql_query("select * from {$excel_down} where wr_is_comment = '0' and wr_content = '{$wr_id}' order by wr_datetime desc");
$number=$temp[0];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.txt {mso-number-format:'\@'}
</style>
</head>
<body>
<table>
<tr>
<td>번호</td>
<td>제목</td>
<td>아이디</td>
<td>이름</td>
<td>작성일</td>
<td>필드1</td>
<td>필드2</td>
<td>필드3</td>
<td>필드4</td>
<td>필드5</td>
<td>필드6</td>
<td>필드7</td>
<td>필드8</td>
<td>필드9</td>
<td>필드10</td>
</tr>
<?php
while($data=sql_fetch_array($result)) {
echo "
<tr>
<td>{$number}</td>
<td>{$data['wr_subject']}</td>
<td>{$data['mb_id']}</td>
<td>{$data['wr_name']}</td>
<td class='txt'>{$data['wr_datetime']}</td>
<td class='txt'>{$data['wr_1']}</td>
<td class='txt'>{$data['wr_2']}</td>
<td class='txt'>{$data['wr_3']}</td>
<td class='txt'>{$data['wr_4']}</td>
<td class='txt'>{$data['wr_5']}</td>
<td class='txt'>{$data['wr_6']}</td>
<td class='txt'>{$data['wr_7']}</td>
<td class='txt'>{$data['wr_8']}</td>
<td class='txt'>{$data['wr_9']}</td>
<td class='txt'>{$data['wr_10']}</td>
</tr>
";
$number--;
}
?>
</table>
</body>
</html>
추천
7
7
댓글 30개
감사합니다~
감사합니다.
사용후기 ..
제가 설정 후 적용 결과
" 을(를) 다운로드할 수 없습니다.
이 인터넷 사이트를 열 수 없습니다. 요청한 사이트를 사용할 수 없거나 찾을 수 없습니다. 나중에 다시 시도하십시오.
라는 에러가 나오네요 혹시 비슷하신 분 있으신가요~^?^
제가 설정 후 적용 결과
" 을(를) 다운로드할 수 없습니다.
이 인터넷 사이트를 열 수 없습니다. 요청한 사이트를 사용할 수 없거나 찾을 수 없습니다. 나중에 다시 시도하십시오.
라는 에러가 나오네요 혹시 비슷하신 분 있으신가요~^?^
익스8이상에서는 되네요 죄송합니다.ㅎ
감사합니다 찾건던데
게시판엑셀다운로드
제가 설정 후 적용 결과
" 을(를) 다운로드할 수 없습니다.
이 인터넷 사이트를 열 수 없습니다. 요청한 사이트를 사용할 수 없거나 찾을 수 없습니다. 나중에 다시 시도하십시오.
저두 그런데요..ㅠ.ㅠ 왜그러지..그대로 했는데..;..
" 을(를) 다운로드할 수 없습니다.
이 인터넷 사이트를 열 수 없습니다. 요청한 사이트를 사용할 수 없거나 찾을 수 없습니다. 나중에 다시 시도하십시오.
저두 그런데요..ㅠ.ㅠ 왜그러지..그대로 했는데..;..
저는 한글도 깨지는데..왜그럴까요??
일단 추천후 스크랩~
덕분에 쉽게 해결했네요 고맙습니다. ^^
정말 고맙습니다!!!! 제가 딱 바라던 기능이었네요.
그리고 한글 깨지는 분들은 위의 지시대로 excel.php 파일만드실때 자신의 언어셋에 맞춰서 수정해주세요.
가령 euc-kr 쓰시는 분들은
//@mysql_query("SET CHARACTER SET utf8"); // 한글깨지면 주석해지
이 부분 앞의 //을 지워 주석해지후 utf8 을 euc-kr로 수정, 그리고
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
이부분의 utf-8 을 euc-kr로 수정해서 쓰시면 정상출력됩니다.
그리고 한글 깨지는 분들은 위의 지시대로 excel.php 파일만드실때 자신의 언어셋에 맞춰서 수정해주세요.
가령 euc-kr 쓰시는 분들은
//@mysql_query("SET CHARACTER SET utf8"); // 한글깨지면 주석해지
이 부분 앞의 //을 지워 주석해지후 utf8 을 euc-kr로 수정, 그리고
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
이부분의 utf-8 을 euc-kr로 수정해서 쓰시면 정상출력됩니다.
정보감사 필요해서 적용해보니
다운 정상으로 됩니다 출력도 한글로 필드1 필드2 나오구여 문제
게시글쓴 제목 내용이 빈칸으로 나오네요
db추가 해야 하나여? 알려주시면 ㄳ
www/kt5/skin/board/basic/excel.php on line 73 에러
<?
while($data=mysql_fetch_array($result)) {
echo "
<tr>
<td>$number</td>
<td>$data[wr_subject]</td>
<td>$data[mb_id]</td>
<td>$data[wr_name]</td>
<td class='txt'>$data[wr_datetime]</td>
<td class='txt'>$data[wr_1]</td>
<td class='txt'>$data[wr_2]</td>
<td class='txt'>$data[wr_3]</td>
<td class='txt'>$data[wr_4]</td>
<td class='txt'>$data[wr_5]</td>
<td class='txt'>$data[wr_6]</td>
<td class='txt'>$data[wr_7]</td>
<td class='txt'>$data[wr_8]</td>
<td class='txt'>$data[wr_9]</td>
<td class='txt'>$data[wr_10]</td>
</tr>
";
$number--;
}
?>
카페24
다운 정상으로 됩니다 출력도 한글로 필드1 필드2 나오구여 문제
게시글쓴 제목 내용이 빈칸으로 나오네요
db추가 해야 하나여? 알려주시면 ㄳ
www/kt5/skin/board/basic/excel.php on line 73 에러
<?
while($data=mysql_fetch_array($result)) {
echo "
<tr>
<td>$number</td>
<td>$data[wr_subject]</td>
<td>$data[mb_id]</td>
<td>$data[wr_name]</td>
<td class='txt'>$data[wr_datetime]</td>
<td class='txt'>$data[wr_1]</td>
<td class='txt'>$data[wr_2]</td>
<td class='txt'>$data[wr_3]</td>
<td class='txt'>$data[wr_4]</td>
<td class='txt'>$data[wr_5]</td>
<td class='txt'>$data[wr_6]</td>
<td class='txt'>$data[wr_7]</td>
<td class='txt'>$data[wr_8]</td>
<td class='txt'>$data[wr_9]</td>
<td class='txt'>$data[wr_10]</td>
</tr>
";
$number--;
}
?>
카페24
전체 게시물이 엑셀다운하지 않고 내용보기에서 보고있는 게시물만 엑셀 다운하려면 어떻게 해야 하는지요?
감사합니다.
감사합니다.
게시판 엑셀다운로드
지금까지 아무 생각없이 잘 사용했는데
개인정보가 들어가 있는 게시판일 경우 따로 권한을 줘야 된다는 생각이 들어서
아래처럼 수정해서 사용중입니다.
스킨폴더에 _common.php 파일이 있으니
excel.php파일 상단에
include_once('./_common.php');
if(!$is_admin) { alert("접근금지!"); exit(); }
추가하고
include "../../../dbconfig.php"; 는 주석처리~
요렇게 사용중입니다~^^
개인정보가 들어가 있는 게시판일 경우 따로 권한을 줘야 된다는 생각이 들어서
아래처럼 수정해서 사용중입니다.
스킨폴더에 _common.php 파일이 있으니
excel.php파일 상단에
include_once('./_common.php');
if(!$is_admin) { alert("접근금지!"); exit(); }
추가하고
include "../../../dbconfig.php"; 는 주석처리~
요렇게 사용중입니다~^^
좋은 아이디어입니다.
코멘트를 뺀 원글만 다운로드 받고자 한다면...
$temp=mysql_fetch_array(mysql_query("select count(*) from $excel_down ")); //where wr_is_comment = '0' and wr_content = '$wr_id' "));
$result=@mysql_query("select * from $excel_down order by wr_datetime desc");// where wr_is_comment = '0' and wr_content = '$wr_id' order by wr_datetime desc");
를 아래와 같이 변경하세요
$temp=mysql_fetch_array(mysql_query("select count(*) from $excel_down where wr_is_comment = '0' and wr_content = '$wr_id' "));
$result=@mysql_query("select * from $excel_down where wr_is_comment = '0' and wr_content = '$wr_id' order by wr_datetime desc");
$temp=mysql_fetch_array(mysql_query("select count(*) from $excel_down ")); //where wr_is_comment = '0' and wr_content = '$wr_id' "));
$result=@mysql_query("select * from $excel_down order by wr_datetime desc");// where wr_is_comment = '0' and wr_content = '$wr_id' order by wr_datetime desc");
를 아래와 같이 변경하세요
$temp=mysql_fetch_array(mysql_query("select count(*) from $excel_down where wr_is_comment = '0' and wr_content = '$wr_id' "));
$result=@mysql_query("select * from $excel_down where wr_is_comment = '0' and wr_content = '$wr_id' order by wr_datetime desc");
코멘트 제외하고 원글만 받고자 하는 경우로 하게되면.... 아예 아무것도 엑셀로 다운이 안되네요;
코멘트 뿐만아니라 원글도 저장안됩니다ㅠ
코멘트 뿐만아니라 원글도 저장안됩니다ㅠ
감사합니다.
원본 링크가 잘못 돼 있어서 이름검색 링크 새로 걸어 둡니다
http://sir.co.kr/g4_skin/81864?sfl=wr_name%2C1&stx=w3holic
막장코더님의 원본
http://sir.co.kr/g4_skin/81864?sfl=wr_name%2C1&stx=w3holic
막장코더님의 원본
넵 감사합니다. 관련링크 수정하겠습니다.
왜 이렇게 될까요?
g4는 이제 사용을 안해서 테스트 계획이 없습니다. -_-''
감사합니다.
저 왜이렇게 나오는걸까요? ㅠㅠ
Warning: include(/test/data/dbconfig.php): failed to open stream: No such file or directory in /home/hosting_users/onad4053/www/test/theme/shoes/skin/board/timer/excel.php on line 5 Warning: include(): Failed opening '/test/data/dbconfig.php' for inclusion (include_path='.:/usr/local/php53/lib/php') in /home/hosting_users/onad4053/www/test/theme/shoes/skin/board/timer/excel.php on line 5 Warning: mysql_connect(): Access denied for user 'onad4053'@'localhost' (using password: NO) in /home/hosting_users/onad4053/www/test/theme/shoes/skin/board/timer/excel.php on line 6 �쒕쾭�� �묒냽�섏� 紐삵뻽�듬땲��.
Warning: include(/test/data/dbconfig.php): failed to open stream: No such file or directory in /home/hosting_users/onad4053/www/test/theme/shoes/skin/board/timer/excel.php on line 5 Warning: include(): Failed opening '/test/data/dbconfig.php' for inclusion (include_path='.:/usr/local/php53/lib/php') in /home/hosting_users/onad4053/www/test/theme/shoes/skin/board/timer/excel.php on line 5 Warning: mysql_connect(): Access denied for user 'onad4053'@'localhost' (using password: NO) in /home/hosting_users/onad4053/www/test/theme/shoes/skin/board/timer/excel.php on line 6 �쒕쾭�� �묒냽�섏� 紐삵뻽�듬땲��.
공개한 소스에는 include(/test/data/dbconfig.php) 가 포함되지 않습니다.
사용하신 내용을 다시 확인해주세요.
또한 data/dbconfig.php 는 그누보드5에서의 해당사항이며
그누보드4는 그 상위폴더에 dbconfig.php 가 존재합니다.
본문 소스를 조금(?) 수정했으니, 내용을 다시 참고해서 사용해보세요
사용하신 내용을 다시 확인해주세요.
또한 data/dbconfig.php 는 그누보드5에서의 해당사항이며
그누보드4는 그 상위폴더에 dbconfig.php 가 존재합니다.
본문 소스를 조금(?) 수정했으니, 내용을 다시 참고해서 사용해보세요
@해피정 그누보도 5에서 적용하긴 했는데...게시글, 댓글 등이 엑셀파일에 보이지는 않네요. 뭔가 다른 설정을 해야 하는지요?
오 필요했던 자료 ㅠㅠ 감사합니다!
$excel_down = $g5['table_prefix'].$_GET['bo_table']; //엑셀 다운로드 테이블
// $excel_down = "g5_write_free"; //엑셀 다운로드 테이블
주석으로 하면 데이터를 가지고 오는데요. 맨 위로 하면 가져오지 못하는데..게시판 이름을 뽑아오지 못하는 것 같은데..어떻게 하면 g5 게시판 g5_write_free 명칭을 뽑아 올 수 있는지요?
// $excel_down = "g5_write_free"; //엑셀 다운로드 테이블
주석으로 하면 데이터를 가지고 오는데요. 맨 위로 하면 가져오지 못하는데..게시판 이름을 뽑아오지 못하는 것 같은데..어떻게 하면 g5 게시판 g5_write_free 명칭을 뽑아 올 수 있는지요?
@라이프게임 그누보드5용은 https://www.happyjung.com/lecture/2851 입니다