/home/mjc1/public_html/manage/adminShopPatchProcess.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
<?php
set_time_limit
(3600);
include(
"./_common.php");

_pr("¼Â Å¸ÀÓ ¸®¹ÌÆ® 30ÃÊ Á¦ÇÑÀ» °É¾î³ù±â ¶§¹®¿¡ ¿À·¡°É¸±°æ¿ì ÇØ´ç ¸®¹ÌÆ®¸¦ º¯°æÀ» ÇÏ´øÁö ÆÄÀÏ È®ÀΠ¹Ù¶÷");

$htmlx "";

$adm_info admin_member_info();
if(!(
$adm_info['admin_id']=='psw' || $adm_info['admin_id']=='kns' || $adm_info['admin_id']=='bsj')){
    echo 
"<script>alert('Á¢±ÙÇϽǠ±ÇÇÑÀÌ ¾ø½À´Ï´Ù.'); window.history.go(-1);</script>"; exit;
}

$dir_list = Array();

function 
dir_scan($save_dir){
    Global 
$dir_list;
    
$dh opendir($save_dir);
    while ((
$file readdir($dh)) !== false) {
        if(!(
$file=='.' || $file=='..' || strpos($file,"tar")>0)){
            
$file_type filetype($save_dir ."/"$file);
            
//_pr("filename: {$save_dir}/{$file} : filetype: " . $file_type);
            
if($file_type=='file'){
                
$dir_list[] = $save_dir."/".$file;
            } else {
                
dir_scan($save_dir."/".$file);
            }
        }
    }
    
closedir($dh);
}

function 
ext_filename($v){
    
$vv explode("/",$v);
    return 
$vv[count($vv)-1];
}

function 
ftp_send_request($save_dir,$dir_list,$sv_info,$shop_type){
    Global 
$htmlx;

    
//_pr($sv_info);

    
$ftp_server $sv_info['ftp_server'];
    
$ftp_user $sv_info['ftp_user'];
    
$ftp_pass $sv_info['ftp_pass'];

    
$conn_id ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); 

    if (@
ftp_login($conn_id$ftp_user$ftp_pass)) {
        
$htmlx .= "\nConnected as $ftp_user@$ftp_server\n";
    } else {
        
$htmlx .= "\nCouldn't connect as $ftp_user\n";
    }

    for(
$i=0;$i<count($dir_list);$i++){
        
$file $dir_list[$i];
        
$local_file $save_dir.substr($file,1,strlen($file));
        
//$r_file = ext_filename($file);
        
$remote_dir $sv_info['remote_dir'];
        for(
$j=0;$j<count($sv_info['remote_shop_dir']);$j++){
            if(
$shop_type!=""){
                if(
$shop_type!=$sv_info['remote_shop_type'][$j]){ continue; }
            }
            
$remote_shop_dir $sv_info['remote_shop_dir'][$j];
            
$remote_file $remote_dir.$remote_shop_dir.substr($file,1,strlen($file));

            
//_pr($remote_file." ".$local_file);

            
if (ftp_put($conn_id$remote_file$local_fileFTP_BINARY)) {
                
$htmlx .= "successfully uploaded $remote_shop_dir$file \n";
            } else {
                
$htmlx .= "There was a problem while uploading $remote_shop_dir$file \n";
            }
        }
    }

    
ftp_close($conn_id);  

}


$shop_type $_POST['shop_type'];
$index_key date("Ymd_H",time());
$base_dir $_SERVER['DOCUMENT_ROOT']."/save_dir/shop_patch";
$save_dir $base_dir."/".$index_key;
mkdir($save_dir,0705);

$file $_FILES['patch_file'];
if(
$file['name']!='' && $file['size']>0){
    
$upload_filename urlencode($file['name']);
    
copy($file['tmp_name'],$save_dir."/".$upload_filename);
}

chdir($save_dir);
$command "tar -xvf {$save_dir}/{$upload_filename} ";
exec($command);

dir_scan(".");
//_pr($dir_list); exit;

$sv_info null;
$sv_info['ftp_server'] = "mjsoft.co";
$sv_info['ftp_user'] = "mjc1";
$sv_info['ftp_pass'] = "mju7&UJMnhy6";
$sv_info['remote_dir'] = "/public_html";
$sql "select * from mBoard_shopping where server = 'mjsoft.co' and cs_type = '{$cs_type}' ";
$res mysql_query($sql,$connect_web);
while(
$info=mysql_fetch_array($res)){
    
$sv_info['remote_shop_dir'][] = $info['dir_name']; 
    
$sv_info['remote_shop_type'][] = $info['skin_type'];    
}
$servers[] = $sv_info;

$sv_info null;
if(
$cs_type=='3'){ // Ãµ³â3´Â 100¹ø ¼­¹ö·Î ¿Å°Ü¼­ ´Ù¸£°Ô Ã³¸®
    
$sv_info['ftp_server'] = "shop2.mjsoft.co"
} else {
    
$sv_info['ftp_server'] = "shop.mjsoft.co";
}
$sv_info['ftp_user'] = "mijin";
$sv_info['ftp_pass'] = "12alwls#$";
if(
$cs_type=='3'){
    
//$sv_info['remote_dir'] = "/www";
    
$sv_info['remote_dir'] = "./home/www";
} else {
    
$sv_info['remote_dir'] = "/home/www";
}
$sql "select * from mBoard_shopping where server = '{$sv_info['ftp_server']}'  and cs_type = '{$cs_type}'  and server = 'shop2.mjsoft.co' and custom_type = 'Ç¥ÁØ' ";
$res mysql_query($sql,$connect_web);
while(
$info=mysql_fetch_array($res)){
    
$sv_info['remote_shop_dir'][] = $info['dir_name']; 
    
$sv_info['remote_shop_type'][] = $info['skin_type'];    
}

$servers[] = $sv_info;

$sv_info null;
$sv_info['ftp_server'] = "shop3.mjsoft.co"
$sv_info['ftp_user'] = "mijin";
$sv_info['ftp_pass'] = "12alwls#$";
if(
$cs_type=='3'){
    
//$sv_info['remote_dir'] = "/www";
    
$sv_info['remote_dir'] = ".";
} else {
    
$sv_info['remote_dir'] = "/home/www";
}
$sql "select * from mBoard_shopping where server = '{$sv_info['ftp_server']}'  and cs_type = '{$cs_type}'  and server = 'shop3.mjsoft.co' and custom_type = 'Ç¥ÁØ' ";
$res mysql_query($sql,$connect_web);
while(
$info=mysql_fetch_array($res)){
    
$sv_info['remote_shop_dir'][] = $info['dir_name']; 
    
$sv_info['remote_shop_type'][] = $info['skin_type'];    
}


$servers[] = $sv_info;

for(
$i=0;$i<count($servers);$i++){
    
ftp_send_request($save_dir,$dir_list,$servers[$i],$shop_type);
}

?>
<textarea name='debug' style='width:800px;height:400px;'><?php echo $htmlx;?></textarea>
<input type='button' value='µ¹¾Æ°¡±â' onclick="document.location.href='admin_shop_patch.php?menu=10&sub=5';">