From c23f6c016116e9e9cb454b2d58f6f8c412b0ac60 Mon Sep 17 00:00:00 2001 From: chicpro Date: Mon, 8 Aug 2016 17:44:29 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=88=98=EC=A0=95=20CSRF?= =?UTF-8?q?=20=EC=B7=A8=EC=95=BD=EC=A0=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bbs/ajax.comment_token.php | 14 +++++++++++++ bbs/write_comment_update.php | 5 +++++ js/common.js | 20 +++++++++++++++++++ mobile/skin/board/basic/view_comment.skin.php | 2 ++ .../skin/board/gallery/view_comment.skin.php | 2 ++ skin/board/basic/view_comment.skin.php | 2 ++ skin/board/gallery/view_comment.skin.php | 2 ++ .../skin/board/basic/view_comment.skin.php | 2 ++ .../skin/board/gallery/view_comment.skin.php | 2 ++ .../skin/board/basic/view_comment.skin.php | 2 ++ .../skin/board/gallery/view_comment.skin.php | 2 ++ 11 files changed, 55 insertions(+) create mode 100644 bbs/ajax.comment_token.php diff --git a/bbs/ajax.comment_token.php b/bbs/ajax.comment_token.php new file mode 100644 index 000000000..c90b09b9e --- /dev/null +++ b/bbs/ajax.comment_token.php @@ -0,0 +1,14 @@ +$token))); +?> \ No newline at end of file diff --git a/bbs/write_comment_update.php b/bbs/write_comment_update.php index d370e625a..e791eb0e6 100644 --- a/bbs/write_comment_update.php +++ b/bbs/write_comment_update.php @@ -3,6 +3,11 @@ define('G5_CAPTCHA', true); include_once('./_common.php'); include_once(G5_CAPTCHA_PATH.'/captcha.lib.php'); +// 토큰체크 +$comment_token = trim(get_session('ss_comment_token')); +if(!trim($_POST['token']) || !$comment_token || $comment_token != $_POST['token']) + alert('올바른 방법으로 이용해 주십시오.'); + // 090710 if (substr_count($wr_content, "&#") > 50) { alert('내용에 올바르지 않은 코드가 다수 포함되어 있습니다.'); diff --git a/js/common.js b/js/common.js index d20942579..4877b7c5b 100644 --- a/js/common.js +++ b/js/common.js @@ -546,6 +546,26 @@ function font_resize(id, rmv_class, add_class) set_cookie("ck_font_resize_add_class", add_class, 1, g5_cookie_domain); } +/** + * 댓글 수정 토큰 +**/ +function set_comment_token(f) +{ + if(typeof f.token === "undefined") + $(f).prepend(''); + + $.ajax({ + url: g5_bbs_url+"/ajax.comment_token.php", + type: "GET", + dataType: "json", + async: false, + cache: false, + success: function(data, textStatus) { + f.token.value = data.token; + } + }); +} + $(function(){ $(".win_point").click(function() { win_point(this.href); diff --git a/mobile/skin/board/basic/view_comment.skin.php b/mobile/skin/board/basic/view_comment.skin.php index 4640365e4..ce49cf92a 100644 --- a/mobile/skin/board/basic/view_comment.skin.php +++ b/mobile/skin/board/basic/view_comment.skin.php @@ -250,6 +250,8 @@ var char_max = parseInt(); // 최대 + set_comment_token(f); + document.getElementById("btn_submit").disabled = "disabled"; return true; diff --git a/mobile/skin/board/gallery/view_comment.skin.php b/mobile/skin/board/gallery/view_comment.skin.php index 4640365e4..ce49cf92a 100644 --- a/mobile/skin/board/gallery/view_comment.skin.php +++ b/mobile/skin/board/gallery/view_comment.skin.php @@ -250,6 +250,8 @@ var char_max = parseInt(); // 최대 + set_comment_token(f); + document.getElementById("btn_submit").disabled = "disabled"; return true; diff --git a/skin/board/basic/view_comment.skin.php b/skin/board/basic/view_comment.skin.php index 1169827de..0afc0f6d6 100644 --- a/skin/board/basic/view_comment.skin.php +++ b/skin/board/basic/view_comment.skin.php @@ -258,6 +258,8 @@ function fviewcomment_submit(f) + set_comment_token(f); + document.getElementById("btn_submit").disabled = "disabled"; return true; diff --git a/skin/board/gallery/view_comment.skin.php b/skin/board/gallery/view_comment.skin.php index 1a46d3b9c..b4b117397 100644 --- a/skin/board/gallery/view_comment.skin.php +++ b/skin/board/gallery/view_comment.skin.php @@ -258,6 +258,8 @@ function fviewcomment_submit(f) + set_comment_token(f); + document.getElementById("btn_submit").disabled = "disabled"; return true; diff --git a/theme/basic/mobile/skin/board/basic/view_comment.skin.php b/theme/basic/mobile/skin/board/basic/view_comment.skin.php index 4640365e4..ce49cf92a 100644 --- a/theme/basic/mobile/skin/board/basic/view_comment.skin.php +++ b/theme/basic/mobile/skin/board/basic/view_comment.skin.php @@ -250,6 +250,8 @@ var char_max = parseInt(); // 최대 + set_comment_token(f); + document.getElementById("btn_submit").disabled = "disabled"; return true; diff --git a/theme/basic/mobile/skin/board/gallery/view_comment.skin.php b/theme/basic/mobile/skin/board/gallery/view_comment.skin.php index 4640365e4..ce49cf92a 100644 --- a/theme/basic/mobile/skin/board/gallery/view_comment.skin.php +++ b/theme/basic/mobile/skin/board/gallery/view_comment.skin.php @@ -250,6 +250,8 @@ var char_max = parseInt(); // 최대 + set_comment_token(f); + document.getElementById("btn_submit").disabled = "disabled"; return true; diff --git a/theme/basic/skin/board/basic/view_comment.skin.php b/theme/basic/skin/board/basic/view_comment.skin.php index 23a29b17a..265b223dd 100644 --- a/theme/basic/skin/board/basic/view_comment.skin.php +++ b/theme/basic/skin/board/basic/view_comment.skin.php @@ -258,6 +258,8 @@ function fviewcomment_submit(f) + set_comment_token(f); + document.getElementById("btn_submit").disabled = "disabled"; return true; diff --git a/theme/basic/skin/board/gallery/view_comment.skin.php b/theme/basic/skin/board/gallery/view_comment.skin.php index ae8515d92..d2a83cd43 100644 --- a/theme/basic/skin/board/gallery/view_comment.skin.php +++ b/theme/basic/skin/board/gallery/view_comment.skin.php @@ -258,6 +258,8 @@ function fviewcomment_submit(f) + set_comment_token(f); + document.getElementById("btn_submit").disabled = "disabled"; return true;