Skip to content

Commit 3e0978a

Browse files
Merge branch 'master' into arrow-animation-fix
2 parents a9ab5f2 + db12db8 commit 3e0978a

File tree

1 file changed

+56
-27
lines changed

1 file changed

+56
-27
lines changed

index.php

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ class updater
1313
{
1414
/** @var bool */
1515
private $availableUpdate = false;
16-
1716
const DOWNLOAD_PATH = '../tmp_uploaded_update';
1817
const ELIGIBLE_SESSION_KEY = 'phplist_updater_eligible';
19-
const CONFIG_FILE = __DIR__ . '/../config/config.php';
20-
2118
private $excludedFiles = array(
2219
'dl.php',
2320
'index.php',
@@ -278,20 +275,27 @@ function deleteFiles()
278275

279276
}
280277

278+
/**
279+
* Get config file path
280+
* @return string
281+
*/
282+
function getConfigFilePath()
283+
{
284+
return __DIR__ . '/../config/config.php';
285+
}
286+
281287
/**
282288
* Get a PDO connection
283289
* @return PDO
284290
* @throws UpdateException
285291
*/
286292
function getConnection()
287293
{
288-
$standardConfig = self::CONFIG_FILE;
289-
290294
if (isset($_SERVER['ConfigFile']) && is_file($_SERVER['ConfigFile'])) {
291295
include $_SERVER['ConfigFile'];
292296

293-
} elseif (file_exists($standardConfig)) {
294-
include $standardConfig;
297+
} elseif (file_exists($this->getConfigFilePath())) {
298+
include $this->getConfigFilePath();
295299
} else {
296300
throw new \UpdateException("Error: Cannot find config file");
297301
}
@@ -325,11 +329,10 @@ function getConnection()
325329
*/
326330
function addMaintenanceMode()
327331
{
328-
$standardConfig = self::CONFIG_FILE;
329332
if (isset($_SERVER['ConfigFile']) && is_file($_SERVER['ConfigFile'])) {
330333
include $_SERVER['ConfigFile'];
331-
} elseif (file_exists($standardConfig)) {
332-
include $standardConfig;
334+
} elseif (file_exists($this->getConfigFilePath())) {
335+
include $this->getConfigFilePath();
333336
} else {
334337
throw new \UpdateException("Error: Cannot find config file");
335338
}
@@ -367,11 +370,10 @@ function addMaintenanceMode()
367370
*/
368371
function removeMaintenanceMode()
369372
{
370-
$standardConfig = self::CONFIG_FILE;
371373
if (isset($_SERVER['ConfigFile']) && is_file($_SERVER['ConfigFile'])) {
372374
include $_SERVER['ConfigFile'];
373-
} elseif (file_exists($standardConfig)) {
374-
include $standardConfig;
375+
} elseif (file_exists($this->getConfigFilePath())) {
376+
include $this->getConfigFilePath();
375377
} else {
376378
throw new \UpdateException("Error: Cannot find config file");
377379
}
@@ -424,6 +426,22 @@ function downloadUpdate()
424426

425427
}
426428

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+
427445
/**
428446
* Creates temporary dir
429447
* @throws UpdateException
@@ -871,38 +889,45 @@ function replaceNewUpdater()
871889
}
872890
break;
873891
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:
874899
$on = $update->addMaintenanceMode();
875900
if ($on === false) {
876901
echo(json_encode(array('continue' => false, 'response' => 'Cannot set the maintenance mode on!')));
877902
} else {
878903
echo(json_encode(array('continue' => true, 'response' => 'Set maintenance mode on', 'autocontinue' => true)));
879904
}
880905
break;
881-
case 11:
906+
case 12:
882907
try {
883908
$update->replacePHPEntryPoints();
884909
echo(json_encode(array('continue' => true, 'response' => 'Replaced entry points', 'autocontinue' => true)));
885910
} catch (\Exception $e) {
886911
echo(json_encode(array('continue' => false, 'response' => $e->getMessage())));
887912
}
888913
break;
889-
case 12:
914+
case 13:
890915
try {
891916
$update->movePluginsInTempFolder();
892917
echo(json_encode(array('continue' => true, 'response' => 'Backing up the plugins', 'autocontinue' => true)));
893918
} catch (\Exception $e) {
894919
echo(json_encode(array('continue' => false, 'response' => $e->getMessage())));
895920
}
896921
break;
897-
case 13:
922+
case 14:
898923
try {
899924
$update->deleteFiles();
900925
echo(json_encode(array('continue' => true, 'response' => 'Old files have been deleted!', 'autocontinue' => true)));
901926
} catch (\Exception $e) {
902927
echo(json_encode(array('continue' => false, 'response' => $e->getMessage())));
903928
}
904929
break;
905-
case 14:
930+
case 15:
906931
try {
907932
$update->moveNewFiles();
908933
echo(json_encode(array('continue' => true, 'response' => 'Moved new files in place!', 'autocontinue' => true)));
@@ -911,47 +936,47 @@ function replaceNewUpdater()
911936
echo(json_encode(array('continue' => false, 'response' => $e->getMessage())));
912937
}
913938
break;
914-
case 15:
939+
case 16:
915940
try {
916941
$update->movePluginsInPlace();
917942
echo(json_encode(array('continue' => true, 'response' => 'Moved plugins in place!', 'autocontinue' => true)));
918943
} catch (\Exception $e) {
919944
echo(json_encode(array('continue' => false, 'response' => $e->getMessage())));
920945
}
921946
break;
922-
case 16:
947+
case 17:
923948
try {
924949
$update->moveEntryPHPpoints();
925950
echo(json_encode(array('continue' => true, 'response' => 'Moved new entry points in place!', 'autocontinue' => true)));
926951
} catch (\Exception $e) {
927952
echo(json_encode(array('continue' => false, 'response' => $e->getMessage())));
928953
}
929954
break;
930-
case 17:
955+
case 18:
931956
try {
932957
$update->moveUpdater();
933958
echo(json_encode(array('continue' => true, 'response' => 'Moved new entry points in place!', 'autocontinue' => true)));
934959
} catch (\Exception $e) {
935960
echo(json_encode(array('continue' => false, 'response' => $e->getMessage())));
936961
}
937962
break;
938-
case 18:
963+
case 19:
939964
try {
940965
$update->deleteTemporaryFiles();
941966
echo(json_encode(array('continue' => true, 'response' => 'Deleted temporary files!', 'autocontinue' => true)));
942967
} catch (\Exception $e) {
943968
echo(json_encode(array('continue' => false, 'response' => $e->getMessage())));
944969
}
945970
break;
946-
case 19:
971+
case 20:
947972
try {
948973
$update->removeMaintenanceMode();
949974
echo(json_encode(array('continue' => true, 'response' => 'Removed maintenance mode', 'autocontinue' => true)));
950975
} catch (\Exception $e) {
951976
echo(json_encode(array('continue' => false, 'response' => $e->getMessage())));
952977
}
953978
break;
954-
case 20:
979+
case 21:
955980
$writeStep = false;
956981
try {
957982
$update->replaceNewUpdater();
@@ -1552,7 +1577,7 @@ function replaceNewUpdater()
15521577
</g>
15531578
</svg>
15541579

1555-
<h1 style="font-family: 'Montserrat', Regular;font-size: 18px;">Updating phpList to the latest
1580+
<h1 style="font-family: 'Montserrat', Regular;font-size: 18px;cursor:auto;">Updating phpList to the latest
15561581
version</h1>
15571582
</div>
15581583
<div id="steps">
@@ -1647,7 +1672,7 @@ function replaceNewUpdater()
16471672
<div class="step last-step">
16481673
<div class="step-image">
16491674
<svg xmlns="http://www.w3.org/2000/svg" width="22.512" height="16.01"
1650-
viewBox="0 0 22.512 16.01">
1675+
viewBox="0 0 22.512 16.01" class="performUpdate">
16511676
<path id="Path_219" data-name="Path 219"
16521677
d="M16100.607-997.888c-2.889,2.889-14.332,14.2-14.332,14.2l-6.68-6.679"
16531678
transform="translate(-16078.847 998.638)" fill="none" stroke="#253746"
@@ -1737,7 +1762,7 @@ function replaceNewUpdater()
17371762
<p class="messages">9000 messages</p><br>
17381763
<p class="price">Price $1</p>
17391764
<p class="subscribers">3000 Subscribers</p>
1740-
<input type="button" onclick="window.open('https://www.phplist.com/register?utm_source=self-hosted-updater')" value="Book"
1765+
<input type="button" onclick="window.open('https://phplist.com/chooseplan')" value="Book"
17411766
style="width: 90px;height: 30px; border: 1px dashed #21AE8A; background: #fff; margin: 0 auto;"
17421767
class="book"/>
17431768
</div>
@@ -1749,6 +1774,7 @@ class="book"/>
17491774
</div><!-- .inner -->
17501775
</div><!-- .outer -->
17511776

1777+
<!-- Load jquery-3.3.1.min.js file -->
17521778
<script type="text/javascript" src="../admin/js/jquery-3.3.1.min.js"></script>
17531779

17541780
<!-- script for arrow animation -->
@@ -1768,6 +1794,7 @@ class="book"/>
17681794
rotated = !rotated;
17691795
}
17701796
</script>
1797+
17711798
<!-- script for slideToggle -->
17721799
<script type="text/javascript">
17731800
$('.outer button').on("click", function () {
@@ -1776,6 +1803,7 @@ class="book"/>
17761803
});
17771804
});
17781805
</script>
1806+
<!-- Arrow transition -->
17791807
<script type="text/javascript">
17801808
$("#center").addClass("cutomMinHeight");
17811809
$(".fixed").addClass("cutomMinHeight");
@@ -1833,7 +1861,7 @@ function setCurrentActionItem(step) {
18331861
7: 1,
18341862
8: 2,
18351863
9: 2,
1836-
10: 3,
1864+
10: 2,
18371865
11: 3,
18381866
12: 3,
18391867
13: 3,
@@ -1844,6 +1872,7 @@ function setCurrentActionItem(step) {
18441872
18: 3,
18451873
19: 3,
18461874
20: 3,
1875+
21: 3,
18471876
};
18481877

18491878
let steps = document.querySelectorAll('.step-image');

0 commit comments

Comments
 (0)