1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17:
18: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
19:
20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
30: class cModuleHandler {
31:
32: 33: 34: 35: 36:
37: private $_modulePath;
38:
39: 40: 41: 42: 43:
44: private $_path;
45:
46: 47: 48: 49: 50:
51: protected $_idmod = NULL;
52:
53: 54: 55: 56: 57:
58: private $_moduleName = NULL;
59:
60: 61: 62: 63: 64:
65: protected $_description;
66:
67: 68: 69: 70: 71:
72: protected $_type;
73:
74: 75: 76: 77: 78:
79: protected $_moduleAlias;
80:
81: 82: 83: 84: 85:
86: protected $_directories = array(
87: 'css' => 'css/',
88: 'js' => 'js/',
89: 'template' => 'template/',
90: 'image' => 'image/',
91: 'lang' => 'lang/',
92: 'php' => 'php/'
93: );
94:
95: 96: 97: 98: 99:
100: protected $_cfg = NULL;
101:
102: 103: 104: 105: 106:
107: protected $_cfgClient = NULL;
108:
109: 110: 111: 112: 113:
114: protected $_client = '0';
115:
116: 117: 118: 119: 120:
121: protected $_input = '';
122:
123: 124: 125: 126: 127:
128: protected $_output = '';
129:
130: 131: 132: 133: 134:
135: protected $_encoding = '';
136:
137: 138: 139: 140: 141: 142:
143: protected $_fileEncoding = '';
144:
145: 146: 147: 148: 149:
150: protected $_idlang = -1;
151:
152: 153: 154: 155:
156: private $_db = NULL;
157:
158: 159: 160: 161:
162: protected static $_encodingStore = array();
163:
164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174:
175: public function __construct($idmod = NULL) {
176: global $cfg, $cfgClient, $lang, $client;
177: $this->_cfg = $cfg;
178: $this->_client = $client;
179: $this->_cfgClient = $cfgClient;
180: $this->_idlang = $lang;
181: $this->_encoding = self::getEncoding();
182: $this->_fileEncoding = getEffectiveSetting('encoding', 'file_encoding', 'UTF-8');
183:
184: $this->_db = cRegistry::getDb();
185:
186: $this->_idmod = $idmod;
187:
188: $this->_initByModule($idmod);
189:
190: if ($this->_makeModuleDirectory() == false) {
191: throw new cException('Can not create main module directory.');
192: }
193: }
194:
195: 196: 197: 198: 199:
200: public static function getEncoding($overrideLanguageId = 0) {
201: $lang = cRegistry::getLanguageId();
202:
203: if ((int) $overrideLanguageId != 0) {
204: $lang = $overrideLanguageId;
205: }
206:
207: if ((int) $lang == 0) {
208: $clientId = cRegistry::getClientId();
209:
210: $clientsLangColl = new cApiClientLanguageCollection();
211: $clientLanguages = $clientsLangColl->getLanguagesByClient($clientId);
212: sort($clientLanguages);
213:
214: if (isset($clientLanguages[0]) && (int) $clientLanguages[0] != 0) {
215: $lang = $clientLanguages[0];
216: }
217: }
218:
219: if (!isset(self::$_encodingStore[$lang])) {
220: $cApiLanguage = new cApiLanguage($lang);
221: self::$_encodingStore[$lang] = $cApiLanguage->get('encoding');
222: }
223:
224: return self::$_encodingStore[$lang];
225: }
226:
227: 228: 229: 230: 231: 232:
233: public function modulePathExistsInDirectory($name) {
234: return is_dir($this->_cfgClient[$this->_client]['module']['path'] . $name . '/');
235: }
236:
237: 238: 239: 240: 241: 242: 243: 244: 245:
246: public function saveContentToFile($templateName, $fileType, $fileContent, $saveDirectory = 'cache') {
247: $sSaveDirectory = $this->_cfgClient[$this->_client]['path']['frontend'] . $saveDirectory . '/';
248: if (!is_dir($sSaveDirectory)) {
249: return false;
250: }
251:
252: $templateName = str_replace(' ', '_', $templateName);
253: $templateName = strtolower($templateName);
254: $fileOperation = cFileHandler::write($sSaveDirectory . $templateName . '.' . $fileType, $fileContent);
255: if ($fileOperation === false) {
256: return false;
257: }
258: $url = $this->_cfgClient[$this->_client]['path']['htmlpath'] . $saveDirectory . '/' . $templateName . '.' . $fileType;
259:
260:
261: $url = str_replace('http://', '//', $url);
262:
263: return $url;
264: }
265:
266: 267: 268: 269: 270: 271: 272: 273: 274:
275: public static function getCleanName($name, $defaultChar = '_') {
276:
277: $name = cString::cleanURLCharacters($name);
278:
279: $firstChar = substr($name, 0, 1);
280: if (!preg_match('/^[a-zA-Z0-9]|_|-$/', $firstChar)) {
281:
282: $name = $defaultChar . substr($name, 1);
283: }
284:
285: return $name;
286: }
287:
288: 289: 290: 291: 292:
293: public function initWithDatabaseRow($db) {
294: if (is_object($db)) {
295: $this->_initByModule($db->f('idmod'));
296: }
297: }
298:
299: 300: 301: 302: 303: 304:
305: protected function _initByModule($idmod = NULL) {
306: if ((int) $idmod == 0) {
307: return;
308: }
309:
310: $cApiModule = new cApiModule($idmod);
311:
312: if (true === $cApiModule->isLoaded()) {
313: $this->_idmod = $idmod;
314: $this->_client = $cApiModule->get('idclient');
315: $this->_description = $cApiModule->get('description');
316: $this->_type = $cApiModule->get('type');
317: $this->_input = '';
318: $this->_output = '';
319:
320: $this->_moduleAlias = $cApiModule->get('alias');
321: $this->_moduleName = $cApiModule->get('name');
322: $this->_path = $this->_cfgClient[$this->_client]['module']['path'];
323: $this->_modulePath = $this->_path . $this->_moduleAlias . '/';
324: }
325: }
326:
327: 328: 329: 330: 331:
332: public function getModulePath() {
333: return $this->_modulePath;
334: }
335:
336: 337: 338: 339: 340: 341: 342: 343:
344: public function getTemplatePath($file = '') {
345: return $this->_modulePath . $this->_directories['template'] . $file;
346: }
347:
348: 349: 350: 351: 352:
353: public function getCssPath() {
354: return $this->_modulePath . $this->_directories['css'];
355: }
356:
357: 358: 359: 360: 361:
362: public function getPhpPath() {
363: return $this->_modulePath . $this->_directories['php'];
364: }
365:
366: 367: 368: 369: 370:
371: public function getJsPath() {
372: return $this->_modulePath . $this->_directories['js'];
373: }
374:
375: 376: 377: 378: 379:
380: public function getCssFileName() {
381: return $this->_moduleAlias . '.css';
382: }
383:
384: 385: 386: 387: 388: 389: 390:
391: protected function getRandomCharacters($count) {
392: $micro1 = microtime();
393: $rand1 = rand(0, time());
394: $rand2 = rand(0, time());
395: return substr(md5($micro1 . $rand1 . $rand2), 0, $count);
396: }
397:
398: 399: 400: 401: 402: 403: 404: 405: 406:
407: public function existFile($type, $fileName) {
408: return cFileHandler::exists($this->_modulePath . $this->_directories[$type] . $fileName);
409: }
410:
411: 412: 413: 414: 415: 416: 417: 418: 419:
420: public function deleteFile($type, $fileName) {
421: if ($this->existFile($type, $fileName)) {
422: return unlink($this->_modulePath . $this->_directories[$type] . $fileName);
423: } else {
424: return false;
425: }
426: }
427:
428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439:
440: public function createModuleFile($type, $fileName = NULL, $content = '') {
441:
442: if (!$this->createModuleDirectory($type)) {
443: return false;
444: }
445:
446:
447: if ($fileName == NULL || $fileName == '') {
448: $fileName = $this->_moduleAlias;
449:
450: if ($type == 'template') {
451: $fileName = $fileName . '.html';
452: } else {
453: $fileName = $fileName . '.' . $type;
454: }
455: }
456:
457:
458: if ($type == 'css' || $type == 'js' || $type == 'template') {
459: if (!$this->existFile($type, $fileName)) {
460: $content = cString::recodeString($content, $this->_encoding, $this->_fileEncoding);
461: if (!$this->isWritable($this->_modulePath . $this->_directories[$type] . $fileName, $this->_modulePath . $this->_directories[$type])) {
462: return false;
463: }
464:
465: if (cFileHandler::write($this->_modulePath . $this->_directories[$type] . $fileName, $content) === false) {
466: $notification = new cGuiNotification();
467: $notification->displayNotification('error', i18n("Can't make file: ") . $fileName);
468: return false;
469: }
470: } else {
471: $content = cString::recodeString($content, $this->_encoding, $this->_fileEncoding);
472: if (!$this->isWritable($this->_modulePath . $this->_directories[$type] . $fileName, $this->_modulePath . $this->_directories[$type])) {
473: return false;
474: }
475: if (cFileHandler::write($this->_modulePath . $this->_directories[$type] . $fileName, $content) === false) {
476: $notification = new cGuiNotification();
477: $notification->displayNotification('error', i18n("Can't make file: ") . $fileName);
478: return false;
479: }
480: }
481: } else {
482: return false;
483: }
484:
485: return true;
486: }
487:
488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499:
500: public function renameModuleFile($type, $oldFileName, $newFileName) {
501: if ($this->existFile($type, $newFileName)) {
502: return false;
503: }
504:
505: if (!$this->existFile($type, $oldFileName)) {
506: return false;
507: }
508:
509: return rename($this->_modulePath . $this->_directories[$type] . $oldFileName, $this->_modulePath . $this->_directories[$type] . $newFileName);
510: }
511:
512: 513: 514: 515: 516: 517:
518: public function getJsFileName() {
519: return $this->_moduleAlias . '.js';
520: }
521:
522: 523: 524: 525: 526: 527: 528: 529: 530: 531:
532: public function getFilesContent($directory, $fileTyp, $fileName = NULL) {
533: if ($fileName == NULL) {
534: $fileName = $this->_moduleAlias . '.' . $fileTyp;
535: }
536:
537: if ($this->existFile($directory, $fileName)) {
538: $content = cFileHandler::read($this->_modulePath . $this->_directories[$directory] . $fileName);
539: $content = iconv($this->_fileEncoding, $this->_encoding . '//IGNORE', $content);
540: return $content;
541: }
542:
543: return false;
544: }
545:
546: 547: 548: 549: 550:
551: protected function _makeModuleDirectory() {
552:
553: if ((int) $this->_client == 0) {
554: return true;
555: }
556:
557: $sMainModuleDirectory = $this->_cfgClient[$this->_client]['module']['path'];
558:
559:
560: if (!is_dir($sMainModuleDirectory) && $sMainModuleDirectory != NULL) {
561: if (mkdir($sMainModuleDirectory, 0777, true) == false) {
562: return false;
563: } else {
564: cDirHandler::setDefaultDirPerms($sMainModuleDirectory);
565: }
566: }
567:
568: return true;
569: }
570:
571: 572: 573: 574: 575: 576: 577:
578: public function getAllFilesFromDirectory($moduleDirectory) {
579: $dir = $this->_modulePath . $this->_directories[$moduleDirectory];
580: return cDirHandler::read($dir);
581: }
582:
583: 584: 585: 586: 587:
588: public function changeModuleName($name) {
589: $this->_moduleAlias = $name;
590: $this->_modulePath = $this->_path . $this->_moduleAlias . '/';
591: }
592:
593: 594: 595: 596: 597: 598: 599:
600: public function eraseModule() {
601:
602: if (cFileHandler::exists($this->_modulePath . 'info.xml')) {
603: return cDirHandler::recursiveRmdir($this->_modulePath);
604: } else {
605: return false;
606: }
607: }
608:
609: 610: 611: 612: 613: 614: 615:
616: public function readInput($issource = false) {
617: if (cFileHandler::exists($this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_input.php') == false) {
618: return false;
619: }
620:
621: $content = cFileHandler::read($this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_input.php');
622:
623: if ($issource == true) {
624: $content = conHtmlentities($content);
625: }
626:
627: return iconv($this->_fileEncoding, $this->_encoding . '//IGNORE', $content);
628: }
629:
630: 631: 632: 633: 634: 635: 636:
637: public function readOutput($issource = false) {
638: if (cFileHandler::exists($this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_output.php') == false) {
639: return false;
640: }
641:
642: $content = cFileHandler::read($this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_output.php');
643:
644: if ($issource == true) {
645: $content = conHtmlentities($content);
646: }
647:
648: return iconv($this->_fileEncoding, $this->_encoding . '//IGNORE', $content);
649: }
650:
651: 652: 653: 654: 655: 656:
657: protected function createModuleDirectory($type) {
658: if (array_key_exists($type, $this->_directories)) {
659: if (!is_dir($this->_modulePath . $this->_directories[$type])) {
660: if (cDirHandler::create($this->_modulePath . $this->_directories[$type]) == false) {
661: return false;
662: } else
663: cDirHandler::setDefaultDirPerms($this->_modulePath . $this->_directories[$type]);
664: } else {
665: return true;
666: }
667: }
668:
669: return true;
670: }
671:
672: 673: 674: 675: 676: 677: 678: 679: 680: 681:
682: public function isWritable($fileName, $directory) {
683: if (cFileHandler::exists($fileName)) {
684: if (!is_writable($fileName)) {
685: return false;
686: }
687: } else {
688: if (!is_writable($directory)) {
689: return false;
690: }
691: }
692: return true;
693: }
694:
695: 696: 697: 698: 699: 700: 701: 702:
703: public function moduleWriteable($type) {
704:
705: if (true === cFileHandler::exists($this->_modulePath . $this->_directories[$type])) {
706: return cFileHandler::writeable($this->_modulePath . $this->_directories[$type]);
707: }
708:
709:
710: if (true === cFileHandler::exists($this->_modulePath)) {
711: return cFileHandler::writeable($this->_modulePath);
712: }
713:
714: return false;
715: }
716:
717: 718: 719: 720: 721: 722: 723: 724:
725: public function saveOutput($output = NULL) {
726: $fileName = $this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_output.php';
727:
728: if (!$this->createModuleDirectory('php') || !$this->isWritable($fileName, $this->_modulePath . $this->_directories['php'])) {
729: return false;
730: }
731:
732: if ($output == NULL) {
733: $output = $this->_output;
734: }
735:
736: $output = cString::recodeString($output, $this->_encoding, $this->_fileEncoding);
737:
738: $fileOperation = cFileHandler::write($fileName, $output);
739:
740: if ($fileOperation === false) {
741: return false;
742: } else {
743: cFileHandler::setDefaultFilePerms($fileName);
744: return true;
745: }
746: }
747:
748: 749: 750: 751: 752: 753: 754: 755:
756: public function saveInput($input = NULL) {
757: $fileName = $this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_input.php';
758:
759: if (!$this->createModuleDirectory('php') || !$this->isWritable($fileName, $this->_modulePath . $this->_directories['php'])) {
760: return false;
761: }
762:
763: if ($input == NULL) {
764: $input = $this->_input;
765: }
766:
767: $input = cString::recodeString($input, $this->_encoding, $this->_fileEncoding);
768:
769: $fileOperation = cFileHandler::write($fileName, $input);
770:
771: if ($fileOperation === false) {
772: return false;
773: } else {
774: cFileHandler::setDefaultFilePerms($fileName);
775: return true;
776: }
777: }
778:
779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792:
793: public function saveInfoXML($moduleName = NULL, $description = NULL, $type = NULL, $alias = NULL) {
794: if ($moduleName == NULL) {
795: $moduleName = $this->_moduleName;
796: }
797:
798: if ($description == NULL) {
799: $description = $this->_description;
800: }
801:
802: if ($type == NULL) {
803: $type = $this->_type;
804: }
805:
806: if ($alias == NULL) {
807: $alias = $this->_moduleAlias;
808: }
809:
810: $oWriter = new cXmlWriter();
811: $oRootElement = $oWriter->addElement('module', '', NULL);
812:
813: $oWriter->addElement('name', conHtmlSpecialChars($moduleName), $oRootElement);
814: $oWriter->addElement('description', conHtmlSpecialChars($description), $oRootElement);
815: $oWriter->addElement('type', conHtmlSpecialChars($type), $oRootElement);
816: $oWriter->addElement('alias', conHtmlSpecialChars($alias), $oRootElement);
817:
818: return $oWriter->saveToFile($this->_modulePath, 'info.xml');
819: }
820:
821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831:
832: public function createModule($input = '', $output = '') {
833: if ($input != '') {
834: $this->_input = $input;
835: }
836:
837: if ($output != '') {
838: $this->_output = $output;
839: }
840:
841: if ($this->modulePathExists()) {
842: return true;
843: }
844:
845: if (mkdir($this->_modulePath) == false) {
846: return false;
847: } else {
848: cDirHandler::setDefaultDirPerms($this->_modulePath);
849: }
850:
851:
852: foreach ($this->_directories as $directory) {
853: if (!is_dir($this->_modulePath . $directory)) {
854: if (mkdir($this->_modulePath . $directory) == false) {
855: return false;
856: } else {
857: cDirHandler::setDefaultDirPerms($this->_modulePath . $directory);
858: }
859: }
860: }
861:
862:
863: if ($this->saveInfoXML() == false) {
864: return false;
865: }
866:
867:
868:
869: $retInput = $this->saveInput();
870: $retOutput = $this->saveOutput();
871:
872: if ($retInput == false || $retOutput == false) {
873: return false;
874: }
875:
876: return true;
877: }
878:
879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889:
890: public function renameModul($old, $new) {
891:
892: if (rename($this->_path . $old, $this->_path . $new) == false) {
893: return false;
894: } else {
895: $retInput = true;
896: $retOutput = true;
897:
898:
899: if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['php'] . $old . '_input.php'))
900: $retInput = rename($this->_path . $new . '/' . $this->_directories['php'] . $old . '_input.php', $this->_path . $new . '/' . $this->_directories['php'] . $new . '_input.php');
901:
902:
903: if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['php'] . $old . '_output.php'))
904: $retOutput = rename($this->_path . $new . '/' . $this->_directories['php'] . $old . '_output.php', $this->_path . $new . '/' . $this->_directories['php'] . $new . '_output.php');
905:
906:
907: if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['css'] . $old . '.css'))
908: rename($this->_path . $new . '/' . $this->_directories['css'] . $old . '.css', $this->_path . $new . '/' . $this->_directories['css'] . $new . '.css');
909:
910:
911: if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['js'] . $old . '.js'))
912: rename($this->_path . $new . '/' . $this->_directories['js'] . $old . '.js', $this->_path . $new . '/' . $this->_directories['js'] . $new . '.js');
913:
914:
915: if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['template'] . $old . '.html'))
916: rename($this->_path . $new . '/' . $this->_directories['template'] . $old . '.html', $this->_path . $new . '/' . $this->_directories['template'] . $new . '.html');
917:
918: if ($retInput == true && $retOutput == true) {
919: return true;
920: } else {
921: return false;
922: }
923: }
924: }
925:
926: 927: 928: 929: 930: 931:
932: public function modulePathExists() {
933: return is_dir($this->_modulePath);
934: }
935:
936: 937: 938: 939: 940: 941:
942: public function testInput() {
943:
944: return $this->_testCode('input');
945:
946: }
947:
948: 949: 950: 951: 952: 953:
954: public function testOutput() {
955:
956: return $this->_testCode('output');
957:
958: }
959:
960: 961: 962: 963: 964: 965: 966: 967:
968: protected function _testCode($inputType) {
969:
970: $result = array(
971: 'state' => false,
972: 'errorMessage' => 'Module path not exist'
973: );
974:
975: if (!$this->modulePathExists()) return $result;
976:
977: $module = new cApiModule($this->_idmod);
978: $isError = 'none';
979:
980:
981: switch ($module->get("error")) {
982: case 'none';
983: $toCheck = $inputType;
984: break;
985: case 'input';
986: if ($inputType == 'output') $toCheck = 'both';
987: break;
988: case 'output';
989: if ($inputType == 'input') $toCheck = 'both';
990: break;
991: case 'both';
992:
993: break;
994: }
995: if ($toCheck !== $module->get("error")) {
996: $module->set("error", $toCheck);
997:
998:
999:
1000: $module->store(true);
1001: }
1002:
1003:
1004: switch($inputType) {
1005: case 'input':
1006:
1007: $code = $this->readInput();
1008: $result = $this->_verifyCode($code, $this->_idmod . "i");
1009: if ($result['state'] !== true) $isError = 'input';
1010:
1011: break;
1012: case 'output':
1013:
1014: $code = $this->readOutput();
1015: $result = $this->_verifyCode($code, $this->_idmod . "o", true);
1016: if ($result['state'] !== true) $isError = 'output';
1017:
1018: break;
1019: }
1020:
1021:
1022: switch ($module->get("error")) {
1023: case 'none';
1024:
1025: break;
1026: case 'input';
1027: if ($isError == 'none' && $inputType == 'output') $isError = 'input';
1028: if ($isError == 'output') $isError = 'both';
1029: break;
1030: case 'output';
1031: if ($isError == 'none' && $inputType == 'input') $isError = 'output';
1032: if ($isError == 'input') $isError = 'both';
1033: break;
1034: case 'both';
1035: if ($isError == 'none' && $inputType == 'input') $isError = 'output';
1036: if ($isError == 'none' && $inputType == 'output') $isError = 'input';
1037: break;
1038: }
1039:
1040:
1041:
1042: if ($isError !== $module->get("error")) {
1043: $module->set("error", $isError);
1044:
1045:
1046:
1047: $module->store(true);
1048: }
1049:
1050: return $result;
1051:
1052: }
1053:
1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065:
1066: protected function _verifyCode($code, $id, $output = false) {
1067: $isError = false;
1068: $result = array(
1069: 'state' => false,
1070: 'errorMessage' => NULL
1071: );
1072:
1073:
1074: $sql = 'SELECT type FROM ' . $this->_cfg['tab']['type'];
1075: $this->_db->query($sql);
1076: while ($this->_db->nextRecord()) {
1077: $code = str_replace($this->_db->f('type') . '[', '$' . $this->_db->f('type') . '[', $code);
1078: }
1079:
1080: $code = preg_replace(',\[(\d+)?CMS_VALUE\[(\d+)\](\d+)?\],i', '[\1\2\3]', $code);
1081: $code = str_replace('CMS_VALUE', '$CMS_VALUE', $code);
1082: $code = str_replace('CMS_VAR', '$CMS_VAR', $code);
1083:
1084:
1085:
1086: if ($output == true) {
1087: $code = "?>\n" . $code . "\n<?php";
1088: }
1089:
1090:
1091: $code = 'function foo' . $id . ' () {' . $code;
1092: $code .= "\n}\n";
1093:
1094:
1095:
1096: $sErs = ini_get('error_prepend_string');
1097: $sEas = ini_get('error_append_string');
1098: @ini_set('error_prepend_string', '<phperror>');
1099: @ini_set('error_append_string', '</phperror>');
1100:
1101:
1102: ob_start();
1103: $display_errors = ini_get('display_errors');
1104: @ini_set('display_errors', true);
1105: $output = eval($code);
1106: @ini_set('display_errors', $display_errors);
1107:
1108:
1109: $output = ob_get_contents();
1110: ob_end_clean();
1111:
1112:
1113: 1114: 1115: 1116: 1117:
1118:
1119:
1120: @ini_set('error_prepend_string', $sErs);
1121: @ini_set('error_append_string', $sEas);
1122:
1123:
1124: if ($isError === false) {
1125: $isError = strpos($output, '<phperror>');
1126: }
1127:
1128:
1129:
1130: if ($isError !== false) {
1131: if (isset($modErrorMessage) === false) {
1132: $pattern = '/(<phperror>|<\/phperror>|<b>|<\/b>|<br>|<br \/>)/im';
1133: $modErrorMessage = trim(preg_replace($pattern, '', $output));
1134: $errorPart1 = substr($modErrorMessage, 0, strpos($modErrorMessage, ' in '));
1135: $errorPart2 = substr($modErrorMessage, strpos($modErrorMessage, ' on line '));
1136: $modErrorMessage = $errorPart1 . $errorPart2;
1137: }
1138: $result['errorMessage'] = sprintf(i18n("Error in module. Error location: %s"), $modErrorMessage);
1139:
1140: }
1141:
1142:
1143: $bHasShortTags = false;
1144: if (preg_match('/<\?\s+/', $code)) {
1145: $bHasShortTags = true;
1146: $result['errorMessage'] = i18n('Please do not use short open tags. (Use <?php instead of <?).');
1147: }
1148:
1149:
1150: if ($bHasShortTags || $isError !== false) {
1151: $result['state'] = false;
1152: } else {
1153: $result['state'] = true;
1154: }
1155:
1156: return $result;
1157:
1158: }
1159:
1160: 1161: 1162: 1163: 1164: 1165: 1166:
1167: protected static function _getModulePath() {
1168: return $this->_modulePath;
1169: }
1170:
1171: }
1172: