Ejemplo n.º 1
0
 function parseSystemKey($sKey, $mixedKeyWrapperHtml = null, $bProcessInjection = true)
 {
     $sRet = '';
     switch ($sKey) {
         case 'version':
             $sRet = bx_get_ver();
             break;
         case 'page_breadcrumb':
             $sRet = $this->getPageBreadcrumb();
             break;
         case 'dol_images':
             $sRet = $this->_processJsImages();
             break;
         case 'dol_lang':
             $sRet = $this->_processJsTranslations();
             break;
         case 'dol_options':
             $sRet = $this->_processJsOptions();
             break;
         case 'menu_top':
             $sRet = BxTemplStudioMenuTop::getInstance()->getCode();
             break;
         case 'copyright':
             $sRet = _t('_copyright', date('Y')) . getVersionComment();
             break;
         default:
             $sRet = parent::parseSystemKey($sKey, $mixedKeyWrapperHtml, false);
     }
     return $this->processInjection($this->getPageNameIndex(), $sKey, $sRet);
 }
Ejemplo n.º 2
0
 public function processing()
 {
     $oController = new BxDolUpgradeController();
     if ($oController->setMaintenanceMode(true)) {
         // if upgrade was successful
         if (($sFolder = $oController->getAvailableUpgrade()) && $oController->runUpgrade($sFolder)) {
             // write upgrade log
             $oController->writeLog();
             // send email notification
             bx_import('BxDolLanguages');
             sendMailTemplateSystem('t_UpgradeSuccess', array('new_version' => bx_get_ver(true), 'conclusion' => $oController->getConclusion() ? _t('_sys_upgrade_conclusion', $oController->getConclusion()) : ''));
             // if next upgrade is available (in case of bulk upgrade) then schedule to run it upon next cron run
             $sUpgradeDir = pathinfo(__FILE__, PATHINFO_DIRNAME);
             if ($oController->getAvailableUpgrade()) {
                 $oUpgrader = bx_instance('BxDolUpgrader');
                 $oUpgrader->setTransientUpgradeCronJob($sUpgradeDir);
             } elseif (0 === strpos($sUpgradeDir, BX_DIRECTORY_PATH_TMP)) {
                 @bx_rrmdir($sUpgradeDir);
             }
         }
         $oController->setMaintenanceMode(false);
     }
     // if something went grong during upgrade
     if ($sErrorMsg = $oController->getErrorMsg()) {
         // write upgrade log
         $oController->writeLog();
         // send email notification
         sendMailTemplateSystem('t_UpgradeFailed', array('error_msg' => $sErrorMsg));
         // disable auto-upgrade if it is failed
         setParam('sys_autoupdate_system', '');
     }
 }
Ejemplo n.º 3
0
 function parseSystemKey($sKey, $mixedKeyWrapperHtml = null, $bProcessInjection = true)
 {
     $sRet = '';
     switch ($sKey) {
         case 'version':
             $sRet = bx_get_ver();
             break;
         case 'page_breadcrumb':
             $sRet = $this->getPageBreadcrumb();
             break;
         case 'dol_images':
             $sRet = $this->_processJsImages();
             break;
         case 'dol_lang':
             $sRet = $this->_processJsTranslations();
             break;
         case 'dol_options':
             $sRet = $this->_processJsOptions();
             break;
         case 'menu_top':
             bx_import('BxTemplStudioMenuTop');
             $sRet = BxTemplStudioMenuTop::getInstance()->getCode();
             break;
         case 'boonex_promo':
             if (getParam('enable_dolphin_footer')) {
                 $sRet = $this->parseHtmlByName('boonex_promo.html', array());
             }
             break;
         case 'promo_code':
             if (defined('BX_PROMO_CODE')) {
                 $sRet = BX_PROMO_CODE;
             } else {
                 $sRet = ' ';
             }
             break;
         case 'copyright':
             $sRet = _t('_copyright', date('Y')) . getVersionComment();
             break;
         default:
             $sRet = parent::parseSystemKey($sKey, $mixedKeyWrapperHtml, false);
     }
     return $this->processInjection($this->getPageNameIndex(), $sKey, $sRet);
 }
Ejemplo n.º 4
0
 public function serviceGetBlockVersion()
 {
     $sJsObject = $this->getPageJsObject();
     $sContent = BxDolStudioTemplate::getInstance()->parseHtmlByName('dbd_versions.html', array('js_object' => $sJsObject, 'domain' => getParam('site_title'), 'version' => bx_get_ver(), 'installed' => bx_time_js(getParam('sys_install_time'))));
     return array('content' => $sContent);
 }
Ejemplo n.º 5
0
 protected function _isCompatibleWith()
 {
     $sVersionCur = bx_get_ver();
     $bCompatible = false;
     if (isset($this->_aConfig['compatible_with']) && is_array($this->_aConfig['compatible_with'])) {
         foreach ($this->_aConfig['compatible_with'] as $iKey => $sVersionReq) {
             $bCompatible = $bCompatible || version_compare($sVersionCur, $sVersionReq, '>=') == 1;
         }
     }
     return $bCompatible;
 }
Ejemplo n.º 6
0
 protected function siteSetup()
 {
     $sFfmpegPath = defined('BX_SYSTEM_FFMPEG') ? BX_SYSTEM_FFMPEG : BX_DIRECTORY_PATH_PLUGINS . 'ffmpeg/ffmpeg.exe';
     $sEmailToCkeckMailSending = class_exists('BxDolDb') && BxDolDb::getInstance() ? BxDolDb::getInstance()->getParam('site_email') : '';
     $oUpgrader = new BxDolUpgrader();
     if (!($sLatestVer = $oUpgrader->getLatestVersionNumber())) {
         $sLatestVer = 'undefined';
     }
     $sVer = bx_get_ver();
     $aMessage = array('type' => BX_DOL_AUDIT_OK);
     if (!version_compare($sVer, $sLatestVer, '>=')) {
         $aMessage = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_version_is_outdated', $sLatestVer));
     }
     $s = $this->getBlock(_t('_sys_audit_version_script'), $sVer, $this->getMsgHTML(_t('_sys_audit_version_script'), $aMessage));
     $s .= $this->getBlock(_t('_sys_audit_permissions'), '', _t('_sys_audit_msg_permissions'));
     $s .= $this->getBlock('ffmpeg', '', _t('_sys_audit_msg_ffmpeg', `{$sFfmpegPath} 2>&1`));
     $s .= $this->getBlock(_t('_sys_audit_mail_sending'), '', _t('_sys_audit_msg_mail_sending'));
     $s .= $this->getBlock(_t('_sys_audit_cron_jobs'), '', _t('_sys_audit_msg_cron_jobs', `crontab -l 2>&1`));
     echo '<h1>' . _t('_sys_audit_header_site_setup') . '</h1>';
     echo "<ul>{$s}</ul>";
 }
Ejemplo n.º 7
0
function bx_site_hash($sSalt = '', $isSkipVersion = false)
{
    return md5($sSalt . ($isSkipVersion ? '' : bx_get_ver()) . BX_DOL_SECRET . BX_DOL_URL_ROOT);
}
Ejemplo n.º 8
0
 protected function isValidPatch($sUnpackedPath, $aVersionUpdateInfo)
 {
     $sPath = $sUnpackedPath . 'files/' . $this->normalizeVersion(bx_get_ver()) . '-' . $this->normalizeVersion($aVersionUpdateInfo['patch']['ver']) . '/';
     $sCheckFilePath = $sPath . 'check.php';
     $sVersionFilePath = $sPath . 'files/inc/version.inc.php';
     return file_exists($sCheckFilePath) && file_exists($sVersionFilePath) && file_exists($sUnpackedPath . 'BxDolUpgradeCron.php');
 }
