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
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • 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:         // Display message for chmod rights on webserver
 58:         if ($_SESSION['setuptype'] == 'setup') {
 59:             $message = i18n("Please check that your config and client directories (including cache, module and upload directories, template-, css- and js-files) has chmod rights 755. Please make sure that the owner for these directories and all files are the same as the owner of your webserver.", "setup");
 60:             $message = nl2br($message);
 61:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_INFO, i18n("Attention: Please give your directories rights on your webserver", "setup"), $message);
 62:         }
 63: 
 64:         $cHTMLErrorMessageList = new cHTMLErrorMessageList();
 65: 
 66:         if (is_null(getMySQLDatabaseExtension())) {
 67:             $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"));
 68:         } else if ($this->_systemtest->testMySQL($_SESSION["dbhost"], $_SESSION["dbuser"], $_SESSION["dbpass"]) == cSystemtest::CON_MYSQL_OK) {
 69:             $this->initDB();
 70:         }
 71: 
 72:         $this->checkCountryLanguageCode();
 73: 
 74:         $cHTMLFoldableErrorMessages = array();
 75: 
 76:         if ($_SESSION["setuptype"] == 'upgrade') {
 77:             // Check if there is an old version of integrated plugins installed
 78:             // in upgrademode.
 79:             $this->doExistingOldPluginTests();
 80: 
 81:             // Check if user updates a system lower than 4.9
 82:             $this->doChangedDirsFilesTest();
 83:         }
 84: 
 85:         $maxExecutionTime = (int) ini_get('max_execution_time');
 86:         if ($maxExecutionTime < 60 && $maxExecutionTime !== 0) {
 87:             $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"));
 88:         }
 89: 
 90:         $results = $this->_systemtest->getResults();
 91: 
 92:         foreach ($results as $result) {
 93:             if ($result["result"]) {
 94:                 continue;
 95:             }
 96: 
 97:             switch ($result["severity"]) {
 98:                 case cSystemtest::C_SEVERITY_INFO:
 99:                     $icon = "images/icons/info.png";
100:                     $iconDescription = i18n("Information", "setup");
101:                     break;
102:                 case cSystemtest::C_SEVERITY_WARNING:
103:                     $icon = "images/icons/warning.png";
104:                     $iconDescription = i18n("Warning", "setup");
105:                     break;
106:                 case cSystemtest::C_SEVERITY_ERROR:
107:                     $icon = "images/icons/error.png";
108:                     $iconDescription = i18n("Fatal error", "setup");
109:                     $errors = true;
110:                     break;
111:             }
112:             $cHTMLFoldableErrorMessages[] = new cHTMLFoldableErrorMessage($result["headline"], $result["message"], $icon, $iconDescription);
113:         }
114: 
115:         if (count($cHTMLFoldableErrorMessages) == 0) {
116:             $cHTMLFoldableErrorMessages[] = new cHTMLFoldableErrorMessage(i18n("No problems detected", "setup"), i18n("Setup could not detect any problems with your system environment", "setup"), "images/icons/info.png");
117:         }
118: 
119:         $cHTMLErrorMessageList->setContent($cHTMLFoldableErrorMessages);
120: 
121:         $this->_stepTemplateClass->set("s", "CONTROL_TESTRESULTS", $cHTMLErrorMessageList->render());
122: 
123:         if ($errors == true) {
124:             $this->setNavigation($previous, "");
125: 
126:             switch ($_SESSION['setuptype']) {
127:                 case "upgrade":
128:                     $thisStep = 'upgrade' . $step;
129:                     break;
130:                 case "setup":
131:                 default:
132:                     $thisStep = 'setup' . $step;
133:                     break;
134:             }
135: 
136:             $link = new cHTMLLink("#");
137:             $link->attachEventDefinition("pageAttach", "onclick", "document.setupform.step.value = '" . $thisStep . "';");
138:             $link->attachEventDefinition("submitAttach", "onclick", "document.setupform.submit();");
139:             $link->setClass("nav navRefresh");
140:             $link->setContent("<span>R</span>");
141: 
142:             $this->_stepTemplateClass->set("s", "NEXT", $link->render());
143:         } else {
144:             $this->setNavigation($previous, $next);
145:         }
146:     }
147: 
148:     /**
149:      * Old constructor
150:      * @deprecated [2016-04-14] This method is deprecated and is not needed any longer. Please use __construct() as constructor function.
151:      * @param $step
152:      * @param $previous
153:      * @param $next
154:      */
155:     public function cSetupSystemtest($step, $previous, $next) {
156:         cDeprecated('This method is deprecated and is not needed any longer. Please use __construct() as constructor function.');
157:        $this->__construct($step, $previous, $next);
158:     }
159: 
160:     public function doExistingOldPluginTests() {
161:         $db = getSetupMySQLDBConnection(false);
162:         $message = '';
163: 
164:         // get all tables in database and list it into array
165:         $avariableTableNames = array();
166:         $tableNames = $db->getTableNames();
167:         if (!is_array($tableNames)) {
168:             return;
169:         }
170: 
171:         foreach ($tableNames as $table) {
172:             $avariableTableNames[] = $table['table_name'];
173:         }
174: 
175:         // list of plugin tables to copy into new plugin tables
176:         $oldPluginTables = array(
177:             'Workflow' => array(
178:                 'piwf_actions',
179:                 'piwf_allocation',
180:                 'piwf_art_allocation',
181:                 'piwf_items',
182:                 'piwf_user_sequences',
183:                 'piwf_workflow'
184:             ),
185:             'Content allocation' => array(
186:                 'pica_alloc',
187:                 'pica_alloc_con',
188:                 'pica_lang'
189:             ),
190:             'Linkchecker' => array(
191:                 'pi_externlinks',
192:                 'pi_linkwhitelist'
193:             )
194:         );
195: 
196:         foreach ($oldPluginTables as $plugin => $tables) {
197:             $pluginExists = false;
198:             foreach ($tables as $currentTable) {
199:                 if (in_array($currentTable, $avariableTableNames)) {
200:                     $pluginExists = true;
201:                 }
202:             }
203: 
204:             if ($pluginExists) {
205:                 $message .= sprintf(i18n('An old Version of Plugin %s is installed on your system.', "setup") . "<br>\n", $plugin);
206:             }
207:         }
208: 
209:         if ($message) {
210:             $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");
211: 
212:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Old Plugins are still installed", "setup"), $message);
213:         }
214:     }
215: 
216:     public function doChangedDirsFilesTest() {
217:         $cfg = cRegistry::getConfig();
218: 
219:         $db = getSetupMySQLDBConnection(false);
220:         $version = getContenidoVersion($db, $cfg['tab']['system_prop']);
221: 
222:         // Display message about changed directories/files when user updates a
223:         // system lower than 4.9
224:         // Also display message for chmod rights on webserver
225:         if ($version && version_compare('4.9', $version) > 0) {
226:             $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");
227:             $message = sprintf($message, '4.9', '4.9');
228:             $message = nl2br($message);
229:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Attention: Some directories/files have been moved", "setup"), $message);
230: 
231:             $message = i18n("Please check that your config and client directories (including cache, module and upload directories, template-, css- and js-files) has chmod rights 755. Please make sure that the owner for these directories and all files are the same as the owner of your webserver.", "setup");
232:             $message = nl2br($message);
233:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_INFO, i18n("Attention: Please give your directories rights on your webserver", "setup"), $message);
234:         }
235:     }
236: 
237:     public function checkCountryLanguageCode() {
238:         if ($_SESSION["setuptype"] != 'upgrade') {
239:             return;
240:         }
241: 
242:         $errors = array();
243: 
244:         cDb::setDefaultConfiguration($GLOBALS['cfg']['db']);
245: 
246:         $clientLanguageCollection = new cApiClientLanguageCollection();
247:         $clientLanguageCollection->query();
248: 
249:         while ($item = $clientLanguageCollection->next()) {
250:             $client = $item->getField('idclient');
251:             $lang = $item->getField('idlang');
252: 
253:             $oLanguage = new cApiLanguage();
254:             $oLanguage->loadByPrimaryKey($lang);
255: 
256:             $languageCode = $oLanguage->getProperty("language", "code", $client);
257:             $contryCode = $oLanguage->getProperty("country", "code", $client);
258: 
259:             $oClient = new cApiClient();
260:             $oClient->loadByPrimaryKey($client);
261:             $clientName = $oClient->getField('name');
262: 
263:             if (cString::getStringLength($languageCode) == 0 || cString::getStringLength($contryCode) == 0) {
264:                 $langName = $oLanguage->getField('name');
265: 
266:                 $oClient = new cApiClient();
267:                 $oClient->loadByPrimaryKey($client);
268: 
269:                 array_push($errors, sprintf(i18n('Language "%s" (%s) of the client "%s" (%s) is configured without ISO language code.', "setup"), $langName, $lang, $clientName, $client));
270:             }
271:         }
272: 
273:         if (count($errors) > 0) {
274:             $this->_systemtest->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("The ISO codes are necessary to convert module translations.", "setup"), implode('<br/>', $errors));
275:         }
276:     }
277: 
278:     public function initDB() {
279:         $this->_systemtest->checkSetupMysql($_SESSION['setuptype'], $_SESSION['dbname'], $_SESSION['dbprefix'], $_SESSION['dbcharset'], $_SESSION['dbcollation']);
280:     }
281: 
282: }
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0