Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cSetupAdminPassword
  • cSetupClientAdjust
  • cSetupClientMode
  • cSetupConfigMode
  • cSetupInstaller
  • cSetupPath
  • cSetupResults
  • cSetupSetupSummary
  • cSetupSystemData
  • cSetupSystemtest
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the system test setup mask.
  4:  *
  5:  * @package Setup
  6:  * @subpackage Form
  7:  * @author Unknown
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 14: 
 15: /**
 16:  * System test setup mask.
 17:  *
 18:  * @package Setup
 19:  * @subpackage Form
 20:  */
 21: class cSetupSystemtest extends cSetupMask {
 22: 
 23:     private $_systemtest;
 24: 
 25:     /**
 26:      * cSetupSystemtest constructor.
 27:      * @param string $step
 28:      * @param bool $previous
 29:      * @param $next
 30:      */
 31:     public function __construct($step, $previous, $next) {
 32:         $cfg = cRegistry::getConfig();
 33: 
 34:         cSetupMask::__construct("templates/setup/forms/systemtest.tpl", $step);
 35: 
 36:         $errors = false;
 37: 
 38:         $this->setHeader(i18n("System Test", "setup"));
 39:         $this->_stepTemplateClass->set("s", "TITLE", i18n("System Test", "setup"));
 40:         $this->_stepTemplateClass->set("s", "DESCRIPTION", i18n("Your system has been tested for compatibility with CONTENIDO:", "setup"));
 41: 
 42:         // reload i18n for contenido locale
 43:         i18nInit('../data/locale/', $_SESSION['language']);
 44: 
 45:         // Initializing cfgClient
 46:         if ($_SESSION['setuptype'] == 'upgrade') {
 47:             setupInitializeCfgClient(true);
 48:         }
 49: 
 50:         $this->_systemtest = new cSystemtest($cfg);
 51:         $this->_systemtest->runTests(false);
 52:         $this->_systemtest->testFilesystem($_SESSION["configmode"] == "save", $_SESSION['setuptype'] == 'upgrade');
 53:         if ($_SESSION['setuptype'] == 'setup') {
 54:             $this->_systemtest->testFrontendFolderCreation();
 55:         }
 56: 
 57:         $cHTMLErrorMessageList = new cHTMLErrorMessageList();
 58: 
 59:         if (is_null(getMySQLDatabaseExtension())) {
 60:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("PHP MySQL Extension missing", "setup"), i18n("CONTENIDO requires the MySQL or MySQLi extension to access MySQL databases. Please configure PHP to use either MySQL or MySQLi.", "setup"));
 61:         } else if ($this->_systemtest->testMySQL($_SESSION["dbhost"], $_SESSION["dbuser"], $_SESSION["dbpass"]) == cSystemtest::CON_MYSQL_OK) {
 62:             $this->initDB();
 63:         }
 64: 
 65:         $this->checkCountryLanguageCode();
 66: 
 67:         $cHTMLFoldableErrorMessages = array();
 68: 
 69:         if ($_SESSION["setuptype"] == 'upgrade') {
 70:             // Check if there is an old version of integrated plugins installed
 71:             // in upgrademode.
 72:             $this->doExistingOldPluginTests();
 73: 
 74:             // Check if user updates a system lower than 4.9
 75:             $this->doChangedDirsFilesTest();
 76:         }
 77: 
 78:         $maxExecutionTime = (int) ini_get('max_execution_time');
 79:         if ($maxExecutionTime < 60 && $maxExecutionTime !== 0) {
 80:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Unable to set max_execution_time", "setup"), i18n("Your PHP configuration for max_execution_time can not be changed via this script. We recommend setting the value for the installation or upgrade process to 60 seconds. You can try to execute the process with your current configuration. If the process is stopped, the system is not usable (any longer)", "setup"));
 81:         }
 82: 
 83:         $results = $this->_systemtest->getResults();
 84: 
 85:         foreach ($results as $result) {
 86:             if ($result["result"]) {
 87:                 continue;
 88:             }
 89: 
 90:             switch ($result["severity"]) {
 91:                 case cSystemtest::C_SEVERITY_INFO:
 92:                     $icon = "images/icons/info.png";
 93:                     $iconDescription = i18n("Information", "setup");
 94:                     break;
 95:                 case cSystemtest::C_SEVERITY_WARNING:
 96:                     $icon = "images/icons/warning.png";
 97:                     $iconDescription = i18n("Warning", "setup");
 98:                     break;
 99:                 case cSystemtest::C_SEVERITY_ERROR:
100:                     $icon = "images/icons/error.png";
101:                     $iconDescription = i18n("Fatal error", "setup");
102:                     $errors = true;
103:                     break;
104:             }
105:             $cHTMLFoldableErrorMessages[] = new cHTMLFoldableErrorMessage($result["headline"], $result["message"], $icon, $iconDescription);
106:         }
107: 
108:         if (count($cHTMLFoldableErrorMessages) == 0) {
109:             $cHTMLFoldableErrorMessages[] = new cHTMLFoldableErrorMessage(i18n("No problems detected", "setup"), i18n("Setup could not detect any problems with your system environment", "setup"), "images/icons/info.png");
110:         }
111: 
112:         $cHTMLErrorMessageList->setContent($cHTMLFoldableErrorMessages);
113: 
114:         $this->_stepTemplateClass->set("s", "CONTROL_TESTRESULTS", $cHTMLErrorMessageList->render());
115: 
116:         if ($errors == true) {
117:             $this->setNavigation($previous, "");
118: 
119:             switch ($_SESSION['setuptype']) {
120:                 case "upgrade":
121:                     $thisStep = 'upgrade' . $step;
122:                     break;
123:                 case "setup":
124:                 default:
125:                     $thisStep = 'setup' . $step;
126:                     break;
127:             }
128: 
129:             $link = new cHTMLLink("#");
130:             $link->attachEventDefinition("pageAttach", "onclick", "document.setupform.step.value = '" . $thisStep . "';");
131:             $link->attachEventDefinition("submitAttach", "onclick", "document.setupform.submit();");
132:             $link->setClass("nav navRefresh");
133:             $link->setContent("<span>R</span>");
134: 
135:             $this->_stepTemplateClass->set("s", "NEXT", $link->render());
136:         } else {
137:             $this->setNavigation($previous, $next);
138:         }
139:     }
140: 
141:     /**
142:      * Old constructor
143:      * @deprecated [2016-04-14] This method is deprecated and is not needed any longer. Please use __construct() as constructor function.
144:      * @param $step
145:      * @param $previous
146:      * @param $next
147:      */
148:     public function cSetupSystemtest($step, $previous, $next) {
149:         cDeprecated('This method is deprecated and is not needed any longer. Please use __construct() as constructor function.');
150:        $this->__construct($step, $previous, $next);
151:     }
152: 
153:     public function doExistingOldPluginTests() {
154:         $db = getSetupMySQLDBConnection(false);
155:         $message = '';
156: 
157:         // get all tables in database and list it into array
158:         $avariableTableNames = array();
159:         $tableNames = $db->getTableNames();
160:         if (!is_array($tableNames)) {
161:             return;
162:         }
163: 
164:         foreach ($tableNames as $table) {
165:             $avariableTableNames[] = $table['table_name'];
166:         }
167: 
168:         // list of plugin tables to copy into new plugin tables
169:         $oldPluginTables = array(
170:             'Workflow' => array(
171:                 'piwf_actions',
172:                 'piwf_allocation',
173:                 'piwf_art_allocation',
174:                 'piwf_items',
175:                 'piwf_user_sequences',
176:                 'piwf_workflow'
177:             ),
178:             'Content allocation' => array(
179:                 'pica_alloc',
180:                 'pica_alloc_con',
181:                 'pica_lang'
182:             ),
183:             'Linkchecker' => array(
184:                 'pi_externlinks',
185:                 'pi_linkwhitelist'
186:             )
187:         );
188: 
189:         foreach ($oldPluginTables as $plugin => $tables) {
190:             $pluginExists = false;
191:             foreach ($tables as $currentTable) {
192:                 if (in_array($currentTable, $avariableTableNames)) {
193:                     $pluginExists = true;
194:                 }
195:             }
196: 
197:             if ($pluginExists) {
198:                 $message .= sprintf(i18n('An old Version of Plugin %s is installed on your system.', "setup") . "<br>\n", $plugin);
199:             }
200:         }
201: 
202:         if ($message) {
203:             $message .= '<br>' . i18n('Please remove all old plugins before you continue. To transfer old plugin data, please copy the old plugin data tables into the new plugin data tables after the installation. The new plugintable names are the same, but contains the table prefix of CONTENIDO. Also delete the old plugin tables after data transfer.', "setup");
204: 
205:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Old Plugins are still installed", "setup"), $message);
206:         }
207:     }
208: 
209:     public function doChangedDirsFilesTest() {
210:         $cfg = cRegistry::getConfig();
211: 
212:         $db = getSetupMySQLDBConnection(false);
213:         $version = getContenidoVersion($db, $cfg['tab']['system_prop']);
214: 
215:         // Display message about changed directories/files when user updates a
216:         // system lower than 4.9
217:         if ($version && version_compare('4.9', $version) > 0) {
218:             $message = i18n("You are updating a previous version of CONTENIDO to %s. Some directories/files have been moved to other sections in %s.\n\nPlease ensure to copy contenido/includes/config.php to data/config/production/config.php and also other configuration files within contenido/includes/ to data/config/production/.", "setup");
219:             $message = sprintf($message, '4.9', '4.9');
220:             $message = nl2br($message);
221:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Attention: Some directories/files have been moved", "setup"), $message);
222:         }
223:     }
224: 
225:     public function checkCountryLanguageCode() {
226:         if ($_SESSION["setuptype"] != 'upgrade') {
227:             return;
228:         }
229: 
230:         $errors = array();
231: 
232:         cDb::setDefaultConfiguration($GLOBALS['cfg']['db']);
233: 
234:         $clientLanguageCollection = new cApiClientLanguageCollection();
235:         $clientLanguageCollection->query();
236: 
237:         while ($item = $clientLanguageCollection->next()) {
238:             $client = $item->getField('idclient');
239:             $lang = $item->getField('idlang');
240: 
241:             $oLanguage = new cApiLanguage();
242:             $oLanguage->loadByPrimaryKey($lang);
243: 
244:             $languageCode = $oLanguage->getProperty("language", "code", $client);
245:             $contryCode = $oLanguage->getProperty("country", "code", $client);
246: 
247:             $oClient = new cApiClient();
248:             $oClient->loadByPrimaryKey($client);
249:             $clientName = $oClient->getField('name');
250: 
251:             if (strlen($languageCode) == 0 || strlen($contryCode) == 0) {
252:                 $langName = $oLanguage->getField('name');
253: 
254:                 $oClient = new cApiClient();
255:                 $oClient->loadByPrimaryKey($client);
256: 
257:                 array_push($errors, sprintf(i18n('Language "%s" (%s) of the client "%s" (%s) is configured without ISO language code.', "setup"), $langName, $lang, $clientName, $client));
258:             }
259:         }
260: 
261:         if (count($errors) > 0) {
262:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("The ISO codes are necessary to convert module translations.", "setup"), implode('<br/>', $errors));
263:         }
264:     }
265: 
266:     public function initDB() {
267:         $this->_systemtest->checkSetupMysql($_SESSION['setuptype'], $_SESSION['dbname'], $_SESSION['dbprefix'], $_SESSION['dbcharset'], $_SESSION['dbcollation']);
268:     }
269: 
270: }
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0