Esempio n. 1
0
 function __construct($sHost, $sLogin, $sPassword, $sPath = '/')
 {
     parent::__construct();
     $this->_sHost = $sHost;
     $this->_sLogin = $sLogin;
     $this->_sPassword = $sPassword;
     $this->_sPathFrom = '';
     $this->_sPathTo = $sPath . ('/' == substr($sPath, -1) ? '' : '/');
 }
 function compileLanguage($mixedLang = 0, $bForce = false)
 {
     $sType = 'all';
     if (!empty($mixedLang)) {
         if (is_string($mixedLang) && !is_numeric($mixedLang)) {
             $sType = 'all_by_name';
         } else {
             if (is_numeric($mixedLang) || is_int($mixedLang)) {
                 $sType = 'all_by_id';
                 $mixedLang = (int) $mixedLang;
             }
         }
     }
     $aLanguages = array();
     $iLanguages = $this->oDb->getLanguagesBy(array('type' => $sType, 'value' => $mixedLang), $aLanguages);
     if ($iLanguages == 0) {
         return false;
     }
     bx_import('BxDolFile');
     $oFile = BxDolFile::getInstance();
     $sNewLine = "\r\n";
     foreach ($aLanguages as $aLanguage) {
         if (!$bForce && (int) $aLanguage['enabled'] != 1) {
             continue;
         }
         $aKeys = array();
         $this->oDb->getKeysBy(array('type' => 'by_language_id_key_key', 'value' => $aLanguage['id']), $aKeys);
         if ($aLanguage['name'] != BX_DOL_LANGUAGE_DEFAULT && getParam('lang_subst_from_en') == 'on') {
             $aKeysAll = array();
             $this->oDb->getKeysBy(array('type' => 'by_language_name_key_key', 'value' => BX_DOL_LANGUAGE_DEFAULT), $aKeysAll);
             $aKeys = array_merge($aKeysAll, $aKeys);
         }
         $sLanguageFile = "lang-" . $aLanguage['name'] . ".php";
         $oFile->delete('cache/' . $sLanguageFile);
         $rHandle = fopen(BX_DIRECTORY_PATH_CACHE . $sLanguageFile, 'w');
         if ($rHandle === false) {
             return false;
         }
         $sContent = "<?php{$sNewLine}\$GLOBALS['LANG'] = array(";
         foreach ($aKeys as $aKey) {
             list($sKey, $sString) = str_replace(array("\\", "'"), array("\\\\", "\\'"), array($aKey['key'], $aKey['string']));
             $sContent .= "{$sNewLine}\t'{$sKey}' => '{$sString}',";
         }
         $sContent = trim($sContent, ',');
         if (fwrite($rHandle, $sContent . "{$sNewLine});?>") === false) {
             return false;
         }
         if (fclose($rHandle) === false) {
             return false;
         }
         @chmod(BX_DIRECTORY_PATH_CACHE . "lang-{$aLanguage['name']}.php", 0666);
     }
     $this->init();
     return true;
 }
Esempio n. 3
0
 protected function _getFileManager()
 {
     $oFile = null;
     if ($this->_bUseFtp) {
         $oFile = new BxDolFtp(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost', getParam('sys_ftp_login'), getParam('sys_ftp_password'), getParam('sys_ftp_dir'));
         if (!$oFile->connect()) {
             return null;
         }
         if (!$oFile->isTrident()) {
             return null;
         }
     } else {
         $oFile = BxDolFile::getInstance();
     }
     return $oFile;
 }
 protected function performCopy($sPackagePath, &$sHomePath)
 {
     if ($this->bUseFtp) {
         $sLogin = getParam('sys_ftp_login');
         $sPassword = getParam('sys_ftp_password');
         $sPath = getParam('sys_ftp_dir');
         if (empty($sLogin) || empty($sPassword) || empty($sPath)) {
             return _t('_adm_str_err_no_ftp_info');
         }
         bx_import('BxDolFtp');
         $oFile = new BxDolFtp($_SERVER['HTTP_HOST'], $sLogin, $sPassword, $sPath);
         if (!$oFile->connect()) {
             return _t('_adm_str_err_cannot_connect_to_ftp');
         }
         if (!$oFile->isDolphin()) {
             return _t('_adm_str_err_destination_not_valid');
         }
     } else {
         bx_import('BxDolFile');
         $oFile = BxDolFile::getInstance();
     }
     $aConfig = self::getModuleConfig($sPackagePath . 'install/config.php');
     if (empty($aConfig) || !is_array($aConfig) || empty($aConfig['home_dir'])) {
         return _t('_adm_str_err_wrong_package_format');
     }
     $sHomePath = $aConfig['home_dir'];
     if (!$oFile->copy($sPackagePath, 'modules/' . $sHomePath)) {
         return _t('_adm_str_err_files_copy_failed');
     }
     return true;
 }
Esempio n. 5
0
 function copyFiles()
 {
     // TODO: use standalone copying
     require_once BX_DIRECTORY_PATH_CLASSES . 'BxDolFile.php';
     $o = BxDolFile::getInstance();
     $sDirSource = bx_ltrim_str(BX_UPGRADE_DIR_UPGRADES . $this->sFolder . '/files/', BX_DIRECTORY_PATH_ROOT);
     if (!$o->copy($sDirSource, '')) {
         return "Files copying failed";
     }
     return true;
 }