Skip to content

Commit 15b9e7c

Browse files
author
Sam Tuke
authored
Merge pull request #67 from phpList/minor-tweaks
Added "Error: " before error messages, fixed css indent
2 parents e04fd4f + 574033f commit 15b9e7c

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

index.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
/**
33
* Automatic updater for phpList 3
4-
* @author Xheni Myrtaj <[email protected]>
54
*
5+
* @author Xheni Myrtaj <[email protected]>
66
*/
77

88
class UpdateException extends \Exception {}
@@ -284,7 +284,7 @@ function getConnection()
284284
} elseif (file_exists($standardConfig)) {
285285
include $standardConfig;
286286
} else {
287-
throw new \UpdateException("Cannot find config file");
287+
throw new \UpdateException("Error: Cannot find config file");
288288
}
289289

290290
$charset = 'utf8mb4';
@@ -367,7 +367,7 @@ function downloadUpdate()
367367
$url = $this->getDownloadUrl();
368368
$zipFile = tempnam(sys_get_temp_dir(), 'phplist-update');
369369
if ($zipFile === false) {
370-
throw new UpdateException("Temporary file cannot be created");
370+
throw new UpdateException("Error: Temporary file cannot be created");
371371
}
372372
// Get The Zip File From Server
373373
$ch = curl_init();
@@ -400,7 +400,7 @@ function temp_dir()
400400

401401
$tempdir = mkdir(self::DOWNLOAD_PATH, 0700);
402402
if ($tempdir === false) {
403-
throw new UpdateException("Could not create temporary file");
403+
throw new UpdateException("Error: Could not create temporary file");
404404
}
405405
}
406406

@@ -429,7 +429,7 @@ function replacePHPEntryPoints()
429429
$current = "Update in progress \n";
430430
$content = file_put_contents(__DIR__.'/../'.$fileName, $current);
431431
if ($content === FALSE) {
432-
throw new UpdateException("Could not write to the $fileName");
432+
throw new UpdateException("Error: Could not write to the $fileName");
433433
}
434434
}
435435

@@ -469,7 +469,7 @@ function moveNewFiles()
469469
$rootDir = __DIR__ . '/../tmp_uploaded_update/phplist/public_html/lists';
470470
$downloadedFiles = scandir($rootDir);
471471
if (count($downloadedFiles) <= 2) {
472-
throw new UpdateException("Download folder is empty!");
472+
throw new UpdateException("Error: Download folder is empty!");
473473
}
474474

475475
foreach ($downloadedFiles as $fileName) {
@@ -480,7 +480,7 @@ function moveNewFiles()
480480
$newFile = __DIR__ . '/../' . $fileName;
481481
$state = rename($oldFile, $newFile);
482482
if ($state === false) {
483-
throw new UpdateException("Could not move new files");
483+
throw new UpdateException("Error: Could not move new files");
484484
}
485485
}
486486
}
@@ -553,7 +553,7 @@ function unZipFiles($toBeExtracted, $extractPath)
553553

554554
/* Open the Zip file */
555555
if ($zip->open($toBeExtracted) !== true) {
556-
throw new \UpdateException("Unable to open the Zip File");
556+
throw new \UpdateException("Error: Unable to open the Zip File");
557557
}
558558
/* Extract Zip File */
559559
$zip->extractTo($extractPath);
@@ -568,7 +568,7 @@ function unZipFiles($toBeExtracted, $extractPath)
568568
function deleteTemporaryFiles() {
569569
$isTempDirDeleted = $this->rmdir_recursive(self::DOWNLOAD_PATH);
570570
if($isTempDirDeleted===false){
571-
throw new \UpdateException("Could not delete temporary files!");
571+
throw new \UpdateException("Error: Could not delete temporary files!");
572572
}
573573

574574
}
@@ -591,12 +591,12 @@ function writeActions($action)
591591
if (!file_exists($actionsdir)) {
592592
$actionsFile = fopen($actionsdir, "w+");
593593
if ($actionsFile === false) {
594-
throw new \UpdateException("Could not create actions file in the config directory, please change permissions");
594+
throw new \UpdateException("Error: Could not create actions file in the config directory, please change permissions");
595595
}
596596
}
597597
$written = file_put_contents($actionsdir, json_encode(array('continue'=>false, 'step'=>$action)));
598598
if($written === false){
599-
throw new \UpdateException("Could not write on $actionsdir");
599+
throw new \UpdateException("Error: Could not write on $actionsdir");
600600
}
601601
}
602602

@@ -734,7 +734,7 @@ function replaceNewUpdater() {
734734
case 3:
735735
$unexpectedFiles = $update->checkRequiredFiles();
736736
if(count($unexpectedFiles) !== 0) {
737-
$elements = "The following files are not expected or required. To continue please move or delete them. \n";;
737+
$elements = "Error: The following files are not expected or required. To continue please move or delete them. \n";;
738738
foreach ($unexpectedFiles as $key=>$fileName){
739739
$elements.=$key."\n";
740740
}
@@ -746,7 +746,7 @@ function replaceNewUpdater() {
746746
case 4:
747747
$notWriteableFiles = $update->checkWritePermissions();
748748
if(count($notWriteableFiles) !== 0) {
749-
$notWriteableElements = "No write permission for the following files: \n";;
749+
$notWriteableElements = "Error: No write permission for the following files: \n";;
750750
foreach ($notWriteableFiles as $key=>$fileName){
751751
$notWriteableElements.=$fileName."\n";
752752
}
@@ -772,11 +772,11 @@ function replaceNewUpdater() {
772772
$backupLocation = realpath(dirname($_POST['backup_location']));
773773
$phplistRootFolder = realpath(__DIR__ . '/../../');
774774
if(strpos($backupLocation, $phplistRootFolder) === 0) {
775-
echo(json_encode(array('retry' => true, 'continue' => false, 'response' => 'Please choose a folder outside of your phpList installation.')));
775+
echo(json_encode(array('retry' => true, 'continue' => false, 'response' => 'Error: Please choose a folder outside of your phpList installation.')));
776776
break;
777777
}
778778
if (!preg_match("/^.*\.(zip)$/i", $_POST['backup_location'])) {
779-
echo(json_encode(array('retry' => true, 'continue' => false, 'response' => 'Please add .zip extension.')));
779+
echo(json_encode(array('retry' => true, 'continue' => false, 'response' => 'Error: Please add .zip extension.')));
780780
break;
781781
}
782782
try {
@@ -990,21 +990,21 @@ function replaceNewUpdater() {
990990
width: 90%;
991991
}
992992
}
993-
994-
@media only screen and (min-width: 1200px) and (max-width: 1400px) {
995-
996-
#center {
997-
margin: auto;
998-
max-width: 75%;
999-
}
1000-
1001-
#display {
1002-
max-width: 70%;
1003-
margin: 0 auto;
1004-
}
1005-
1006-
}
1007-
993+
994+
@media only screen and (min-width: 1200px) and (max-width: 1400px) {
995+
996+
#center {
997+
margin: auto;
998+
max-width: 75%;
999+
}
1000+
1001+
#display {
1002+
max-width: 70%;
1003+
margin: 0 auto;
1004+
}
1005+
1006+
}
1007+
10081008
#display {
10091009
background-color: white;
10101010
padding-left: 20px;

0 commit comments

Comments
 (0)