/home/mjc1/public_html/j3demo/webhard/index.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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<?php
include_once("./_common.php");
include_once(
$j3_path."/webhard/header.php");

$session_key get_microtime();

//_pr($session_key);
$add_mode="Y";
$edit_mode"Y";
$del_mode"Y";

?>
<link rel="stylesheet" href="./iconfont/css/fontello.css"/>
<style>
    .pm_dir { display:inline-block; width:15px; font-size:1.1em;  }
    .dir_tree_class li { padding:4px 0 2px 0; }
</style>
<div id="container">
    <div id="wrapper">
            <section  class="mt50 width_full top_bold_line gray_line_b2">
                <!-- 받으시는 분 입력 시작 { -->
                <div class="float_l width400 p20_50 gray_r_line2" style='overflow:auto;height:550px;'>
                    <?php include("dir.inc.php");?>
                </div>
                <div class="file_list_class float_l width640 p20_50 gray_r_line2" style='overflow:auto;height:550px;'>
                    <input type='hidden' name='cur_dir' value=''>
                    <input type='hidden' name='cur_page' value='1'>
                    <div class="sub-btn-area">
                        <div class="sub-btn mb10">
                        <?php if($add_mode=='Y'){?>
                            &nbsp;&nbsp;<input type='button' value='파일 추가' onclick='add_file()'>
                        <?php ?>
                        <?php if($del_mode=='Y'){?>
                            &nbsp;&nbsp;<input type='button' value='파일 삭제' onclick='file_del()'>
                        <?php ?>
                        &nbsp;&nbsp;<input type='button' value='다운로드' onclick='file_down()'>
                        </div>
                    </div>
                    <table class="width_full top_bold_line">
                        <colgroup>
<?php if($edit_mode=='Y'){ ?>
                            <col class="width50">
<?php }?>
                            <col class="width300"><col class="width100"><col class="width100"><col class="width80">
                        </colgroup>
                        <thead>
                        <tr>
<?php if($edit_mode=='Y'){ ?>
                            <th class="p15_0 txt14 gray_line_b">
                                <input type='checkbox' name='ck_all' class='check_all_class'>
                            </th>
<?php }?>
                            <th class="p15_0 txt14 gray_line_b">파일명</th>
                            <th class="p15_0 txt14 gray_line_b">파일크기</th>
                            <th class="p15_0 txt14 gray_line_b">등록일</th>
                            <th class="p15_0 txt14 gray_line_b">파일URL</th>
                        </tr>
                        <thead>
                        <tbody>

                        </tbody>
                    </table>
                    <div class='pg_wrap table_page_wrap' style='padding-top:0px;'>

                    </div>
                </div>
                <!-- } 받으시는 분 입력 끝 -->
                <form name='file_list_form' id='file_list_form' method='post' onsubmit='return false;' class='none'>
                    페이지<input type='text' name='page' value='1'><br>
                    폴더<input type='text' name='folder' value=''><br>
                </form>
            </section>
            <!-- } 배송정보 끝 -->

<!--버튼-->
            <div class="mt50 align_c">
                <!--<input type="button" class="box170_50 white bold line0 bg_custom2 pointer file_process_class" value="업로드하기" />
                <input type="button" class="box170_50 custom2 bold align_c bg_white custom_line2 pointer add_file_upload" value="파일추가" />-->
            </div>
            <!--//버튼-->

    </div><!-- #wrapper -->
</div><!-- #container -->

<script>
$(function(){
    load_dir1();
    $(".new_folder_span").hide();

    $(document).on("mouseenter",".dir_click_class",function(){
        $(this).addClass("pointer");
    });

    $(document).on("click",".dir_click_class",function(){
        $v = $(this).data("dir");
        $("#file_list_form input[name='folder']").val($v);
        $("input[name='cur_dir']").val($v);
        $page = 1;
        file_list_get($page);
    });

    $(document).on("click",".close_url_class",function(){
        $(".url_class").css("display","none");
    });
});

    $(function(){
        $(".close_url_class").click(function(){
            $(".url_class").css("display","none");
        });
    });

    function url_show(this_val){
        $(this_val).closest("td").find(".url_class").show();
    }

function show_debug($v){
    $("#debug textarea").html("<p>§"+$v+"§</p>").show();
}

function file_list_get($page){
    $("#file_list_form input[name='page']").val($page);
    form_data = $("#file_list_form").serialize();
    $.post("ajax.file_list_get_process.php",form_data,function(rtn){
        //show_debug(rtn);
        $vv = rtn.split("§§");
        $(".file_list_class table tbody").html($vv[0]);
        $(".pg_wrap").html($vv[1]);
        $("input[name='cur_page']").val($page);
    });
}

function add_file(){
    $("#modal_member_box3 .attached_class").html('');

    $v = $(".file_attach_input").val();
    $(".file_td").html($v);

    $("#modal_member_box3").dialog({
        resizable: true, height:600, width:800, modal: true, title:"파일 업로드 [선택]",
        buttons: {
            닫기: function() {
                $( this ).dialog( "close" );
            }
        }
    });
}

function file_del(){
    $flag = 0;
    $flag_idx = "";
    $(".code_idx_class").each(function(){
        if($(this).is(":checked")){
            $v = $(this).closest("td").find("input[name='codes[]']").val();
            $flag_idx = $flag_idx + $v+",";
        }
    });
    $flag_idx = $flag_idx.substr(0,$flag_idx.length-1);
    if($flag_idx==''){ alert('삭제할 파일을 선택하시기 바랍니다.'); return; }
    if(confirm('해당파일들을 정말로 삭제하시겠습니까?')){
        $("#dir_move_form input[name='idxs']").val($flag_idx);

        $form_obj = $("#dir_move_form");
        form_data = $form_obj.serialize();
        form_data = form_data + "&mode=file_del";
        $.post("ajax.file_list_process.php",form_data,function(rtn){
            if(rtn=='OK'){ 
                $cur_page = $("input[name='cur_page']").val();
                file_list_get($cur_page);
            } else { 
                alert(rtn); 
            }
        });
    }
}

function file_down(){
    $flag = 0;
    $flag_idx = "";
    $(".code_idx_class").each(function(){
        if($(this).is(":checked")){
            $v = $(this).closest("td").find("input[name='codes[]']").val();
            $flag_idx = $flag_idx + $v+",";
        }
    });
    $flag_idx = $flag_idx.substr(0,$flag_idx.length-1);
    if($flag_idx==''){ alert('다운로드할 파일을 선택하시기 바랍니다.'); return; }
    document.location.href='file_zip_download.php?idxs='+$flag_idx;
}

</script>
<?php

if($dir!=''){
    
// $dir정보 넘어올시 처리
    
$dir_s explode("/",$dir);

    
$op_dir "";
    
$level 1;
    
$timeout 250;
    foreach(
$dir_s as $key=>$val){
        if(
$level==1){
            
$op_dir $val;
        } else {
            
$op_dir .= "/".$val;
        }
?>
<script>
$(function(){
    setTimeout(function(){
        $(".icon-plus-squared").each(function(){
            $level = $(this).data("level");
            if($level=='<?php echo $level;?>'){
                $span = $(this).find("span").text();
                if($span=='<?php echo $op_dir;?>'){
                    $(this).click();
                    $li = $(this).closest("li").find(".dir_click_class");
                    $li.click();
                }
            }
        });
    },<?php echo $timeout;?>);
});
</script>
<?php
        $level
++;
        
$timeout += 250;
    }
?>
<script>
setTimeout(function(){
    $(".dir_click_class").each(function(){
        $dir = $(this).data("dir");
        if($dir=='<?php echo $dir?>'){
            $(this).click();
        }
    });
},<?php echo $timeout;?>);
</script>
<?php
}
?>

<div id="modal_member_box3" class='modal_class' title="거래처수정" style="display:none;width:100%; height:100%; padding-top:3px;padding-left:3px;background-color:#FFFFFF;position:relative;">
    <script>
    $(function(){
        $("#file_form").ajaxForm({
            dataType: 'json',
            beforeSend: function() {
                $('#debug').append( "beforeSend...\n" );
            },
            complete: function(data) {
                $('#debug')
                    .append( "complete...\n" )
                    .append( JSON.stringify( data.responseJSON ) + "\n" );
            
                obj = data.responseJSON;
                $(".attached_class").append(obj.file_html);

                $("#file_form input[name^=attach]").each(function(){ // 첨부파일 필드 초기회
                    if($(this).attr("type")=='file'){ $(this).val(''); }
                });
                $(".foo_class").hide();
                file_list_get(1);
            }
        });

        $(".file_process_class").click(function(){
            $file_cnt = 0;
            $("#file_form input[name='attach[]']").each(function(){
                $val = $(this).val();
                if($val!=''){ $file_cnt++; }
            });
            if($file_cnt==0){ alert('첨부파일을 등록하시기 바랍니다.'); return; }

            $("#file_form").submit();
        });

        $(".add_file_upload").click(function(){
            $v = $(".file_attach_input").val();
            $(".file_td").append($v);
        });

        $(document).on("click",".file_del_class",function(){
            $this = $(this);
            if(confirm('정말로 삭제하시겠습니까?')){
                $idx = $(this).data('idx');
                form_data = "mode=del&idx="+$idx
                $.post("./ajax.file_upload_process.php",form_data,function(rtn){
                    if(rtn=='OK'){
                        $obj = $this.closest("p");
                        $obj.remove();
                        file_list_get(1);
                    } else {
                        alert(rtn);
                    }
                });
            }
        });

        $(document).on("change","input[name='attach[]']",function(){ // 이미지 미리 보기
            readURL(this);
        });

        $(document).on("click",".f_box_del_class",function(){ // 첨부 input삭제
            if($(".f_box_del_class").length>1){
                $(this).closest("p").remove();
            }
        });

    });

    function show_debug($v){
        $("#debug").append("<p>§"+$v+"§</p>");
    }

    function readURL(input) {
        $fn = $(input).val().split(".");
        $ext = $fn[$fn.length-1].toLowerCase();
        if($ext=='jpg' || $ext=='png' || $ext=='gif'){
            if (input.files && input.files[0]) {
                var reader = new FileReader();
                reader.onload = function(e) {
                    $img = $(input).closest("p").find("#foo");
                    $img.attr('src', e.target.result);
                    $img.show();
                }
                reader.readAsDataURL(input.files[0]);
            }
        }
    }   

    function dir_select(){
        load_dir1();
        $("#modal_member_box2").dialog({
            resizable: true, height:400, width:600, modal: true, title:"폴더 [선택]",
            buttons: {
                폴더선택: function() {
                    $("#modal_member_box3 input[name='cur_dir']").val($("#modal_member_box2 input[name='cur_dir']").val());
                    $("#modal_member_box3 input[name='new_dir']").val($("#modal_member_box2 input[name='new_dir']").val());
                    $( this ).dialog( "close" );
                },
                닫기: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    }
    </script>

    <div id='debug' class='none'><textarea></textarea></div>
    <script src='<?php echo $j3_js_url?>/jquery.form.min.js'></script>
    <form name='file_form' id='file_form' method='post' onsubmit='return false;' action="ajax.file_upload_process.php" enctype='multipart/form-data'>
    <input type='hidden' name='session_key' value='<?php echo $session_key?>'>
            <section  class="mt50 width_full top_bold_line gray_line_b2">
                <!-- 받으시는 분 입력 시작 { -->
                <div class="float_l width800 p20_50 gray_r_line2">
                    <table class="width_full">
                        <caption class="mb20 txt16 bold align_l">파일업로드</caption>
                        <colgroup>
                            <col class="width100"><col class="">
                        </colgroup>
                        <tbody>
                        <tr>
                            <th scope="row" class="p5_0 gray2 align_l">
                                <input type='button' value='폴더 선택' onclick='dir_select()'>
                            </th>
                            <td class="p3_0">
                                <input type='text' name='cur_dir' readonly value='' class='width300' style=''>/<input type='text' name='new_dir' value='' class='width100'>(새폴더추가)
                            </td>
                        </tr>
                        <tr>
                            <th scope="row" class="p5_0 gray2 align_l">첨부파일</th>
                            <textarea class='none file_attach_input'><p class='pt5'><input type='file' name='attach[]'>&nbsp;<img id='foo' src='' class='none foo_class' style='max-width:200px;'> <span class='f_box_del_class'>[x]</span></p></textarea><!-- 추가 복사용 -->
                            <td class="p3_0 file_td">
                                <p class='pt5'><input type='file' name='attach[]'>&nbsp;<img id='foo' src='' class='none foo_class' style='max-width:200px;'></p>
                            </td>
                        </tr>
                        <tr>
                            <td>첨부된 파일</>
                            <td class='attached_class'>

                            </td>
                        </tr>
                    </table>
                </div>
                <!-- } 받으시는 분 입력 끝 -->

            </section>
            <!-- } 배송정보 끝 -->
</form>

<!--버튼-->
            <div class="mt50 align_c">
                <input type="button" class="box170_50 white bold line0 bg_custom2 pointer file_process_class" value="업로드하기" />
                <input type="button" class="box170_50 custom2 bold align_c bg_white custom_line2 pointer add_file_upload" value="파일추가" />
            </div>
            <!--//버튼-->

</div>

<div id="modal_member_box2" class='modal_class' title="거래처수정" style="display:none;width:100%; height:100%; padding-top:3px;padding-left:3px;background-color:#FFFFFF;position:relative;">
    <?php include("dir.inc.php");?>
</div>