파일설명부분에 TEXTAREA처리하기 부분해결 그리고 질문!!! > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

파일설명부분에 TEXTAREA처리하기 부분해결 그리고 질문!!! 정보

파일설명부분에 TEXTAREA처리하기 부분해결 그리고 질문!!!

본문

우선 꼭 필요한 코드를 제공해주신 눈까리님께 감사드립니다.
해당글의 댓글 참조=> http://www.sir.co.kr/bbs/tb.php/g4_qa/62230
 
눈까리님께서 제공해주신 소스로 이미지+글, 이미지+글 의 형식으로 갤러리는 드디어 구현하게 되었습니다.
여기서 말한 글 이라함은 메모나 설명의 정도가 아닌 장문의 텍스트형식입니다.
보시면 아시겠지만 파일설명 부분을 글박스로 처리하셔서 사용하기 편하게 되어있습니다.
딱 원하던 기능이지요.
자잘한 버그가 있다던데 다음 사항을 빼고 특별한 버그는 아직 발견되지 않았습니다.
 
1. 해결한 문제
해당코드를 파일출력부분에 넣고 보니 입력땐 문제가 없는데 수정때 "add_file('');\n"; 문이 프린트되며 2개 생성, 테이블망가지는 현상 => board/bbs/wrire.php 의 파일설명부분 강제삭제.
파일#2번 부터 사용함으로써 해결...ㅡ.ㅡ;;

2. 궁금증
write.update.skin.php 에 추가하는 그 코드는 특별히 추가해주지 않아도 정상작동하고 추가시 글 입력할때마다 PHP문들이 잠깐 화면에 지저분하게 노출되던데 용도가???
현재는 이 코드 없이 write.skin.php의 파일출력부분 소스만 사용하여 쓰고 있습니다.
 
3. (중요!) 미해결 문제
파일설명부분에 글 입력시 엔터<br>이 먹지 않아 view페이지에 쭉 나열되는 현상.
=> 이것때문에 일주일째 고생중입니다. 제발 부탁드립니다..ㅠ.ㅡ
 
