1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
/** |
4
|
|
|
* @class installAdminController |
5
|
|
|
* @author NAVER ([email protected]) |
6
|
|
|
* @brief admin controller class of the install module |
7
|
|
|
*/ |
8
|
|
|
class installAdminController extends install |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @brief Initialization |
12
|
|
|
*/ |
13
|
|
|
function init() |
14
|
|
|
{ |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @brief Install the module |
19
|
|
|
*/ |
20
|
|
|
function procInstallAdminInstall() |
21
|
|
|
{ |
22
|
|
|
$module_name = Context::get('module_name'); |
23
|
|
|
if(!$module_name) return new object(-1, 'invalid_request'); |
24
|
|
|
|
25
|
|
|
$oInstallController = getController('install'); |
26
|
|
|
$oInstallController->installModule($module_name, './modules/'.$module_name); |
27
|
|
|
|
28
|
|
|
$this->setMessage('success_installed'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @brief Upate the module |
33
|
|
|
*/ |
34
|
|
|
function procInstallAdminUpdate() |
35
|
|
|
{ |
36
|
|
|
@set_time_limit(0); |
|
|
|
|
37
|
|
|
$module_name = Context::get('module_name'); |
38
|
|
|
if(!$module_name) return new object(-1, 'invalid_request'); |
39
|
|
|
|
40
|
|
|
$oModule = getModule($module_name, 'class'); |
41
|
|
|
if($oModule) $output = $oModule->moduleUpdate(); |
42
|
|
|
else $output = new Object(-1, 'invalid_request'); |
43
|
|
|
|
44
|
|
|
return $output; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @brief Change settings |
49
|
|
|
*/ |
50
|
|
|
function procInstallAdminSaveTimeZone() |
51
|
|
|
{ |
52
|
|
|
$db_info = Context::getDBInfo(); |
53
|
|
|
|
54
|
|
|
$admin_ip_list = Context::get('admin_ip_list'); |
55
|
|
|
|
56
|
|
|
if($admin_ip_list) |
57
|
|
|
{ |
58
|
|
|
$admin_ip_list = preg_replace("/[\r|\n|\r\n]+/",",",$admin_ip_list); |
59
|
|
|
$admin_ip_list = preg_replace("/\s+/","",$admin_ip_list); |
60
|
|
|
if(preg_match('/(<\?|<\?php|\?>)/xsm', $admin_ip_list)) |
61
|
|
|
{ |
62
|
|
|
$admin_ip_list = ''; |
63
|
|
|
} |
64
|
|
|
$admin_ip_list .= ',127.0.0.1,' . $_SERVER['REMOTE_ADDR']; |
65
|
|
|
$admin_ip_list = explode(',',trim($admin_ip_list, ',')); |
66
|
|
|
$admin_ip_list = array_unique($admin_ip_list); |
67
|
|
|
if(!IpFilter::validate($admin_ip_list)) { |
68
|
|
|
return new Object(-1, 'msg_invalid_ip'); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$default_url = Context::get('default_url'); |
73
|
|
View Code Duplication |
if($default_url && strncasecmp('http://', $default_url, 7) !== 0 && strncasecmp('https://', $default_url, 8) !== 0) $default_url = 'http://'.$default_url; |
74
|
|
|
if($default_url && substr($default_url, -1) !== '/') $default_url = $default_url.'/'; |
75
|
|
|
|
76
|
|
|
/* convert NON Alphabet URL to punycode URL - Alphabet URL will not be changed */ |
77
|
|
|
require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
78
|
|
|
$IDN = new idna_convert(array('idn_version' => 2008)); |
79
|
|
|
$default_url = $IDN->encode($default_url); |
80
|
|
|
|
81
|
|
|
$use_ssl = Context::get('use_ssl'); |
82
|
|
|
if(!$use_ssl) $use_ssl = 'none'; |
83
|
|
|
|
84
|
|
|
$http_port = Context::get('http_port'); |
85
|
|
|
$https_port = Context::get('https_port'); |
86
|
|
|
|
87
|
|
|
$use_rewrite = Context::get('use_rewrite'); |
88
|
|
|
if($use_rewrite!='Y') $use_rewrite = 'N'; |
89
|
|
|
|
90
|
|
|
$use_sso = Context::get('use_sso'); |
91
|
|
|
if($use_sso !='Y') $use_sso = 'N'; |
92
|
|
|
|
93
|
|
|
$use_db_session = Context::get('use_db_session'); |
94
|
|
|
if($use_db_session!='Y') $use_db_session = 'N'; |
95
|
|
|
|
96
|
|
|
$qmail_compatibility = Context::get('qmail_compatibility'); |
97
|
|
|
if($qmail_compatibility!='Y') $qmail_compatibility = 'N'; |
98
|
|
|
|
99
|
|
|
$use_html5 = Context::get('use_html5'); |
100
|
|
|
if(!$use_html5) $use_html5 = 'N'; |
101
|
|
|
|
102
|
|
|
$db_info->default_url = $default_url; |
103
|
|
|
$db_info->qmail_compatibility = $qmail_compatibility; |
104
|
|
|
$db_info->use_db_session = $use_db_session; |
105
|
|
|
$db_info->use_rewrite = $use_rewrite; |
106
|
|
|
$db_info->use_sso = $use_sso; |
107
|
|
|
$db_info->use_ssl = $use_ssl; |
108
|
|
|
$db_info->use_html5 = $use_html5; |
109
|
|
|
$db_info->admin_ip_list = $admin_ip_list; |
110
|
|
|
|
111
|
|
|
if($http_port) $db_info->http_port = (int) $http_port; |
112
|
|
|
else if($db_info->http_port) unset($db_info->http_port); |
113
|
|
|
|
114
|
|
|
if($https_port) $db_info->https_port = (int) $https_port; |
115
|
|
|
else if($db_info->https_port) unset($db_info->https_port); |
116
|
|
|
|
117
|
|
|
unset($db_info->lang_type); |
118
|
|
|
|
119
|
|
|
$oInstallController = getController('install'); |
120
|
|
|
if(!$oInstallController->makeConfigFile()) |
121
|
|
|
{ |
122
|
|
|
return new Object(-1, 'msg_invalid_request'); |
123
|
|
|
} |
124
|
|
|
else |
125
|
|
|
{ |
126
|
|
|
Context::setDBInfo($db_info); |
127
|
|
|
if($default_url) |
|
|
|
|
128
|
|
|
{ |
129
|
|
|
$site_args = new stdClass; |
130
|
|
|
$site_args->site_srl = 0; |
131
|
|
|
$site_args->domain = $default_url; |
132
|
|
|
$oModuleController = getController('module'); |
133
|
|
|
$oModuleController->updateSite($site_args); |
134
|
|
|
} |
135
|
|
|
$this->setRedirectUrl(Context::get('error_return_url')); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
function procInstallAdminUpdateIndexModule() |
140
|
|
|
{ |
141
|
|
|
if(!Context::get('index_module_srl') || !Context::get('menu_item_srl')) |
142
|
|
|
{ |
143
|
|
|
return new Object(-1, 'msg_invalid_request'); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
$site_args = new stdClass(); |
147
|
|
|
$site_args->site_srl = 0; |
148
|
|
|
$site_args->index_module_srl = Context::get('index_module_srl'); |
149
|
|
|
$oModuleController = getController('module'); |
150
|
|
|
$oModuleController->updateSite($site_args); |
151
|
|
|
|
152
|
|
|
// get menu item info |
153
|
|
|
$menuItemSrl = Context::get('menu_item_srl'); |
154
|
|
|
$oMenuAdminModel = getAdminModel('menu'); |
155
|
|
|
$output = $oMenuAdminModel->getMenuItemInfo($menuItemSrl); |
156
|
|
|
|
157
|
|
|
// update homeSitemap.php cache file |
158
|
|
|
$oMenuAdminController = getAdminController('menu'); |
159
|
|
|
$homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile(); |
160
|
|
|
if(file_exists($homeMenuCacheFile)) |
161
|
|
|
{ |
162
|
|
|
include($homeMenuCacheFile); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
if(!$homeMenuSrl || $homeMenuSrl != $output->menu_srl) |
|
|
|
|
166
|
|
|
{ |
167
|
|
|
$oMenuAdminController->makeHomemenuCacheFile($output->menu_srl); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
$this->setMessage('success_updated'); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
function procInstallAdminRemoveFTPInfo() |
174
|
|
|
{ |
175
|
|
|
$ftp_config_file = Context::getFTPConfigFile(); |
176
|
|
|
if(file_exists($ftp_config_file)) unlink($ftp_config_file); |
177
|
|
|
if($_SESSION['ftp_password']) unset($_SESSION['ftp_password']); |
178
|
|
|
$this->setMessage('success_deleted'); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
function procInstallAdminSaveFTPInfo() |
182
|
|
|
{ |
183
|
|
|
$ftp_info = Context::getFTPInfo(); |
184
|
|
|
$ftp_info->ftp_user = Context::get('ftp_user'); |
185
|
|
|
$ftp_info->ftp_port = Context::get('ftp_port'); |
186
|
|
|
$ftp_info->ftp_host = Context::get('ftp_host'); |
187
|
|
|
$ftp_info->ftp_pasv = Context::get('ftp_pasv'); |
188
|
|
|
if(!$ftp_info->ftp_pasv) $ftp_info->ftp_pasv = "N"; |
189
|
|
|
$ftp_info->sftp = Context::get('sftp'); |
190
|
|
|
|
191
|
|
|
$ftp_root_path = Context::get('ftp_root_path'); |
192
|
|
|
if(substr($ftp_root_path, strlen($ftp_root_path)-1) == "/") |
193
|
|
|
{ |
194
|
|
|
$ftp_info->ftp_root_path = $ftp_root_path; |
195
|
|
|
} |
196
|
|
|
else |
197
|
|
|
{ |
198
|
|
|
$ftp_info->ftp_root_path = $ftp_root_path.'/'; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
if(ini_get('safe_mode')) |
202
|
|
|
{ |
203
|
|
|
$ftp_info->ftp_password = Context::get('ftp_password'); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
$buff = '<?php if(!defined("__XE__")) exit();'."\n\$ftp_info = new stdClass;\n"; |
207
|
|
|
foreach($ftp_info as $key => $val) |
208
|
|
|
{ |
209
|
|
|
if(!$val) continue; |
210
|
|
|
if(preg_match('/(<\?|<\?php|\?>|fputs|fopen|fwrite|fgets|fread|file_get_contents|file_put_contents|exec|proc_open|popen|passthru|show_source|phpinfo|system|\/\*|\*\/|chr\()/xsm', preg_replace('/\s/', '', $val))) |
211
|
|
|
{ |
212
|
|
|
continue; |
213
|
|
|
} |
214
|
|
|
$buff .= sprintf("\$ftp_info->%s = '%s';\n", $key, str_replace("'","\\'",$val)); |
215
|
|
|
} |
216
|
|
|
$buff .= "?>"; |
217
|
|
|
$config_file = Context::getFTPConfigFile(); |
218
|
|
|
FileHandler::WriteFile($config_file, $buff); |
219
|
|
|
if($_SESSION['ftp_password']) unset($_SESSION['ftp_password']); |
220
|
|
|
|
221
|
|
|
$this->setMessage('success_updated'); |
222
|
|
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigFtp'); |
223
|
|
|
$this->setRedirectUrl($returnUrl); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
function procInstallAdminConfig() |
227
|
|
|
{ |
228
|
|
|
$use_mobile_view = Context::get('use_mobile_view'); |
229
|
|
|
if($use_mobile_view!='Y') $use_mobile_view = 'N'; |
230
|
|
|
|
231
|
|
|
$time_zone = Context::get('time_zone'); |
232
|
|
|
|
233
|
|
|
$db_info = Context::getDBInfo(); |
234
|
|
|
$db_info->use_mobile_view = $use_mobile_view; |
235
|
|
|
$db_info->time_zone = $time_zone; |
236
|
|
|
|
237
|
|
|
unset($db_info->lang_type); |
238
|
|
|
Context::setDBInfo($db_info); |
239
|
|
|
$oInstallController = getController('install'); |
240
|
|
|
if(!$oInstallController->makeConfigFile()) |
241
|
|
|
{ |
242
|
|
|
return new Object(-1, 'msg_invalid_request'); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
$site_args = new stdClass(); |
246
|
|
|
$site_args->site_srl = 0; |
247
|
|
|
$site_args->index_module_srl = Context::get('index_module_srl');// |
248
|
|
|
$site_args->default_language = Context::get('change_lang_type');// |
249
|
|
|
$oModuleController = getController('module'); |
250
|
|
|
$oModuleController->updateSite($site_args); |
251
|
|
|
|
252
|
|
|
//언어 선택 |
253
|
|
|
$selected_lang = Context::get('selected_lang'); |
254
|
|
|
$this->saveLangSelected($selected_lang); |
255
|
|
|
|
256
|
|
|
//save icon images |
257
|
|
|
$deleteFavicon = Context::get('is_delete_favicon'); |
258
|
|
|
$deleteMobicon = Context::get('is_delete_mobicon'); |
259
|
|
|
|
260
|
|
|
$this->updateIcon('favicon.ico',$deleteFavicon); |
|
|
|
|
261
|
|
|
$this->updateIcon('mobicon.png',$deleteMobicon); |
|
|
|
|
262
|
|
|
|
263
|
|
|
//모듈 설정 저장(썸네일, 풋터스크립트) |
264
|
|
|
$config = new stdClass(); |
265
|
|
|
$config->thumbnail_type = Context::get('thumbnail_type'); |
266
|
|
|
$config->htmlFooter = Context::get('htmlFooter'); |
267
|
|
|
$config->siteTitle = Context::get('site_title'); |
268
|
|
|
$this->setModulesConfig($config); |
269
|
|
|
|
270
|
|
|
$this->setRedirectUrl(Context::get('error_return_url')); |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
public function procInstallAdminConfigIconUpload() { |
274
|
|
|
$this->setTemplatePath($this->module_path.'tpl'); |
|
|
|
|
275
|
|
|
$this->setTemplateFile("after_upload_config_image.html"); |
276
|
|
|
|
277
|
|
|
$favicon = Context::get('favicon'); |
278
|
|
|
$mobicon = Context::get('mobicon'); |
279
|
|
|
if(!$favicon && !$mobicon) { |
280
|
|
|
Context::set('msg', Context::getLang("msg_invalid_format")); |
281
|
|
|
return; |
282
|
|
|
} |
283
|
|
|
if($favicon) { |
284
|
|
|
$name = 'favicon'; |
285
|
|
|
$tmpFileName = $this->saveIconTmp($favicon,'favicon.ico'); |
286
|
|
|
} else { |
287
|
|
|
$name = 'mobicon'; |
288
|
|
|
$tmpFileName = $this->saveIconTmp($mobicon,'mobicon.png'); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
Context::set('name', $name); |
292
|
|
|
Context::set('tmpFileName', $tmpFileName.'?'.$_SERVER['REQUEST_TIME']); |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @brief Supported languages (was procInstallAdminSaveLangSelected) |
297
|
|
|
*/ |
298
|
|
|
function saveLangSelected($selected_lang) |
299
|
|
|
{ |
300
|
|
|
$langs = $selected_lang; |
301
|
|
|
|
302
|
|
|
$lang_supported = Context::loadLangSupported(); |
303
|
|
|
$buff = null; |
304
|
|
|
for($i=0;$i<count($langs);$i++) |
|
|
|
|
305
|
|
|
{ |
306
|
|
|
$buff .= sprintf("%s,%s\n", $langs[$i], $lang_supported[$langs[$i]]); |
307
|
|
|
|
308
|
|
|
} |
309
|
|
|
FileHandler::writeFile(_XE_PATH_.'files/config/lang_selected.info', trim($buff)); |
310
|
|
|
//$this->setMessage('success_updated'); |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/* 썸내일 보여주기 방식 변경.*/ |
314
|
|
|
function setModulesConfig($config) |
315
|
|
|
{ |
316
|
|
|
$args = new stdClass(); |
317
|
|
|
|
318
|
|
|
if(!$config->thumbnail_type || $config->thumbnail_type != 'ratio' ) $args->thumbnail_type = 'crop'; |
319
|
|
|
else $args->thumbnail_type = 'ratio'; |
320
|
|
|
|
321
|
|
|
$oModuleController = getController('module'); |
322
|
|
|
$oModuleController->insertModuleConfig('document',$args); |
323
|
|
|
|
324
|
|
|
unset($args); |
325
|
|
|
|
326
|
|
|
$args = new stdClass; |
327
|
|
|
$args->htmlFooter = $config->htmlFooter; |
328
|
|
|
$args->siteTitle = $config->siteTitle; |
329
|
|
|
$oModuleController->updateModuleConfig('module',$args); |
330
|
|
|
|
331
|
|
|
return $output; |
|
|
|
|
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
private function saveIconTmp($icon, $iconname) |
335
|
|
|
{ |
336
|
|
|
|
337
|
|
|
$site_info = Context::get('site_module_info'); |
338
|
|
|
$virtual_site = ''; |
339
|
|
|
if($site_info->site_srl) |
340
|
|
|
{ |
341
|
|
|
$virtual_site = $site_info->site_srl . '/'; |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
$target_file = $icon['tmp_name']; |
345
|
|
|
$type = $icon['type']; |
346
|
|
|
$relative_filename = 'files/attach/xeicon/'.$virtual_site.'tmp/'.$iconname; |
347
|
|
|
$target_filename = _XE_PATH_.$relative_filename; |
348
|
|
|
|
349
|
|
|
list($width, $height, $type_no, $attrs) = @getimagesize($target_file); |
|
|
|
|
350
|
|
|
if($iconname == 'favicon.ico') |
351
|
|
|
{ |
352
|
|
|
if(!preg_match('/^.*(x-icon|\.icon)$/i',$type)) { |
353
|
|
|
Context::set('msg', '*.ico '.Context::getLang('msg_possible_only_file')); |
354
|
|
|
return; |
355
|
|
|
} |
356
|
|
|
} |
357
|
|
|
else if($iconname == 'mobicon.png') |
358
|
|
|
{ |
359
|
|
|
if(!preg_match('/^.*(png).*$/',$type)) { |
360
|
|
|
Context::set('msg', '*.png '.Context::getLang('msg_possible_only_file')); |
361
|
|
|
return; |
362
|
|
|
} |
363
|
|
|
if(!(($height == '57' && $width == '57') || ($height == '114' && $width == '114'))) { |
364
|
|
|
Context::set('msg', Context::getLang('msg_invalid_format').' (size : 57x57, 114x114)'); |
365
|
|
|
return; |
366
|
|
|
} |
367
|
|
|
} |
368
|
|
|
else |
369
|
|
|
{ |
370
|
|
|
Context::set('msg', Context::getLang('msg_invalid_format')); |
371
|
|
|
return; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
$fitHeight = $fitWidth = $height; |
|
|
|
|
375
|
|
|
//FileHandler::createImageFile($target_file, $target_filename, $fitHeight, $fitWidth, $ext); |
376
|
|
|
FileHandler::copyFile($target_file, $target_filename); |
377
|
|
|
return $relative_filename; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
private function updateIcon($iconname, $deleteIcon = false) { |
381
|
|
|
|
382
|
|
|
$site_info = Context::get('site_module_info'); |
383
|
|
|
$virtual_site = ''; |
384
|
|
|
if($site_info->site_srl) |
385
|
|
|
{ |
386
|
|
|
$virtual_site = $site_info->site_srl . '/'; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
$image_filepath = _XE_PATH_.'files/attach/xeicon/' . $virtual_site; |
390
|
|
|
|
391
|
|
|
if($deleteIcon) { |
392
|
|
|
FileHandler::removeFile($image_filepath.$iconname); |
393
|
|
|
return; |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
$tmpicon_filepath = $image_filepath.'tmp/'.$iconname; |
397
|
|
|
$icon_filepath = $image_filepath.$iconname; |
398
|
|
|
if(file_exists($tmpicon_filepath)) |
399
|
|
|
{ |
400
|
|
|
FileHandler::moveFile($tmpicon_filepath, $icon_filepath); |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
FileHandler::removeFile($tmpicon_filepath); |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
|
407
|
|
|
} |
408
|
|
|
/* End of file install.admin.controller.php */ |
409
|
|
|
/* Location: ./modules/install/install.admin.controller.php */ |
410
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: