@@ -426,6 +426,22 @@ function downloadUpdate()
426426
427427 }
428428
429+ /**
430+ * Check the downloaded phpList version. Return false if it's a downgrade.
431+ * @throws UpdateException
432+ * @return bool
433+ */
434+ function checkForDowngrade ()
435+ {
436+ $ downloadedVersion = file_get_contents (self ::DOWNLOAD_PATH .'/phplist/public_html/lists/admin/init.php ' );
437+ preg_match_all ('/define\(\"VERSION\",\"(.*)\"\);/ ' , $ downloadedVersion , $ matches );
438+
439+ if (isset ($ matches [1 ][0 ]) && version_compare ($ this ->getCurrentVersion (), $ matches [1 ][0 ])) {
440+ return true ;
441+ }
442+ return false ;
443+ }
444+
429445 /**
430446 * Creates temporary dir
431447 * @throws UpdateException
@@ -873,38 +889,45 @@ function replaceNewUpdater()
873889 }
874890 break ;
875891 case 10 :
892+ if ($ update -> checkForDowngrade ()) {
893+ echo (json_encode (array ('continue ' => true , 'autocontinue ' => true , 'response ' => 'Not a downgrade! ' )));
894+ } else {
895+ echo (json_encode (array ('continue ' => false , 'response ' => 'Downgrade is not supported. ' )));
896+ }
897+ break ;
898+ case 11 :
876899 $ on = $ update ->addMaintenanceMode ();
877900 if ($ on === false ) {
878901 echo (json_encode (array ('continue ' => false , 'response ' => 'Cannot set the maintenance mode on! ' )));
879902 } else {
880903 echo (json_encode (array ('continue ' => true , 'response ' => 'Set maintenance mode on ' , 'autocontinue ' => true )));
881904 }
882905 break ;
883- case 11 :
906+ case 12 :
884907 try {
885908 $ update ->replacePHPEntryPoints ();
886909 echo (json_encode (array ('continue ' => true , 'response ' => 'Replaced entry points ' , 'autocontinue ' => true )));
887910 } catch (\Exception $ e ) {
888911 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
889912 }
890913 break ;
891- case 12 :
914+ case 13 :
892915 try {
893916 $ update ->movePluginsInTempFolder ();
894917 echo (json_encode (array ('continue ' => true , 'response ' => 'Backing up the plugins ' , 'autocontinue ' => true )));
895918 } catch (\Exception $ e ) {
896919 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
897920 }
898921 break ;
899- case 13 :
922+ case 14 :
900923 try {
901924 $ update ->deleteFiles ();
902925 echo (json_encode (array ('continue ' => true , 'response ' => 'Old files have been deleted! ' , 'autocontinue ' => true )));
903926 } catch (\Exception $ e ) {
904927 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
905928 }
906929 break ;
907- case 14 :
930+ case 15 :
908931 try {
909932 $ update ->moveNewFiles ();
910933 echo (json_encode (array ('continue ' => true , 'response ' => 'Moved new files in place! ' , 'autocontinue ' => true )));
@@ -913,47 +936,47 @@ function replaceNewUpdater()
913936 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
914937 }
915938 break ;
916- case 15 :
939+ case 16 :
917940 try {
918941 $ update ->movePluginsInPlace ();
919942 echo (json_encode (array ('continue ' => true , 'response ' => 'Moved plugins in place! ' , 'autocontinue ' => true )));
920943 } catch (\Exception $ e ) {
921944 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
922945 }
923946 break ;
924- case 16 :
947+ case 17 :
925948 try {
926949 $ update ->moveEntryPHPpoints ();
927950 echo (json_encode (array ('continue ' => true , 'response ' => 'Moved new entry points in place! ' , 'autocontinue ' => true )));
928951 } catch (\Exception $ e ) {
929952 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
930953 }
931954 break ;
932- case 17 :
955+ case 18 :
933956 try {
934957 $ update ->moveUpdater ();
935958 echo (json_encode (array ('continue ' => true , 'response ' => 'Moved new entry points in place! ' , 'autocontinue ' => true )));
936959 } catch (\Exception $ e ) {
937960 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
938961 }
939962 break ;
940- case 18 :
963+ case 19 :
941964 try {
942965 $ update ->deleteTemporaryFiles ();
943966 echo (json_encode (array ('continue ' => true , 'response ' => 'Deleted temporary files! ' , 'autocontinue ' => true )));
944967 } catch (\Exception $ e ) {
945968 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
946969 }
947970 break ;
948- case 19 :
971+ case 20 :
949972 try {
950973 $ update ->removeMaintenanceMode ();
951974 echo (json_encode (array ('continue ' => true , 'response ' => 'Removed maintenance mode ' , 'autocontinue ' => true )));
952975 } catch (\Exception $ e ) {
953976 echo (json_encode (array ('continue ' => false , 'response ' => $ e ->getMessage ())));
954977 }
955978 break ;
956- case 20 :
979+ case 21 :
957980 $ writeStep = false ;
958981 try {
959982 $ update ->replaceNewUpdater ();
@@ -1844,7 +1867,7 @@ function setCurrentActionItem(step) {
18441867 7: 1,
18451868 8: 2,
18461869 9: 2,
1847- 10: 3 ,
1870+ 10: 2 ,
18481871 11: 3,
18491872 12: 3,
18501873 13: 3,
@@ -1855,6 +1878,7 @@ function setCurrentActionItem(step) {
18551878 18: 3,
18561879 19: 3,
18571880 20: 3,
1881+ 21: 3,
18581882 };
18591883
18601884 let steps = document.querySelectorAll('.step-image');
0 commit comments