Ejemplo n.º 9
0
function getVersionComment()
{
    $aVer = explode('.', bx_get_ver());
    // version output made for debug possibilities.
    // randomizing made for security issues. do not change it...
    $aVerR[0] = $aVer[0];
    $aVerR[1] = rand(0, 100);
    $aVerR[2] = $aVer[1];
    $aVerR[3] = rand(0, 100);
    $aVerR[4] = $aVer[2];
    return '<!-- ' . implode(' ', $aVerR) . ' -->';
}
Ejemplo n.º 10
0
 protected function siteSetup()
 {
     $sDolphinPath = defined('BX_DIRECTORY_PATH_ROOT') ? BX_DIRECTORY_PATH_ROOT : BX_INSTALL_DIR_ROOT;
     $sEmailToCkeckMailSending = class_exists('BxDolDb') && BxDolDb::getInstance() ? BxDolDb::getInstance()->getParam('site_email') : '';
     $sLatestDolphinVer = file_get_contents("http://rss.boonex.com/");
     if (preg_match('#<dolphin>([\\.0-9]+)</dolphin>#', $sLatestDolphinVer, $m)) {
         $sLatestDolphinVer = $m[1];
     } else {
         $sLatestDolphinVer = 'undefined';
     }
     $sDolphinVer = bx_get_ver();
     $aMessage = array('type' => BX_DOL_AUDIT_OK);
     if (!version_compare($sDolphinVer, $sLatestDolphinVer, '>=')) {
         $aMessage = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_version_is_outdated', $sLatestDolphinVer));
     }
     $s = '';
     $s .= $this->getBlock(_t('_sys_audit_version_dolphin'), $sDolphinVer, $this->getMsgHTML(_t('_sys_audit_version_dolphin'), $aMessage));
     //$s .= $this->getBlock(_t('_sys_audit_permissions'), '', _t('_sys_audit_msg_permissions'));
     //$s .= $this->getBlock('ffmpeg', '', _t('_sys_audit_msg_ffmpeg', `{$sDolphinPath}flash/modules/global/app/ffmpeg.exe 2>&1`));
     $s .= $this->getBlock(_t('_sys_audit_mail_sending'), '', _t('_sys_audit_msg_mail_sending'));
     $s .= $this->getBlock(_t('_sys_audit_cron_jobs'), '', _t('_sys_audit_msg_cron_jobs', `crontab -l 2>&1`));
     echo '<h1>' . _t('_sys_audit_header_site_setup') . '</h1>';
     echo "<ul>{$s}</ul>";
 }