PHP는 전혀 모르는 짜깁기형 극 초보입니다.
고수님들의 도움이 절실히 필요합니다. 도와주세요. ㅠ.ㅡ
 
 
[현재쓰고 있는 write.skin.php 파일 전문] => <? if ($is_file) { ?> 이부분을 봐주세요.
 
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$g4[path]/lib/cheditor.lib.php");
include_once "$board_skin_path/skin.lib.php";
if ($is_category) {
    $nc_category_location   = "./board.php?bo_table=$bo_table&sca=$sca&sfl=wr_10&stx=";
    $nc_category_option     = get_nc_category_option($bo_table, $sca);
}
if ($w == 'r') $content = '';
?>
<link rel="stylesheet" href="<?=$board_skin_path?>/style.css" type="text/css">
<script src="<?=$g4[editor_path]?>/cheditor.js"></script>
<?=cheditor1('wr_content', $write[wr_content]);?>
<script language="javascript">
// 글자수 제한
var char_min = parseInt(<?=$write_min?>); // 최소
var char_max = parseInt(<?=$write_max?>); // 최대
<? include_once "$board_skin_path/category.data.php"; ?>
</script>
<!-- 김선용 2005.4 - ff(불여우) 에서는 innerhtml 사용시 폼이 <table> 아래에 있으면 인식하지 못합니다. -->
<form name="fwrite" method="post" action="javascript:fwrite_check(document.fwrite);" enctype="multipart/form-data" style="margin:0px;">
<input type=hidden name=null><!-- 삭제하지 마십시오. -->
<input type=hidden name=w        value="<?=$w?>">
<input type=hidden name=bo_table value="<?=$bo_table?>">
<input type=hidden name=wr_id    value="<?=$wr_id?>">
<input type=hidden name=sfl      value="<?=$sfl?>">
<input type=hidden name=stx      value="<?=$stx?>">
<input type=hidden name=spt      value="<?=$spt?>">
<input type=hidden name=sst      value="<?=$sst?>">
<input type=hidden name=sod      value="<?=$sod?>">
<input type=hidden name=page     value="<?=$page?>">
<table width="<?=$width?>" align=center cellpadding=0 cellspacing=0><tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan=2 height=2 bgcolor=#303030></td></tr>
<tr><td style='padding-left:20px' colspan=2 height=38 bgcolor=#3a3a3a><font color="#ffffff">▣ <?=$title_msg?></font></td></tr>
<? if ($is_name) { ?>
<tr>
    <td style='padding-left:20px; height:30px;'>· 이름</td>
    <td><input class=input2 maxlength=20 size=15 name=wr_name itemname="이름" required value="<?=$name?>"></td></tr>
<tr><td colspan=2 height=1 bgcolor=#e7e7e7></td></tr>
<? } ?>
<? if ($is_password) { ?>
<tr>
    <td style='padding-left:20px; height:30px;'>· 패스워드</td>
    <td><input class=input2 type=password maxlength=20 size=15 name=wr_password itemname="패스워드" <?=$password_required?>></td></tr>
<tr><td colspan=2 height=1 bgcolor=#e7e7e7></td></tr>
<? } ?>
<tr>
    <td width=120 style='padding-left:20px; height:30px;'><font color="#ffffff">· 옵션</font></td>
    <td><? if ($is_notice) { ?><input type=checkbox name=notice value="1" <?=$notice_checked?>><font color="#ffffff"> 공지</font><? } ?>
        <?/* if ($is_html) { ?><INPUT onclick="html_auto_br(this);" type=checkbox value="<?=$html_value?>" name="html" <?=$html_checked?>><span class=w_title>HTML</span> <? } */?>
        <input type='hidden' name='html' value='html1'>
        <? if ($is_secret) { ?><input type=checkbox value="secret" name="secret" <?=$secret_checked?>><span class=w_title>비밀글</span> <? } ?>
        <? if ($is_mail) { ?><input type=checkbox value="mail" name="mail" <?=$recv_email_checked?>>답변메일받기 <? } ?> </td></tr>
<tr><td colspan=2 height=1 bgcolor=#e7e7e7></td></tr>
<? if ($is_category) { ?>
<tr>
    <td style='padding-left:20px; height:30px;'>· 분류</td>
    <td>
        <select name=ca_name required itemname="분류" onChange="category_data(this.value,'wr_10');">
            <option value="">선택하세요<?=$category_option?>
        </select>
        <select name="wr_10">
            <option value="">선택하세요</option>
        </select>
    </td>
</tr>
<tr><td colspan=2 height=1 bgcolor=#e7e7e7></td></tr>
<? } ?>
<tr>
    <td style='padding-left:20px; height:30px;'><font color="#ffffff">· 제목</font></td>
    <td><input class=input2 style="width:100%;" name=wr_subject itemname="제목" required value="<?=$subject?>"></td></tr>
<tr><td colspan=2 height=1 bgcolor=#e7e7e7></td></tr>
<tr>
    <td style='padding-left:20px;'><font color="#ffffff">· 내용</font></td>
    <td style='padding:5 0 5 0;'><?=cheditor2('fwrite', 'wr_content', '100%', '200');?></td>
</tr>
<tr><td colspan=2 height=1 bgcolor=#e7e7e7></td></tr>
<? if ($is_file) { ?>
<tr>
    <td style='padding-left:20px; height:30px;'>
<table cellpadding=0 cellspacing=0>
<tr><td style=" padding-top: 10px;" class=small><font color="#ffffff">· 파일 <span onclick="add_file();" style='cursor:pointer;'>+</span> <span onclick="del_file();" style='cursor:pointer;'>-</span></font>
</td></tr>
</table></td>
    <td style='padding:5 0 5 0;'>
<?
if ($w == "u")
{
$sql = "select bf_file, bf_content from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$result = sql_query($sql);
for($i=0; $row=sql_fetch_array($result); $i++){
        if ($row[bf_file])
        {
$file_script .= "<table border=0 width=100% cellpadding=0 cellspacing=0><tr><td colspan=2 class=small><input type='file' class=input2 size=40 name='bf_file[$i]' title='파일 용량 $upload_max_filesize 이하만 업로드 가능'>  <img src='$g4[path]/img00/buy_arr.gif' border=0 align=absmiddle>사진설명란.";
            $file_script .= "<input type='checkbox' name='bf_file_del[$i]' value='1'><a href='{$file[$i][href]}'>{$file[$i][source]}({$file[$i][size]})</a> 파일 삭제</td></tr>";
if ($is_file_content)
$bf_id = "bf_content_{$i}";            
//
//<input class=input2 type=text id='bf_content_{$i} name='bf_content[$i]' value='".addslashes(get_text($row[bf_content]))."'>
$file_script .= "<tr><td width='98%'><textarea id='bf_content_{$i}' name='bf_content[$i]' style='width:100%; word-break:break-all;' rows=3 itemname='내용' required class=input2>".addslashes(get_text($row[bf_content]))."</textarea></td><td width=2% valign=top><a href=javascript:textarea_decrease('bf_content_{$i}',3);><img src='$board_skin_path/img/up.gif' border=0><br><a href=javascript:textarea_original('bf_content_{$i}',3);><img src='$board_skin_path/img/start.gif' border=0><br><a href=javascript:textarea_increase('bf_content_{$i}',3);><img src='$board_skin_path/img/down.gif' border=0></a></td></tr>";
$file_script .= "</table>";
        }
    }
    $file_length = $file[count] - 1;
echo $file_script;
}
if ($file_length < 0)
{
    $run_script .= "add_file('');\n";
    $file_length = 0;
}
?>
<table id="variableFiles" cellpadding=0 cellspacing=0 width=100%></table><?// print_r2($file); ?>
        <script language="JavaScript">
        var flen = 0;
        function add_file(delete_code)
        {
            var upload_count = <?=(int)$board[bo_upload_count]?>;
            if (upload_count && flen >= upload_count)
            {
                alert("이 게시판은 "+upload_count+"개 까지만 파일 업로드가 가능합니다.");
                return;
            }
var temp_html="";
            var objTbl;
            var objRow;
            var objCell;
            if (document.getElementById)
                objTbl = document.getElementById("variableFiles");
            else
                objTbl = document.all["variableFiles"];
            objRow = objTbl.insertRow(objTbl.rows.length);
            objCell = objRow.insertCell(0);
            temp_html = "<table border=0 width=100% cellpadding=0 cellspacing=0><tr><td colspan=2 class=small><input type='file' class=input2 size=40 name='bf_file[]' title='파일 용량 <?=$upload_max_filesize?> 이하만 업로드 가능'>  <img src='<?=$g4[path]?>/img00/buy_arr.gif' border=0 align=absmiddle>사진설명란.";
            if (delete_code)
                temp_html += delete_code;
            else
            {
temp_html += "</td></tr>";
                <? if ($is_file_content) { ?>
                temp_html += "<tr><td width='100%'><textarea id='bf_content_"+flen+"' name='bf_content[]' style='width:100%; word-break:break-all;' rows=3 itemname='내용' required class=input2></textarea></td><td width=15 nowrap valign=top style='padding:2 2 2 2;'><img src='<?=$board_skin_path?>/img/up.gif' onclick=\"textarea_decrease('bf_content_"+flen+"', 3);\" style='cursor:hand;'><BR><img src='<?=$g4[path]?>/img00/space.gif' border=0><img src='<?=$board_skin_path?>/img/start.gif'  onclick=\"textarea_original('bf_content_"+flen+"', 3);\" style='cursor:hand;'><BR><img src='<?=$g4[path]?>/img00/space.gif' border=0><img src='<?=$board_skin_path?>/img/down.gif' onclick=\"textarea_increase('bf_content_"+flen+"', 3);\" style='cursor:hand;'></td></tr>";
                <? } ?>
                ;
            }
objCell.innerHTML = temp_html+"</table><img src='<?=$g4[path]?>/img00/space.gif' border=0 height=5>";
            flen++;
        }
        <?=$run_script; //수정시에 필요한 스크립트?>
        function del_file()
        {
            // file_length 이하로는 필드가 삭제되지 않아야 합니다.
            var file_length = <?=(int)$file_length?>;
            var objTbl = document.getElementById("variableFiles");
            if (objTbl.rows.length - 0 > file_length)
            {
                objTbl.deleteRow(objTbl.rows.length - 1);
                flen--;
            }
        }
        </script></td>
</tr>
<? } ?>
<? if ($is_trackback) { ?>
<tr>
    <td style='padding-left:20px; height:30px;'>· 트랙백주소</td>
    <td><input class=input2 size=50 name=wr_trackback itemname="트랙백" value="<?=$trackback?>">
        <? if ($w=="u") { ?><input class=input2 type=checkbox name="re_trackback" value="1">핑 보냄<? } ?></td>
</tr>
<? } ?>
<? if ($is_norobot) { ?>
<tr>
    <td style='padding-left:20px; height:30px;'>· <?=$norobot_str?></td>
    <td><input class=input2 type=input size=10 name=wr_key itemname="자동등록방지" required>  * 왼쪽의 글자중 <font color="red">빨간글자만</font> 순서대로 입력하세요.</td>
</tr>
<tr><td colspan=2 height=1 bgcolor=#3a3a3a></td></tr>
<? } ?>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td width="100%" height="10" bgcolor="#3a3a3a"></td>
</tr>
<tr>
    <td width="100%" align="center" valign="top">
        <input type=image id="btn_submit" src="<?=$board_skin_path?>/img/btn_write.gif" border=0 accesskey='s'> 
        <a href="./board.php?bo_table=<?=$bo_table?>"><img id="btn_list" src="<?=$board_skin_path?>/img/btn_list.gif" border=0></a></td>
</tr>
</table>
</td></tr></table>
</form>

<script language="javascript">
<?
// 관리자라면 분류 선택에 '공지' 옵션을 추가함
if ($is_admin)
{
    echo "
    if (typeof(document.fwrite.ca_name) != 'undefined')
    {
        document.fwrite.ca_name.options.length += 1;
        document.fwrite.ca_name.options[document.fwrite.ca_name.options.length-1].value = '공지';
        document.fwrite.ca_name.options[document.fwrite.ca_name.options.length-1].text = '공지';
    }";
}
?>
with (document.fwrite) {
    if (typeof(wr_name) != "undefined")
        wr_name.focus();
    else if (typeof(wr_subject) != "undefined")
        wr_subject.focus();
    else if (typeof(wr_content) != "undefined")
        wr_content.focus();
    if (typeof(ca_name) != "undefined")
        if (w.value == "u")
            ca_name.value = "<?=$write[ca_name]?>";
}
function html_auto_br(obj)
{
    if (obj.checked) {
        result = confirm("자동 줄바꿈을 하시겠습니까?\n\n자동 줄바꿈은 게시물 내용중 줄바뀐 곳을<br>태그로 변환하는 기능입니다.");
        if (result)
            obj.value = "html2";
        else
            obj.value = "html1";
    }
    else
        obj.value = "";
}
function fwrite_check(f)
{
    var s = "";
    if (s = word_filter_check(f.wr_subject.value)) {
        alert("제목에 금지단어('"+s+"')가 포함되어있습니다");
        return;
    }
    if (s = word_filter_check(f.wr_content.value)) {
        alert("내용에 금지단어('"+s+"')가 포함되어있습니다");
        return;
    }
    if (char_min > 0 || char_max > 0)
    {
        var cnt = parseInt(document.getElementById('char_count').innerhtml);
        if (char_min > 0 && char_min > cnt)
        {
            alert("내용은 "+char_min+"글자 이상 쓰셔야 합니다.");
            return;
        } else if (char_max > 0 && char_max < cnt)
        {
            alert("내용은 "+char_max+"글자 이하로 쓰셔야 합니다.");
            return;
        }
    }
    if (typeof(f.wr_key) != "undefined") {
        if (hex_md5(f.wr_key.value) != md5_norobot_key) {
            alert("자동등록방지용 빨간글자가 순서대로 입력되지 않았습니다.");
            f.wr_key.focus();
            return;
        }
    }
    <?=cheditor3('wr_content');?>
    f.action = "./write_update.php";
    f.submit();
}
</script>

댓글 전체

아... 신기 하네요. 일주일 내내 삽질만 하다가 백기들고 도움요청하고선... 기다리고 있는데...
의외로 쉽게 해결되어 버렸습니다. ㅠ.ㅡ

앞으로도 비슷한 문제가 생기시는 분들은 보시고 해결하시면 될듯 합니다.
해결은 write.skin.php에서가 아닌, view.skin.php에서 해결 되었습니다.

문제 : 파일설명부분에 글 입력시 엔터<br>이 먹지 않아 view페이지에 쭉 나열되는 현상.
해결 방법 : view.skin.php의
// 파일 출력
        for ($i=0; $i<=count($view[file]); $i++) {
            if ($view[file][$i][view])
                echo $view[file][$i][view] . "<br><br><br>";
                echo $view[file][$i][content]. "<p><br>";
        }
        ?></span>

이 부분에서 echo $view[file][$i][content] 을 echo nl2br($view[file][$i][content]) 로 수정.
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT