/** * * @param Cx\Core_Modules\Listing\Model\ExportInterface $exportInterface * @param type $filename * @throws \Cx\Lib\FileSystem\FileSystemException */ public function exportToFile(\Cx\Core_Modules\Listing\Model\Entity\Exportable $exportInterface, $filename) { try { $objFile = new \Cx\Lib\FileSystem\File($filename); $objFile->touch(); $objFile->write($this->export($exportInterface)); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); throw new DataSetException("Failed to export data to file {$filename}!"); } }
function _writeNewConfigurationFile() { global $_CORELANG, $_ARRAYLANG, $_DBCONFIG, $_PATHCONFIG, $_FTPCONFIG, $_CONFIGURATION, $_CONFIG; $ftpStatus = $_FTPCONFIG['is_activated'] ? 'true' : 'false'; $charset = 'UTF-8'; $dbCharset = 'utf8'; $_FTPCONFIG['port'] = intval($_FTPCONFIG['port']); $configurationTpl = <<<CONFIG_TPL <?php global \$_DBCONFIG, \$_PATHCONFIG, \$_FTPCONFIG, \$_CONFIG; /** * @exclude * * Cloudrexx CMS Web Installer * Please use the Cloudrexx CMS installer to configure this file * or edit this file and configure the parameters for your site and * database manually. */ /** * ------------------------------------------------------------------------- * Set installation status * ------------------------------------------------------------------------- */ define('CONTREXX_INSTALLED', true); /** * ------------------------------------------------------------------------- * Database configuration section * ------------------------------------------------------------------------- */ \$_DBCONFIG['host'] = '{$_DBCONFIG['host']}'; // This is normally set to localhost \$_DBCONFIG['database'] = '{$_DBCONFIG['database']}'; // Database name \$_DBCONFIG['tablePrefix'] = '{$_DBCONFIG['tablePrefix']}'; // Database table prefix \$_DBCONFIG['user'] = '******'user']}'; // Database username \$_DBCONFIG['password'] = '******'password']}'; // Database password \$_DBCONFIG['dbType'] = '{$_DBCONFIG['dbType']}'; // Database type (e.g. mysql,postgres ..) \$_DBCONFIG['charset'] = '{$dbCharset}'; // Charset (default, latin1, utf8, ..) \$_DBCONFIG['timezone'] = '{$_CONFIG['timezone']}'; // Controller's timezone for model \$_DBCONFIG['collation'] = '{$_DBCONFIG['collation']}'; /** * ------------------------------------------------------------------------- * Site path specific configuration * ------------------------------------------------------------------------- */ \$_PATHCONFIG['ascms_root'] = ''; \$_PATHCONFIG['ascms_root_offset'] = ''; // example: '/cms'; \$_PATHCONFIG['ascms_installation_root'] = \$_PATHCONFIG['ascms_root']; \$_PATHCONFIG['ascms_installation_offset'] = \$_PATHCONFIG['ascms_root_offset']; // example: '/cms'; /** * ------------------------------------------------------------------------- * Ftp specific configuration * ------------------------------------------------------------------------- */ \$_FTPCONFIG['is_activated'] = {$ftpStatus}; // Ftp support true or false \$_FTPCONFIG['host'] = '{$_FTPCONFIG['host']}';// This is normally set to localhost \$_FTPCONFIG['port'] = {$_FTPCONFIG['port']}; // Ftp remote port \$_FTPCONFIG['username'] = '******'username']}'; // Ftp login username \$_FTPCONFIG['password'] = '******'password']}'; // Ftp login password \$_FTPCONFIG['path'] = '{$_FTPCONFIG['path']}'; // Ftp path to cms (must not include ascms_root_offset) /** * ------------------------------------------------------------------------- * Base setup (altering might break the system!) * ------------------------------------------------------------------------- */ // Set character encoding \$_CONFIG['coreCharacterEncoding'] = 'UTF-8'; // example 'UTF-8' CONFIG_TPL; // write settings try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . '/config/configuration.php'); $objFile->makeWritable(); $objFile->write($configurationTpl); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_WRITE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/configuration.php')); setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_DOCUMENT_ROOT . '/config/configuration.php', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } return true; }
/** * End caching functions. Check for a sessionId: if not set, write pagecontent to a file. */ public function endContrexxCaching($page) { if (!$this->boolIsEnabled) { return null; } if (session_id() != '' && \FWUser::getFWUserObject()->objUser->login()) { return null; } if (!$page->getCaching()) { return null; } $strCacheContents = ob_get_contents(); ob_end_flush(); $handleFile = $this->strCachePath . $this->strCacheFilename . "_" . $page->getId(); $File = new \Cx\Lib\FileSystem\File($handleFile); $File->write($strCacheContents); }
/** * Write all settings into the config-file * */ function _createSettingsFile() { global $_ARRLANG; $objDb = $this->_getDbObject($statusMsg); if ($objDb === false) { return $statusMsg; } else { $strSettingsFile = $_SESSION['installer']['config']['documentRoot'] . $_SESSION['installer']['config']['offsetPath'] . '/config/settings.php'; if (!\Cx\Lib\FileSystem\FileSystem::touch($strSettingsFile) || !\Cx\Lib\FileSystem\FileSystem::makeWritable($strSettingsFile)) { return sprintf($_ARRLANG['TXT_SETTINGS_ERROR_WRITABLE'], $strSettingsFile); } //Header & Footer $strHeader = "<?php\n"; $strHeader .= "/**\n"; $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n"; $strHeader .= "* Do not try to edit it manually!\n"; $strHeader .= "*/\n\n"; $strFooter = "\n"; //Get module-names $objResult = $objDb->Execute("SELECT id, name FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "modules`"); if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { $arrModules[$objResult->fields['id']] = $objResult->fields['name']; $objResult->MoveNext(); } } //Get values $objResult = $objDb->Execute("SELECT setname, setmodule, setvalue FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "settings` ORDER BY setmodule ASC, setname ASC"); $intMaxLen = 0; if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { $intMaxLen = strlen($objResult->fields['setname']) > $intMaxLen ? strlen($objResult->fields['setname']) : $intMaxLen; $arrValues[$objResult->fields['setmodule']][$objResult->fields['setname']] = $objResult->fields['setvalue']; $objResult->MoveNext(); } } $intMaxLen += strlen('$_CONFIG[\'\']') + 1; //needed for formatted output //Write values $data = $strHeader; $strBody = ''; foreach ($arrValues as $intModule => $arrInner) { $strBody .= "/**\n"; $strBody .= "* -------------------------------------------------------------------------\n"; $strBody .= "* " . ucfirst(isset($arrModules[$intModule]) ? $arrModules[$intModule] : '') . "\n"; $strBody .= "* -------------------------------------------------------------------------\n"; $strBody .= "*/\n"; foreach ($arrInner as $strName => $strValue) { $strBody .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $strName . '\']'); $strBody .= "= "; $strBody .= (is_numeric($strValue) ? $strValue : '"' . str_replace('"', '\\"', $strValue) . '"') . ";\n"; } $strBody .= "\n"; } $data .= $strBody; $data .= $strFooter; try { $objFile = new \Cx\Lib\FileSystem\File($strSettingsFile); $objFile->write($data); return true; } catch (\Cx\Lib\FileSystem\FileSystemException $e) { DBG::msg($e->getMessage()); } return false; } }
/** * Updates the license * @param \Cx\Core_Modules\License\License $license The license to update * @param array $_CONFIG The configuration array * @param boolean $forceUpdate (optional) If set to true, update is performed even if time to update is not reached yet * @param boolean $forceTemplate (optional) If set to true, the server is requested to send the template * @param array $_CORELANG (optional) Core language array * @param string $response (optional) Server response as JSON. If this is set, no HTTP request is perfomed * @return null */ public function update(&$license, $_CONFIG, $forceUpdate = false, $forceTemplate = false, $_CORELANG = array(), $response = '') { if (!$forceUpdate && !$this->isTimeToUpdate($_CONFIG) && empty($response)) { return; } $sm = new \Cx\Core\Config\Controller\Config(); if (!$sm->isWritable()) { throw new \Exception($_CORELANG['TXT_SETTINGS_ERROR_NO_WRITE_ACCESS']); } if ($response) { $response = json_decode($response); } else { $response = $this->fetchResponse($license, $_CONFIG, $forceTemplate, $_CORELANG); if (!$response) { // status: error return; } } $upgradeUrl = $response->license->upgradeUrl; if ($response->license->partner->upgradeUrl) { $upgradeUrl = $response->license->partner->upgradeUrl; } // create new license $installationId = $license->getInstallationId(); $licenseKey = $license->getLicenseKey(); if ($response->license->installationId != null) { $installationId = $response->license->installationId; } if ($response->license->key != null) { $licenseKey = $response->license->key; } if (!empty($response->common->template)) { if (\FWUser::getFWUserObject()->objUser->getAdminStatus()) { try { $file = new \Cx\Lib\FileSystem\File(ASCMS_TEMP_PATH . '/licenseManager.html'); $file->write($response->common->template); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { } } } $this->requestInterval = $response->license->settings->requestInterval; if (!is_int($this->requestInterval) || $this->requestInterval < 0 || $this->requestInterval > 365 * 24) { $this->requestInterval = 1; } $dashboardMessages = array(); foreach ($response->license->messages->dashboard as $lang => $message) { $dashboardMessages[$lang] = new \Cx\Core_Modules\License\Message($lang, $message->text, $message->type, $message->link, $message->linkTarget, $message->showInDashboard); } $licenseManagementMessages = array(); foreach ($response->license->messages->licenseManagement as $lang => $message) { $licenseManagementMessages[$lang] = new \Cx\Core_Modules\License\Message($lang, $message->text, $message->type, $message->link, $message->linkTarget, $message->showInDashboard); } $gzMessages = array(); foreach ($response->license->messages->grayZone as $lang => $message) { $gzMessages[$lang] = new \Cx\Core_Modules\License\Message($lang, $message->text, $message->type, $message->link, $message->linkTarget, $message->showInDashboard); } $partner = new \Cx\Core_Modules\License\Person($response->license->partner->companyName, $response->license->partner->title, $response->license->partner->firstname, $response->license->partner->lastname, $response->license->partner->address, $response->license->partner->zip, $response->license->partner->city, $response->license->partner->country, $response->license->partner->phone, $response->license->partner->url, $response->license->partner->mail); $customer = new \Cx\Core_Modules\License\Person($response->license->customer->companyName, $response->license->customer->title, $response->license->customer->firstname, $response->license->customer->lastname, $response->license->customer->address, $response->license->customer->zip, $response->license->customer->city, $response->license->customer->country, $response->license->customer->phone, $response->license->customer->url, $response->license->customer->mail); $version = new \Cx\Core_Modules\License\Version($response->versions->currentStable->number, $response->versions->currentStable->name, $response->versions->currentStable->codeName, $response->versions->currentStable->state, $response->versions->currentStable->releaseDate); $license = new \Cx\Core_Modules\License\License($response->license->state, $response->license->edition, $response->license->availableComponents, $response->license->legalComponents, $response->license->validTo, $response->license->createdAt, $response->license->registeredDomains, $installationId, $licenseKey, $licenseManagementMessages, $license->getVersion(), $partner, $customer, $response->license->settings->grayZoneTime, $gzMessages, $response->license->settings->frontendLockTime, $this->requestInterval, 0, time(), $upgradeUrl, $response->license->isUpgradable == 'true', $dashboardMessages); $license->check(); return; }
/** * update skin file * @access public */ function update() { \Permission::checkAccess(47, 'static'); $themes = !empty($_POST['themes']) && !stristr($_POST['themes'], '..') ? contrexx_input2raw($_POST['themes']) : null; $themesPage = !empty($_POST['themesPage']) && !stristr($_POST['themesPage'], '..') ? contrexx_input2raw($_POST['themesPage']) : null; $isComponentFile = !empty($_POST['is_application']); $objImageManager = new \ImageManager(); if (empty($themes) || empty($themesPage) || $objImageManager->_isImage($this->path . $themes . $themesPage)) { return false; } $pageContent = contrexx_input2raw($_POST['content']); // Change the replacement variables from [[TITLE]] into {TITLE} $pageContent = preg_replace('/\\[\\[([A-Z0-9_]*?)\\]\\]/', '{\\1}', $pageContent); try { if (self::isFileTypeComponent($themesPage)) { $themesPage = self::getComponentFilePath($themesPage, false); } if (!file_exists($this->websiteThemesPath . $themes . $themesPage)) { $dir = str_replace(basename($themesPage), "", $themesPage); \Cx\Lib\FileSystem\FileSystem::make_folder($this->websiteThemesPath . $themes . '/' . $dir, true); } $filePath = $this->websiteThemesPath . $themes . $themesPage; if ($isComponentFile && file_exists($filePath)) { // override from application template, rename the file if its already exists $pathInfo = pathinfo($filePath); $idx = 1; while (file_exists($filePath)) { $filePath = $pathInfo['dirname'] . '/' . $pathInfo['filename'] . '_custom_' . $idx++ . '.' . $pathInfo['extension']; } $_POST['themesPage'] = self::getThemeRelativePath(preg_replace('#' . $this->websiteThemesPath . $themes . '#', '', $filePath)); } $objFile = new \Cx\Lib\FileSystem\File($filePath); if (!file_exists($filePath)) { $objFile->touch(); } $objFile->write($pageContent); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); } }
/** * Store the website details into the YML file * * @param string $folderPath * @param string $filePath * @param array $ymlContent * * @return null */ public function storeUpdateWebsiteDetailsToYml($folderPath, $filePath, $ymlContent) { if (empty($folderPath) || empty($filePath)) { return; } try { if (!file_exists($folderPath)) { \Cx\Lib\FileSystem\FileSystem::make_folder($folderPath); } $file = new \Cx\Lib\FileSystem\File($filePath); $file->touch(); $yaml = new \Symfony\Component\Yaml\Yaml(); $file->write($yaml->dump(array('PendingCodeBaseChanges' => $ymlContent))); } catch (\Exception $e) { \DBG::log($e->getMessage()); } }
function _updateSettings() { global $objUpdate, $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG, $arrSettings, $arrSettingsByName; // TODO: Unused // $setVars = false; $arrSettings = array(3 => array('setname' => 'dnsServer', 'setvalue' => 'ns1.contrexxdns.net', 'setmodule' => 1), 4 => array('setname' => 'bannerStatus', 'setvalue' => '0', 'setmodule' => 28), 5 => array('setname' => 'spamKeywords', 'setvalue' => 'sex, viagra', 'setmodule' => 1), 11 => array('setname' => 'coreAdminName', 'setvalue' => 'Webmaster', 'setmodule' => 1), 18 => array('setname' => 'corePagingLimit', 'setvalue' => '30', 'setmodule' => 1), 19 => array('setname' => 'searchDescriptionLength', 'setvalue' => '150', 'setmodule' => 5), 23 => array('setname' => 'coreIdsStatus', 'setvalue' => 'off', 'setmodule' => 1), 24 => array('setname' => 'coreAdminEmail', 'setvalue' => '*****@*****.**', 'setmodule' => 1), 29 => array('setname' => 'contactFormEmail', 'setvalue' => '*****@*****.**', 'setmodule' => 6), 34 => array('setname' => 'sessionLifeTime', 'setvalue' => '3600', 'setmodule' => 1), 35 => array('setname' => 'lastAccessId', 'setvalue' => '1', 'setmodule' => 1), 37 => array('setname' => 'newsTeasersStatus', 'setvalue' => '0', 'setmodule' => 8), 39 => array('setname' => 'feedNewsMLStatus', 'setvalue' => '0', 'setmodule' => 22), 40 => array('setname' => 'calendarheadlines', 'setvalue' => '1', 'setmodule' => 21), 41 => array('setname' => 'calendarheadlinescount', 'setvalue' => '5', 'setmodule' => 21), 42 => array('setname' => 'blockStatus', 'setvalue' => '1', 'setmodule' => 7), 44 => array('setname' => 'calendarheadlinescat', 'setvalue' => '0', 'setmodule' => 21), 45 => array('setname' => 'calendardefaultcount', 'setvalue' => '16', 'setmodule' => 21), 48 => array('setname' => 'blockRandom', 'setvalue' => '1', 'setmodule' => 7), 49 => array('setname' => 'directoryHomeContent', 'setvalue' => '0', 'setmodule' => 12), 50 => array('setname' => 'cacheEnabled', 'setvalue' => 'off', 'setmodule' => 1), 51 => array('setname' => 'coreGlobalPageTitle', 'setvalue' => 'Contrexx Example Page', 'setmodule' => 1), 52 => array('setname' => 'cacheExpiration', 'setvalue' => '86400', 'setmodule' => 1), 53 => array('setname' => 'domainUrl', 'setvalue' => 'localhost', 'setmodule' => 1), 54 => array('setname' => 'xmlSitemapStatus', 'setvalue' => 'off', 'setmodule' => 1), 55 => array('setname' => 'systemStatus', 'setvalue' => 'on', 'setmodule' => 1), 56 => array('setname' => 'searchVisibleContentOnly', 'setvalue' => 'on', 'setmodule' => 1), 57 => array('setname' => 'protocolHttpsFrontend', 'setvalue' => 'off', 'setmodule' => 1), 58 => array('setname' => 'protocolHttpsBackend', 'setvalue' => 'off', 'setmodule' => 1), 59 => array('setname' => 'forceDomainUrl', 'setvalue' => 'off', 'setmodule' => 1), 60 => array('setname' => 'forumHomeContent', 'setvalue' => '0', 'setmodule' => 20), 62 => array('setname' => 'coreSmtpServer', 'setvalue' => '0', 'setmodule' => 1), 63 => array('setname' => 'languageDetection', 'setvalue' => 'on', 'setmodule' => 1), 64 => array('setname' => 'podcastHomeContent', 'setvalue' => '0', 'setmodule' => 35), 65 => array('setname' => 'googleMapsAPIKey', 'setvalue' => '', 'setmodule' => 1), 66 => array('setname' => 'forumTagContent', 'setvalue' => '0', 'setmodule' => 20), 68 => array('setname' => 'dataUseModule', 'setvalue' => '0', 'setmodule' => 48), 69 => array('setname' => 'frontendEditingStatus', 'setvalue' => 'off', 'setmodule' => 1), 71 => array('setname' => 'coreListProtectedPages', 'setvalue' => 'on', 'setmodule' => 1), 72 => array('setname' => 'useKnowledgePlaceholders', 'setvalue' => '0', 'setmodule' => 56), 73 => array('setname' => 'advancedUploadFrontend', 'setvalue' => 'off', 'setmodule' => 52), 74 => array('setname' => 'advancedUploadBackend', 'setvalue' => 'on', 'setmodule' => 52), 75 => array('setname' => 'installationId', 'setvalue' => '', 'setmodule' => 1), 76 => array('setname' => 'licenseKey', 'setvalue' => '', 'setmodule' => 1), 77 => array('setname' => 'contactCompany', 'setvalue' => 'Ihr Firmenname', 'setmodule' => 1), 78 => array('setname' => 'contactAddress', 'setvalue' => 'Musterstrasse 12', 'setmodule' => 1), 79 => array('setname' => 'contactZip', 'setvalue' => '3600', 'setmodule' => 1), 80 => array('setname' => 'contactPlace', 'setvalue' => 'Musterhausen', 'setmodule' => 1), 81 => array('setname' => 'contactCountry', 'setvalue' => 'Musterland', 'setmodule' => 1), 82 => array('setname' => 'contactPhone', 'setvalue' => '033 123 45 67', 'setmodule' => 1), 83 => array('setname' => 'contactFax', 'setvalue' => '033 123 45 68', 'setmodule' => 1), 84 => array('setname' => 'sessionLifeTimeRememberMe', 'setvalue' => '1209600', 'setmodule' => 1), 85 => array('setname' => 'dashboardNews', 'setvalue' => 'on', 'setmodule' => 1), 86 => array('setname' => 'dashboardStatistics', 'setvalue' => 'on', 'setmodule' => 1), 87 => array('setname' => 'timezone', 'setvalue' => 'Europe/Zurich', 'setmodule' => 1), 88 => array('setname' => 'googleAnalyticsTrackingId', 'setvalue' => '', 'setmodule' => 1), 89 => array('setname' => 'passwordComplexity', 'setvalue' => 'off', 'setmodule' => 1), 90 => array('setname' => 'licenseState', 'setvalue' => 'OK', 'setmodule' => 66), 91 => array('setname' => 'licenseValidTo', 'setvalue' => '', 'setmodule' => 66), 92 => array('setname' => 'coreCmsEdition', 'setvalue' => 'Trial', 'setmodule' => 66), 93 => array('setname' => 'licenseMessage', 'setvalue' => '', 'setmodule' => 66), 94 => array('setname' => 'licenseCreatedAt', 'setvalue' => '', 'setmodule' => 66), 95 => array('setname' => 'licenseDomains', 'setvalue' => '', 'setmodule' => 66), 96 => array('setname' => 'licenseGrayzoneMessages', 'setvalue' => '', 'setmodule' => 66), 97 => array('setname' => 'coreCmsVersion', 'setvalue' => '3.0.4', 'setmodule' => 66), 98 => array('setname' => 'coreCmsCodeName', 'setvalue' => 'Nikola Tesla', 'setmodule' => 66), 99 => array('setname' => 'coreCmsStatus', 'setvalue' => 'Stable', 'setmodule' => 66), 100 => array('setname' => 'coreCmsReleaseDate', 'setvalue' => '12.04.2013', 'setmodule' => 66), 101 => array('setname' => 'licensePartner', 'setvalue' => '', 'setmodule' => 66), 102 => array('setname' => 'licenseCustomer', 'setvalue' => '', 'setmodule' => 66), 103 => array('setname' => 'availableComponents', 'setvalue' => '', 'setmodule' => 66), 104 => array('setname' => 'upgradeUrl', 'setvalue' => 'http://license.contrexx.com/', 'setmodule' => 66), 105 => array('setname' => 'isUpgradable', 'setvalue' => 'off', 'setmodule' => 66), 106 => array('setname' => 'dashboardMessages', 'setvalue' => 'YToxOntzOjI6ImRlIjtPOjMxOiJDeFxDb3JlX01vZHVsZXNcTGljZW5zZVxNZXNzYWdlIjo2OntzOjQxOiIAQ3hcQ29yZV9Nb2R1bGVzXExpY2Vuc2VcTWVzc2FnZQBsYW5nQ29kZSI7czoyOiJkZSI7czozNzoiAEN4XENvcmVfTW9kdWxlc1xMaWNlbnNlXE1lc3NhZ2UAdGV4dCI7czo5MjoiU2llIGJlbnV0emVuIGRlbiBSZWxlYXNlIENhbmRpZGF0ZSB2b24gQ29udHJleHggMy4gS2xpY2tlbiBTaWUgaGllciB1bSBOZXVpZ2tlaXRlbiB6dSBzZWhlbiEiO3M6Mzc6IgBDeFxDb3JlX01vZHVsZXNcTGljZW5zZVxNZXNzYWdlAHR5cGUiO3M6MTA6Indhcm5pbmdib3giO3M6Mzc6IgBDeFxDb3JlX01vZHVsZXNcTGljZW5zZVxNZXNzYWdlAGxpbmsiO3M6MjE6ImluZGV4LnBocD9jbWQ9bGljZW5zZSI7czo0MzoiAEN4XENvcmVfTW9kdWxlc1xMaWNlbnNlXE1lc3NhZ2UAbGlua1RhcmdldCI7czo1OiJfc2VsZiI7czo0ODoiAEN4XENvcmVfTW9kdWxlc1xMaWNlbnNlXE1lc3NhZ2UAc2hvd0luRGFzaGJvYXJkIjtiOjE7fX0=', 'setmodule' => 66), 112 => array('setname' => 'coreCmsName', 'setvalue' => 'Contrexx', 'setmodule' => 66), 113 => array('setname' => 'useCustomizings', 'setvalue' => 'off', 'setmodule' => 1), 114 => array('setname' => 'licenseGrayzoneTime', 'setvalue' => '14', 'setmodule' => 66), 115 => array('setname' => 'licenseLockTime', 'setvalue' => '10', 'setmodule' => 66), 116 => array('setname' => 'licenseUpdateInterval', 'setvalue' => '24', 'setmodule' => 66), 117 => array('setname' => 'licenseFailedUpdate', 'setvalue' => '0', 'setmodule' => 66), 118 => array('setname' => 'licenseSuccessfulUpdate', 'setvalue' => '0', 'setmodule' => 66), 119 => array('setname' => 'cacheUserCache', 'setvalue' => 'off', 'setmodule' => 1), 120 => array('setname' => 'cacheOPCache', 'setvalue' => 'off', 'setmodule' => 1), 121 => array('setname' => 'cacheUserCacheMemcacheConfig', 'setvalue' => '{\\"ip":\\"127.0.0.1\\",\\"port\\":11211}', 'setmodule' => 1), 122 => array('setname' => 'cacheProxyCacheVarnishConfig', 'setvalue' => '{\\"ip":\\"127.0.0.1\\",\\"port\\":8080}', 'setmodule' => 1)); $arrSettingsByName = array(); foreach ($arrSettings as $setid => $data) { $arrSettingsByName[$data['setname']] = $setid; } // change googleSitemapStatus to xmlSitemapStatus $query = "SELECT 1 FROM `" . DBPREFIX . "settings` WHERE `setname`='googleSitemapStatus'"; $objResult = $objDatabase->SelectLimit($query, 1); if ($objResult) { if ($objResult->RecordCount() == 1) { $query = "UPDATE `" . DBPREFIX . "settings` SET `setname` = 'xmlSitemapStatus' WHERE `setname` = 'googleSitemapStatus'"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } try { //remove fileuploader setting \Cx\Lib\UpdateUtil::sql('DELETE FROM ' . DBPREFIX . 'settings WHERE setid=70 AND setname="fileUploaderStatus"'); } catch (\Cx\Lib\UpdateException $e) { DBG::trace(); return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } foreach ($arrSettings as $setId => $arrSetting) { if (!_updateSettingsTable($setId, $arrSetting)) { return false; } } $query = "UPDATE `" . DBPREFIX . "settings` SET `setmodule`=1 WHERE `setmodule`=0"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } //timezone (Contrexx 3.0.1) $arrTimezoneIdentifiers = timezone_identifiers_list(); if (isset($_POST['timezone']) && array_key_exists($_POST['timezone'], $arrTimezoneIdentifiers)) { $_SESSION['contrexx_update']['update']['timezone'] = $_POST['timezone']; } if (isset($_SESSION['contrexx_update']['update']['timezone']) && array_key_exists(ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['timezone']), $arrTimezoneIdentifiers)) { try { \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'settings` SET `setvalue` = "' . $arrTimezoneIdentifiers[$_SESSION['contrexx_update']['update']['timezone']] . '" WHERE `setname` = "timezone"'); // add timezone to $_CONFIG array so it will be written in configuration.php in components/core/core.php $_CONFIG['timezone'] = $arrTimezoneIdentifiers[$_SESSION['contrexx_update']['update']['timezone']]; } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } else { $selected = -1; if (($defaultTimezoneId = array_search(@date_default_timezone_get(), $arrTimezoneIdentifiers)) && !empty($defaultTimezoneId)) { $selected = $defaultTimezoneId; } $options = '<option value="-1"' . ($selected == -1 ? ' selected="selected"' : '') . '>' . $_CORELANG['TXT_PLEASE_SELECT'] . '</option>'; foreach ($arrTimezoneIdentifiers as $id => $name) { $dateTimeZone = new DateTimeZone($name); $dateTime = new DateTime('now', $dateTimeZone); $timeOffset = $dateTimeZone->getOffset($dateTime); $sign = $timeOffset < 0 ? '-' : '+'; $gmt = 'GMT ' . $sign . gmdate('g:i', $timeOffset); $options .= '<option value="' . $id . '"' . ($selected == $id ? ' selected="selected"' : '') . '>' . $name . ' (' . $gmt . ')' . '</option>'; } setUpdateMsg($_CORELANG['TXT_TIMEZONE'], 'title'); setUpdateMsg($_CORELANG['TXT_TIMEZONE_INTRODUCTION'] . ' <select name="timezone">' . $options . '</select>', 'msg'); setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_UPDATE_NEXT'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button'); return false; } // write settings $strFooter = ''; $arrModules = ''; \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOCUMENT_ROOT . '/config/'); if (!file_exists(ASCMS_DOCUMENT_ROOT . '/config/settings.php')) { if (!touch(ASCMS_DOCUMENT_ROOT . '/config/settings.php')) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_CREATE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/settings.php')); setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR'], ASCMS_DOCUMENT_ROOT . '/config/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOCUMENT_ROOT . '/config/settings.php'); if (is_writable(ASCMS_DOCUMENT_ROOT . '/config/settings.php')) { try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . '/config/settings.php'); //Header & Footer $strHeader = "<?php\n"; $strHeader .= "/**\n"; $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n"; $strHeader .= "* Do not try to edit it manually!\n"; $strHeader .= "*/\n\n"; $strFooter .= "?>"; //Get module-names $objResult = $objDatabase->Execute('SELECT id, name FROM ' . DBPREFIX . 'modules'); if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { $arrModules[$objResult->fields['id']] = $objResult->fields['name']; $objResult->MoveNext(); } } //Get values $objResult = $objDatabase->Execute('SELECT setname, setmodule, setvalue FROM ' . DBPREFIX . 'settings ORDER BY setmodule ASC, setname ASC '); $intMaxLen = 0; $arrValues = array(); while ($objResult && !$objResult->EOF) { $intMaxLen = strlen($objResult->fields['setname']) > $intMaxLen ? strlen($objResult->fields['setname']) : $intMaxLen; $arrValues[$objResult->fields['setmodule']][$objResult->fields['setname']] = $objResult->fields['setvalue']; $objResult->MoveNext(); } $intMaxLen += strlen('$_CONFIG[\'\']') + 1; //needed for formatted output $fileContent = $strHeader; foreach ($arrValues as $intModule => $arrInner) { $fileContent .= "/**\n"; $fileContent .= "* -------------------------------------------------------------------------\n"; if (isset($arrModules[$intModule])) { $fileContent .= "* " . ucfirst($arrModules[$intModule]) . "\n"; } else { $fileContent .= "* " . $intModule . "\n"; } $fileContent .= "* -------------------------------------------------------------------------\n"; $fileContent .= "*/\n"; foreach ($arrInner as $strName => $strValue) { $fileContent .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $strName . '\']'); $fileContent .= "= "; $fileContent .= (is_numeric($strValue) ? $strValue : '"' . $strValue . '"') . ";\n"; } $fileContent .= "\n"; } $fileContent .= $strFooter; $objFile->write($fileContent); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_WRITE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/settings.php')); setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_DOCUMENT_ROOT . '/config/settings.php', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } $query = "\n ALTER TABLE " . DBPREFIX . "settings\n CHANGE COLUMN setid setid integer(6) UNSIGNED NOT NULL auto_increment;\n "; if (!$objDatabase->Execute($query)) { return _databaseError($query, $objDatabase->ErrorMsg()); } try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'settings_image', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(50)', 'after' => 'id'), 'value' => array('type' => 'text', 'after' => 'name'))); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) { try { \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_cut_width', '500')); \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_cut_height', '500')); \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_scale_width', '800')); \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_scale_height', '800')); \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_compression', '100')); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } return true; }
function contentManagerUpdates() { //Database migration try { //update module name \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "modules` (`id`, `name`, `distributor`, `description_variable`, `status`, `is_required`, `is_core`, `is_active`, `is_licensed`) VALUES ('72', 'ContentManager', 'DEV', 'TXT_CONTENTMANAGER_MODULE_DESCRIPTION', 'n', '0', '1', '1', '1')"); //update navigation url \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=ContentManager&act=new' WHERE `area_id` = 5"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=ContentManager' WHERE `area_id` = 6"); \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=ContentManager' WHERE `area_id` = 161"); //Alter the content_page table structure \Cx\Lib\UpdateUtil::table(DBPREFIX . 'content_page', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'node_id' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'id'), 'nodeIdShadowed' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'node_id'), 'lang' => array('type' => 'INT(11)', 'after' => 'nodeIdShadowed'), 'type' => array('type' => 'VARCHAR(16)', 'after' => 'lang'), 'caching' => array('type' => 'TINYINT(1)', 'after' => 'type'), 'updatedAt' => array('type' => 'timestamp', 'after' => 'caching'), 'updatedBy' => array('type' => 'CHAR(40)', 'after' => 'updatedAt'), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'updatedBy'), 'linkTarget' => array('type' => 'VARCHAR(16)', 'notnull' => false, 'after' => 'title'), 'contentTitle' => array('type' => 'VARCHAR(255)', 'after' => 'linkTarget'), 'slug' => array('type' => 'VARCHAR(255)', 'after' => 'contentTitle'), 'content' => array('type' => 'longtext', 'after' => 'slug'), 'sourceMode' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'content'), 'customContent' => array('type' => 'VARCHAR(64)', 'notnull' => false, 'after' => 'sourceMode'), 'useCustomContentForAllChannels' => array('type' => 'INT(2)', 'notnull' => false, 'after' => 'customContent'), 'applicationTemplate' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'after' => 'useCustomContentForAllChannels'), 'useCustomApplicationTemplateForAllChannels' => array('type' => 'TINYINT(2)', 'after' => 'applicationTemplate'), 'cssName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useCustomApplicationTemplateForAllChannels'), 'cssNavName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'cssName'), 'skin' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'cssNavName'), 'useSkinForAllChannels' => array('type' => 'INT(2)', 'notnull' => false, 'after' => 'skin'), 'metatitle' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useSkinForAllChannels'), 'metadesc' => array('type' => 'text', 'after' => 'metatitle'), 'metakeys' => array('type' => 'text', 'after' => 'metadesc'), 'metarobots' => array('type' => 'VARCHAR(7)', 'notnull' => false, 'after' => 'metakeys'), 'start' => array('type' => 'timestamp', 'after' => 'metarobots'), 'end' => array('type' => 'timestamp', 'after' => 'start'), 'editingStatus' => array('type' => 'VARCHAR(16)', 'after' => 'end'), 'protection' => array('type' => 'INT(11)', 'after' => 'editingStatus'), 'frontendAccessId' => array('type' => 'INT(11)', 'after' => 'protection'), 'backendAccessId' => array('type' => 'INT(11)', 'after' => 'frontendAccessId'), 'display' => array('type' => 'TINYINT(1)', 'after' => 'backendAccessId'), 'active' => array('type' => 'TINYINT(1)', 'after' => 'display'), 'target' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'active'), 'module' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'target'), 'cmd' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'after' => 'module')), array('node_id' => array('fields' => array('node_id', 'lang'), 'type' => 'UNIQUE'), 'IDX_D8E86F54460D9FD7' => array('fields' => array('node_id'))), 'InnoDB', '', array('node_id' => array('table' => DBPREFIX . 'content_node', 'column' => 'id', 'onDelete' => 'SET NULL', 'onUpdate' => 'NO ACTION'))); } catch (\Cx\Lib\UpdateException $e) { return "Error: {$e->sql}"; } $virtualComponents = array('Agb', 'Ids', 'Imprint', 'Privacy'); //migrating custom application template $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository(); $pages = $pageRepo->findBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION)); foreach ($pages as $page) { try { //virtual components do not migrating custom application template if (in_array(ucfirst($page->getModule()), $virtualComponents)) { continue; } $designTemplateName = $page->getSkin() ? $themeRepo->findById($page->getSkin())->getFoldername() : $themeRepo->getDefaultTheme()->getFoldername(); $cmd = !$page->getCmd() ? 'Default' : ucfirst($page->getCmd()); $moduleFolderName = contrexx_isCoreModule($page->getModule()) ? 'core_modules' : 'modules'; $themesPath = ASCMS_THEMES_PATH . '/' . $designTemplateName; //check common module or core_module folder exists if (!file_exists($themesPath . '/' . $moduleFolderName)) { \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName); } //check module's folder exists if (!file_exists($themesPath . '/' . $moduleFolderName . '/' . $page->getModule())) { \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName . '/' . $page->getModule()); } //check module's template folder exists if (!file_exists($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template')) { \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template'); } //check module's Frontend folder exists if (!file_exists($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template/Frontend')) { \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template/Frontend'); } $targetPath = $themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template/Frontend'; $applicationTemplateName = getFilename($targetPath, $cmd . '_custom_' . FWLanguage::getLanguageCodeById($page->getLang())); if (file_exists($targetPath)) { //create a application template file $file = new \Cx\Lib\FileSystem\File($targetPath . '/' . $applicationTemplateName); $file->write($page->getContent()); } //update application template $page->setContent('{APPLICATION_DATA}'); $page->setApplicationTemplate($applicationTemplateName); $page->setUseCustomApplicationTemplateForAllChannels(1); \Env::get('em')->persist($page); \Env::get('em')->flush(); } catch (\Exception $e) { throw new \Exception('Error :' . $e); } } return 'Application template migrated successfully.'; }
/** * Set the component's name in frontend and backend language files * @param string $baseDir Directory in which the recursive replace should be done */ public function setComponentName($baseDir) { $componentNamePlaceholder = '{COMPONENT_NAME}'; $directoryIterator = new \RecursiveDirectoryIterator($baseDir); $iterator = new \RecursiveIteratorIterator($directoryIterator); $files = new \RegexIterator($iterator, '/^.+(frontend|backend)\\.php$/i', \RegexIterator::GET_MATCH); // recursive foreach frontend.php and backend.php file foreach ($files as $file) { // prepare data $file = current($file); // file_get_contents() $objFile = new \Cx\Lib\FileSystem\File($file); $content = $objFile->getData(); $content = preg_replace('/' . preg_quote($componentNamePlaceholder) . '/', preg_quote($this->componentName), $content); echo 'Replace ' . $componentNamePlaceholder . ' by ' . $this->componentName . ' in ' . $file . "\n"; $objFile->write($content); } }
/** * Exports a DataSet to a file using an export interface * * @param Cx\Core_Modules\Listing\Model\Entity\Exportable $exportInterface * @param string $filename * @param boolean $useCache * @throws \Cx\Lib\FileSystem\FileSystemException */ public function exportToFile(\Cx\Core_Modules\Listing\Model\Entity\Exportable $exportInterface, $filename, $useCache = true) { try { $objFile = new \Cx\Lib\FileSystem\File($filename); $objFile->touch(); $export = $this->export($exportInterface); $objFile->write($export); // delete old key from cache, to reload it on the next import if ($useCache) { $cache = \Cx\Core\Core\Controller\Cx::instanciate()->getComponent('Cache'); if (!$cache) { throw new DataSetException('Cache component not available at this stage!'); } $cache->delete($filename); } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); throw new DataSetException("Failed to export data to file {$filename}!"); } }
/** * This should only be executed when updating from version 2.2.6 or older * Fix for the following tickets: * http://bugs.contrexx.com/contrexx/ticket/1412 * http://bugs.contrexx.com/contrexx/ticket/1043 * @see http://helpdesk.comvation.com/131276-Die-Navigation-meiner-Seite-wird-nicht-mehr-korrekt-angezeigt * * Adds placeholder {LEVELS_FULL} to all non-empty subnavbars * Adds placeholder {LEVELS_BRANCH} to all navbars having a block named 'navigation' but none 'level_1' */ function _updateNavigations() { global $objDatabase, $_CORELANG; $navbars = array('navbar', 'navbar2', 'navbar3'); $subnavbars = array('subnavbar', 'subnavbar2', 'subnavbar3'); // Find all themes $result = $objDatabase->Execute('SELECT `themesname`, `foldername` FROM `' . DBPREFIX . 'skins`'); if ($result->EOF) { \DBG::msg('No themes, really?'); return false; } // Update navigations for all themes $errorMessages = ''; while (!$result->EOF) { if (!is_dir(ASCMS_THEMES_PATH . '/' . $result->fields['foldername'])) { \DBG::msg('Skipping theme "' . $result->fields['themesname'] . '"; No such folder!'); $errorMessages .= '<div class="message-warning">' . sprintf($_CORELANG['TXT_CSS_UPDATE_MISSING_FOLDER'], $result->fields['themesname']) . '</div>'; $result->moveNext(); continue; } \DBG::msg('Updating navigations for theme "' . $result->fields['themesname'] . '" (' . $type . ')'); // add {LEVELS_FULL} to all non-empty subnavbars foreach ($subnavbars as $subnavbar) { try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_THEMES_PATH . '/' . $result->fields['foldername'] . '/' . $subnavbar . '.html'); $content = $objFile->getData(); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } if (trim($content) == '') { continue; } $content = '{LEVELS_FULL}' . "\r\n" . $content; try { $objFile->write($content); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } \DBG::msg('Updated file ' . $subnavbar . '.html for theme ' . $result->fields['themesname']); } // add {LEVELS_BRANCH} to all navbars matching the following criterias: // 1. blockExists('navigation') // 2. !blockExists('level_1') foreach ($navbars as $navbar) { try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_THEMES_PATH . '/' . $result->fields['foldername'] . '/' . $navbar . '.html'); $content = $objFile->getData(); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } if (trim($content) == '') { continue; } $template = new \Cx\Core\Html\Sigma('.'); $template->setTemplate($content); if (!$template->blockExists('navigation')) { continue; } if ($template->blockExists('level_1')) { continue; } $content = '{LEVELS_BRANCH}' . "\r\n" . $content; try { $objFile->write($content); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } \DBG::msg('Updated file ' . $navbar . '.html for theme ' . $result->fields['themesname']); } $result->moveNext(); } if (!empty($errorMessages)) { setUpdateMsg($errorMessages, 'msg'); setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button'); $_SESSION['contrexx_update']['update']['done'][] = 'navigations'; return false; } return true; }
/** * Write sitemap-file * * @global object * @global array * @param array An array containing the language ID's of which languages should be included in the sitemap. * @param string The two letter language code of the selected language used as the virtual language path */ protected function writeXML() { $filename = \FWLanguage::getLanguageCodeById($this->lang) ? sprintf(self::$strFileNameWithLang, \FWLanguage::getLanguageCodeById($this->lang)) : self::$strFileName; $xml = $this->render(); try { $filePath = \Env::get('cx')->getWebsiteDocumentRootPath(); $objFile = new \Cx\Lib\FileSystem\File($filePath . self::$strFilePath . '/' . $filename); $objFile->touch(); $objFile->write($xml); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::log($e->getMessage()); return false; } return true; }
/** * Checks if file exists, if not - creates new one with metadata * * @param string $filename * @param array $unique_keys * @param string $identifier * @return boolean * @throws \Cx\Core\Setting\Controller\SettingException */ protected function prepareFile($filename, $unique_keys = array(), $identifier) { if ($this->fileExistsAndNotEmpty($filename)) { return true; } \DBG::log('Creating new file'); try { $file = new \Cx\Lib\FileSystem\File($filename); $file->touch(); $data = trim($file->getData()); if (empty($data)) { $inidata = "meta:\n" . " auto_increment: 1\n"; if (!empty($identifier)) { $inidata .= " identifier: {$identifier}\n"; } if (!empty($unique_keys)) { $inidata .= " unique_keys:\n"; foreach ($unique_keys as $key) { $inidata .= " - {$key}"; } } $file->write($inidata); } } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::log('EX ' . $e->getMessage()); throw new \Cx\Core\Setting\Controller\YamlRepositoryException($e->getMessage()); } }
/** * Write feed * * Writes the rss feed. * * @return boolean */ function write() { global $_CORELANG; if (!$this->_create()) { return false; } try { $objFile = new \Cx\Lib\FileSystem\File($this->xmlDocumentPath); $objFile->write(preg_replace('/\\f/', '', $this->xmlDocument)); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { if (file_exists($this->xmlDocumentPath)) { array_push($this->arrErrorMsg, sprintf($_CORELANG['TXT_UNABLE_TO_WRITE_TO_FILE'], $this->xmlDocumentPath)); } else { array_push($this->arrErrorMsg, sprintf($_CORELANG['TXT_UNABLE_TO_CREATE_FILE'], $this->xmlDocumentPath)); } return false; } return true; }
private function testLoad($path, $name) { if (!file_exists($path) || !$this->checkClassExistsInFile($name, $path)) { return false; } $path = substr($path, strlen($this->cx->getCodeBaseDocumentRootPath())); if (!$this->loadClass($path, $name)) { return false; } try { $objFile = new \Cx\Lib\FileSystem\File($this->userClassCacheFile); if (!file_exists($this->userClassCacheFile)) { $objFile->touch(); } $cacheArr = unserialize(file_get_contents($this->classLoader->getFilePath($this->userClassCacheFile))); $cacheArr[$name] = $path; $objFile->write(serialize($cacheArr)); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); } return true; }
/** * Writes the component.yml file with the data defined in component data array * * @param \Cx\Core\View\Model\Entity\Theme $theme the theme object */ public function saveComponentData(\Cx\Core\View\Model\Entity\Theme $theme) { global $_ARRAYLANG; if (!file_exists(\Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername())) { if (!\Cx\Lib\FileSystem\FileSystem::make_folder(\Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername())) { \Message::add($theme->getFoldername() . " : " . $_ARRAYLANG['TXT_THEME_UNABLE_TO_CREATE']); } } $filePath = \Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername() . '/component.yml'; try { $file = new \Cx\Lib\FileSystem\File($filePath); $file->touch(); $yaml = new \Symfony\Component\Yaml\Yaml(); $file->write($yaml->dump(array('DlcInfo' => $theme->getComponentData()))); } catch (\Exception $e) { \DBG::log($e->getMessage()); throw new $e(); } }
/** * Parses ESI directives internally if configured to do so * @param string $htmlCode HTML code to replace ESI directives in * @return string Parsed HTML code */ public function internalEsiParsing($htmlCode, $cxNotYetInitialized = false) { if (!is_a($this->getSsiProxy(), '\\Cx\\Core_Modules\\Cache\\Model\\Entity\\ReverseProxyCloudrexx')) { return $htmlCode; } // Replace include tags $settings = $this->getSettings(); // apply ESI dynamic variables foreach ($this->dynVars as $groupName => $vars) { foreach ($vars as $varName => $url) { $esiPlaceholder = '$(' . $groupName . '{\'' . $varName . '\'})'; if (strpos($htmlCode, $esiPlaceholder) === false) { continue; } $varValue = $this->getApiResponseForUrl($url); $htmlCode = str_replace($esiPlaceholder, $varValue, $htmlCode); } } $replaceEsiFn = function ($matches) use(&$cxNotYetInitialized, $settings) { // return cached content if available $cacheFile = $this->getCacheFileNameFromUrl($matches[1]); if ($settings['internalSsiCache'] == 'on' && file_exists($this->strCachePath . $cacheFile)) { if (filemtime($this->strCachePath . $cacheFile) > time() - $this->intCachingTime) { return file_get_contents($this->strCachePath . $cacheFile); } else { $file = new \Cx\Lib\FileSystem\File($this->strCachePath . $cacheFile); $file->delete(); } } if ($cxNotYetInitialized) { \Cx\Core\Core\Controller\Cx::instanciate(\Cx\Core\Core\Controller\Cx::MODE_MINIMAL, true, null, true); $cxNotYetInitialized = false; } // TODO: Somehow FRONTEND_LANG_ID is sometimes undefined here... if (!defined('FRONTEND_LANG_ID')) { define('FRONTEND_LANG_ID', 1); } $content = $this->getApiResponseForUrl($matches[1]); if ($settings['internalSsiCache'] == 'on') { $file = new \Cx\Lib\FileSystem\File($this->strCachePath . $cacheFile); $file->write($content); } return $content; }; do { // Random include tags $htmlCode = preg_replace_callback('#<!-- ESI_RANDOM_START -->[\\s\\S]*<esi:assign name="content_list">\\s*\\[([^\\]]+)\\]\\s*</esi:assign>[\\s\\S]*<!-- ESI_RANDOM_END -->#', function ($matches) { $uris = explode('\',\'', substr($matches[1], 1, -1)); $randomNumber = rand(0, count($uris) - 1); $uri = $uris[$randomNumber]; // this needs to match the format below! return '<esi:include src="' . $uri . '" onerror="continue"/>'; }, $htmlCode); $htmlCode = preg_replace_callback('#<esi:include src="([^"]+)" onerror="continue"/>#', $replaceEsiFn, $htmlCode, -1, $count); // repeat replacement to recursively parse ESI-tags } while ($count); return $htmlCode; }