15 $this->_sModulePath = $this->_sBasePath .
$aConfig[
'module_dir'];
17 $this->_aActions = array_merge($this->_aActions, array(
18 'check_module_exists' => array(
19 'title' =>
_t(
'_adm_txt_modules_check_module_exists'),
21 'check_module_version' => array(
22 'title' =>
_t(
'_adm_txt_modules_check_module_version'),
24 'check_module_hash' => array(
25 'title' =>
_t(
'_adm_txt_modules_check_module_hash'),
27 'update_files' => array(
28 'title' =>
_t(
'_adm_txt_modules_update_files'),
37 'operation_title' =>
_t(
'_adm_txt_modules_operation_update', $this->_aConfig[
'title'], $this->_aConfig[
'version_from'], $this->_aConfig[
'version_to'])
41 $aModuleInfo = $MySQL->getRow(
"SELECT `id`, `version` FROM `sys_modules` WHERE `path`= ? AND `uri`= ? LIMIT 1", [$this->_aConfig[
'module_dir'], $this->_aConfig[
'module_uri']]);
44 'message' => $this->
_displayResult(
'check_module_exists',
false,
'_adm_txt_modules_module_not_found'),
49 if($aModuleInfo[
'version'] != $this->_aConfig[
'version_from'])
51 'message' => $this->
_displayResult(
'check_module_version',
false,
'_adm_txt_modules_wrong_version'),
56 $aFilesOrig = $MySQL->getAllWithKey(
"SELECT `file`, `hash` FROM `sys_modules_file_tracks` WHERE `module_id`= ?",
"file", [$aModuleInfo[
'id']]);
59 $this->
_hash($this->_sModulePath, $aFiles);
60 foreach($aFiles
as $aFile)
61 if(!isset($aFilesOrig[$aFile[
'file']]) || $aFilesOrig[$aFile[
'file']][
'hash'] != $aFile[
'hash'])
63 'message' => $this->
_displayResult(
'check_module_hash',
false,
'_adm_txt_modules_module_was_modified'),
70 $MySQL->query(
"UPDATE `sys_modules` SET `version`='" . $this->_aConfig[
'version_to'] .
"' WHERE `id`='" . $aModuleInfo[
'id'] .
"'");
71 $MySQL->query(
"DELETE FROM `sys_modules_file_tracks` WHERE `module_id`='" . $aModuleInfo[
'id'] .
"'");
74 $this->
_hash(CH_DIRECTORY_PATH_ROOT .
'modules/' . $this->_aConfig[
'module_dir'], $aFiles);
75 foreach($aFiles
as $aFile)
76 $MySQL->query(
"INSERT IGNORE INTO `sys_modules_file_tracks`(`module_id`, `file`, `hash`) VALUES('" . $aModuleInfo[
'id'] .
"', '" . $aFile[
'file'] .
"', '" . $aFile[
'hash'] .
"')");
85 $sPath = $this->_sHomePath .
'source/';
86 if(!file_exists($sPath))
89 $sFtpHost =
getParam(
'sys_ftp_host');
91 $sFtpHost = $_SERVER[
'HTTP_HOST'];
94 if($oFtp->connect() ==
false)
103 $aLanguages = $MySQL->getAll(
"SELECT `ID` AS `id`, `Name` AS `name`, `Title` AS `title` FROM `sys_localization_languages`");
106 $sModuleConfig = $this->_sHomePath .
'install/config.php';
107 if(!file_exists($sModuleConfig))
110 include($sModuleConfig);
111 $iCategoryId = (int)$MySQL->getOne(
"SELECT `ID` FROM `sys_localization_categories` WHERE `Name`='" .
$aConfig[
'language_category'] .
"' LIMIT 1");
113 foreach($aLanguages
as $aLanguage)
118 foreach($aLanguages
as $aLanguage) {
132 $sPath = $this->_sHomePath .
'install/langs/' . $aLanguage[
'name'] .
'.php';
133 if(!file_exists($sPath))
return false;
138 if(isset($aLangContentDelete) && is_array($aLangContentDelete))
139 foreach($aLangContentDelete
as $sKey)
140 $MySQL->query(
"DELETE FROM `tk`, `ts` USING `sys_localization_keys` AS `tk` LEFT JOIN `sys_localization_strings` AS `ts` ON `tk`.`ID`=`ts`.`IDKey` WHERE `tk`.`Key`='" . $sKey .
"' AND `ts`.`IDLanguage`='" . $aLanguage[
'id'] .
"'");
143 if(isset($aLangContentAdd) && is_array($aLangContentAdd))
144 foreach($aLangContentAdd
as $sKey => $sValue) {
145 $mixedResult = $MySQL->query(
"INSERT IGNORE INTO `sys_localization_keys`(`IDCategory`, `Key`) VALUES('" . $iCategoryId .
"', '" . $sKey .
"')");
146 if($mixedResult ===
false || $mixedResult <= 0)
149 $iLangKeyId = (int)$MySQL->lastId();
150 $MySQL->query(
"INSERT INTO `sys_localization_strings`(`IDKey`, `IDLanguage`, `String`) VALUES('" . $iLangKeyId .
"', '" . $aLanguage[
'id'] .
"', '" . addslashes($sValue) .
"')");
154 if(isset($aLangContentUpdate) && is_array($aLangContentUpdate))
155 foreach($aLangContentUpdate
as $sKey => $sValue) {
156 $iLangKeyId = (int)$MySQL->getOne(
"SELECT `ID` FROM `sys_localization_keys` WHERE `Key`='" . $sKey .
"'");
160 $MySQL->query(
"UPDATE `sys_localization_strings` SET `String`='" . addslashes(
clear_xss($sValue)) .
"' WHERE `IDKey`='" . $iLangKeyId .
"' AND `IDLanguage`='" . $aLanguage[
'id'] .
"'");