/home/mjc1/public_html/j3demo/adm/ajax.product_use_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
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
<?php
$dir 
".";
include_once(
$dir."/_common.php");

function 
prod_use_img($files$post){
    Global 
$j3_data_path$j3_data_url;

    
$v_ct_idx $post['ct_idx'];
    if(
$post['iu_img_del']=='Y'){
        
$del_path $j3_data_path."/item_use/iu_{$v_ct_idx}";
        
unlink($del_path);
    }
    
$msg "";
    if(
$files['iu_file']['name']!='' && $v_ct_idx>0){
        
        
$f_type explode("/",$files['iu_file']['type']);
        if(
$f_type[1]=='jpeg' || $f_type[1]=='gif' || $f_type[1]=='png'){ // 확장자가 이미지일경우만

            
if($files['iu_file']['size']*1<5242880){
                
$file_name "iu_{$v_ct_idx}";
                
$dest $j3_data_path."/item_use/";
                @
mkdir($destG5_DIR_PERMISSION);
                @
chmod($destG5_DIR_PERMISSION);
                
move_uploaded_file($files['iu_file']['tmp_name'],$dest.$file_name);
                @
chmod($dest.$file_nameG5_FILE_PERMISSION);

                
$rtn $dest $j3_data_url."/item_use/".$file_name;
                
$mode_ok "Y";
            } else {
                
$msg "5MB이하파일만 업로드 가능합니다.";
            }
        } else {
            
$msg "jpg, gif, png 파일만 업로드 가능합니다.";
        }
    }
    return 
$msg;
}

//$_POST['buyprice'] = preg_replace("/[^0-9]/", "", $_POST['buyprice']);

$mode_ok "Y";

if(
$sel_del=='Y' && $mode_ok=='Y') { // 삭제
    
$mode "delete"
    
    
$code_list "";
    foreach(
$code_idx as $key=>$val){
        
$code_list .= "{$codes[$val]},";
    }
    if(
$mode_ok=='Y'){
        
$code_list substr($code_list,0,strlen($code_list)-1);

        
update_del_log("shop_prod_use""idx"$code_list,"del"); // 삭제 로그 처리
        
$sql "delete from shop_prod_use where idx in ({$code_list}) ";
        
$res mysql_query($sql,$connect_j3); $all_sql .= $sql;
    }
} else if(
$code!='' && $mode_ok=='Y'){ // 수정
    
$mode "update";

    
$msg prod_use_img($_FILES$_POST);

    if(
$msg==''){
        
$sql "update shop_prod_use set
                    pcode = '
{$pcode}', ccode = '{$ccode}', iu_name = '{$iu_name}', 
                    iu_subject = '
{$iu_subject}', iu_content = '{$iu_content}', iu_time = '{$iu_time}'
                    , iu_ip = '"
.$_SERVER['REMOTE_ADDR']."', iu_score = '{$iu_score}', iu_view = '{$iu_view}', ct_idx = '{$ct_idx}'
                where idx = '
{$code}'
        "
;
        
mysql_query($sql,$connect_j3); $all_sql .= $sql;

        
update_del_log("shop_prod_use""idx"$code,""); // 업데이트 로그 처리
    
} else {
        
$mode_ok="N";
    }

    
} else {
    
$mode "new";

    
$msg prod_use_img($_FILES$_POST);

    if(
$msg==''){
        
$sql "insert into shop_prod_use set
                    pcode = '
{$pcode}', ccode = '{$ccode}', iu_name = '{$iu_name}', 
                    iu_subject = '
{$iu_subject}', iu_content = '{$iu_content}', iu_time = '{$iu_time}'
                    , iu_ip = '"
.$_SERVER['REMOTE_ADDR']."', iu_score = '{$iu_score}', iu_view = '{$iu_view}', ct_idx = '{$ct_idx}'
        "
;
        
mysql_query($sql,$connect_j3); $all_sql .= $sql;
    } else {
        
$mode_ok="N";
    }
}

if(
$sel_del=='Y'){
    echo 
"<?php xml version='1.0' encoding='utf-8'?><output>";
    echo 
"<mode>".$mode."</mode>";
    echo 
"<mode_ok>".$mode_ok."</mode_ok>";
    echo 
"<rtn_url>".$rtn_url."</rtn_url>";
    echo 
"<msg>".$msg."</msg>";
    echo 
"<sql>".$all_sql."</sql>";
    echo 
"</output>";
} else {
?>
    <script>
    <?php if($mode_ok=="N"){ ?>
        alert('<?php echo $msg;?>');
    <?php ?>
        document.location.href="product_use.php?<?php echo $qstr;?>"
    </script>
<?php
}
?>