Ejemplo n.º 11
0
 public function runUpgrade($sFolder)
 {
     $this->aLogMsgs = array();
     $this->sError = false;
     if (bx_get_ver() != BX_DOL_VERSION) {
         $this->sError = 'Database and files versions are different';
         return false;
     }
     // set current folder
     $this->oUtil->setFolder($sFolder);
     // run oprations with files
     $aFilesOperations = array('executeCheck' => "{$sFolder} upgrade will be applied", 'checkPermissions' => "Files permissions are ok and can be overwritten", 'copyFiles' => "Files copying successfully completed", 'filesDelete' => "Deprecated files were successfully deleted or there is no files to delete", 'updateFilesHash' => "System files hash was successfully updated");
     foreach ($aFilesOperations as $sFunc => $sSuccessMsg) {
         $mixedResult = $this->oUtil->{$sFunc}();
         if (true !== $mixedResult) {
             $this->sError = $mixedResult;
             return false;
         } else {
             $this->aLogMsgs[] = $sSuccessMsg;
         }
     }
     // run system SQL upgrade
     $mixedResult = $this->oUtil->isExecuteSQLAvail();
     if (true === $mixedResult) {
         $mixedResult = $this->oUtil->executeSQL();
         if (true !== $mixedResult) {
             $sTemplateMessage = $mixedResult;
             $this->sError = $mixedResult;
             return false;
         } else {
             $this->aLogMsgs[] = "System SQL script was successfully executed";
         }
     } elseif (false === $mixedResult) {
         // just skip if not available found
     } else {
         $this->sError = $mixedResult;
         return false;
     }
     // get list of available language files updates
     if (false === ($aLangs = $this->oUtil->readLangs())) {
         $this->sError = 'Error reading the directory with language updates';
         return false;
     } else {
         $sTemplateMessage = "The following languages will be affected for system:\n";
         if (!$aLangs) {
             $sTemplateMessage .= " - No languages will be affected\n";
         } else {
             foreach ($aLangs as $sLang) {
                 $sTemplateMessage .= ' - ' . $sLang . "\n";
             }
         }
         $this->aLogMsgs[] = trim($sTemplateMessage);
     }
     // run system langs upgrade
     if ($aLangs) {
         $mixedResult = $this->oUtil->executeLangsAdd();
         if (true !== $mixedResult) {
             $this->sError = $mixedResult;
             return false;
         } else {
             $this->aLogMsgs[] = "System language strings were successfully added";
         }
     }
     // run system custom script upgrade
     $mixedResult = $this->oUtil->isExecuteScriptAvail();
     if (true === $mixedResult) {
         $mixedResult = $this->oUtil->executeScript();
         if (true !== $mixedResult) {
             $this->sError = $mixedResult;
             return false;
         } else {
             $this->aLogMsgs[] = "System after update custom script was successfully executed";
         }
     } elseif (false === $mixedResult) {
         // just skip if not available found
     } else {
         $this->sError = $mixedResult;
         return false;
     }
     // get list of modules updates
     if (false !== ($aModules = $this->oUtil->readModules())) {
         $sTemplateMessage = "The following modules will be updated:\n";
         if (!$aModules) {
             $sTemplateMessage .= " - No modules will be updated\n";
         } else {
             foreach ($aModules as $sModule) {
                 $sTemplateMessage .= ' - ' . $sModule . "\n";
             }
         }
         $this->aLogMsgs[] = trim($sTemplateMessage);
     }
     if (!$aModules) {
         $aModules = array();
     }
     foreach ($aModules as $sModule) {
         // run module SQL upgrade
         $mixedResult = $this->oUtil->isExecuteSQLAvail($sModule);
         if (true === $mixedResult) {
             $mixedResult = $this->oUtil->executeSQL($sModule);
             if (true !== $mixedResult) {
                 $this->sError = $mixedResult;
                 return false;
             } else {
                 $this->aLogMsgs[] = "'{$sModule}' module SQL script was successfully executed";
             }
         } elseif (false === $mixedResult) {
             // just skip if not available found
         } else {
             $this->sError = $mixedResult;
             return false;
         }
         // get list of available language files updates
         if (false === ($aLangs = $this->oUtil->readLangs($sModule))) {
             $this->sError = 'Error reading the directory with language updates';
             return false;
         } else {
             $sTemplateMessage = "The following languages will be affected for '{$sModule}' module:\n";
             if (!$aLangs) {
                 $sTemplateMessage .= " - No languages will be affected\n";
             } else {
                 foreach ($aLangs as $sLang) {
                     $sTemplateMessage .= ' - ' . $sLang . "\n";
                 }
             }
             $this->aLogMsgs[] = trim($sTemplateMessage);
         }
         // run module langs upgrade
         if ($aLangs) {
             $mixedResult = $this->oUtil->executeLangsAdd($sModule);
             if (true !== $mixedResult) {
                 $this->sError = $mixedResult;
                 return false;
             } else {
                 $this->aLogMsgs[] = "'{$sModule}' module language strings were successfully added";
             }
         }
         // run module custom script upgrade
         $mixedResult = $this->oUtil->isExecuteScriptAvail($sModule);
         if (true === $mixedResult) {
             $mixedResult = $this->oUtil->executeScript($sModule);
             if (true !== $mixedResult) {
                 $this->sError = $mixedResult;
                 return false;
             } else {
                 $this->aLogMsgs[] = "'{$sModule}' module after update custom script was successfully executed";
             }
         } elseif (false === $mixedResult) {
             // just skip if not available
         } else {
             $this->sError = $mixedResult;
             return false;
         }
         // run module custom script upgrade
         $sResult = $this->oUtil->executeConclusion($sModule);
         if ($sResult) {
             $this->aLogMsgs[] = $sResult;
         }
     }
     // run module custom script upgrade
     $sResult = $this->oUtil->executeConclusion();
     if ($sResult) {
         $this->sConclusion = $sResult;
     }
     return true;
 }
