/home/mjc1/public_html/j3demo/webhard/ajax.file_list_process.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
<?php
include_once("./_common.php");

if(
$mode=='dir'){
    if(
$cur_dir=='' && $new_dir!=''){
        
$dir "/".$new_dir;
    }
    if(
$cur_dir!='' && $new_dir==''){
        
$dir "/".$cur_dir;
    }
    if(
$cur_dir!='' && $new_dir!=''){
        
$dir "/".$cur_dir."/".$new_dir;
    }
    if(
$idxs!=''){
        
$sql "update webhard set b_virt_dir = '{$dir}' where idx in ({$idxs}) ";
        
mysql_query($sql,$connect_j3);
        echo 
"OK";
    } else {
        echo 
"이동할 파일이 선택되지 않았습니다.";
    }
}

if(
$mode=='file_copy'){
    
$datetime date("Y-m-d H:i:s",time());

    
$sql "select * from webhard where idx = '{$idxs}' ";
    
$res mysql_query($sql,$connect_j3);
    
$info mysql_fetch_array($res);

    if(
$cur_dir=='' && $new_dir!=''){
        
$dir "/".$new_dir;
    }
    if(
$cur_dir!='' && $new_dir==''){
        
$dir "/".$cur_dir;
    }
    if(
$cur_dir!='' && $new_dir!=''){
        
$dir "/".$cur_dir."/".$new_dir;
    }

    
$sql "insert into webhard set
                        b_table = '
{$info['b_table']}', b_idx = '{$info['b_idx']}', b_no = '{$info['b_no']}' , b_oriname = '{$info['b_oriname']}',
                        b_filename = '
{$info['b_filename']}', b_download = 0, b_filesize = '{$info['b_filesize']}', 
                        b_width = '
{$info['b_width']}', b_height = '{$info['b_height']}', b_regdate = '{$datetime}',
                        b_session_key = '
{$info['b_session_key']}', b_savedir = '{$info['b_savedir']}', b_realpos = '{$info['b_realpos']}',
                        b_virt_dir = '
{$dir}'
            "
;
    
mysql_query($sql,$connect_j3);
    echo 
"OK";
}

if(
$mode=='file_del'){
    
$idx_list explode(",",$idxs);
    foreach(
$idx_list as $key=>$idx){
        
$sql "select * from webhard where idx = '{$idx}' ";
        
$res mysql_query($sql,$connect_j3);
        
$info mysql_fetch_array($res);

        
$sql "select count(*) as cnt from webhard where b_realpos = '{$info['b_realpos']}' ";
        
$res mysql_query($sql,$connect_j3);
        
$cnt_info mysql_fetch_array($res);
        if(
$cnt_info['cnt']>1){
            
$sql "delete from webhard where idx = '{$idx}' ";
            
mysql_query($sql,$connect_j3);
        } else {
            
$sql "delete from webhard where idx = '{$idx}' ";
            
mysql_query($sql,$connect_j3);

            
unlink($info['b_realpos']); // 서버위치가 1개이면 파일을 삭제함
        
}
    }

    echo 
"OK";
}

?>