소스 검색

show html instead of plain text on Die commands

CauseFX 4 년 전
부모
커밋
b7ca489f92
2개의 변경된 파일32개의 추가작업 그리고 6개의 파일을 삭제
  1. 5 5
      api/classes/organizr.class.php
  2. 27 1
      api/functions/organizr-functions.php

+ 5 - 5
api/classes/organizr.class.php

@@ -189,7 +189,7 @@ class Organizr
 			if ($this->config['blacklisted'] !== '') {
 				if (in_array($currentIP, $this->arrayIP($this->config['blacklisted']))) {
 					$this->debug('User was sent to blackhole - Blacklisted IPs: ' . $this->config['blacklisted']);
-					die($this->config['blacklistedMessage']);
+					die($this->showHTML('Blacklisted', $this->config['blacklistedMessage']));
 				}
 			}
 		}
@@ -570,7 +570,7 @@ class Organizr
 	private function checkPHP()
 	{
 		if (!(version_compare(PHP_VERSION, $this->minimumPHP) >= 0)) {
-			die('Organizr needs PHP Version: ' . $this->minimumPHP . '<br/> You have PHP Version: ' . PHP_VERSION);
+			die($this->showHTML('PHP Version', 'Organizr needs PHP Version: ' . $this->minimumPHP . '<br/> You have PHP Version: ' . PHP_VERSION));
 		}
 	}
 	
@@ -579,7 +579,7 @@ class Organizr
 		if ($this->hasDB()) {
 			$db = is_writable($this->config['dbLocation'] . $this->config['dbName']);
 			if (!$db) {
-				die('Organizr DB is not writable!!!  Please fix...');
+				die($this->showHTML('Organizr DB is not writable!', 'Please check permissions and/or disk space'));
 			}
 		}
 	}
@@ -595,7 +595,7 @@ class Organizr
 				@$this->rrmdir($cleanup);
 			}
 			if (file_exists($tempLock)) {
-				die('upgrading');
+				die($this->showHTML('Upgrading', 'Please wait...'));
 			}
 			$updateDB = false;
 			$updateSuccess = true;
@@ -649,7 +649,7 @@ class Organizr
 				$this->debug('Updated config version to ' . $this->version);
 			}
 			if ($updateSuccess == false) {
-				die('Database update failed - Please manually check logs and fix - Then reload this page');
+				die($this->showHTML('Database update failed', 'Please manually check logs and fix - Then reload this page'));
 			}
 			return true;
 		}

+ 27 - 1
api/functions/organizr-functions.php

@@ -489,7 +489,7 @@ trait OrganizrFunctions
 			ob_end_flush(); // Send the output to the browser
 			die();
 		} else {
-			die("Invalid Request");
+			die($this->showHTML('Invalid Request', 'No image returned'));
 		}
 	}
 	
@@ -734,4 +734,30 @@ trait OrganizrFunctions
 		}
 		return $options;
 	}
+	
+	public function showHTML(string $title = 'Organizr Alert', string $notice = '')
+	{
+		return
+			'<!DOCTYPE html>
+			<html lang="en">
+			<head>
+				<link rel="stylesheet" href="' . $this->getServerPath() . '/css/mvp.css">
+				<meta charset="utf-8">
+				<meta name="description" content="Trakt OAuth">
+				<meta name="viewport" content="width=device-width, initial-scale=1.0">
+				<title>' . $title . '</title>
+			</head>
+
+			<body>
+				<main>
+					<section>
+						<aside>
+							<h3>' . $title . '</h3>
+							<p>' . $notice . '</p>
+						</aside>
+					</section>
+				</main>
+			</body>
+			</html>';
+	}
 }