/home/mjc1/public_html/adm/auth_list.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?php
$sub_menu 
"100200";
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) ";
if (
$stx) {
    
$sql_search .= " and ( ";
    switch (
$sfl) {
        default :
            
$sql_search .= " ({$sfl} like '%{$stx}%') ";
            break;
    }
    
$sql_search .= " ) ";
}

if (!
$sst) {
    
$sst  "a.mb_id, au_menu";
    
$sod "";
}
$sql_order " order by $sst $sod ";

$sql " select count(*) as cnt
            
{$sql_common}
            
{$sql_search}
            
{$sql_order} ";
$row sql_fetch($sql);
$total_count $row['cnt'];

$rows $config['cf_page_rows'];
$total_page  ceil($total_count $rows);  // 전체 페이지 계산
if ($page 1$page 1// 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page 1) * $rows// 시작 열을 구함

$sql " select *
            
{$sql_common}
            
{$sql_search}
            
{$sql_order}
            limit 
{$from_record}{$rows} ";
$result sql_query($sql);

$listall '<a href="'.$_SERVER['PHP_SELF'].'" class="ov_listall">전체목록</a>';

$g5['title'] = "관리권한설정";
include_once(
'./admin.head.php');

$colspan 5;
?>

<div class="local_ov01 local_ov">
    <?php echo $listall ?>
    설정된 관리권한 <?php echo number_format($total_count?>
</div>

<form name="fsearch" id="fsearch" class="local_sch01 local_sch" method="get">
<input type="hidden" name="sfl" value="a.mb_id" id="sfl">

<label for="stx" class="sound_only">회원아이디<strong class="sound_only"> 필수</strong></label>
<input type="text" name="stx" value="<?php echo $stx ?>" id="stx" required class="required frm_input">
<input type="submit" value="검색" id="fsearch_submit" class="btn_submit">

</form>

<form name="fauthlist" id="fauthlist" method="post" action="./auth_list_delete.php" onsubmit="return fauthlist_submit(this);">
<input type="hidden" name="sst" value="<?php echo $sst ?>">
<input type="hidden" name="sod" value="<?php echo $sod ?>">
<input type="hidden" name="sfl" value="<?php echo $sfl ?>">
<input type="hidden" name="stx" value="<?php echo $stx ?>">
<input type="hidden" name="page" value="<?php echo $page ?>">
<input type="hidden" name="token" value="<?php echo $token ?>">

<div class="tbl_head01 tbl_wrap">
    <table>
    <caption><?php echo $g5['title']; ?> 목록</caption>
    <thead>
    <tr>
        <th scope="col">
            <label for="chkall" class="sound_only">현재 페이지 회원 전체</label>
            <input type="checkbox" name="chkall" value="1" id="chkall" onclick="check_all(this.form)">
        </th>
        <th scope="col"><?php echo subject_sort_link('a.mb_id'?>회원아이디</a></th>
        <th scope="col"><?php echo subject_sort_link('mb_nick'?>닉네임</a></th>
        <th scope="col">메뉴</th>
        <th scope="col">권한</th>
    </tr>
    </thead>
    <tbody>
    <?php
    $count 
0;
    for (
$i=0$row=sql_fetch_array($result); $i++)
    {
        
$is_continue false;
        
// 회원아이디가 없는 메뉴는 삭제함
        
if($row['mb_id'] == '' && $row['mb_nick'] == '') {
            
sql_query(" delete from {$g5['auth_table']} where au_menu = '{$row['au_menu']}' ");
            
$is_continue true;
        }

        
// 메뉴번호가 바뀌는 경우에 현재 없는 저장된 메뉴는 삭제함
        
if (!isset($auth_menu[$row['au_menu']]))
        {
            
sql_query(" delete from {$g5['auth_table']} where au_menu = '{$row['au_menu']}' ");
            
$is_continue true;
        }

        if(
$is_continue)
            continue;

        
$mb_nick get_sideview($row['mb_id'], $row['mb_nick'], $row['mb_email'], $row['mb_homepage']);

        
$bg 'bg'.($i%2);
    
?>
    <tr class="<?php echo $bg?>">
        <td class="td_chk">
            <input type="hidden" name="au_menu[<?php echo $i ?>]" value="<?php echo $row['au_menu'?>">
            <input type="hidden" name="mb_id[<?php echo $i ?>]" value="<?php echo $row['mb_id'?>">
            <label for="chk_<?php echo $i?>" class="sound_only"><?php echo $row['mb_nick'?>님 권한</label>
            <input type="checkbox" name="chk[]" value="<?php echo $i ?>" id="chk_<?php echo $i ?>">
        </td>
        <td class="td_mbid"><a href="?sfl=a.mb_id&amp;stx=<?php echo $row['mb_id'?>"><?php echo $row['mb_id'?></a></td>
        <td class="td_auth_mbnick"><?php echo $mb_nick ?></td>
        <td class="td_menu">
            <?php echo $row['au_menu'?>
            <?php echo $auth_menu[$row['au_menu']] ?>
        </td>
        <td class="td_auth"><?php echo $row['au_auth'?></td>
    </tr>
    <?php
        $count
++;
    }

    if (
$count == 0)
        echo 
'<tr><td colspan="'.$colspan.'" class="empty_table">자료가 없습니다.</td></tr>';
    
?>
    </tbody>
    </table>
</div>

<div class="btn_list01 btn_list">
    <input type="submit" name="act_button" value="선택삭제" onclick="document.pressed=this.value">
</div>

<?php
//if (isset($stx))
//    echo '<script>document.fsearch.sfl.value = "'.$sfl.'";</script>'."\n";

if (strstr($sfl'mb_id'))
    
$mb_id $stx;
else
    
$mb_id '';
?>
</form>

<?php
$pagelist 
get_paging(G5_IS_MOBILE $config['cf_mobile_pages'] : $config['cf_write_pages'], $page$total_page$_SERVER['PHP_SELF'].'?'.$qstr.'&amp;page=');
echo 
$pagelist;

?>

<form name="fauthlist2" id="fauthlist2" action="./auth_update.php" method="post" autocomplete="off" onsubmit='return false;'>
<input type="hidden" name="sfl" value="<?php echo $sfl ?>">
<input type="hidden" name="stx" value="<?php echo $stx ?>">
<input type="hidden" name="sst" value="<?php echo $sst ?>">
<input type="hidden" name="sod" value="<?php echo $sod ?>">
<input type="hidden" name="page" value="<?php echo $page ?>">
<input type="hidden" name="token" value="<?php echo $token ?>">
<input type="hidden" name="au_menu_list" value="">

<section id="add_admin">
    <h2 class="h2_frm">관리권한 추가</h2>

    <div class="local_desc01 local_desc">
        <p>
            다음 양식에서 회원에게 관리권한을 부여하실 수 있습니다.<br>
            권한 <strong>r</strong>은 읽기권한, <strong>w</strong>는 쓰기권한, <strong>d</strong>는 삭제권한입니다.
        </p>
    </div>

    <div class="tbl_frm01 tbl_wrap">
        <table>
        <colgroup>
            <col class="grid_4">
            <col>
        </colgroup>
        <tbody>
        <tr>
            <th scope="row"><label for="mb_id">회원아이디<strong class="sound_only">필수</strong></label></th>
            <td>
                <strong id="msg_mb_id" class="msg_sound_only"></strong>
                <input type="text" name="mb_id" value="<?php echo $mb_id ?>" id="mb_id" required class="required frm_input">
                <input type='button' class="btn_submit2" id='mb_sel_btn' value='회원확인' onclick='sel_id()'>
            </td>
        </tr>
        <tr>
            <th scope="row"><label for="au_menu">접근가능메뉴<strong class="sound_only">필수</strong></label></th>
            <td>
                <select id="au_menu" name="au_menu" required class="required" multiple size=15>
                    <option value=''>선택하세요</option>
                    <?php
                    
foreach($auth_menu as $key=>$value)
                    {
                        if (!(
substr($key, -3) == '000' || $key == '-' || !$key))
                            echo 
'<option value="'.$key.'">'.$key.' '.$value.'</option>';
                    }
                    
?>
                </select>
                    <div class='auth_div2'>
                        shift +  click : 범위 선택<br>
                        ctrl +  click : 개별 선택<br>
                        이미 적용된메뉴는 권한지정이 수정되어 적용되며, 권한 삭제는 위의 리스트에서 삭제 처리함
                    </div>
            </td>
        </tr>
        <tr>
            <th scope="row">권한지정</th>
            <td>
                <div style='z-index:3'>
                <input type="checkbox" name="r" value="r" id="r" checked>
                <label for="r">r (읽기)</label>
                <input type="checkbox" name="w" value="w" id="w">
                <label for="w">w (쓰기)</label>
                <input type="checkbox" name="d" value="d" id="d">
                <label for="d">d (삭제)</label>
                </div>
            </td>
        </tr>
        </tbody>
        </table>
    </div>

    <div class="btn_confirm01 btn_confirm">
        <input type="button" value="추가" class="btn_submit" onclick="add_auth()">
    </div>
</section>

</form>

<script>
function fauthlist_submit(f)
{
    if (!is_checked("chk[]")) {
        alert(document.pressed+" 하실 항목을 하나 이상 선택하세요.");
        return false;
    }

    if(document.pressed == "선택삭제") {
        if(!confirm("선택한 자료를 정말 삭제하시겠습니까?")) {
            return false;
        }
    }

    return true;
}

function sel_id(){
    if($("#mb_sel_btn").val()=='선택해제'){
        $("#mb_sel_btn").val('회원확인');
        $("input[name=mb_id]").attr("readonly",false);
        $("input[name=mb_id]").val('');
        return;
    }
    vx = $("input[name=mb_id]").val();
    $.ajax({
        type : "POST",    url : "<?php echo G5_ADMIN_URL?>/get_sel_id.php",    data: "mb_id="+vx, dataType : "xml",    
        success : function(xml){
            f = document.all;
            rtn_code = $(xml).find("rtn_code").text();
            if(rtn_code=='100'){
                alert('회원이 확인되었습니다.');
                $("input[name=mb_id]").attr("readonly",true);
                $("#mb_sel_btn").val('선택해제');
            } else {
                alert('정상적인 회원아이디가 아닙니다.');
            }
        },    
        error : function(v){ alert('실패!'); }
    });
}

function add_auth(){
    if($("#mb_sel_btn").val()!='선택해제'){ alert('회원을 선택하시기 바랍니다.'); return;    }

    var aml = "";
    $("#au_menu option").each(
        function(){
            if($(this).attr("selected")){
                aml = aml + $(this).val() + ",";
            }
        }
    );
    if(aml==''){ alert('접근가능메뉴를 선택하시기 바랍니다.'); return;    }
    else { $("input[name=au_menu_list]").val(aml); }

    var form_val = $('#fauthlist2').serialize();
    $.ajax({
        type : "POST",    url : "<?php echo G5_ADMIN_URL?>/get_add_auth.php",    data: form_val, dataType : "xml",    
        success : function(xml){
            f = document.all;
            rtn_code = $(xml).find("rtn_code").text();
            cnt = $(xml).find("cnt").text();
            if(rtn_code=='100'){
                alert(cnt+'건의 접근가능메뉴가 설정되었습니다.');
                document.location.reload();
            }
        },    
        error : function(v){ alert('실패!'); }
    });

}

</script>

<?php
include_once ('./admin.tail.php');
?>