@@ -212,6 +212,7 @@ class ModuleScanner
212
212
'call_user_func ' ,
213
213
'call_user_func_array ' ,
214
214
'create_function ' ,
215
+ 'phpinfo ' ,
215
216
216
217
217
218
//mutliple files per function call
@@ -575,6 +576,7 @@ public function isPHPFile($contents)
575
576
// found <?, it's PHP
576
577
return true ;
577
578
}
579
+
578
580
return false ;
579
581
}
580
582
@@ -588,13 +590,14 @@ public function scanFile($file)
588
590
{
589
591
$ issues = array ();
590
592
if (!$ this ->isValidExtension ($ file )) {
591
- $ issues [] = translate ('ML_INVALID_EXT ' );
593
+ $ issues [] = translate ('ML_INVALID_EXT ' , ' Administration ' );
592
594
$ this ->issues ['file ' ][$ file ] = $ issues ;
593
595
return $ issues ;
594
596
}
595
597
if ($ this ->isConfigFile ($ file )) {
596
- $ issues [] = translate ('ML_OVERRIDE_CORE_FILES ' );
598
+ $ issues [] = translate ('ML_OVERRIDE_CORE_FILES ' , ' Administration ' );
597
599
$ this ->issues ['file ' ][$ file ] = $ issues ;
600
+
598
601
return $ issues ;
599
602
}
600
603
$ contents = file_get_contents ($ file );
@@ -609,7 +612,7 @@ public function scanFile($file)
609
612
if (is_string ($ token [0 ])) {
610
613
switch ($ token [0 ]) {
611
614
case '` ' :
612
- $ issues ['backtick ' ] = translate ('ML_INVALID_FUNCTION ' ) . " '`' " ;
615
+ $ issues ['backtick ' ] = translate ('ML_INVALID_FUNCTION ' , ' Administration ' ) . " '`' " ;
613
616
// no break
614
617
case '( ' :
615
618
if ($ checkFunction ) {
@@ -625,9 +628,15 @@ public function scanFile($file)
625
628
case T_WHITESPACE : break ;
626
629
case T_EVAL :
627
630
if (in_array ('eval ' , $ this ->blackList ) && !in_array ('eval ' , $ this ->blackListExempt )) {
628
- $ issues []= translate ('ML_INVALID_FUNCTION ' ) . ' eval() ' ;
631
+ $ issues []= translate ('ML_INVALID_FUNCTION ' , ' Administration ' ) . ' eval() ' ;
629
632
}
630
633
break ;
634
+ case T_ECHO :
635
+ $ issues []= translate ('ML_INVALID_FUNCTION ' , 'Administration ' ) . ' echo ' ;
636
+ break ;
637
+ case T_EXIT :
638
+ $ issues []= translate ('ML_INVALID_FUNCTION ' , 'Administration ' ) . ' exit / die ' ;
639
+ break ;
631
640
case T_STRING :
632
641
$ token [1 ] = strtolower ($ token [1 ]);
633
642
if ($ lastToken !== false && $ lastToken [0 ] == T_NEW ) {
@@ -651,21 +660,20 @@ public function scanFile($file)
651
660
// check static blacklist for methods
652
661
if (!empty ($ this ->methodsBlackList [$ token [1 ]])) {
653
662
if ($ this ->methodsBlackList [$ token [1 ]] == '* ' ) {
654
- $ issues []= translate ('ML_INVALID_METHOD ' ) . ' ' .$ token [1 ]. '() ' ;
663
+ $ issues []= translate ('ML_INVALID_METHOD ' , ' Administration ' ) . ' ' .$ token [1 ]. '() ' ;
655
664
break ;
656
- } else {
657
- if ($ lastToken [0 ] == T_DOUBLE_COLON && $ index > 2 && $ tokens [$ index -2 ][0 ] == T_STRING ) {
658
- $ classname = strtolower ($ tokens [$ index -2 ][1 ]);
659
- if (in_array ($ classname , $ this ->methodsBlackList [$ token [1 ]])) {
660
- $ issues []= translate ('ML_INVALID_METHOD ' ) . ' ' .$ classname . ':: ' . $ token [1 ]. '() ' ;
661
- break ;
662
- }
665
+ }
666
+ if ($ lastToken [0 ] == T_DOUBLE_COLON && $ index > 2 && $ tokens [$ index -2 ][0 ] == T_STRING ) {
667
+ $ classname = strtolower ($ tokens [$ index -2 ][1 ]);
668
+ if (in_array ($ classname , $ this ->methodsBlackList [$ token [1 ]])) {
669
+ $ issues []= translate ('ML_INVALID_METHOD ' , 'Administration ' ) . ' ' .$ classname . ':: ' . $ token [1 ]. '() ' ;
670
+ break ;
663
671
}
664
672
}
665
673
}
666
674
//this is a method call, check the black list
667
675
if (in_array ($ token [1 ], $ this ->methodsBlackList )) {
668
- $ issues []= translate ('ML_INVALID_METHOD ' ) . ' ' .$ token [1 ]. '() ' ;
676
+ $ issues []= translate ('ML_INVALID_METHOD ' , ' Administration ' ) . ' ' .$ token [1 ]. '() ' ;
669
677
}
670
678
break ;
671
679
}
@@ -681,7 +689,7 @@ public function scanFile($file)
681
689
// no break
682
690
case T_VARIABLE :
683
691
$ checkFunction = true ;
684
- $ possibleIssue = translate ('ML_INVALID_FUNCTION ' ) . ' ' . $ token [1 ] . '() ' ;
692
+ $ possibleIssue = translate ('ML_INVALID_FUNCTION ' , ' Administration ' ) . ' ' . $ token [1 ] . '() ' ;
685
693
break ;
686
694
687
695
default :
@@ -866,18 +874,13 @@ public function scanPackage($path)
866
874
/**
867
875
*This function will take all issues of the current instance and print them to the screen
868
876
**/
869
- public function displayIssues ($ package= 'Package ' )
877
+ public function displayIssues ($ package = 'Package ' )
870
878
{
871
- echo '<h2> ' .str_replace ('{PACKAGE} ' , $ package , translate ('ML_PACKAGE_SCANNING ' )). '</h2><BR><h2 class="error"> ' . translate ('ML_INSTALLATION_FAILED ' ) . '</h2><br><p> ' .str_replace ('{PACKAGE} ' , $ package , translate ('ML_PACKAGE_NOT_CONFIRM ' )). '</p><ul><li> ' . translate ('ML_OBTAIN_NEW_PACKAGE ' ) . '<li> ' . translate ('ML_RELAX_LOCAL ' ).
872
- '</ul></p><br> ' . translate ('ML_SUGAR_LOADING_POLICY ' ) . ' <a href=" http://kb.sugarcrm.com/custom/module-loader-restrictions-for-sugar-open-cloud/"> ' . translate ('ML_SUITE_KB ' ) . '</a>. ' .
873
- '<br> ' . translate ('ML_AVAIL_RESTRICTION ' ). ' <a href=" http://developers.sugarcrm.com/wordpress/2009/08/14/module-loader-restrictions/"> ' . translate ('ML_SUITE_DZ ' ) . '</a>.<br><br> ' ;
874
-
875
-
876
- foreach ($ this ->issues as $ type =>$ issues ) {
877
- echo '<div class="error"><h2> ' . ucfirst ($ type ) .' ' . translate ('ML_ISSUES ' ) . '</h2> </div> ' ;
879
+ foreach ($ this ->issues as $ type => $ issues ) {
880
+ echo '<h2 class="error"> ' . ucfirst ($ type ) . ' ' . translate ('ML_ISSUES ' , 'Administration ' ) . '</h2> ' ;
878
881
echo '<div id="details ' . $ type . '" > ' ;
879
- foreach ($ issues as $ file=> $ issue ) {
880
- $ file = str_replace ( $ this -> pathToModule . ' / ' , '' , $ file );
882
+ foreach ($ issues as $ file => $ issue ) {
883
+ $ file = preg_replace ( ' /.*\/ / ' , '' , $ file );
881
884
echo '<div style="position:relative;left:10px"><b> ' . $ file . '</b></div><div style="position:relative;left:20px"> ' ;
882
885
if (is_array ($ issue )) {
883
886
foreach ($ issue as $ i ) {
@@ -893,6 +896,36 @@ public function displayIssues($package='Package')
893
896
echo "<br><input class='button' onclick='document.location.href= \"index.php?module=Administration&action=UpgradeWizard&view=module \"' type='button' value= \"" . translate ('LBL_UW_BTN_BACK_TO_MOD_LOADER ' ) . "\" /> " ;
894
897
}
895
898
899
+ /**
900
+ *This function will take all issues of the current instance and add them to a string
901
+ **/
902
+ public function getIssuesLog ($ package = 'Package ' )
903
+ {
904
+ $ message = '' ;
905
+
906
+ foreach ($ this ->issues as $ type => $ issues ) {
907
+ $ message .= '<h2 class="error"> ' . ucfirst ($ type ) . ' ' . translate ('ML_ISSUES ' ,
908
+ 'Administration ' ) . '</h2> ' ;
909
+ $ message .= '<div id="details ' . $ type . '" > ' ;
910
+ foreach ($ issues as $ file => $ issue ) {
911
+ $ file = preg_replace ('/.*\// ' , '' , $ file );
912
+ $ message .= '<div style="position:relative;left:10px"><b> ' . $ file . '</b></div><div style="position:relative;left:20px"> ' ;
913
+ if (is_array ($ issue )) {
914
+ foreach ($ issue as $ i ) {
915
+ $ message .= "$ i<br> " ;
916
+ }
917
+ } else {
918
+ $ message .= "$ issue<br> " ;
919
+ }
920
+ $ message .= "</div> " ;
921
+ }
922
+ $ message .= '</div> ' ;
923
+ }
924
+
925
+ return $ message ;
926
+ }
927
+
928
+
896
929
/**
897
930
* Lock config settings
898
931
*/
@@ -912,7 +945,7 @@ public function checkConfig($file)
912
945
{
913
946
$ config_hash_after = md5 (serialize ($ GLOBALS ['sugar_config ' ]));
914
947
if ($ config_hash_after != $ this ->config_hash ) {
915
- $ this ->issues ['file ' ][$ file ] = array (translate ('ML_CONFIG_OVERRIDE ' ));
948
+ $ this ->issues ['file ' ][$ file ] = array (translate ('ML_CONFIG_OVERRIDE ' , ' Administration ' ));
916
949
return $ this ->issues ;
917
950
}
918
951
return false ;
0 commit comments