Ejemplo n.º 12
0
 public function install($aParams, $bAutoEnable = false)
 {
     $bAutoEnable = $bAutoEnable || isset($aParams['auto_enable']) && (bool) $aParams['auto_enable'];
     //--- Check whether the module was already installed ---//
     if ($this->oDb->isModule($this->_aConfig['home_uri'])) {
         return array('message' => _t('_adm_err_modules_already_installed'), 'result' => false);
     }
     $aResult = array();
     bx_alert('system', 'before_install', 0, false, array('config' => $this->_aConfig, 'result' => &$aResult));
     if ($aResult && !$aResult['result']) {
         return $aResult;
     }
     //--- Check mandatory settings ---//
     if ($this->oDb->isModuleParamsUsed($this->_aConfig['home_uri'], $this->_aConfig['home_dir'], $this->_aConfig['db_prefix'], $this->_aConfig['class_prefix'])) {
         return array('message' => _t('_adm_txt_modules_params_used'), 'result' => false);
     }
     //--- Check version compatibility ---//
     $bCompatible = false;
     if (isset($this->_aConfig['compatible_with']) && is_array($this->_aConfig['compatible_with'])) {
         foreach ($this->_aConfig['compatible_with'] as $iKey => $sVersion) {
             $sVersion = '/^' . str_replace(array('.', 'x'), array('\\.', '[A-Za-z0-9-]+'), $sVersion) . '$/is';
             $bCompatible = $bCompatible || preg_match($sVersion, bx_get_ver()) > 0;
         }
     }
     if (!$bCompatible) {
         return array('message' => $this->_displayResult('check_script_version', false, '_adm_err_modules_wrong_version_script'), 'result' => false);
     }
     //--- Check for available translations ---//
     $oFile = $this->_getFileManager();
     $sModuleUri = $this->_aConfig['home_uri'];
     $aLanguages = $this->oDb->getModulesBy(array('type' => 'languages'));
     foreach ($aLanguages as $aLanguage) {
         if ($aLanguage['uri'] == 'en') {
             continue;
         }
         $aLanguageConfig = self::getModuleConfig(BX_DIRECTORY_PATH_MODULES . $aLanguage['path'] . '/install/config.php');
         if (empty($aLanguageConfig)) {
             continue;
         }
         if (!isset($aLanguageConfig['includes'][$sModuleUri]) || empty($aLanguageConfig['includes'][$sModuleUri])) {
             continue;
         }
         $sSrcPath = 'modules/' . $aLanguage['path'] . 'install/data/' . $aLanguageConfig['includes'][$sModuleUri];
         $sDstPath = $aLanguageConfig['includes'][$sModuleUri];
         $oFile->copy($sSrcPath, $sDstPath);
     }
     //--- Check actions ---//
     $aResult = $this->_perform('install');
     if ($aResult['result']) {
         $sDependencies = "";
         if (isset($this->_aConfig['install']['check_dependencies']) && (int) $this->_aConfig['install']['check_dependencies'] == 1 && isset($this->_aConfig['dependencies']) && is_array($this->_aConfig['dependencies'])) {
             $this->_aConfig['dependencies'] = array_keys($this->_aConfig['dependencies']);
         }
         $iModuleId = $this->oDb->insertModule($this->_aConfig);
         bx_import('BxDolModule');
         $sTitleKey = BxDolModule::getTitleKey($this->_aConfig['home_uri']);
         bx_import('BxDolStudioLanguagesUtils');
         $oLanguages = BxDolStudioLanguagesUtils::getInstance();
         $oLanguages->addLanguageString($sTitleKey, $this->_aConfig['title']);
         $oLanguages->compileLanguage();
         $aFiles = array();
         $this->hashFiles($this->_sModulePath, $aFiles);
         foreach ($aFiles as $aFile) {
             $this->oDb->insertModuleTrack($iModuleId, $aFile);
         }
         $this->oDb->cleanMemory('sys_modules_' . $this->_aConfig['home_uri']);
         $this->oDb->cleanMemory('sys_modules_' . $iModuleId);
         $this->oDb->cleanMemory('sys_modules');
     }
     bx_alert('system', 'install', 0, false, array('config' => $this->_aConfig, 'result' => &$aResult));
     if ($aResult['result'] && $bAutoEnable) {
         $aResultEnable = $this->enable($aParams);
         $aResult['result'] = $aResult['result'] & $aResultEnable['result'];
         $aResult['message'] = $aResult['message'] . $aResultEnable['message'];
     }
     return $aResult;
 }