var KILHO_COMMENT = 'https://comment.kilho.net'; function addComment(author, comment, regdate, imgUrl) { if(imgUrl === undefined) imgUrl = 'https://kilho.net/wp-content/uploads/2019/05/avatar-85x85.jpg'; var newComment = '
' + comment.replace(/\n/g, '') + '
<\/p>\n\t\t
\n\t\t\t\ub313\uae00 *<\/span><\/label> <\/textarea>\n\t\t<\/p>\n\t\t\n\t\t\t\uc774\ub984 *<\/span><\/label> \n\t\t<\/p>\n\t\t\n\t\t\t\uc774\uba54\uc77c *<\/span><\/label> \n\t\t<\/p>\n\t\t\uc6f9\uc0ac\uc774\ud2b8<\/label> <\/p>\n\t\t\n\t\t\t\ub313\uae00 \ub2ec\uae30<\/button>\n\t\t<\/p>\n\t<\/form>\n<\/div>\n"); /* * 이 위젯에는 로그인이 없다. 댓글은 전부 비회원으로 들어간다(mb_no = NULL). * * 예전에는 kilho.net 워드프레스가 남긴 wordpress_display_name 쿠키로 이름을 * 알아내고, 알아냈으면 이름·이메일 칸을 감췄다. 워드프레스를 떼면서 그 쿠키가 * 없어져 전부 익명이 됐다. * * 2026-08-08 그 자리를 comment.kilho.net 자체 로그인으로 메워 봤다가 도로 * 걷어냈다. 신원을 붙드는 까닭은 보통 "본인만 고치거나 지우게" 하려는 것인데, * 이 댓글은 고치지도 지우지도 못한다 — 사장님이 하나씩 보고 승인한 것만 * 공개된다. 지킬 것이 없는 자리를 지키려고 사람마다 로그인을 시킬 이유가 없다. * * 그래서 옛 방식으로 돌아간다. 쿠키가 이름을 알려 주면 두 칸을 감춘다. * 지금 그 자리를 잇는 것이 인증서버의 kh_nick · kh_no 다. */ /* * kh_nick(이름) · kh_no(회원번호) — 인증서버가 .kilho.net 에 심고(로그인) * 지운다(로그아웃). auth.kilho.net 의 config.php MB_HINT_COOKIE · MB_HINT_NO_COOKIE * · lib/session.php. httponly 를 일부러 꺼 두어 제휴 사이트 JS 가 읽게 만든 * 값이고, 한글이 들어가므로 setcookie() 가 URL 인코딩한 것을 여기서 푼다. * * 서명이 없어 고쳐 쓸 수 있다. 그래도 잃을 것이 없다 — mb_no 는 붙지 않고, * 모든 댓글이 승인 대기(status=0)를 지나 사장님 눈을 거친 뒤에야 보인다. * 서버도 이 값을 확인된 신원으로 다루지 않는다(write.php 주석 참고). */ function khCookie(name) { var m = document.cookie.match(new RegExp('(^|;\\s*)' + name + '=([^;]*)')); if (!m) { return ''; } try { return decodeURIComponent(m[2]).trim(); } catch (e) { return ''; // 인코딩이 깨진 값. 없는 것으로 친다. } } /** 길호넷 로그인 흔적이 있나 — 이름과 번호가 둘 다 있어야 한다 */ function hinted() { return khCookie('kh_nick') !== '' && khCookie('kh_no') !== ''; } function paintNotes() { var $n = jQuery('#comment-notes').empty(); if (hinted()) { /* * 이름을 아니까 묻지 않는다. 두 칸을 감추고, 값도 보내지 않는다 — * 서버가 쿠키에서 직접 읽는다(그래서 아래 요청이 withCredentials 다). * 보내 봐야 서버가 덮어쓰므로 오갈 이유가 없다. */ jQuery('.comment-form-author, .comment-form-email, .comment-form-url').hide(); // .text() 다. 이름을 HTML 로 넣으면 닉네임 자리가 태그 자리가 된다. $n.text(khCookie('kh_nick') + '(으)로 로그인 됨. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); return; } jQuery('.comment-form-author, .comment-form-email, .comment-form-url').show(); $n.text('이메일 주소는 공개되지 않습니다. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); } paintNotes(); jQuery('#btn_comment').click(function(e) { e.preventDefault(); var comment = jQuery('#comment').val().trim(); var author = jQuery('#author').val().trim(); var email = jQuery('#email').val().trim(); var known = hinted(); if (!comment) { alert('댓글을 입력해주세요.'); return; } if (!known && (!author || !email)) { alert('모든 필수 필드를 입력해주세요.'); return; } jQuery(this).prop('disabled', true); // 감춘 칸은 보내지 않는다. 안 보이는 칸에 남아 있던 값이 따라가면 // 사람이 지웠다고 여긴 것이 조용히 저장된다. var commentData = known ? { comment: comment } : { comment: comment, author: author, email: email, url: jQuery('#url').val() }; jQuery.ajax({ url: KILHO_COMMENT + '/write.json', type: 'POST', data: commentData, // 쿠키를 실어 보낸다. 이것이 빠지면 서버가 kh_nick 을 못 읽어 // 이름 없는 요청이 되고 400 이 난다. 붙는 곳이 전부 *.kilho.net 이라 // 같은 사이트이므로 SameSite=Lax 인 쿠키도 그대로 실린다. xhrFields: { withCredentials: true }, success: function(response) { Swal.fire({ title: '성공적!', html: '댓글이 성공적으로 전송되었습니다.관리자 승인 후 게시됩니다.', icon: 'success', confirmButtonText: '확인' }); ['author', 'email', 'url'].forEach(id => jQuery(`#${id}`).val('')); jQuery('#comment').val(''); jQuery('#btn_comment').prop('disabled', false); }, error: function(xhr, status, error) { Swal.fire({ title: '웁스...', html: '댓글 등록에 실패했습니다.다시 시도해주세요.', icon: 'error', confirmButtonText: '확인' }); jQuery('#btn_comment').prop('disabled', false); } }); }); jQuery.ajax({ url: KILHO_COMMENT + '/view.json', type: 'GET', dataType: 'json', success: function(response) { if(response) { response.forEach(function(commentData) { addComment(commentData.author, commentData.comment, commentData.regdate, commentData.imgUrl); }); } }, error: function(xhr, status, error) { console.error('데이터를 불러오는 데 실패했습니다: ' + error); } }); });
\n\t\t\t\uc774\ub984 *<\/span><\/label> \n\t\t<\/p>\n\t\t\n\t\t\t\uc774\uba54\uc77c *<\/span><\/label> \n\t\t<\/p>\n\t\t\uc6f9\uc0ac\uc774\ud2b8<\/label> <\/p>\n\t\t\n\t\t\t\ub313\uae00 \ub2ec\uae30<\/button>\n\t\t<\/p>\n\t<\/form>\n<\/div>\n"); /* * 이 위젯에는 로그인이 없다. 댓글은 전부 비회원으로 들어간다(mb_no = NULL). * * 예전에는 kilho.net 워드프레스가 남긴 wordpress_display_name 쿠키로 이름을 * 알아내고, 알아냈으면 이름·이메일 칸을 감췄다. 워드프레스를 떼면서 그 쿠키가 * 없어져 전부 익명이 됐다. * * 2026-08-08 그 자리를 comment.kilho.net 자체 로그인으로 메워 봤다가 도로 * 걷어냈다. 신원을 붙드는 까닭은 보통 "본인만 고치거나 지우게" 하려는 것인데, * 이 댓글은 고치지도 지우지도 못한다 — 사장님이 하나씩 보고 승인한 것만 * 공개된다. 지킬 것이 없는 자리를 지키려고 사람마다 로그인을 시킬 이유가 없다. * * 그래서 옛 방식으로 돌아간다. 쿠키가 이름을 알려 주면 두 칸을 감춘다. * 지금 그 자리를 잇는 것이 인증서버의 kh_nick · kh_no 다. */ /* * kh_nick(이름) · kh_no(회원번호) — 인증서버가 .kilho.net 에 심고(로그인) * 지운다(로그아웃). auth.kilho.net 의 config.php MB_HINT_COOKIE · MB_HINT_NO_COOKIE * · lib/session.php. httponly 를 일부러 꺼 두어 제휴 사이트 JS 가 읽게 만든 * 값이고, 한글이 들어가므로 setcookie() 가 URL 인코딩한 것을 여기서 푼다. * * 서명이 없어 고쳐 쓸 수 있다. 그래도 잃을 것이 없다 — mb_no 는 붙지 않고, * 모든 댓글이 승인 대기(status=0)를 지나 사장님 눈을 거친 뒤에야 보인다. * 서버도 이 값을 확인된 신원으로 다루지 않는다(write.php 주석 참고). */ function khCookie(name) { var m = document.cookie.match(new RegExp('(^|;\\s*)' + name + '=([^;]*)')); if (!m) { return ''; } try { return decodeURIComponent(m[2]).trim(); } catch (e) { return ''; // 인코딩이 깨진 값. 없는 것으로 친다. } } /** 길호넷 로그인 흔적이 있나 — 이름과 번호가 둘 다 있어야 한다 */ function hinted() { return khCookie('kh_nick') !== '' && khCookie('kh_no') !== ''; } function paintNotes() { var $n = jQuery('#comment-notes').empty(); if (hinted()) { /* * 이름을 아니까 묻지 않는다. 두 칸을 감추고, 값도 보내지 않는다 — * 서버가 쿠키에서 직접 읽는다(그래서 아래 요청이 withCredentials 다). * 보내 봐야 서버가 덮어쓰므로 오갈 이유가 없다. */ jQuery('.comment-form-author, .comment-form-email, .comment-form-url').hide(); // .text() 다. 이름을 HTML 로 넣으면 닉네임 자리가 태그 자리가 된다. $n.text(khCookie('kh_nick') + '(으)로 로그인 됨. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); return; } jQuery('.comment-form-author, .comment-form-email, .comment-form-url').show(); $n.text('이메일 주소는 공개되지 않습니다. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); } paintNotes(); jQuery('#btn_comment').click(function(e) { e.preventDefault(); var comment = jQuery('#comment').val().trim(); var author = jQuery('#author').val().trim(); var email = jQuery('#email').val().trim(); var known = hinted(); if (!comment) { alert('댓글을 입력해주세요.'); return; } if (!known && (!author || !email)) { alert('모든 필수 필드를 입력해주세요.'); return; } jQuery(this).prop('disabled', true); // 감춘 칸은 보내지 않는다. 안 보이는 칸에 남아 있던 값이 따라가면 // 사람이 지웠다고 여긴 것이 조용히 저장된다. var commentData = known ? { comment: comment } : { comment: comment, author: author, email: email, url: jQuery('#url').val() }; jQuery.ajax({ url: KILHO_COMMENT + '/write.json', type: 'POST', data: commentData, // 쿠키를 실어 보낸다. 이것이 빠지면 서버가 kh_nick 을 못 읽어 // 이름 없는 요청이 되고 400 이 난다. 붙는 곳이 전부 *.kilho.net 이라 // 같은 사이트이므로 SameSite=Lax 인 쿠키도 그대로 실린다. xhrFields: { withCredentials: true }, success: function(response) { Swal.fire({ title: '성공적!', html: '댓글이 성공적으로 전송되었습니다.관리자 승인 후 게시됩니다.', icon: 'success', confirmButtonText: '확인' }); ['author', 'email', 'url'].forEach(id => jQuery(`#${id}`).val('')); jQuery('#comment').val(''); jQuery('#btn_comment').prop('disabled', false); }, error: function(xhr, status, error) { Swal.fire({ title: '웁스...', html: '댓글 등록에 실패했습니다.다시 시도해주세요.', icon: 'error', confirmButtonText: '확인' }); jQuery('#btn_comment').prop('disabled', false); } }); }); jQuery.ajax({ url: KILHO_COMMENT + '/view.json', type: 'GET', dataType: 'json', success: function(response) { if(response) { response.forEach(function(commentData) { addComment(commentData.author, commentData.comment, commentData.regdate, commentData.imgUrl); }); } }, error: function(xhr, status, error) { console.error('데이터를 불러오는 데 실패했습니다: ' + error); } }); });
\n\t\t\t\uc774\uba54\uc77c *<\/span><\/label> \n\t\t<\/p>\n\t\t\uc6f9\uc0ac\uc774\ud2b8<\/label> <\/p>\n\t\t\n\t\t\t\ub313\uae00 \ub2ec\uae30<\/button>\n\t\t<\/p>\n\t<\/form>\n<\/div>\n"); /* * 이 위젯에는 로그인이 없다. 댓글은 전부 비회원으로 들어간다(mb_no = NULL). * * 예전에는 kilho.net 워드프레스가 남긴 wordpress_display_name 쿠키로 이름을 * 알아내고, 알아냈으면 이름·이메일 칸을 감췄다. 워드프레스를 떼면서 그 쿠키가 * 없어져 전부 익명이 됐다. * * 2026-08-08 그 자리를 comment.kilho.net 자체 로그인으로 메워 봤다가 도로 * 걷어냈다. 신원을 붙드는 까닭은 보통 "본인만 고치거나 지우게" 하려는 것인데, * 이 댓글은 고치지도 지우지도 못한다 — 사장님이 하나씩 보고 승인한 것만 * 공개된다. 지킬 것이 없는 자리를 지키려고 사람마다 로그인을 시킬 이유가 없다. * * 그래서 옛 방식으로 돌아간다. 쿠키가 이름을 알려 주면 두 칸을 감춘다. * 지금 그 자리를 잇는 것이 인증서버의 kh_nick · kh_no 다. */ /* * kh_nick(이름) · kh_no(회원번호) — 인증서버가 .kilho.net 에 심고(로그인) * 지운다(로그아웃). auth.kilho.net 의 config.php MB_HINT_COOKIE · MB_HINT_NO_COOKIE * · lib/session.php. httponly 를 일부러 꺼 두어 제휴 사이트 JS 가 읽게 만든 * 값이고, 한글이 들어가므로 setcookie() 가 URL 인코딩한 것을 여기서 푼다. * * 서명이 없어 고쳐 쓸 수 있다. 그래도 잃을 것이 없다 — mb_no 는 붙지 않고, * 모든 댓글이 승인 대기(status=0)를 지나 사장님 눈을 거친 뒤에야 보인다. * 서버도 이 값을 확인된 신원으로 다루지 않는다(write.php 주석 참고). */ function khCookie(name) { var m = document.cookie.match(new RegExp('(^|;\\s*)' + name + '=([^;]*)')); if (!m) { return ''; } try { return decodeURIComponent(m[2]).trim(); } catch (e) { return ''; // 인코딩이 깨진 값. 없는 것으로 친다. } } /** 길호넷 로그인 흔적이 있나 — 이름과 번호가 둘 다 있어야 한다 */ function hinted() { return khCookie('kh_nick') !== '' && khCookie('kh_no') !== ''; } function paintNotes() { var $n = jQuery('#comment-notes').empty(); if (hinted()) { /* * 이름을 아니까 묻지 않는다. 두 칸을 감추고, 값도 보내지 않는다 — * 서버가 쿠키에서 직접 읽는다(그래서 아래 요청이 withCredentials 다). * 보내 봐야 서버가 덮어쓰므로 오갈 이유가 없다. */ jQuery('.comment-form-author, .comment-form-email, .comment-form-url').hide(); // .text() 다. 이름을 HTML 로 넣으면 닉네임 자리가 태그 자리가 된다. $n.text(khCookie('kh_nick') + '(으)로 로그인 됨. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); return; } jQuery('.comment-form-author, .comment-form-email, .comment-form-url').show(); $n.text('이메일 주소는 공개되지 않습니다. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); } paintNotes(); jQuery('#btn_comment').click(function(e) { e.preventDefault(); var comment = jQuery('#comment').val().trim(); var author = jQuery('#author').val().trim(); var email = jQuery('#email').val().trim(); var known = hinted(); if (!comment) { alert('댓글을 입력해주세요.'); return; } if (!known && (!author || !email)) { alert('모든 필수 필드를 입력해주세요.'); return; } jQuery(this).prop('disabled', true); // 감춘 칸은 보내지 않는다. 안 보이는 칸에 남아 있던 값이 따라가면 // 사람이 지웠다고 여긴 것이 조용히 저장된다. var commentData = known ? { comment: comment } : { comment: comment, author: author, email: email, url: jQuery('#url').val() }; jQuery.ajax({ url: KILHO_COMMENT + '/write.json', type: 'POST', data: commentData, // 쿠키를 실어 보낸다. 이것이 빠지면 서버가 kh_nick 을 못 읽어 // 이름 없는 요청이 되고 400 이 난다. 붙는 곳이 전부 *.kilho.net 이라 // 같은 사이트이므로 SameSite=Lax 인 쿠키도 그대로 실린다. xhrFields: { withCredentials: true }, success: function(response) { Swal.fire({ title: '성공적!', html: '댓글이 성공적으로 전송되었습니다.관리자 승인 후 게시됩니다.', icon: 'success', confirmButtonText: '확인' }); ['author', 'email', 'url'].forEach(id => jQuery(`#${id}`).val('')); jQuery('#comment').val(''); jQuery('#btn_comment').prop('disabled', false); }, error: function(xhr, status, error) { Swal.fire({ title: '웁스...', html: '댓글 등록에 실패했습니다.다시 시도해주세요.', icon: 'error', confirmButtonText: '확인' }); jQuery('#btn_comment').prop('disabled', false); } }); }); jQuery.ajax({ url: KILHO_COMMENT + '/view.json', type: 'GET', dataType: 'json', success: function(response) { if(response) { response.forEach(function(commentData) { addComment(commentData.author, commentData.comment, commentData.regdate, commentData.imgUrl); }); } }, error: function(xhr, status, error) { console.error('데이터를 불러오는 데 실패했습니다: ' + error); } }); });
\uc6f9\uc0ac\uc774\ud2b8<\/label> <\/p>\n\t\t\n\t\t\t\ub313\uae00 \ub2ec\uae30<\/button>\n\t\t<\/p>\n\t<\/form>\n<\/div>\n"); /* * 이 위젯에는 로그인이 없다. 댓글은 전부 비회원으로 들어간다(mb_no = NULL). * * 예전에는 kilho.net 워드프레스가 남긴 wordpress_display_name 쿠키로 이름을 * 알아내고, 알아냈으면 이름·이메일 칸을 감췄다. 워드프레스를 떼면서 그 쿠키가 * 없어져 전부 익명이 됐다. * * 2026-08-08 그 자리를 comment.kilho.net 자체 로그인으로 메워 봤다가 도로 * 걷어냈다. 신원을 붙드는 까닭은 보통 "본인만 고치거나 지우게" 하려는 것인데, * 이 댓글은 고치지도 지우지도 못한다 — 사장님이 하나씩 보고 승인한 것만 * 공개된다. 지킬 것이 없는 자리를 지키려고 사람마다 로그인을 시킬 이유가 없다. * * 그래서 옛 방식으로 돌아간다. 쿠키가 이름을 알려 주면 두 칸을 감춘다. * 지금 그 자리를 잇는 것이 인증서버의 kh_nick · kh_no 다. */ /* * kh_nick(이름) · kh_no(회원번호) — 인증서버가 .kilho.net 에 심고(로그인) * 지운다(로그아웃). auth.kilho.net 의 config.php MB_HINT_COOKIE · MB_HINT_NO_COOKIE * · lib/session.php. httponly 를 일부러 꺼 두어 제휴 사이트 JS 가 읽게 만든 * 값이고, 한글이 들어가므로 setcookie() 가 URL 인코딩한 것을 여기서 푼다. * * 서명이 없어 고쳐 쓸 수 있다. 그래도 잃을 것이 없다 — mb_no 는 붙지 않고, * 모든 댓글이 승인 대기(status=0)를 지나 사장님 눈을 거친 뒤에야 보인다. * 서버도 이 값을 확인된 신원으로 다루지 않는다(write.php 주석 참고). */ function khCookie(name) { var m = document.cookie.match(new RegExp('(^|;\\s*)' + name + '=([^;]*)')); if (!m) { return ''; } try { return decodeURIComponent(m[2]).trim(); } catch (e) { return ''; // 인코딩이 깨진 값. 없는 것으로 친다. } } /** 길호넷 로그인 흔적이 있나 — 이름과 번호가 둘 다 있어야 한다 */ function hinted() { return khCookie('kh_nick') !== '' && khCookie('kh_no') !== ''; } function paintNotes() { var $n = jQuery('#comment-notes').empty(); if (hinted()) { /* * 이름을 아니까 묻지 않는다. 두 칸을 감추고, 값도 보내지 않는다 — * 서버가 쿠키에서 직접 읽는다(그래서 아래 요청이 withCredentials 다). * 보내 봐야 서버가 덮어쓰므로 오갈 이유가 없다. */ jQuery('.comment-form-author, .comment-form-email, .comment-form-url').hide(); // .text() 다. 이름을 HTML 로 넣으면 닉네임 자리가 태그 자리가 된다. $n.text(khCookie('kh_nick') + '(으)로 로그인 됨. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); return; } jQuery('.comment-form-author, .comment-form-email, .comment-form-url').show(); $n.text('이메일 주소는 공개되지 않습니다. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); } paintNotes(); jQuery('#btn_comment').click(function(e) { e.preventDefault(); var comment = jQuery('#comment').val().trim(); var author = jQuery('#author').val().trim(); var email = jQuery('#email').val().trim(); var known = hinted(); if (!comment) { alert('댓글을 입력해주세요.'); return; } if (!known && (!author || !email)) { alert('모든 필수 필드를 입력해주세요.'); return; } jQuery(this).prop('disabled', true); // 감춘 칸은 보내지 않는다. 안 보이는 칸에 남아 있던 값이 따라가면 // 사람이 지웠다고 여긴 것이 조용히 저장된다. var commentData = known ? { comment: comment } : { comment: comment, author: author, email: email, url: jQuery('#url').val() }; jQuery.ajax({ url: KILHO_COMMENT + '/write.json', type: 'POST', data: commentData, // 쿠키를 실어 보낸다. 이것이 빠지면 서버가 kh_nick 을 못 읽어 // 이름 없는 요청이 되고 400 이 난다. 붙는 곳이 전부 *.kilho.net 이라 // 같은 사이트이므로 SameSite=Lax 인 쿠키도 그대로 실린다. xhrFields: { withCredentials: true }, success: function(response) { Swal.fire({ title: '성공적!', html: '댓글이 성공적으로 전송되었습니다.관리자 승인 후 게시됩니다.', icon: 'success', confirmButtonText: '확인' }); ['author', 'email', 'url'].forEach(id => jQuery(`#${id}`).val('')); jQuery('#comment').val(''); jQuery('#btn_comment').prop('disabled', false); }, error: function(xhr, status, error) { Swal.fire({ title: '웁스...', html: '댓글 등록에 실패했습니다.다시 시도해주세요.', icon: 'error', confirmButtonText: '확인' }); jQuery('#btn_comment').prop('disabled', false); } }); }); jQuery.ajax({ url: KILHO_COMMENT + '/view.json', type: 'GET', dataType: 'json', success: function(response) { if(response) { response.forEach(function(commentData) { addComment(commentData.author, commentData.comment, commentData.regdate, commentData.imgUrl); }); } }, error: function(xhr, status, error) { console.error('데이터를 불러오는 데 실패했습니다: ' + error); } }); });
\n\t\t\t\ub313\uae00 \ub2ec\uae30<\/button>\n\t\t<\/p>\n\t<\/form>\n<\/div>\n"); /* * 이 위젯에는 로그인이 없다. 댓글은 전부 비회원으로 들어간다(mb_no = NULL). * * 예전에는 kilho.net 워드프레스가 남긴 wordpress_display_name 쿠키로 이름을 * 알아내고, 알아냈으면 이름·이메일 칸을 감췄다. 워드프레스를 떼면서 그 쿠키가 * 없어져 전부 익명이 됐다. * * 2026-08-08 그 자리를 comment.kilho.net 자체 로그인으로 메워 봤다가 도로 * 걷어냈다. 신원을 붙드는 까닭은 보통 "본인만 고치거나 지우게" 하려는 것인데, * 이 댓글은 고치지도 지우지도 못한다 — 사장님이 하나씩 보고 승인한 것만 * 공개된다. 지킬 것이 없는 자리를 지키려고 사람마다 로그인을 시킬 이유가 없다. * * 그래서 옛 방식으로 돌아간다. 쿠키가 이름을 알려 주면 두 칸을 감춘다. * 지금 그 자리를 잇는 것이 인증서버의 kh_nick · kh_no 다. */ /* * kh_nick(이름) · kh_no(회원번호) — 인증서버가 .kilho.net 에 심고(로그인) * 지운다(로그아웃). auth.kilho.net 의 config.php MB_HINT_COOKIE · MB_HINT_NO_COOKIE * · lib/session.php. httponly 를 일부러 꺼 두어 제휴 사이트 JS 가 읽게 만든 * 값이고, 한글이 들어가므로 setcookie() 가 URL 인코딩한 것을 여기서 푼다. * * 서명이 없어 고쳐 쓸 수 있다. 그래도 잃을 것이 없다 — mb_no 는 붙지 않고, * 모든 댓글이 승인 대기(status=0)를 지나 사장님 눈을 거친 뒤에야 보인다. * 서버도 이 값을 확인된 신원으로 다루지 않는다(write.php 주석 참고). */ function khCookie(name) { var m = document.cookie.match(new RegExp('(^|;\\s*)' + name + '=([^;]*)')); if (!m) { return ''; } try { return decodeURIComponent(m[2]).trim(); } catch (e) { return ''; // 인코딩이 깨진 값. 없는 것으로 친다. } } /** 길호넷 로그인 흔적이 있나 — 이름과 번호가 둘 다 있어야 한다 */ function hinted() { return khCookie('kh_nick') !== '' && khCookie('kh_no') !== ''; } function paintNotes() { var $n = jQuery('#comment-notes').empty(); if (hinted()) { /* * 이름을 아니까 묻지 않는다. 두 칸을 감추고, 값도 보내지 않는다 — * 서버가 쿠키에서 직접 읽는다(그래서 아래 요청이 withCredentials 다). * 보내 봐야 서버가 덮어쓰므로 오갈 이유가 없다. */ jQuery('.comment-form-author, .comment-form-email, .comment-form-url').hide(); // .text() 다. 이름을 HTML 로 넣으면 닉네임 자리가 태그 자리가 된다. $n.text(khCookie('kh_nick') + '(으)로 로그인 됨. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); return; } jQuery('.comment-form-author, .comment-form-email, .comment-form-url').show(); $n.text('이메일 주소는 공개되지 않습니다. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)'); } paintNotes(); jQuery('#btn_comment').click(function(e) { e.preventDefault(); var comment = jQuery('#comment').val().trim(); var author = jQuery('#author').val().trim(); var email = jQuery('#email').val().trim(); var known = hinted(); if (!comment) { alert('댓글을 입력해주세요.'); return; } if (!known && (!author || !email)) { alert('모든 필수 필드를 입력해주세요.'); return; } jQuery(this).prop('disabled', true); // 감춘 칸은 보내지 않는다. 안 보이는 칸에 남아 있던 값이 따라가면 // 사람이 지웠다고 여긴 것이 조용히 저장된다. var commentData = known ? { comment: comment } : { comment: comment, author: author, email: email, url: jQuery('#url').val() }; jQuery.ajax({ url: KILHO_COMMENT + '/write.json', type: 'POST', data: commentData, // 쿠키를 실어 보낸다. 이것이 빠지면 서버가 kh_nick 을 못 읽어 // 이름 없는 요청이 되고 400 이 난다. 붙는 곳이 전부 *.kilho.net 이라 // 같은 사이트이므로 SameSite=Lax 인 쿠키도 그대로 실린다. xhrFields: { withCredentials: true }, success: function(response) { Swal.fire({ title: '성공적!', html: '댓글이 성공적으로 전송되었습니다.관리자 승인 후 게시됩니다.', icon: 'success', confirmButtonText: '확인' }); ['author', 'email', 'url'].forEach(id => jQuery(`#${id}`).val('')); jQuery('#comment').val(''); jQuery('#btn_comment').prop('disabled', false); }, error: function(xhr, status, error) { Swal.fire({ title: '웁스...', html: '댓글 등록에 실패했습니다.다시 시도해주세요.', icon: 'error', confirmButtonText: '확인' }); jQuery('#btn_comment').prop('disabled', false); } }); }); jQuery.ajax({ url: KILHO_COMMENT + '/view.json', type: 'GET', dataType: 'json', success: function(response) { if(response) { response.forEach(function(commentData) { addComment(commentData.author, commentData.comment, commentData.regdate, commentData.imgUrl); }); } }, error: function(xhr, status, error) { console.error('데이터를 불러오는 데 실패했습니다: ' + error); } }); });
' + comment.replace(/\n/g, '
' + '') + '