그누보드 글쓰기 소스
본문
게시판에 글쓰는부분의 소스를 보고있습니다.
여기보시면 토큰체크를 하는데 사용되는 bo_table 이라는 변수는 common.php 파일의
이부분인가요?
글을 작성하고 전송되는값을 캡쳐했을때
캡쳐되는 아래의 사진에들어가는 token에는 어떤값들이들어가나요?
답변 1
게시판 글쓰기 하실 때
/js/common.js 에서 토큰을 생성합니다.
function get_write_token(bo_table)
{
var token = "";
$.ajax({
type: "POST",
url: g5_bbs_url+"/write_token.php",
data: { bo_table: bo_table },
cache: false,
async: false,
dataType: "json",
success: function(data) {
if(data.error) {
alert(data.error);
if(data.url)
document.location.href = data.url;
return false;
}
token = data.token;
}
});
return token;
}
$(function() {
$(document).on("click", "form[name=fwrite] input:submit, form[name=fwrite] button:submit, form[name=fwrite] input:image", function() {
var f = this.form;
if (typeof(f.bo_table) == "undefined") {
return;
}
var bo_table = f.bo_table.value;
var token = get_write_token(bo_table);
if(!token) {
alert("토큰 정보가 올바르지 않습니다.");
return false;
}
var $f = $(f);
if(typeof f.token === "undefined")
$f.prepend('<input type="hidden" name="token" value="">');
$f.find("input[name=token]").val(token);
return true;
});
});
답변을 작성하시기 전에 로그인 해주세요.