그누푸시앱을 위한 그누보드 코어 수정방법(아미나 빌더)
주의사항 : 제시된 줄 수는 그누보드5.2.2버전 기준이므로 빌더 종류나 버전에 따라 줄 수가 다를 수 있고, 내용도 다를 수 있습니다.
그럴때는 해당내용을 직접 찾아주셔야 합니다.
[코어수정]
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------- lib/apms.lib.php파일 --------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
*** 2183번째줄에 아래 함수를 찾음.
// Response Act
function apms_response_act($id) {
*** 이 함수 안에 2247번째줄쯤에 아래 내용을 찾음
switch($row['type']) {
case '1' : $url = G5_SHOP_URL.'/item.php?it_id='.$row['it_id'].$c_id; break;
case '2' : $url = G5_BBS_URL.'/board.php?bo_table='.$row['bo_table'].'&wr_id='.$row['wr_id'].$c_id; break;
case '3' : $url = G5_BBS_URL.'/qaview.php?qa_id='.$row['wr_id']; break;
}
*** 이 내용을 아래 내용으로 바꿈. (또는 case '7' : $url = $row['target_url']; break; <- 이 한줄을 추가함)
switch($row['type']) {
case '1' : $url = G5_SHOP_URL.'/item.php?it_id='.$row['it_id'].$c_id; break;
case '2' : $url = G5_BBS_URL.'/board.php?bo_table='.$row['bo_table'].'&wr_id='.$row['wr_id'].$c_id; break;
case '3' : $url = G5_BBS_URL.'/qaview.php?qa_id='.$row['wr_id']; break;
case '7' : $url = $row['target_url']; break;
}
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//-------------------- bbs/login_check.php파일 ------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
*** 59번째 줄 쯤에 아래의 내용을 찾음
set_session('ss_mb_key', md5($mb['mb_datetime'] . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']));
*** 이 내용 아래에 다음의 한 줄을 추가
if(preg_match("/GNUPUSH/", $_SERVER['HTTP_USER_AGENT'])) sync_device_memb_id_webview_login($mb['mb_id']);
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//------------------ bbs/memo_form_update.php파일 ---------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
*** 62번째줄 쯤에 아래의 내용을 찾음
// 쪽지 INSERT
$sql = " insert into {$g5['memo_table']} ( me_id, me_recv_mb_id, me_send_mb_id, me_send_datetime, me_memo ) values ( '$me_id', '$recv_mb_id', '{$member['mb_id']}', '".G5_TIME_YMDHIS."', '{$_POST['me_memo']}' ) ";
sql_query($sql);
*** 이 내용 다음에 아래의 내용을 추가
send_push_new_memo($recv_mb_id,$member['mb_id'],$_POST['me_memo'],$me_id);
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//---------------- bbs/register_form_update.php파일 -------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
(1) 회원가입시 동기화 처리
*** 293번째줄에 아래 내용을 찾음.
// 메일인증 사용하지 않는 경우에만 로그인
if (!$config['cf_use_email_certify'])
set_session('ss_mb_id', $mb_id);
*** 이 내용을 아래 내용으로 바꿈
// 메일인증 사용하지 않는 경우에만 로그인
if (!$config['cf_use_email_certify']){
set_session('ss_mb_id', $mb_id);
if(preg_match("/GNUPUSH/", $_SERVER['HTTP_USER_AGENT'])) sync_device_memb_id_webview_login($mb_id);
}
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//---------------- bbs/write_comment_update.php파일 -------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
*** 236번째줄쯤
// 포인트 부여
if($is_cmt_point) {
insert_point($member['mb_id'], $board['bo_comment_point'], "{$board['bo_subject']} {$wr_id}-{$comment_id} 댓글쓰기", $bo_table, $comment_id, '댓글');
}
*** 이 내용 다음에 아래의 내용을 추가
$gnu_config = get_gnupushapp_config();
send_push_new_comment($write_table,$bo_table,$board['bo_subject'],$board[$gnu_config['board_grant_c']],$wr_id,$comment_id,$tmp_comment,$tmp_comment_reply,$wr['ca_name'],$wr_secret,$wr_content,$mb_id,$wr_name);
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//-------------- bbs/write_comment_update.page.php파일 -----------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
*** 236번째줄쯤
// 포인트 부여
if($is_cmt_point) {
insert_point($member['mb_id'], $board['bo_comment_point'], "{$board['bo_subject']} {$wr_id}-{$comment_id} 댓글쓰기", $bo_table, $comment_id, '댓글');
}
*** 이 내용 다음에 아래의 내용을 추가
$gnu_config = get_gnupushapp_config();
send_push_new_comment($write_table,$bo_table,$board['bo_subject'],$board[$gnu_config['board_grant_c']],$wr_id,$comment_id,$tmp_comment,$tmp_comment_reply,$wr['ca_name'],$wr_secret,$wr_content,$mb_id,$wr_name);
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//-------------------- bbs/write_update.php파일 -----------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
(1) 첨부파일 로직을 위한 수정
*** 약 541번째줄에 아래의 내용을 찾음.
// 파일개수 체크
$file_count = 0;
$upload_count = count($_FILES['bf_file']['name']);
*** 이 줄 위에 아래의 내용을 추가
if(preg_match("/GNUPUSH/", $_SERVER['HTTP_USER_AGENT']) && $rnum = get_session('gnupushapp_file_up') && !preg_match("/GNUPUSHIPHONE/", $_SERVER['HTTP_USER_AGENT'])){
$rnum = get_session('gnupushapp_file_up');
$file_count = 0;
$query = "select bf_no,bf_file from {$g5['board_file_table']} where bf_rstring = '{$rnum}'";
$wr_p = sql_query($query);
for ($i=0; $row_p=sql_fetch_array($wr_p); $i++)
{
if($row_p['bf_file']){
$file_count++;
}
}
sql_query(" update {$write_table} set wr_file = '$file_count' where wr_id = '{$wr_id}' ");
$gnupushapp_file_wr_id = get_session('gnupushapp_file_wr_id');
$query = "select * from {$g5['board_file_table']} where bf_rstring = '{$rnum}' ";
$wr_p = sql_query($query);
for ($i=0; $row=sql_fetch_array($wr_p); $i++)
{
if($w != 'u') {
//해당 file DB값을 토대로 새로운 wr_id값으로 새로 넣는다.
$sql = " insert into {$g5['board_file_table']}
set bo_table = '{$bo_table}',
wr_id = '{$wr_id}',
bf_no = '{$row['bf_no']}',
bf_source = '{$row['bf_source']}',
bf_file = '{$row['bf_file']}',
bf_content = '{$row['bf_content']}',
bf_download = '{$row['bf_download']}',
bf_filesize = '{$row['bf_filesize']}',
bf_width = '{$row['bf_width']}',
bf_height = '{$row['bf_height']}',
bf_type = '{$row['bf_type']}',
bf_datetime = '{$row['bf_datetime']}',
bf_rstring = '{$row['bf_rstring']}' ";
}else{
//해당 file DB값을 토대로 새로운 wr_id값으로 새로 넣거나 기존 bf_no가 있으면 덮어쓰기 한다.
if($row['wr_id'] == $gnupushapp_file_wr_id){
$query = "select count(*) as cnt from {$g5['board_file_table']}
where bo_table = '{$bo_table}'
and wr_id = '{$wr_id}'
and bf_no = '{$row['bf_no']}' ";
$row_dd = sql_fetch($query);
//기존 파일db가 있으면 덮어쓰기
if($row_dd['cnt'] > 0){
$sql = " update {$g5['board_file_table']}
set bf_source = '{$row['bf_source']}',
bf_file = '{$row['bf_file']}',
bf_content = '{$row['bf_content']}',
bf_download = '{$row['bf_download']}',
bf_filesize = '{$row['bf_filesize']}',
bf_width = '{$row['bf_width']}',
bf_height = '{$row['bf_height']}',
bf_type = '{$row['bf_type']}',
bf_datetime = '{$row['bf_datetime']}',
bf_rstring = '{$row['bf_rstring']}'
where bo_table = '{$bo_table}'
and wr_id = '{$wr_id}'
and bf_no = '{$row['bf_no']}' ";
}else{
//기존 파일 DB가 없으므로 새로 insert
$sql = " insert into {$g5['board_file_table']}
set bo_table = '{$bo_table}',
wr_id = '{$wr_id}',
bf_no = '{$row['bf_no']}',
bf_source = '{$row['bf_source']}',
bf_file = '{$row['bf_file']}',
bf_content = '{$row['bf_content']}',
bf_download = '{$row['bf_download']}',
bf_filesize = '{$row['bf_filesize']}',
bf_width = '{$row['bf_width']}',
bf_height = '{$row['bf_height']}',
bf_type = '{$row['bf_type']}',
bf_datetime = '{$row['bf_datetime']}',
bf_rstring = '{$row['bf_rstring']}' ";
}
}
}
sql_query($sql);
}
$sql = " delete from {$g5['board_file_table']}
where bo_table = '{$bo_table}'
and wr_id = '{$gnupushapp_file_wr_id}' ";
sql_query($sql);
set_session('gnupushapp_file_up', '');
// 파일의 개수를 게시물에 업데이트 한다.
$row = sql_fetch(" select count(*) as cnt from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ");
}else{
*** 그 다음에 850번째줄쯤 보면 아래의 내용을 찾음.
// 파일의 개수를 게시물에 업데이트 한다.
$row = sql_fetch(" select count(*) as cnt from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ");
sql_query(" update {$write_table} set wr_file = '{$row['cnt']}' where wr_id = '{$wr_id}' ");
*** 이 다음줄에 } 를 추가 그래서 아래와 같이 됨.
// 파일의 개수를 게시물에 업데이트 한다.
$row = sql_fetch(" select count(*) as cnt from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ");
sql_query(" update {$write_table} set wr_file = '{$row['cnt']}' where wr_id = '{$wr_id}' ");
}
**************************************************************************
(2) 새글,답글 푸시 알림을 위한 로직 추가
*** 856번째줄쯤 아래의 내용을 찾는다.
// 자동저장된 레코드를 삭제한다.
sql_query(" delete from {$g5['autosave_table']} where as_uid = '{$uid}' ");
//------------------------------------------------------------------------------
*** 이 다음줄에 아래의 내용을 추가
if($w == '' || $w == 'r') {
$gnu_config = get_gnupushapp_config();
send_push_new_post($write_table,$bo_table,$board['bo_subject'],$board[$gnu_config['board_grant_c']],$wr_id,$wr_num,$wr_reply,$ca_name,$secret,get_text(stripslashes($wr_subject)),conv_unescape_nl(stripslashes($wr_content)),$member['mb_id'],$wr_name,$row['cnt']);
}
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//-------------------- bbs/qawrite_update.php파일 ----------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
(1) 문자알림시 푸시앱 사용자에게는 문자대신 푸시 알림 가게 하기
*** 343번째 줄에 아래 내용을 찾음
// SMS 알림
if($config['cf_sms_use'] == 'icode' && $qaconfig['qa_use_sms']) {
*** 이 내용을 아래의 내용으로 바꿈!!!
$go_sms = true;
$thumb_src = "none";
if($upload[1]['file']){
$thumb_src = $upload[1]['file'];
}else if($upload[2]['file']){
$thumb_src = $upload[2]['file'];
}
if($w == '' || $w == 'r') {
if($config['as_admin']){
$mb_tmp = $config['cf_admin'].','.$config['as_admin'];
$mb_arr = explode(",", $mb_tmp);
$mb_arr = array_values(array_unique($mb_arr));
for($igg=0; $igg < count($mb_arr); $igg++) {
$ex_md_id = check_device_exist($mb_arr[$igg],"notice");
if($ex_md_id){
$go_sms = false;
send_push_new_qa($w,$qa_id,get_text(stripslashes($qa_subject)),conv_unescape_nl(stripslashes($qa_content)),$member['mb_id'],$mb_arr[$igg],$qaconfig['qa_title'],$thumb_src,$member['mb_nick']);
}
}
}else{
$ex_md_id = check_device_exist($config['cf_admin'],"notice");
if($ex_md_id){
$go_sms = false;
send_push_new_qa($w,$qa_id,get_text(stripslashes($qa_subject)),conv_unescape_nl(stripslashes($qa_content)),$member['mb_id'],$config['cf_admin'],$qaconfig['qa_title'],$thumb_src,$member['mb_nick']);
}
}
}elseif($w == 'a') {
$ex_md_id = check_device_exist($write['mb_id'],"myreply");
if($ex_md_id){
$go_sms = false;
send_push_new_qa($w,$qa_id,get_text(stripslashes($qa_subject)),conv_unescape_nl(stripslashes($qa_content)),$config['cf_admin'],$write['mb_id'],$qaconfig['qa_title'],$thumb_src,$member['mb_nick']);
}
}
// SMS 알림
if($go_sms && $config['cf_sms_use'] == 'icode' && $qaconfig['qa_use_sms']) {
-----------------------------------------------------------------------------
코어수정 끝
-----------------------------------------------------------------------------
[스킨 수정]
//-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------//
//----------------------- skin/board/basic/write.skin.php파일 -----------------------//
//-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------//
(1) 모바일 새글 쓰기 할 때 첨부파일 동작위한 수정 1
*** 최상단부분에 아래의 내용을 찾음.
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
*** 이 다음줄에 아래의 내용 추가
if(preg_match("/GNUPUSH/", $_SERVER['HTTP_USER_AGENT']) && !preg_match("/GNUPUSHIPHONE/", $_SERVER['HTTP_USER_AGENT'])){
$rnum = get_random_string_gnu('10');
$sql = " select MAX(gf_ix) as cnt from g5_gnupushapp_file_num ";
$row = sql_fetch($sql);
$gnupushapp_file_wr_id = $row['cnt'];
$gnupushapp_file_wr_id++;
$gnupushapp_file_wr_id = $gnupushapp_file_wr_id * (-1);
sql_query(" INSERT INTO g5_gnupushapp_file_num
SET `gf_rnum` = '{$rnum}'
", true);
set_session('gnupushapp_file_up', $rnum);
set_session('gnupushapp_file_bo_table', $bo_table);
set_session('gnupushapp_file_img_src', '');
set_session('gnupushapp_file_count', '');
set_session('gnupushapp_file_source', '');
set_session('gnupushapp_file_size','');
set_session('gnupushapp_file_wr_id',$gnupushapp_file_wr_id);
set_session('gnupushapp_file_w',$w);
if($w == 'u'){
set_session('gnupushapp_file_original_wr_id',$wr_id);
}
}
*************************************************************************
(2) 모바일 새글 쓰기 할 때 첨부파일 동작위한 수정 2
*** form 중간부분 233번째 줄에 첨부파일 부분을 찾음
<?php if ($is_file) { ?>
<style>
#variableFiles { width:100%; margin:0; border:0; }
#variableFiles td { padding:0px 0px 7px; border:0; }
#variableFiles input[type=file] { box-shadow : none; border: 1px solid #ccc !important; outline:none; }
#variableFiles .form-group { margin-left:0; margin-right:0; margin-bottom:7px; }
#variableFiles .checkbox-inline { padding-top:0px; font-weight:normal; }
</style>
*** 이 부분 아래의 아래의 내용을 추가
<?php
// 그누푸시앱 첨부파일
if(preg_match("/GNUPUSH/", $_SERVER['HTTP_USER_AGENT']) && !preg_match("/GNUPUSHIPHONE/", $_SERVER['HTTP_USER_AGENT'])){
$upload_max_filesize_m = number_format(floor($board['bo_upload_size'] / 1000000)) . 'MB';
if($w == 'u'){
$file_num = $write['wr_file']."/".$file_count;
}else{
$file_num = "0/".$file_count;
}
?>
<div class="form-group">
<label class="col-sm-2 control-label">첨부파일</label>
<div class="col-sm-10">
<div id="file_status">파일 허용 용량 : 개당 <?php echo $upload_max_filesize_m ?> / 파일 개수 <?php echo $file_num ?></div>
<button type="button" onclick="window.Android.open('<?php echo $rnum ?>');" class="btn btn-sm btn-color"><i class="fa fa-plus-circle fa-lg"></i> 파일선택</button>
</div>
</div>
<div class="form-group" style="margin-bottom:0;">
<div class="col-sm-10 col-sm-offset-2">
<table id="variableFiles"><tbody>
<tr>
<td>
<ul id="files" style="padding: 0px; margin-left: 0px;">
<?php
if($w =='u'){
$sql = " update {$g5['board_file_table']}
set bf_rstring = '{$rnum}'
where bo_table = '{$bo_table}'
and wr_id = '{$wr_id}' ";
sql_query($sql);
}
for ($i=0; $is_file && $i<$file_count; $i++) {
if($w == 'u' && $file[$i]['file']) {
$file_no = $i;
$ext = substr($file[$i]['source'], -4);
$ext = strtolower($ext);
$extImg = in_array($ext, array('.jpg', 'jpeg', '.gif', '.png'));
if($extImg){
$image_src = G5_DATA_URL.'/file/'.$bo_table.'/'.urlencode($file[$i]['file']);
?>
<li id="file_<?php echo $file_no ?>" style="margin:10 0;list-style:none;display:list-item"><img src="<?php echo $image_src ?>" width="50" height="50"><?php echo $file[$i]['source'].'('.$file[$i]['size'].')'; ?> <button type="button" onclick="window.Android.delete('<?php echo $file_no ?>');" class="btn_frmline">삭제</button><br><br></li>
<?php }else{ ?>
<li id="file_<?php echo $file_no ?>" style="margin:10 0;list-style:none;display:list-item"><?php echo $file[$i]['source'].'('.$file[$i]['size'].')'; ?> <button type="button" onclick="window.Android.delete('<?php echo $file_no ?>');" class="btn_frmline">삭제</button><br><br></li>
<?php } }else{ ?>
<li id="file_<?php echo $i ?>" style="margin:10 0;list-style:none;display:none"></li>
<?php
} }
?>
</ul>
</td></tr>
</tbody></table>
</div>
</div>
<?php
}else{
?>
*** 378번째 줄에 아래의 내용을 찾음
function del_file() {
// file_length 이하로는 필드가 삭제되지 않아야 합니다.
var file_length = <?php echo (int)$file_length; ?>;
var objTbl = document.getElementById("variableFiles");
if (objTbl.rows.length - 1 > file_length) {
objTbl.deleteRow(objTbl.rows.length - 1);
flen--;
}
}
</script>
*** 이 다음 줄에 아래의 내용 추가
<?php } ?>
***********************************************************************************
(3) 모바일 새글 쓰기 할 때 첨부파일 동작위한 수정 3
*** 하단부분에 </form>끝나는 부분 또는 <script>부분 바로 위에 아래의 내용을 추가함
<?php if(preg_match("/GNUPUSH/", $_SERVER['HTTP_USER_AGENT']) && !preg_match("/GNUPUSHIPHONE/", $_SERVER['HTTP_USER_AGENT'])){ ?>
<iframe id="iframe_dd" name="iframe_dd" src="" style="position:absolute; top:-9999px; left:-9999px" border=0></iframe>
<?php } ?>
***********************************************************************************
(4) 모바일 새글 쓰기 할 때 첨부파일 동작위한 수정 4
*** <script>부분에 아래의 함수들을 추가해줌.
function aftermobileFileUpload(file_no,fileSize,sourceFilename,download_url,bf_no){
var file_count = "<?php echo $file_count;?>";
var file_no_b = Number(file_no) + 1;
var c = '파일 허용 용량 : 개당 <?php echo $upload_max_filesize_m ?> / 파일 개수 '+ file_no_b + '/'+file_count;
$("#file_status").empty();
$("#file_status").append(c);
var b="";
var type = isImage(sourceFilename);
var ext = getExtension(sourceFilename);
var res = sourceFilename.substring(0, 12);
var final_sourcefilename = res + "···."+ext;
if(type=="img"){
b+='<div style="border:1px solid #ccc;overflow: hidden;margin-bottom:15px"><div style="float:left;height:80px;background-color: #eee;border-right:1px solid #ccc;padding-left:10px;padding-right:10px;padding-top:30px;">파일 '+bf_no+'</div><div style="margin-left:10px;height:80px;padding: 5px 10px;overflow: hidden"><img src="'+download_url+'" width="50" height="50"><br>'+final_sourcefilename+'('+fileSize+') <button type="button" onclick="window.Android.delete('+bf_no+');" class="btn_frmline">삭제</button></div></div>';
}else{
b+='<div style="border:1px solid #ccc;overflow: hidden;margin-bottom:15px"><div style="float:left;height:40px;background-color: #eee;border-right:1px solid #ccc;padding: 10px 10px;">파일 '+bf_no+'</div><div style="margin-left:10px;height:40px;padding: 10px 10px;overflow: hidden">'+final_sourcefilename+'('+fileSize+') <button type="button" onclick="window.Android.delete('+bf_no+');" class="btn_frmline">삭제</button></div></div>';
}
$("#file_"+bf_no).append(b);
$("#file_"+bf_no).css("display","list-item");
}
function del_re(a){
$('#file_'+ a).empty();
$("#file_"+a).css("display","none");
var str = $("#file_status").text();
var arrayStr = str.split("/");
var num = arrayStr[1].substr(-1, 1);
var file_count = "<?php echo $file_count;?>";
var file_no_b = Number(num) - 1;
var c = arrayStr[0]+' / 파일 개수 '+ file_no_b + '/'+file_count;
$("#file_status").empty();
$("#file_status").append(c);
}
function getExtension(filename) {
var parts = filename.split('.');
return parts[parts.length - 1];
}
function isImage(filename) {
var ext = getExtension(filename);
var retval = 'etc';
switch (ext.toLowerCase()) {
case 'jpg': retval = 'img'; break;
case 'jpeg': retval = 'img'; break;
case 'gif': retval = 'img'; break;
case 'bmp': retval = 'img'; break;
case 'png': retval = 'img'; break;
case 'mp3': retval = 'music'; break;
case 'wav': retval = 'music'; break;
case 'ogg': retval = 'music'; break;
case 'aac': retval = 'music'; break;
case 'webm': retval = 'media'; break;
case 'mp4': retval = 'media'; break;
case 'ogv': retval = 'media'; break;
case 'avi': retval = 'media'; break;
case 'mov': retval = 'media'; break;
case 'mkv': retval = 'media'; break;
}
return retval;
}
------------------------------------------------------------------------------------------
테마 스킨 수정 끝
------------------------------------------------------------------------------------------