1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: 17: 18: 19: 20: 21:
22: class cSystemtest {
23:
24: 25: 26: 27: 28:
29: const CON_SETUP_MIN_PHP_VERSION = '7.0.0';
30:
31: 32: 33: 34: 35:
36: const C_SEVERITY_NONE = 1;
37:
38: 39: 40: 41: 42:
43: const C_SEVERITY_INFO = 2;
44:
45: 46: 47: 48: 49: 50:
51: const C_SEVERITY_WARNING = 3;
52:
53: 54: 55: 56: 57: 58:
59: const C_SEVERITY_ERROR = 4;
60:
61: 62: 63: 64: 65: 66:
67: const CON_PREDICT_SUFFICIENT = 1;
68:
69: 70: 71: 72: 73: 74:
75: const CON_PREDICT_NOTPREDICTABLE = 2;
76:
77: 78: 79: 80: 81: 82:
83: const CON_PREDICT_CHANGEPERM_SAMEOWNER = 3;
84:
85: 86: 87: 88: 89: 90:
91: const CON_PREDICT_CHANGEPERM_SAMEGROUP = 4;
92:
93: 94: 95: 96: 97: 98:
99: const CON_PREDICT_CHANGEPERM_OTHERS = 5;
100:
101: 102: 103: 104: 105: 106:
107: const CON_PREDICT_CHANGEUSER = 6;
108:
109: 110: 111: 112: 113: 114:
115: const CON_PREDICT_CHANGEGROUP = 7;
116:
117: 118: 119: 120: 121: 122:
123: const CON_PREDICT_WINDOWS = 8;
124:
125: 126: 127: 128: 129: 130:
131: const CON_BASEDIR_NORESTRICTION = 1;
132:
133: 134: 135: 136: 137: 138:
139: const CON_BASEDIR_DOTRESTRICTION = 2;
140:
141: 142: 143: 144: 145: 146:
147: const CON_BASEDIR_RESTRICTIONSUFFICIENT = 3;
148:
149: 150: 151: 152: 153: 154:
155: const CON_BASEDIR_INCOMPATIBLE = 4;
156:
157: 158: 159: 160: 161: 162:
163: const CON_EXTENSION_AVAILABLE = 1;
164:
165: 166: 167: 168: 169: 170:
171: const CON_EXTENSION_UNAVAILABLE = 2;
172:
173: 174: 175: 176: 177: 178:
179: const CON_EXTENSION_CANTCHECK = 3;
180:
181: 182: 183: 184: 185: 186:
187: const CON_IMAGERESIZE_GD = 1;
188:
189: 190: 191: 192: 193: 194:
195: const CON_IMAGERESIZE_IMAGEMAGICK = 2;
196:
197: 198: 199: 200: 201: 202:
203: const CON_IMAGERESIZE_CANTCHECK = 3;
204:
205: 206: 207: 208: 209: 210:
211: const CON_IMAGERESIZE_NOTHINGAVAILABLE = 4;
212:
213: 214: 215: 216: 217: 218:
219: const CON_MYSQL_OK = 1;
220:
221: 222: 223: 224: 225: 226: 227:
228: const CON_MYSQL_STRICT_MODE = 2;
229:
230: 231: 232: 233: 234: 235: 236:
237: const CON_MYSQL_CANT_CONNECT = 3;
238:
239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250:
251: protected $_messages;
252:
253: 254: 255: 256: 257:
258: protected $_config;
259:
260: 261: 262: 263: 264: 265: 266: 267:
268: public function __construct($config) {
269: $this->_config = $config;
270: }
271:
272: 273: 274: 275: 276: 277: 278: 279: 280: 281:
282: public function runTests($testFileSystem = true) {
283: $this->storeResult($this->testPHPVersion(), self::C_SEVERITY_ERROR, sprintf(i18n("PHP Version lower than %s"), self::CON_SETUP_MIN_PHP_VERSION), sprintf(i18n("CONTENIDO requires PHP %s or higher as it uses functionality first introduced with this version. Please update your PHP version."), self::CON_SETUP_MIN_PHP_VERSION), i18n("The PHP version is higher than ") . self::CON_SETUP_MIN_PHP_VERSION);
284: $this->storeResult($this->testFileUploadSetting(), self::C_SEVERITY_WARNING, i18n("File uploads disabled"), sprintf(i18n("Your PHP version is not configured for file uploads. You can't upload files using CONTENIDO's file manager unless you configure PHP for file uploads. See %s for more information"), '<a target="_blank" href="http://www.php.net/manual/en/ini.core.php#ini.file-uploads">http://www.php.net/manual/en/ini.core.php#ini.file-uploads</a>'), i18n("PHP file upload is enabled"));
285: $this->storeResult($this->testMagicQuotesRuntimeSetting(), self::C_SEVERITY_ERROR, i18n("PHP setting 'magic_quotes_runtime' is turned on"), i18n("The PHP setting 'magic_quotes_runtime' is turned on. CONTENIDO has been developed to comply with magic_quotes_runtime=Off as this is the PHP default setting. You have to change this directive to make CONTENIDO work."), i18n("'magic_quotes_runtime' is turned off"));
286: $this->storeResult($this->testMagicQuotesSybaseSetting(), self::C_SEVERITY_ERROR, i18n("PHP Setting 'magic_quotes_sybase' is turned on"), i18n("The PHP Setting 'magic_quotes_sybase' is turned on. CONTENIDO has been developed to comply with magic_quotes_sybase=Off as this is the PHP default setting. You have to change this directive to make CONTENIDO work."), i18n("'magic_quotes_sybase' is turned off"));
287: $this->storeResult($this->testMaxExecutionTime(), self::C_SEVERITY_WARNING, i18n("PHP maximum execution time is less than 30 seconds"), i18n("PHP is configured for a maximum execution time of less than 30 seconds. This could cause problems with slow web servers and/or long operations in the backend. Our recommended execution time is 120 seconds on slow web servers, 60 seconds for medium ones and 30 seconds for fast web servers."), i18n("PHP allows execution times longer than 30 seconds"));
288: $this->storeResult($this->testZIPArchive(), self::C_SEVERITY_WARNING, i18n("The class ZipArchive could not be found"), i18n("This could cause some problems, but CONTENIDO is able to run without it. You should check your PHP installation."), i18n("The ZipArchive class is enabled"));
289:
290: $test = $this->checkOpenBasedirCompatibility();
291: switch ($test) {
292: case self::CON_BASEDIR_NORESTRICTION:
293: $this->storeResult(true, self::C_SEVERITY_ERROR, "", "", i18n("open_basedir directive doesn't enforce any restrictions"));
294: break;
295: case self::CON_BASEDIR_DOTRESTRICTION:
296: $this->storeResult(false, self::C_SEVERITY_ERROR, i18n("open_basedir directive set to '.'"), i18n("The directive open_basedir is set to '.' (e.g. current directory). This means that CONTENIDO is unable to access files in a logical upper level in the filesystem. This will cause problems managing the CONTENIDO frontends. Either add the full path of this CONTENIDO installation to the open_basedir directive, or turn it off completely."));
297: break;
298: case self::CON_BASEDIR_RESTRICTIONSUFFICIENT:
299: $this->storeResult(false, self::C_SEVERITY_INFO, i18n("open_basedir setting might be insufficient"), i18n("Setup believes that the PHP directive open_basedir is configured sufficient, however, if you encounter errors like 'open_basedir restriction in effect. File <filename> is not within the allowed path(s): <path>', you have to adjust the open_basedir directive"));
300: break;
301: case self::CON_BASEDIR_INCOMPATIBLE:
302: $this->storeResult(false, self::C_SEVERITY_ERROR, i18n("open_basedir directive incompatible"), i18n("Setup has checked your PHP open_basedir directive and reckons that it is not sufficient. Please change the directive to include the CONTENIDO installation or turn it off completely."));
303: break;
304: }
305:
306: $this->storeResult($this->testMemoryLimit(), self::C_SEVERITY_WARNING, i18n("PHP memory_limit directive too small"), i18n("The memory_limit directive is set to 32 MB or lower. This might be not enough for CONTENIDO to operate correctly. We recommend to disable this setting completely, as this can cause problems with large CONTENIDO projects."), i18n("Memory limit is either high enough or deactivated"));
307: $this->storeResult($this->testPHPSQLSafeMode(), self::C_SEVERITY_ERROR, i18n("PHP sql.safe_mode turned on"), i18n("The PHP directive sql.safe_mode is turned on. This causes problems with the SQL queries issued by CONTENIDO. Please turn that directive off."), i18n("sql.safe_mode is deactivated"));
308: $this->storeResult($this->isPHPExtensionLoaded("gd") == self::CON_EXTENSION_AVAILABLE, self::C_SEVERITY_WARNING, i18n("PHP GD-Extension is not loaded"), i18n("The PHP GD-Extension is not loaded. Some third-party modules rely on the GD functionality. If you don't enable the GD extension, you will encounter problems with modules like galleries."), i18n("GD extension loaded"));
309: if ($this->isPHPExtensionLoaded("gd") == self::CON_EXTENSION_AVAILABLE) {
310: $this->storeResult($this->testGDGIFRead(), self::C_SEVERITY_INFO, i18n("GD-Library GIF read support missing"), i18n("Your GD version doesn't support reading GIF files. This might cause problems with some modules."), i18n("GD is able to read GIFs"));
311: $this->storeResult($this->testGDGIFWrite(), self::C_SEVERITY_INFO, i18n("GD-Library GIF write support missing"), i18n("Your GD version doesn't support writing GIF files. This might cause problems with some modules."), i18n("GD is able to write GIFs"));
312: $this->storeResult($this->testGDJPEGRead(), self::C_SEVERITY_INFO, i18n("GD-Library JPEG read support missing"), i18n("Your GD version doesn't support reading JPEG files. This might cause problems with some modules."), i18n("GD is able to read JPEGs"));
313: $this->storeResult($this->testGDJPEGWrite(), self::C_SEVERITY_INFO, i18n("GD-Library JPEG write support missing"), i18n("Your GD version doesn't support writing JPEG files. This might cause problems with some modules."), i18n("GD is able to write JPEGs"));
314: $this->storeResult($this->testGDPNGRead(), self::C_SEVERITY_INFO, i18n("GD-Library PNG read support missing"), i18n("Your GD version doesn't support reading PNG files. This might cause problems with some modules."), i18n("GD is able to read PNGs"));
315: $this->storeResult($this->testGDPNGWrite(), self::C_SEVERITY_INFO, i18n("GD-Library PNG write support missing"), i18n("Your GD version doesn't support writing PNG files. This might cause problems with some modules."), i18n("GD is able to write PNGs"));
316: }
317: $this->storeResult($this->isPHPExtensionLoaded("pcre") == self::CON_EXTENSION_AVAILABLE, self::C_SEVERITY_ERROR, i18n("PHP PCRE Extension is not loaded"), i18n("The PHP PCRE Extension is not loaded. CONTENIDO uses PCRE-functions like preg_repace and preg_match and won't work without the PCRE Extension."), i18n("PCRE extension loaded"));
318: $this->storeResult($this->isPHPExtensionLoaded("xml") == self::CON_EXTENSION_AVAILABLE, self::C_SEVERITY_ERROR, i18n("PHP XML Extension is not loaded"), i18n("The PHP XML Extension is not loaded. CONTENIDO won't work without the XML Extension."), i18n("XML extension loaded"));
319: $this->storeResult($this->testDOMDocument(), self::C_SEVERITY_ERROR, i18n("Class 'DOMDocument' is not available"), i18n("The class DOMDocument could not be found. Please check your PHP installation and enable the XML extension if necessary. CONTENIDO won't work without it."), i18n("DOMDocument is available"));
320: $this->storeResult($this->testXMLParserCreate(), self::C_SEVERITY_ERROR, i18n("Function 'xml_parser_create' is not available"), i18n("The function xml_parser_create could not be found. Please check your PHP installation and enable the XML extension if necessary. CONTENIDO won't work without it."), i18n("xml_parser_create is available"));
321: $this->storeResult(class_exists("SimpleXMLElement") && function_exists("dom_import_simplexml"), self::C_SEVERITY_ERROR, i18n("The class SimpleXML is missing"), i18n("The SimpleXML class is missing. Make sure that the extension is installed and activated"), i18n("SimpleXML is available"));
322: $this->storeResult($this->isPHPExtensionLoaded("mbstring") == self::CON_EXTENSION_AVAILABLE, self::C_SEVERITY_ERROR, i18n("PHP mbstring extension is not loaded"), i18n("Since version 4.9.4 CONTENIDO requires the mbstring extension to be loaded and activated! Without it CONTENIDO won't work!"), i18n("mbstring extension is loaded"));
323:
324: $result = $this->checkImageResizer();
325: switch ($result) {
326: case self::CON_IMAGERESIZE_CANTCHECK:
327: $this->storeResult(false, self::C_SEVERITY_WARNING, i18n("Unable to check for a suitable image resizer"), i18n("Setup has tried to check for a suitable image resizer (which is, for exampl, required for thumbnail creation), but was not able to clearly identify one. If thumbnails won't work, make sure you've got either the GD-extension or ImageMagick available."));
328: break;
329: case self::CON_IMAGERESIZE_NOTHINGAVAILABLE:
330: $this->storeResult(false, self::C_SEVERITY_ERROR, i18n("No suitable image resizer available"), i18n("Setup checked your image resizing support, however, it was unable to find a suitable image resizer. Thumbnails won't work correctly or won't be looking good. Install the GD-Extension or ImageMagick"));
331: break;
332: case self::CON_IMAGERESIZE_GD:
333: $this->storeResult(true, self::C_SEVERITY_WARNING, "", "", i18n("GD extension is available and usable to handle images"));
334: break;
335: case self::CON_IMAGERESIZE_IMAGEMAGICK:
336: $this->storeResult(true, self::C_SEVERITY_WARNING, "", "", i18n("ImageMagick extension is available and usable to handle images"));
337: break;
338: }
339:
340: $this->storeResult($this->testIconv(), self::C_SEVERITY_ERROR, i18n("PHP iconv functions are not available."), i18n("PHP has been compiled with the --without-iconv directive. CONTENIDO won't work without the iconv functions."), i18n("iconv is available"));
341:
342: $result = $this->testMySQL($this->_config['db']['connection']['host'], $this->_config['db']['connection']['user'], $this->_config['db']['connection']['password']);
343: switch ($result) {
344: case self::CON_MYSQL_OK:
345: $this->storeResult(true, self::C_SEVERITY_ERROR, "", "", i18n("Database connection works"));
346: break;
347: case self::CON_MYSQL_STRICT_MODE:
348: $this->storeResult(false, self::C_SEVERITY_ERROR, i18n('MySQL is running in strict mode'), i18n('MySQL is running in strict mode, CONTENIDO will not work with this mode. Please change your sql_mode!'));
349: break;
350: default:
351: $this->storeResult(false, self::C_SEVERITY_ERROR, i18n("MySQL database connect failed"), sprintf(i18n("Setup was unable to connect to the MySQL Server (Server %s, Username %s). Please correct the MySQL data and try again.<br><br>The error message given was: %s"), $this->_config['db']['connection']['host'], $this->_config['db']['connection']['user'], $result));
352: }
353:
354: if ($testFileSystem) {
355: $this->storeResult($this->testFilesystem(), self::C_SEVERITY_WARNING, i18n("Permission error"), i18n("CONTENIDO doesn't have the necessary permissions to write all the files it needs. Please check your filesystem permissions."), i18n("Filesystem checks"), i18n("CONTENIDO has all the necessary permissions to read and write files"));
356: }
357: }
358:
359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374:
375: public function storeResult($result, $severity, $errorHeadline = "", $errorMessage = "", $successHeadline = "", $successMessage = "") {
376: if ($result) {
377: $this->_messages[] = array(
378: "result" => $result,
379: "severity" => $severity,
380: "headline" => $successHeadline,
381: "message" => $successMessage
382: );
383: } else {
384: $this->_messages[] = array(
385: "result" => $result,
386: "severity" => $severity,
387: "headline" => $errorHeadline,
388: "message" => $errorMessage
389: );
390: }
391: }
392:
393: 394: 395: 396: 397: 398:
399: public function getResults() {
400: return $this->_messages;
401: }
402:
403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433:
434: protected function getFileInfo($sFilename) {
435: if (!cFileHandler::exists($sFilename)) {
436: return false;
437: }
438:
439: $oiFilePermissions = fileperms($sFilename);
440: if ($oiFilePermissions === false) {
441: return false;
442: }
443:
444: switch (true) {
445: case (($oiFilePermissions & 0xC000) == 0xC000):
446: $info = 's';
447: $type = "socket";
448: break;
449: case (($oiFilePermissions & 0xA000) == 0xA000):
450: $info = 'l';
451: $type = "symbolic link";
452: break;
453: case (($oiFilePermissions & 0x8000) == 0x8000):
454: $info = '-';
455: $type = "regular file";
456: break;
457: case (($oiFilePermissions & 0x6000) == 0x6000):
458: $info = 'b';
459: $type = "block special";
460: break;
461: case (($oiFilePermissions & 0x4000) == 0x4000):
462: $info = 'd';
463: $type = "directory";
464: break;
465: case (($oiFilePermissions & 0x2000) == 0x2000):
466: $info = 'c';
467: $type = "character special";
468: break;
469: case (($oiFilePermissions & 0x1000) == 0x1000):
470: $info = 'p';
471: $type = "FIFO pipe";
472: break;
473: default:
474: $info = "u";
475: $type = "Unknown";
476: break;
477: }
478:
479: $aFileinfo = array();
480: $aFileinfo["info"] = $info;
481: $aFileinfo["type"] = $type;
482: $aFileinfo["owner"]["read"] = ($oiFilePermissions & 0x0100) ? true : false;
483: $aFileinfo["owner"]["write"] = ($oiFilePermissions & 0x0080) ? true : false;
484: $aFileinfo["group"]["read"] = ($oiFilePermissions & 0x0020) ? true : false;
485: $aFileinfo["group"]["write"] = ($oiFilePermissions & 0x0010) ? true : false;
486: $aFileinfo["others"]["read"] = ($oiFilePermissions & 0x0004) ? true : false;
487: $aFileinfo["others"]["write"] = ($oiFilePermissions & 0x0002) ? true : false;
488: $aFileinfo["owner"]["id"] = fileowner($sFilename);
489: $aFileinfo["group"]["id"] = filegroup($sFilename);
490: return $aFileinfo;
491: }
492:
493: 494: 495: 496: 497: 498: 499:
500: protected function canWriteFile($filename) {
501: clearstatcache();
502: if (cFileHandler::exists($filename)) {
503: return cFileHandler::writeable($filename);
504: } else {
505: return cFileHandler::writeable(dirname($filename));
506: }
507: }
508:
509: 510: 511: 512: 513: 514: 515:
516: protected function canWriteDir($dirname) {
517: clearstatcache();
518: return cDirHandler::exists($dirname) && is_writable($dirname);
519: }
520:
521: 522: 523: 524: 525: 526: 527: 528:
529: protected function getServerUID() {
530: if (function_exists("posix_getuid")) {
531: return posix_getuid();
532: }
533:
534: $sFilename = md5(mt_rand()) . ".txt";
535:
536: if (is_writeable(".")) {
537: cFileHandler::create($sFilename, "test");
538: $iUserId = fileowner($sFilename);
539: cFileHandler::remove($sFilename);
540:
541: return $iUserId;
542: } else {
543: if (is_writeable("/tmp/")) {
544: cFileHandler::create("/tmp/" . $sFilename, "w");
545: $iUserId = fileowner("/tmp/" . $sFilename);
546: cFileHandler::remove("/tmp/" . $sFilename);
547:
548: return $iUserId;
549: }
550: return false;
551: }
552: }
553:
554: 555: 556: 557: 558: 559: 560: 561:
562: protected function getServerGID() {
563: if (function_exists("posix_getgid")) {
564: return posix_getgid();
565: }
566:
567: $sFilename = md5(mt_rand()) . ".txt";
568:
569: if (is_writeable(".")) {
570: cFileHandler::create($sFilename, "test");
571: $iUserId = filegroup($sFilename);
572: cFileHandler::remove($sFilename);
573:
574: return $iUserId;
575: } else {
576: return false;
577: }
578: }
579:
580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591:
592: protected function predictCorrectFilepermissions($file) {
593:
594:
595: if ($this->isWindows()) {
596: return self::CON_PREDICT_WINDOWS;
597: }
598:
599:
600:
601:
602: if (cFileHandler::writeable($file) && cFileHandler::readable($file)) {
603: return self::CON_PREDICT_SUFFICIENT;
604: }
605:
606:
607:
608:
609: $iServerUID = $this->getServerUID();
610: if ($iServerUID === false) {
611: return self::CON_PREDICT_NOTPREDICTABLE;
612: }
613:
614:
615:
616:
617: $iServerGID = $this->getServerGID();
618: if ($iServerGID === false) {
619: return self::CON_PREDICT_NOTPREDICTABLE;
620: }
621:
622: $aFilePermissions = $this->getFileInfo($file);
623:
624: if ($this->getSafeModeStatus()) {
625:
626: if ($iServerUID == $aFilePermissions["owner"]["id"]) {
627: return self::CON_PREDICT_CHANGEPERM_SAMEOWNER;
628: }
629:
630: if ($this->getSafeModeGidStatus()) {
631:
632: if ($iServerGID == $aFilePermissions["group"]["id"]) {
633: return self::CON_PREDICT_CHANGEPERM_SAMEGROUP;
634: }
635:
636: return self::CON_PREDICT_CHANGEGROUP;
637: }
638: } else {
639:
640: if ($iServerUID == $aFilePermissions["owner"]["id"]) {
641: return self::CON_PREDICT_CHANGEPERM_SAMEOWNER;
642: }
643:
644: if ($iServerGID == $aFilePermissions["group"]["id"]) {
645: return self::CON_PREDICT_CHANGEPERM_SAMEGROUP;
646: }
647:
648: return self::CON_PREDICT_CHANGEPERM_OTHERS;
649: }
650: }
651:
652: 653: 654: 655: 656: 657: 658: 659:
660: protected function getPHPIniSetting($setting) {
661:
662: $value = @ini_get($setting);
663:
664: return $value;
665: }
666:
667: 668: 669: 670: 671: 672: 673:
674: protected function getAsBytes($val) {
675: if (cString::getStringLength($val) == 0) {
676: return 0;
677: }
678: $val = trim($val);
679: $last = $val{cString::getStringLength($val) - 1};
680: switch ($last) {
681: case 'k':
682: case 'K':
683: return (int) $val * 1024;
684: break;
685: case 'm':
686: case 'M':
687: return (int) $val * 1048576;
688: break;
689: case 'g':
690: case 'G':
691: return (int) $val * 1048576 * 1024;
692: break;
693: default:
694: return $val;
695: }
696: }
697:
698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709:
710: protected function doMySQLConnect($host, $username, $password) {
711: $aOptions = array(
712: 'connection' => array(
713: 'host' => $host,
714: 'user' => $username,
715: 'password' => $password
716: )
717: );
718: $db = null;
719: try {
720: $db = new cDb($aOptions);
721: } catch (cDbException $e) {
722: return array(
723: $db,
724: false
725: );
726: }
727:
728: if ($db->connect() == 0) {
729: return array(
730: $db,
731: false
732: );
733: } else {
734: return array(
735: $db,
736: true
737: );
738: }
739: }
740:
741: 742: 743: 744: 745: 746: 747: 748:
749: public function isPHPExtensionLoaded($extension) {
750: $value = extension_loaded($extension);
751:
752: if ($value === NULL) {
753: return self::CON_EXTENSION_CANTCHECK;
754: }
755:
756: if ($value === true) {
757: return self::CON_EXTENSION_AVAILABLE;
758: } else {
759: return self::CON_EXTENSION_UNAVAILABLE;
760: }
761: }
762:
763: 764: 765: 766: 767:
768: public function isWindows() {
769: if (cString::toLowerCase(cString::getPartOfString(PHP_OS, 0, 3)) == "win") {
770: return true;
771: } else {
772: return false;
773: }
774: }
775:
776: 777: 778: 779: 780: 781:
782: public function testPHPVersion() {
783: if (version_compare(phpversion(), self::CON_SETUP_MIN_PHP_VERSION, '>=') == true) {
784: return true;
785: } else {
786: return false;
787: }
788: }
789:
790: 791: 792: 793: 794:
795: public function getSafeModeStatus() {
796: if ($this->getPHPIniSetting("safe_mode") == "1") {
797: return true;
798: } else {
799: return false;
800: }
801: }
802:
803: 804: 805: 806: 807:
808: public function getSafeModeGidStatus() {
809: if ($this->getPHPIniSetting("safe_mode_gid") == "1") {
810: return true;
811: } else {
812: return false;
813: }
814: }
815:
816: 817: 818: 819: 820:
821: public function testXMLParserCreate() {
822: return function_exists("xml_parser_create");
823: }
824:
825: 826: 827: 828: 829:
830: public function testFileUploadSetting() {
831: return $this->getPHPIniSetting('file_uploads');
832: }
833:
834: 835: 836: 837: 838:
839: public function testMagicQuotesRuntimeSetting() {
840: return !$this->getPHPIniSetting('magic_quotes_runtime');
841: }
842:
843: 844: 845: 846: 847:
848: public function testMagicQuotesSybaseSetting() {
849: return !$this->getPHPIniSetting('magic_quotes_sybase');
850: }
851:
852: 853: 854: 855: 856:
857: public function testMaxExecutionTime() {
858: return (intval($this->getPHPIniSetting('max_execution_time') == 0) || (intval($this->getPHPIniSetting('max_execution_time')) >= 30));
859: }
860:
861: 862: 863: 864: 865:
866: public function testZIPArchive() {
867: return class_exists("ZipArchive");
868: }
869:
870: 871: 872: 873: 874:
875: public function testMemoryLimit() {
876: $memoryLimit = $this->getAsBytes($this->getPHPIniSetting("memory_limit"));
877: return ($memoryLimit > 1024 * 1024 * 32) || ($memoryLimit == 0) || ('-1' === $memoryLimit);
878: }
879:
880: 881: 882: 883: 884:
885: public function testPHPSQLSafeMode() {
886: return !$this->getPHPIniSetting('sql.safe_mode');
887: }
888:
889: 890: 891: 892: 893:
894: public function testDOMDocument() {
895: return class_exists("DOMDocument");
896: }
897:
898: 899: 900: 901: 902: 903:
904: public function testPHPExtension($ext) {
905: return $this->isPHPExtensionLoaded($ext) == CON_EXTENSION_AVAILABLE;
906: }
907:
908: 909: 910: 911: 912:
913: public function testIconv() {
914: return function_exists("iconv");
915: }
916:
917: 918: 919: 920: 921:
922: public function testGDGIFRead() {
923: if (($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_AVAILABLE) && ($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_CANTCHECK)) {
924: return false;
925: }
926: return function_exists("imagecreatefromgif");
927: }
928:
929: 930: 931: 932: 933:
934: public function testGDGIFWrite() {
935: if (($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_AVAILABLE) && ($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_CANTCHECK)) {
936: return false;
937: }
938: return function_exists("imagegif");
939: }
940:
941: 942: 943: 944: 945:
946: public function testGDJPEGRead() {
947: if (($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_AVAILABLE) && ($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_CANTCHECK)) {
948: return false;
949: }
950: return function_exists("imagecreatefromjpeg");
951: }
952:
953: 954: 955: 956: 957:
958: public function testGDJPEGWrite() {
959: if (($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_AVAILABLE) && ($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_CANTCHECK)) {
960: return false;
961: }
962: return function_exists("imagejpeg");
963: }
964:
965: 966: 967: 968: 969:
970: public function testGDPNGRead() {
971: if (($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_AVAILABLE) && ($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_CANTCHECK)) {
972: return false;
973: }
974: return function_exists("imagecreatefrompng");
975: }
976:
977: 978: 979: 980: 981:
982: public function testGDPNGWrite() {
983: if (($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_AVAILABLE) && ($this->isPHPExtensionLoaded('gd') != self::CON_EXTENSION_CANTCHECK)) {
984: return false;
985: }
986: return function_exists("imagepng");
987: }
988:
989: 990: 991: 992: 993:
994: public function testMySQLExtension() {
995: if ($this->isPHPExtensionLoaded("mysql") == self::CON_EXTENSION_AVAILABLE) {
996: return true;
997: } else {
998: return false;
999: }
1000: }
1001:
1002: 1003: 1004: 1005: 1006:
1007: public function testMySQLiExtension() {
1008: if ($this->isPHPExtensionLoaded("mysqli") == self::CON_EXTENSION_AVAILABLE) {
1009: return true;
1010: } else {
1011: return false;
1012: }
1013: }
1014:
1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025:
1026: public function testMySQLModeStrict($host, $username, $password) {
1027:
1028: $dbCfg = array(
1029: 'connection' => array(
1030: 'host' => $host,
1031: 'user' => $username,
1032: 'password' => $password
1033: )
1034: );
1035:
1036: $db = new cDb($dbCfg);
1037: $db->query('SELECT LOWER(@@GLOBAL.sql_mode) AS sql_mode');
1038: if ($db->nextRecord()) {
1039: if (cString::findFirstPos($db->f('sql_mode'), 'strict_trans_tables') !== false || cString::findFirstPos($db->f('sql_mode'), 'strict_all_tables') !== false) {
1040: return false;
1041: }
1042: }
1043: return true;
1044: }
1045:
1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056:
1057: public function testMySQL($host, $username, $password) {
1058: list($handle, $status) = $this->doMySQLConnect($host, $username, $password);
1059:
1060: $errorMessage = "";
1061: if ($this->testMySQLiExtension() && !$this->testMySQLExtension()) {
1062: if (!empty($handle)) {
1063: $errorMessage = mysqli_error($handle->getLinkId());
1064: } else {
1065: $errorMessage = mysqli_error();
1066: }
1067: } else {
1068: $errorMessage = mysql_error();
1069: }
1070: if ($errorMessage != "") {
1071: return $errorMessage;
1072: }
1073:
1074: if (false === isset($handle) || $handle->getLinkId()->errno == 1045) {
1075: return self::CON_MYSQL_CANT_CONNECT;
1076: }
1077:
1078: if (!$this->testMySQLModeStrict($host, $username, $password)) {
1079: return self::CON_MYSQL_STRICT_MODE;
1080: }
1081:
1082: return self::CON_MYSQL_OK;
1083: }
1084:
1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094:
1095: public function testFilesystem($testConfig = true, $testFrontend = true) {
1096: global $cfgClient;
1097:
1098: $status = true;
1099:
1100: $files = array(
1101:
1102: array(
1103: 'filename' => $this->_config['path']['contenido_logs'] . "errorlog.txt",
1104: 'severity' => self::C_SEVERITY_WARNING
1105: ),
1106: array(
1107: 'filename' => $this->_config['path']['contenido_logs'] . "setuplog.txt",
1108: 'severity' => self::C_SEVERITY_WARNING
1109: ),
1110: array(
1111: 'filename' => $this->_config['path']['contenido_cronlog'] . "pseudo-cron.log",
1112: 'severity' => self::C_SEVERITY_WARNING
1113: ),
1114: array(
1115: 'filename' => $this->_config['path']['contenido_cronlog'] . "session_cleanup.php.job",
1116: 'severity' => self::C_SEVERITY_WARNING
1117: ),
1118: array(
1119: 'filename' => $this->_config['path']['contenido_cronlog'] . "send_reminder.php.job",
1120: 'severity' => self::C_SEVERITY_WARNING
1121: ),
1122: array(
1123: 'filename' => $this->_config['path']['contenido_cronlog'] . "optimize_database.php.job",
1124: 'severity' => self::C_SEVERITY_WARNING
1125: ),
1126: array(
1127: 'filename' => $this->_config['path']['contenido_cronlog'] . "move_old_stats.php.job",
1128: 'severity' => self::C_SEVERITY_WARNING
1129: ),
1130: array(
1131: 'filename' => $this->_config['path']['contenido_cronlog'] . "move_articles.php.job",
1132: 'severity' => self::C_SEVERITY_WARNING
1133: ),
1134: array(
1135: 'filename' => $this->_config['path']['contenido_cronlog'] . "linkchecker.php.job",
1136: 'severity' => self::C_SEVERITY_WARNING
1137: ),
1138: array(
1139: 'filename' => $this->_config['path']['contenido_cronlog'] . "run_newsletter_job.php.job",
1140: 'severity' => self::C_SEVERITY_WARNING
1141: ),
1142: array(
1143: 'filename' => $this->_config['path']['contenido_cronlog'] . "setfrontenduserstate.php.job",
1144: 'severity' => self::C_SEVERITY_WARNING
1145: ),
1146: array(
1147: 'filename' => $this->_config['path']['contenido_cronlog'] . "advance_workflow.php.job",
1148: 'severity' => self::C_SEVERITY_WARNING
1149: ),
1150: array(
1151: 'filename' => $this->_config['path']['contenido_cache'],
1152: 'severity' => self::C_SEVERITY_WARNING,
1153: 'dir' => true
1154: ),
1155: array(
1156: 'filename' => $this->_config['path']['contenido_temp'],
1157: 'severity' => self::C_SEVERITY_WARNING,
1158: 'dir' => true
1159: ),
1160: array(
1161: 'filename' => $this->_config['path']['contenido_config'] . "config.php",
1162: 'severity' => self::C_SEVERITY_ERROR,
1163: 'config' => $testConfig
1164: )
1165: );
1166:
1167: $frontendFiles = array(
1168: "cache",
1169: "cache/code",
1170: "css",
1171: "data",
1172: "data/layouts",
1173: "data/logs",
1174: "data/modules",
1175: "data/version",
1176: "data/version/css",
1177: "data/version/js",
1178: "data/version/layout",
1179: "data/version/module",
1180: "data/version/templates",
1181: "js",
1182: "templates",
1183: "upload"
1184: );
1185:
1186: $ret = true;
1187: foreach ($files as $key => $file) {
1188:
1189: $name = $file['filename'];
1190: $severity = $file['severity'];
1191: $frontend = $file['frontend'];
1192: $config = $file['config'];
1193:
1194: if (array_key_exists('frontend', $file) && $frontend != false) {
1195: $ret = $this->testSingleFile($name, $severity, $frontend);
1196: } else if (array_key_exists('config', $file) && $config != false) {
1197: $ret = $this->testSingleFile($name, $severity);
1198: } else if (!array_key_exists('frontend', $file) && !array_key_exists('config', $file)) {
1199: $ret = $this->testSingleFile($name, $severity, $config);
1200: }
1201: if ($ret == false) {
1202: $status = false;
1203: }
1204: }
1205:
1206: if ($testFrontend) {
1207: foreach ($cfgClient as $oneClient) {
1208: if (!is_array($oneClient)) {
1209: continue;
1210: }
1211: foreach ($frontendFiles as $file) {
1212:
1213:
1214:
1215:
1216:
1217: if ($_SESSION['setuptype'] == 'upgrade' && ($file == "data/layouts" || $file == "data/modules") && !cDirHandler::exists($oneClient["path"]["frontend"] . $file)) {
1218: continue;
1219: } else {
1220: $ret = $this->testSingleFile($oneClient["path"]["frontend"] . $file, self::C_SEVERITY_WARNING, true);
1221: }
1222:
1223: if ($ret == false) {
1224: $status = false;
1225: }
1226: }
1227: }
1228: }
1229:
1230: return $status;
1231: }
1232:
1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247:
1248: protected function testSingleFile($filename, $severity, $dir = false) {
1249: if (cString::findFirstPos($filename, $this->_config["path"]["frontend"]) === 0) {
1250: $length = cString::getStringLength($this->_config["path"]["frontend"]) + 1;
1251: $shortFilename = cString::getPartOfString($filename, $length);
1252: } else {
1253: $shortFilename = $filename;
1254: }
1255:
1256: if (!$dir) {
1257: $status = $this->canWriteFile($filename);
1258: } else {
1259: $status = $this->canWriteDir($filename);
1260: }
1261:
1262: $title = sprintf(i18n("Can't write %s"), $shortFilename);
1263: $message = sprintf(i18n("Setup or CONTENIDO can't write to the file %s. Please change the file permissions to correct this problem."), $shortFilename);
1264:
1265: if ($status == false) {
1266: if (cFileHandler::exists($filename)) {
1267: $perm = $this->predictCorrectFilepermissions($filename);
1268:
1269: switch ($perm) {
1270: case self::CON_PREDICT_WINDOWS:
1271: $predictMessage = i18n("Your Server runs Windows. Due to that, Setup can't recommend any file permissions.");
1272: break;
1273: case self::CON_PREDICT_NOTPREDICTABLE:
1274: $predictMessage = sprintf(i18n("Due to a very restrictive environment, an advise is not possible. Ask your system administrator to enable write access to the file %s, especially in environments where ACL (Access Control Lists) are used."), $shortFilename);
1275: break;
1276: case self::CON_PREDICT_CHANGEPERM_SAMEOWNER:
1277: $mfileperms = cString::getPartOfString(sprintf("%o", fileperms($filename)), -3);
1278: $mfileperms{0} = intval($mfileperms{0}) | 0x6;
1279: $predictMessage = sprintf(i18n("Your web server and the owner of your files are identical. You need to enable write access for the owner, e.g. using chmod u+rw %s, setting the file mask to %s or set the owner to allow writing the file."), $shortFilename, $mfileperms);
1280: break;
1281: case self::CON_PREDICT_CHANGEPERM_SAMEGROUP:
1282: $mfileperms = cString::getPartOfString(sprintf("%o", fileperms($filename)), -3);
1283: $mfileperms{1} = intval($mfileperms{1}) | 0x6;
1284: $predictMessage = sprintf(i18n("Your web server's group and the group of your files are identical. You need to enable write access for the group, e.g. using chmod g+rw %s, setting the file mask to %s or set the group to allow writing the file."), $shortFilename, $mfileperms);
1285: break;
1286: case self::CON_PREDICT_CHANGEPERM_OTHERS:
1287: $mfileperms = cString::getPartOfString(sprintf("%o", fileperms($filename)), -3);
1288: $mfileperms{2} = intval($mfileperms{2}) | 0x6;
1289: $predictMessage = sprintf(i18n("Your web server is not equal to the file owner, and is not in the webserver's group. It would be highly insecure to allow world write acess to the files. If you want to install anyways, enable write access for all others, e.g. using chmod o+rw %s, setting the file mask to %s or set the others to allow writing the file."), $shortFilename, $mfileperms);
1290: break;
1291: }
1292: } else {
1293: $target = dirname($filename);
1294:
1295: $perm = $this->predictCorrectFilepermissions($target);
1296:
1297: switch ($perm) {
1298: case self::CON_PREDICT_WINDOWS:
1299: $predictMessage = i18n("Your Server runs Windows. Due to that, Setup can't recommend any directory permissions.");
1300: break;
1301: case self::CON_PREDICT_NOTPREDICTABLE:
1302: $predictMessage = sprintf(i18n("Due to a very restrictive environment, an advise is not possible. Ask your system administrator to enable write access to the file or directory %s, especially in environments where ACL (Access Control Lists) are used."), dirname($shortFilename));
1303: break;
1304: case self::CON_PREDICT_CHANGEPERM_SAMEOWNER:
1305: $mfileperms = cString::getPartOfString(sprintf("%o", @fileperms($target)), -3);
1306: $mfileperms{0} = intval($mfileperms{0}) | 0x6;
1307: $predictMessage = sprintf(i18n("Your web server and the owner of your directory are identical. You need to enable write access for the owner, e.g. using chmod u+rw %s, setting the directory mask to %s or set the owner to allow writing the directory."), dirname($shortFilename), $mfileperms);
1308: break;
1309: case self::CON_PREDICT_CHANGEPERM_SAMEGROUP:
1310: $mfileperms = cString::getPartOfString(sprintf("%o", @fileperms($target)), -3);
1311: $mfileperms{1} = intval($mfileperms{1}) | 0x6;
1312: $predictMessage = sprintf(i18n("Your web server's group and the group of your directory are identical. You need to enable write access for the group, e.g. using chmod g+rw %s, setting the directory mask to %s or set the group to allow writing the directory."), dirname($shortFilename), $mfileperms);
1313: break;
1314: case self::CON_PREDICT_CHANGEPERM_OTHERS:
1315: $mfileperms = cString::getPartOfString(sprintf("%o", @fileperms($target)), -3);
1316: $mfileperms{2} = intval($mfileperms{2}) | 0x6;
1317: $predictMessage = sprintf(i18n("Your web server is not equal to the directory owner, and is not in the webserver's group. It would be highly insecure to allow world write acess to the directory. If you want to install anyways, enable write access for all others, e.g. using chmod o+rw %s, setting the directory mask to %s or set the others to allow writing the directory."), dirname($shortFilename), $mfileperms);
1318: break;
1319: }
1320: }
1321:
1322: $this->storeResult(false, $severity, $title, $message . "<br><br>" . $predictMessage);
1323: if ($title && $message) {
1324: $status = false;
1325: }
1326: }
1327:
1328: return $status;
1329: }
1330:
1331: 1332: 1333: 1334: 1335: 1336: 1337: 1338:
1339: public function testFrontendFolderCreation() {
1340: $directories = array(
1341: "cms/cache",
1342: "cms/cache/code",
1343: "cms/css",
1344: "cms/data",
1345: "cms/data/layouts",
1346: "cms/data/modules",
1347: "cms/data/version",
1348: "cms/data/version/css",
1349: "cms/data/version/js",
1350: "cms/data/version/layout",
1351: "cms/data/version/module",
1352: "cms/data/version/templates",
1353: "cms/js",
1354: "cms/templates",
1355: "cms/upload"
1356: );
1357:
1358: $ret = true;
1359:
1360: foreach ($directories as $dir) {
1361: if (!cDirHandler::exists("../" . $dir)) {
1362: if (!mkdir("../" . $dir)) {
1363: $ret = false;
1364: $this->storeResult(false, self::C_SEVERITY_WARNING, sprintf(i18n("Could not find or create directory %s"), $dir), i18n("The frontend expects certain directories to exist and it needs to be able to write to these directories. You have to set chmod rights 755 to these directories."));
1365: } elseif (!cDirHandler::chmod("../" . $dir, cDirHandler::getDefaultPermissions())) {
1366: $ret = false;
1367: $this->storeResult(false, self::C_SEVERITY_WARNING, sprintf(i18n("Could not find or create directory %s"), $dir), i18n("The frontend expects certain directories to exist and it needs to be able to write to these directories. You have to set chmod rights 755 to these directories."));
1368: }
1369: }
1370: }
1371:
1372: return $ret;
1373: }
1374:
1375: 1376: 1377: 1378: 1379: 1380:
1381: public function checkOpenBasedirCompatibility() {
1382: $value = $this->getPHPIniSetting("open_basedir");
1383:
1384: if ($this->isWindows()) {
1385: $aBasedirEntries = explode(";", $value);
1386: } else {
1387: $aBasedirEntries = explode(":", $value);
1388: }
1389:
1390: if (count($aBasedirEntries) == 1 && $aBasedirEntries[0] == $value) {
1391: return self::CON_BASEDIR_NORESTRICTION;
1392: }
1393:
1394: if (in_array(".", $aBasedirEntries) && count($aBasedirEntries) == 1) {
1395: return self::CON_BASEDIR_DOTRESTRICTION;
1396: }
1397:
1398: $sCurrentDirectory = getcwd();
1399:
1400: foreach ($aBasedirEntries as $entry) {
1401: if (cString::findFirstOccurrenceCI($sCurrentDirectory, $entry)) {
1402: return self::CON_BASEDIR_RESTRICTIONSUFFICIENT;
1403: }
1404: }
1405:
1406: return self::CON_BASEDIR_INCOMPATIBLE;
1407: }
1408:
1409: 1410: 1411: 1412: 1413: 1414:
1415: public function checkImageResizer() {
1416: $iGDStatus = $this->isPHPExtensionLoaded('gd');
1417:
1418: if ($iGDStatus == self::CON_EXTENSION_AVAILABLE) {
1419: return self::CON_IMAGERESIZE_GD;
1420: }
1421:
1422: if (function_exists('imagecreate')) {
1423: return self::CON_IMAGERESIZE_GD;
1424: }
1425:
1426: if(function_exists("checkAndInclude")) {
1427: checkAndInclude($this->_config['path']['contenido'] . 'includes/functions.api.images.php');
1428: } else {
1429: cInclude('includes', 'functions.api.images.php');
1430: }
1431: if (cApiIsImageMagickAvailable()) {
1432: return self::CON_IMAGERESIZE_IMAGEMAGICK;
1433: }
1434:
1435: if ($iGDStatus === self::CON_EXTENSION_CANTCHECK) {
1436: return self::CON_IMAGERESIZE_CANTCHECK;
1437: } else {
1438: return self::CON_IMAGERESIZE_NOTHINGAVAILABLE;
1439: }
1440: }
1441:
1442: 1443: 1444: 1445: 1446: 1447: 1448: 1449: 1450: 1451:
1452: public function checkSetupMysql($setupType, $databaseName, $databasePrefix, $charset = '', $collation = '') {
1453: switch ($setupType) {
1454: case "setup":
1455:
1456: $db = getSetupMySQLDBConnection(false);
1457:
1458:
1459: $status = checkMySQLDatabaseExists($db, $databaseName);
1460:
1461: if ($status) {
1462:
1463: $db = getSetupMySQLDBConnection();
1464: $db->connect();
1465:
1466:
1467: $db->query('SHOW TABLES LIKE "%s_actions"', $databasePrefix);
1468:
1469: if ($db->nextRecord()) {
1470: $this->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("MySQL database already exists and seems to be filled", "setup"), sprintf(i18n("Setup checked the database %s and found the table %s. It seems that you already have a CONTENIDO installation in this database. If you want to install anyways, change the database prefix. If you want to upgrade from a previous version, choose 'upgrade' as setup type.", "setup"), $databaseName, sprintf("%s_actions", $databasePrefix)));
1471: return;
1472: }
1473:
1474:
1475: $db->query('SHOW TABLES LIKE "%s_test"', $databasePrefix);
1476: if ($db->nextRecord()) {
1477: $this->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("MySQL test table already exists in the database", "setup"), sprintf(i18n("Setup checked the database %s and found the test table %s. Please remove it before continuing.", "setup"), $databaseName, sprintf("%s_test", $databasePrefix)));
1478: return;
1479: }
1480:
1481:
1482: $status = checkMySQLTableCreation($db, $databaseName, sprintf("%s_test", $databasePrefix));
1483: if (!$status) {
1484: $this->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("Unable to create tables in the selected MySQL database", "setup"), sprintf(i18n("Setup tried to create a test table in the database %s and failed. Please assign table creation permissions to the database user you entered, or ask an administrator to do so.", "setup"), $databaseName));
1485: return;
1486: }
1487:
1488:
1489: $status = checkMySQLDropTable($db, $databaseName, sprintf("%s_test", $databasePrefix));
1490: if (!$status) {
1491: $this->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Unable to remove the test table", "setup"), sprintf(i18n("Setup tried to remove the test table %s in the database %s and failed due to insufficient permissions. Please remove the table %s manually.", "setup"), sprintf("%s_test", $databasePrefix), $databaseName, sprintf("%s_test", $databasePrefix)));
1492: }
1493: } else {
1494: $db->connect();
1495:
1496: $status = checkMySQLDatabaseCreation($db, $databaseName, $charset, $collation);
1497: if (!$status) {
1498: $this->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("Unable to create the database in the MySQL server", "setup"), sprintf(i18n("Setup tried to create a test database and failed. Please assign database creation permissions to the database user you entered, ask an administrator to do so, or create the database manually.", "setup")));
1499: return;
1500: }
1501:
1502:
1503: $status = checkMySQLTableCreation($db, $databaseName, sprintf("%s_test", $databasePrefix));
1504: if (!$status) {
1505: $this->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("Unable to create tables in the selected MySQL database", "setup"), sprintf(i18n("Setup tried to create a test table in the database %s and failed. Please assign table creation permissions to the database user you entered, or ask an administrator to do so.", "setup"), $databaseName));
1506: return;
1507: }
1508:
1509:
1510: $status = checkMySQLDropTable($db, $databaseName, sprintf("%s_test", $databasePrefix));
1511: if (!$status) {
1512: $this->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Unable to remove the test table", "setup"), sprintf(i18n("Setup tried to remove the test table %s in the database %s and failed due to insufficient permissions. Please remove the table %s manually.", "setup"), sprintf("%s_test", $databasePrefix), $databaseName, sprintf("%s_test", $databasePrefix)));
1513: }
1514: }
1515: break;
1516: case "upgrade":
1517: $db = getSetupMySQLDBConnection(false);
1518:
1519:
1520: $status = checkMySQLDatabaseExists($db, $databaseName);
1521: if (!$status) {
1522: $this->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("No data found for the upgrade", "setup"), sprintf(i18n("Setup tried to locate the data for the upgrade, however, the database %s doesn't exist. You need to copy your database first before running setup.", "setup"), $databaseName));
1523: return;
1524: }
1525:
1526: $db = getSetupMySQLDBConnection();
1527:
1528:
1529: $sql = 'SHOW TABLES LIKE "%s_actions"';
1530: $db->query(sprintf($sql, $databasePrefix));
1531: if (!$db->nextRecord()) {
1532: $this->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("No data found for the upgrade", "setup"), sprintf(i18n("Setup tried to locate the data for the upgrade, however, the database %s contains no tables. You need to copy your database first before running setup.", "setup"), $databaseName));
1533: return;
1534: }
1535:
1536: break;
1537: }
1538: }
1539:
1540: }
1541: