diff --git a/adm/admin.js b/adm/admin.js index a3f4c7d64..60412fa4a 100644 --- a/adm/admin.js +++ b/adm/admin.js @@ -71,4 +71,51 @@ function delete_confirm2(msg) return true; else return false; -} \ No newline at end of file +} + +function get_ajax_token() +{ + var token = ""; + + $.ajax({ + type: "POST", + url: "./ajax.token.php", + 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 input:submit", function() { + var f = this.form; + var token = get_ajax_token(); + + if(!token) { + alert("토큰 정보가 올바르지 않습니다."); + return false; + } + + var $f = $(f); + + if(typeof f.token === "undefined") + $f.append(''); + + $f.find("input[name=token]").val(token); + + return true; + }); +}); \ No newline at end of file diff --git a/adm/admin.lib.php b/adm/admin.lib.php index bc1ab9fcd..fb68772d7 100644 --- a/adm/admin.lib.php +++ b/adm/admin.lib.php @@ -346,6 +346,54 @@ function order_select($fld, $sel='') return $s; } +// 불법접근을 막도록 토큰을 생성하면서 토큰값을 리턴 +function get_admin_token() +{ + $token = md5(uniqid(rand(), true)); + set_session('ss_admin_token', $token); + + return $token; +} + + +// POST로 넘어온 토큰과 세션에 저장된 토큰 비교 +function check_admin_token() +{ + $token = get_session('ss_admin_token'); + set_session('ss_admin_token', ''); + + if(!$token || !$_POST['token'] || $token != $_POST['token']) + alert('올바른 방법으로 이용해 주십시오.'); + + return true; +} + +// 관리자 페이지 referer 체크 +function admin_referer_check($return=false) +{ + $referer = trim($_SERVER['HTTP_REFERER']); + if(!$referer) { + $msg = '정보가 올바르지 않습니다.'; + + if($return) + return $msg; + else + alert($msg, G5_URL); + } + + $p = @parse_url($referer); + $host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']); + + if($host != $p['host']) { + $msg = '올바른 방법으로 이용해 주십시오.'; + + if($return) + return $msg; + else + alert($msg, G5_URL); + } +} + // 접근 권한 검사 if (!$member['mb_id']) { diff --git a/adm/ajax.token.php b/adm/ajax.token.php new file mode 100644 index 000000000..f6a100a1f --- /dev/null +++ b/adm/ajax.token.php @@ -0,0 +1,14 @@ +$error, 'url'=>G5_URL))); + +$token = get_admin_token(); + +die(json_encode(array('error'=>'', 'token'=>$token, 'url'=>''))); +?> \ No newline at end of file diff --git a/adm/auth_list.php b/adm/auth_list.php index 3dfad19f5..4058b8e53 100644 --- a/adm/auth_list.php +++ b/adm/auth_list.php @@ -5,8 +5,6 @@ include_once('./_common.php'); if ($is_admin != 'super') alert('최고관리자만 접근 가능합니다.'); -$token = get_token(); - $sql_common = " from {$g5['auth_table']} a left join {$g5['member_table']} b on (a.mb_id=b.mb_id) "; $sql_search = " where (1) "; @@ -73,7 +71,7 @@ $colspan = 5; - +
@@ -168,7 +166,7 @@ echo $pagelist; - +

관리권한 추가

diff --git a/adm/auth_list_delete.php b/adm/auth_list_delete.php index ccb69c575..46acecce6 100644 --- a/adm/auth_list_delete.php +++ b/adm/auth_list_delete.php @@ -7,7 +7,7 @@ check_demo(); if ($is_admin != 'super') alert('최고관리자만 접근 가능합니다.'); -check_token(); +check_admin_token(); $count = count($_POST['chk']); diff --git a/adm/auth_update.php b/adm/auth_update.php index 59833028d..44a0ff437 100644 --- a/adm/auth_update.php +++ b/adm/auth_update.php @@ -9,7 +9,7 @@ $mb = get_member($mb_id); if (!$mb['mb_id']) alert('존재하는 회원아이디가 아닙니다.'); -check_token(); +check_admin_token(); $sql = " insert into {$g5['auth_table']} set mb_id = '{$_POST['mb_id']}', diff --git a/adm/board_copy.php b/adm/board_copy.php index 1d78d2c30..01a725e58 100644 --- a/adm/board_copy.php +++ b/adm/board_copy.php @@ -13,6 +13,7 @@ include_once(G5_PATH.'/head.sub.php');
+
diff --git a/adm/board_copy_update.php b/adm/board_copy_update.php index 3718c09e1..95df487a4 100644 --- a/adm/board_copy_update.php +++ b/adm/board_copy_update.php @@ -4,6 +4,8 @@ include_once('./_common.php'); auth_check($auth[$sub_menu], 'w'); +check_admin_token(); + $target_table = trim($_POST['target_table']); $target_subject = trim($_POST['target_subject']); diff --git a/adm/board_form.php b/adm/board_form.php index 1d3664147..6855e3cb6 100644 --- a/adm/board_form.php +++ b/adm/board_form.php @@ -166,6 +166,7 @@ $frm_submit .= ''; +

게시판 기본 설정

diff --git a/adm/board_form_update.php b/adm/board_form_update.php index 558561b4d..5ca561216 100644 --- a/adm/board_form_update.php +++ b/adm/board_form_update.php @@ -7,6 +7,8 @@ if ($w == 'u') auth_check($auth[$sub_menu], 'w'); +check_admin_token(); + if (!$_POST['gr_id']) { alert('그룹 ID는 반드시 선택하세요.'); } if (!$bo_table) { alert('게시판 TABLE명은 반드시 입력하세요.'); } if (!preg_match("/^([A-Za-z0-9_]{1,20})$/", $bo_table)) { alert('게시판 TABLE명은 공백없이 영문자, 숫자, _ 만 사용 가능합니다. (20자 이내)'); } diff --git a/adm/board_list_update.php b/adm/board_list_update.php index 9d8850660..20bba640a 100644 --- a/adm/board_list_update.php +++ b/adm/board_list_update.php @@ -51,7 +51,7 @@ if ($_POST['act_button'] == "선택수정") { auth_check($auth[$sub_menu], 'd'); - check_token(); + check_admin_token(); // _BOARD_DELETE_ 상수를 선언해야 board_delete.inc.php 가 정상 작동함 define('_BOARD_DELETE_', true); diff --git a/adm/boardgroup_form.php b/adm/boardgroup_form.php index c27e27178..e32ae8274 100644 --- a/adm/boardgroup_form.php +++ b/adm/boardgroup_form.php @@ -38,6 +38,7 @@ include_once('./admin.head.php'); +
diff --git a/adm/boardgroup_form_update.php b/adm/boardgroup_form_update.php index 1ff30cbe9..c29558fdd 100644 --- a/adm/boardgroup_form_update.php +++ b/adm/boardgroup_form_update.php @@ -9,6 +9,8 @@ auth_check($auth[$sub_menu], 'w'); if ($is_admin != 'super' && $w == '') alert('최고관리자만 접근 가능합니다.'); +check_admin_token(); + if (!preg_match("/^([A-Za-z0-9_]{1,10})$/", $_POST['gr_id'])) alert('그룹 ID는 공백없이 영문자, 숫자, _ 만 사용 가능합니다. (10자 이내)'); diff --git a/adm/boardgroup_list.php b/adm/boardgroup_list.php index 7fe391650..59f59a1cd 100644 --- a/adm/boardgroup_list.php +++ b/adm/boardgroup_list.php @@ -88,7 +88,7 @@ $colspan = 10; - +
diff --git a/adm/boardgroup_list_update.php b/adm/boardgroup_list_update.php index e7f9816eb..c10cd247f 100644 --- a/adm/boardgroup_list_update.php +++ b/adm/boardgroup_list_update.php @@ -8,6 +8,8 @@ check_demo(); auth_check($auth[$sub_menu], 'w'); +check_admin_token(); + $count = count($_POST['chk']); if(!$count) diff --git a/adm/boardgroupmember_form.php b/adm/boardgroupmember_form.php index 74737330e..4158cadbc 100644 --- a/adm/boardgroupmember_form.php +++ b/adm/boardgroupmember_form.php @@ -4,8 +4,6 @@ include_once('./_common.php'); auth_check($auth[$sub_menu], 'w'); -$token = get_token(); - $mb = get_member($mb_id); if (!$mb['mb_id']) alert('존재하지 않는 회원입니다.'); @@ -18,7 +16,7 @@ $colspan = 4; - +

아이디 , 이름 , 닉네임

diff --git a/adm/boardgroupmember_update.php b/adm/boardgroupmember_update.php index e36badf1a..95f8372b3 100644 --- a/adm/boardgroupmember_update.php +++ b/adm/boardgroupmember_update.php @@ -28,7 +28,7 @@ if ($w == '') } else { - check_token(); + check_admin_token(); $sql = " insert into {$g5['group_member_table']} set gr_id = '{$_POST['gr_id']}', @@ -45,7 +45,7 @@ else if ($w == 'd' || $w == 'ld') if(!$count) alert('삭제할 목록을 하나이상 선택해 주세요.'); - check_token(); + check_admin_token(); for($i=0; $i<$count; $i++) { $gm_id = $_POST['chk'][$i]; diff --git a/adm/config_form.php b/adm/config_form.php index 2619ad458..e89d6f72f 100644 --- a/adm/config_form.php +++ b/adm/config_form.php @@ -4,8 +4,6 @@ include_once('./_common.php'); auth_check($auth[$sub_menu], 'r'); -$token = get_token(); - if ($is_admin != 'super') alert('최고관리자만 접근 가능합니다.'); @@ -229,7 +227,7 @@ if ($config['cf_sms_use'] && $config['cf_icode_id'] && $config['cf_icode_pw']) { ?> - +

홈페이지 기본환경 설정

diff --git a/adm/config_form_update.php b/adm/config_form_update.php index 2c1279df4..773e5408a 100644 --- a/adm/config_form_update.php +++ b/adm/config_form_update.php @@ -13,7 +13,7 @@ $mb = get_member($cf_admin); if (!$mb['mb_id']) alert('최고관리자 회원아이디가 존재하지 않습니다.'); -check_token(); +check_admin_token(); // 본인확인을 사용할 경우 아이핀, 휴대폰인증 중 하나는 선택되어야 함 if($_POST['cf_cert_use'] && !$_POST['cf_cert_ipin'] && !$_POST['cf_cert_hp']) diff --git a/adm/contentform.php b/adm/contentform.php index a20bf373e..01e9ecc01 100644 --- a/adm/contentform.php +++ b/adm/contentform.php @@ -60,6 +60,7 @@ include_once (G5_ADMIN_PATH.'/admin.head.php'); +
diff --git a/adm/contentformupdate.php b/adm/contentformupdate.php index 57c26e172..1d6131c69 100644 --- a/adm/contentformupdate.php +++ b/adm/contentformupdate.php @@ -5,10 +5,13 @@ include_once('./_common.php'); if ($w == "u" || $w == "d") check_demo(); -if ($w == 'd') +if ($w == 'd') { + admin_referer_check(); auth_check($auth[$sub_menu], "d"); -else +} else { + check_admin_token(); auth_check($auth[$sub_menu], "w"); +} @mkdir(G5_DATA_PATH."/content", G5_DIR_PERMISSION); @chmod(G5_DATA_PATH."/content", G5_DIR_PERMISSION); diff --git a/adm/faqform.php b/adm/faqform.php index bce421e89..79dcd2b13 100644 --- a/adm/faqform.php +++ b/adm/faqform.php @@ -31,6 +31,7 @@ include_once (G5_ADMIN_PATH.'/admin.head.php'); +
diff --git a/adm/faqformupdate.php b/adm/faqformupdate.php index 723850c95..4b4e918cf 100644 --- a/adm/faqformupdate.php +++ b/adm/faqformupdate.php @@ -5,10 +5,13 @@ include_once('./_common.php'); if ($w == "u" || $w == "d") check_demo(); -if ($W == 'd') +if ($W == 'd') { + admin_referer_check(); auth_check($auth[$sub_menu], "d"); -else +} else { + check_admin_token(); auth_check($auth[$sub_menu], "w"); +} $sql_common = " fa_subject = '$fa_subject', fa_content = '$fa_content', diff --git a/adm/faqmasterform.php b/adm/faqmasterform.php index eb7f105a8..545bf9b60 100644 --- a/adm/faqmasterform.php +++ b/adm/faqmasterform.php @@ -36,6 +36,7 @@ include_once (G5_ADMIN_PATH.'/admin.head.php'); +
diff --git a/adm/faqmasterformupdate.php b/adm/faqmasterformupdate.php index d86e0eed4..a24681e9d 100644 --- a/adm/faqmasterformupdate.php +++ b/adm/faqmasterformupdate.php @@ -5,10 +5,13 @@ include_once('./_common.php'); if ($w == "u" || $w == "d") check_demo(); -if ($W == 'd') +if ($W == 'd') { + admin_referer_check(); auth_check($auth[$sub_menu], "d"); -else +} else { + check_admin_token(); auth_check($auth[$sub_menu], "w"); +} @mkdir(G5_DATA_PATH."/faq", G5_DIR_PERMISSION); @chmod(G5_DATA_PATH."/faq", G5_DIR_PERMISSION); diff --git a/adm/mail_delete.php b/adm/mail_delete.php index 73396ca1f..a190802eb 100644 --- a/adm/mail_delete.php +++ b/adm/mail_delete.php @@ -6,7 +6,7 @@ check_demo(); auth_check($auth[$sub_menu], 'd'); -check_token(); +check_admin_token(); $count = count($_POST['chk']); diff --git a/adm/mail_form.php b/adm/mail_form.php index 579c46bf6..d1e688e76 100644 --- a/adm/mail_form.php +++ b/adm/mail_form.php @@ -5,8 +5,6 @@ include_once(G5_EDITOR_LIB); auth_check($auth[$sub_menu], 'r'); -$token = get_token(); - $html_title = '회원메일'; if ($w == 'u') { @@ -30,7 +28,7 @@ include_once('./admin.head.php'); - +
diff --git a/adm/mail_select_list.php b/adm/mail_select_list.php index c05622971..c201a6da2 100644 --- a/adm/mail_select_list.php +++ b/adm/mail_select_list.php @@ -4,8 +4,6 @@ include_once('./_common.php'); auth_check($auth[$sub_menu], 'r'); -$token = get_token(); - $ma_last_option = ""; $sql_common = " from {$g5['member_table']} "; @@ -69,7 +67,7 @@ include_once('./admin.head.php'); ?> - +
diff --git a/adm/mail_select_update.php b/adm/mail_select_update.php index 6bf996421..219e58573 100644 --- a/adm/mail_select_update.php +++ b/adm/mail_select_update.php @@ -8,7 +8,7 @@ $html_title = '회원메일 발송'; check_demo(); -check_token(); +check_admin_token(); include_once('./admin.head.php'); include_once(G5_LIB_PATH.'/mailer.lib.php'); diff --git a/adm/mail_update.php b/adm/mail_update.php index db96987f3..ff539cd55 100644 --- a/adm/mail_update.php +++ b/adm/mail_update.php @@ -7,7 +7,7 @@ if ($w == 'u' || $w == 'd') auth_check($auth[$sub_menu], 'w'); -check_token(); +check_admin_token(); if ($w == '') { diff --git a/adm/member_delete.php b/adm/member_delete.php index 69240378f..5eee6a74d 100644 --- a/adm/member_delete.php +++ b/adm/member_delete.php @@ -17,7 +17,7 @@ else if (is_admin($mb['mb_id']) == "super") else if ($mb['mb_level'] >= $member['mb_level']) alert("자신보다 권한이 높거나 같은 회원은 삭제할 수 없습니다."); -check_token(); +check_admin_token(); // 회원자료 삭제 member_delete($mb['mb_id']); diff --git a/adm/member_form.php b/adm/member_form.php index 3e056459e..2d261b20a 100644 --- a/adm/member_form.php +++ b/adm/member_form.php @@ -4,8 +4,6 @@ include_once('./_common.php'); auth_check($auth[$sub_menu], 'w'); -$token = get_token(); - if ($w == '') { $required_mb_id = 'required'; @@ -144,7 +142,7 @@ add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js - +
diff --git a/adm/member_form_update.php b/adm/member_form_update.php index 310e5e8d1..29aba6432 100644 --- a/adm/member_form_update.php +++ b/adm/member_form_update.php @@ -8,7 +8,7 @@ if ($w == 'u') auth_check($auth[$sub_menu], 'w'); -check_token(); +check_admin_token(); $mb_id = trim($_POST['mb_id']); diff --git a/adm/member_list.php b/adm/member_list.php index 9eaf3e43c..45dd3d395 100644 --- a/adm/member_list.php +++ b/adm/member_list.php @@ -114,6 +114,7 @@ $colspan = 16; +
diff --git a/adm/member_list_delete.php b/adm/member_list_delete.php index c4810fc8f..4610a365f 100644 --- a/adm/member_list_delete.php +++ b/adm/member_list_delete.php @@ -6,7 +6,7 @@ check_demo(); auth_check($auth[$sub_menu], "d"); -check_token(); +check_admin_token(); $msg = ""; for ($i=0; $idbconfig.php 파일에 $g5[\'menu_table\'] = G5_TABLE_PREFIX.\'menu\'; 를 추가해 주세요.'); @@ -40,7 +38,7 @@ $colspan = 7; - +
diff --git a/adm/menu_list_update.php b/adm/menu_list_update.php index 2d55a7226..f05e2ec22 100644 --- a/adm/menu_list_update.php +++ b/adm/menu_list_update.php @@ -7,7 +7,7 @@ check_demo(); if ($is_admin != 'super') alert('최고관리자만 접근 가능합니다.'); -check_token(); +check_admin_token(); // 이전 메뉴정보 삭제 $sql = " delete from {$g5['menu_table']} "; diff --git a/adm/newwinform.php b/adm/newwinform.php index ac83b261c..cf936891c 100644 --- a/adm/newwinform.php +++ b/adm/newwinform.php @@ -32,6 +32,7 @@ include_once (G5_ADMIN_PATH.'/admin.head.php'); +

초기화면 접속 시 자동으로 뜰 팝업레이어를 설정합니다.

diff --git a/adm/newwinformupdate.php b/adm/newwinformupdate.php index 94746c6f8..89a5e4d4d 100644 --- a/adm/newwinformupdate.php +++ b/adm/newwinformupdate.php @@ -5,10 +5,13 @@ include_once('./_common.php'); if ($w == "u" || $w == "d") check_demo(); -if ($w == 'd') +if ($w == 'd') { + admin_referer_check(); auth_check($auth[$sub_menu], "d"); -else +} else { + check_admin_token(); auth_check($auth[$sub_menu], "w"); +} $sql_common = " nw_device = '{$_POST['nw_device']}', nw_begin_time = '{$_POST['nw_begin_time']}', diff --git a/adm/point_list.php b/adm/point_list.php index eaed7aaff..8c5712925 100644 --- a/adm/point_list.php +++ b/adm/point_list.php @@ -4,8 +4,6 @@ include_once('./_common.php'); auth_check($auth[$sub_menu], 'r'); -$token = get_token(); - $sql_common = " from {$g5['point_table']} "; $sql_search = " where (1) "; @@ -100,7 +98,7 @@ else - +
diff --git a/adm/point_list_delete.php b/adm/point_list_delete.php index 9d106ac8e..5d59e942e 100644 --- a/adm/point_list_delete.php +++ b/adm/point_list_delete.php @@ -6,7 +6,7 @@ check_demo(); auth_check($auth[$sub_menu], 'd'); -check_token(); +check_admin_token(); $count = count($_POST['chk']); if(!$count) diff --git a/adm/point_update.php b/adm/point_update.php index 24a318c9a..2240e6022 100644 --- a/adm/point_update.php +++ b/adm/point_update.php @@ -4,7 +4,7 @@ include_once('./_common.php'); auth_check($auth[$sub_menu], 'w'); -check_token(); +check_admin_token(); $mb_id = $_POST['mb_id']; $po_point = $_POST['po_point']; diff --git a/adm/poll_delete.php b/adm/poll_delete.php index 0a20f2d5f..3cae4f3cf 100644 --- a/adm/poll_delete.php +++ b/adm/poll_delete.php @@ -6,7 +6,7 @@ check_demo(); auth_check($auth[$sub_menu], 'd'); -check_token(); +check_admin_token(); $count = count($_POST['chk']); diff --git a/adm/poll_form.php b/adm/poll_form.php index 795719edf..6181b1375 100644 --- a/adm/poll_form.php +++ b/adm/poll_form.php @@ -4,8 +4,6 @@ include_once('./_common.php'); auth_check($auth[$sub_menu], 'w'); -$token = get_token(); - $html_title = '투표'; if ($w == '') $html_title .= ' 생성'; @@ -28,7 +26,7 @@ include_once('./admin.head.php'); - +
diff --git a/adm/poll_form_update.php b/adm/poll_form_update.php index f9cdc17f8..a3cba14ad 100644 --- a/adm/poll_form_update.php +++ b/adm/poll_form_update.php @@ -8,7 +8,7 @@ if ($w == 'u' || $w == 'd') auth_check($auth[$sub_menu], 'w'); -check_token(); +check_admin_token(); if ($w == '') { diff --git a/adm/poll_list.php b/adm/poll_list.php index 2de51e514..81e04a42b 100644 --- a/adm/poll_list.php +++ b/adm/poll_list.php @@ -4,8 +4,6 @@ include_once('./_common.php'); auth_check($auth[$sub_menu], 'r'); -$token = get_token(); - $sql_common = " from {$g5['poll_table']} "; $sql_search = " where (1) "; @@ -79,7 +77,7 @@ $colspan = 7; - +
diff --git a/adm/qa_config.php b/adm/qa_config.php index 4357e0240..4409eaa7b 100644 --- a/adm/qa_config.php +++ b/adm/qa_config.php @@ -5,8 +5,6 @@ include_once(G5_EDITOR_LIB); auth_check($auth[$sub_menu], 'r'); -$token = get_token(); - $g5['title'] = '1:1문의 설정'; include_once ('./admin.head.php'); @@ -119,7 +117,7 @@ if(!isset($qaconfig['qa_include_head'])) { ?> - +

1:1문의 설정

diff --git a/adm/qa_config_update.php b/adm/qa_config_update.php index 783b35677..c83311192 100644 --- a/adm/qa_config_update.php +++ b/adm/qa_config_update.php @@ -6,7 +6,7 @@ check_demo(); auth_check($auth[$sub_menu], 'w'); -check_token(); +check_admin_token(); $sql = " update {$g5['qa_config_table']} set qa_title = '{$_POST['qa_title']}', diff --git a/adm/theme_update.php b/adm/theme_update.php index e40f310d8..1197f3078 100644 --- a/adm/theme_update.php +++ b/adm/theme_update.php @@ -5,6 +5,8 @@ include_once('./_common.php'); if ($is_admin != 'super') die('최고관리자만 접근 가능합니다.'); +admin_referer_check(); + $theme = trim($_POST['theme']); $theme_dir = get_theme_dir();