diff --git a/public/assets/eeprom-logo.png b/public/assets/eeprom-logo.png new file mode 100644 index 0000000..2762e24 Binary files /dev/null and b/public/assets/eeprom-logo.png differ diff --git a/public/assets/style.css b/public/assets/style.css new file mode 100644 index 0000000..c119c69 --- /dev/null +++ b/public/assets/style.css @@ -0,0 +1,110 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; + position: relative; +} + +html, +body { + width: 100%; + height: 100%; +} + +body { + background-color: #111; + color: #fff; + font: 12px/20px Verdana, Geneva, 'Dejavu Sans', Arial, Helvetica, sans-serif; +} + +.eeprom { + width: 100%; + height: 100%; + display: flex; + justify-content: flex-start; + align-items: center; + flex-direction: column; +} + +.eeprom-inner { + margin: auto; +} + +.eeprom-header { + margin: 20px 0; + padding: 0 20px; +} + +.eeprom-logo { + max-width: 590px; + width: 100%; +} +.eeprom-description { + text-align: center; +} + +.eeprom-stats { + display: flex; + align-items: center; + justify-content: center; + flex-wrap: wrap; +} + +.eeprom-stat { + text-align: center; + margin: 10px; +} +.eeprom-stat-title { + font-size: 1.4em; +} +.eeprom-stat-num { + height: 50px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} +.eeprom-stat-num-big { + font-size: 2em; + line-height: 1.2em; +} +.eeprom-stat-num-small { + font-size: .9em; +} + +.eeprom-divider { + height: 60px; + background-color: #8559a5; + width: 1px; + margin: 20px; +} + +.eeprom-footer { + font-size: .8em; + opacity: .6; + text-align: center; + margin: 20px 0; + padding: 0 20px; +} + +.eeprom-footer a { + color: inherit; + text-decoration: none; +} +.eeprom-footer a:hover, +.eeprom-footer a:focus { + text-decoration: underline; +} + +@media(max-width: 600px) { + .eeprom-divider { + display: none; + } + + .eeprom-stat { + border: 1px solid #8559a5; + border-radius: 2px; + padding: 10px; + min-width: 200px; + } +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..a05df68 --- /dev/null +++ b/public/index.html @@ -0,0 +1,101 @@ + + + + + + EEPROM + + + +
+
+
+ +
+

File Upload Service

+
+
+
+
+
+
---
+
 
+
+
+ Size +
+
+
+
+
+
---
+
+
+ Files +
+
+
+
+
+
---
+
+
+ Types +
+
+
+
+
+
---
+
+
+ Uploaders +
+
+
+ +
+
+ + + diff --git a/public/index.php b/public/index.php index e3f315c..17dbf11 100644 --- a/public/index.php +++ b/public/index.php @@ -21,18 +21,6 @@ function eepromOriginAllowed(string $origin): bool { return in_array($origin, $allowed); } -function eepromByteSymbol(int $bytes, bool $decimal = true, array $symbols = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']): string { - if($bytes < 1) - return '0 B'; - - $divider = $decimal ? 1000 : 1024; - $exp = floor(log($bytes) / log($divider)); - $bytes = $bytes / pow($divider, $exp); - $symbol = $symbols[$exp]; - - return sprintf("%.2f %s%sB", $bytes, $symbol, $symbol !== '' && !$decimal ? 'i' : ''); -} - if($_SERVER['HTTP_HOST'] !== Config::get('Uploads', 'api_domain')) { $reqMethod = 'GET'; // short domain is read only, prevent deleting $reqPath = '/uploads/' . trim($reqPath, '/'); @@ -179,7 +167,7 @@ if($reqPath === '/eeprom.js' && is_file(PRM_ROOT . '/eeprom.js')) { header('Content-Type: text/plain; charset=us-ascii'); -if($reqPath === '/' || $reqPath === '/stats' || $reqPath === '/html') { +if($reqPath === '/' || $reqPath === '/stats.json') { $fileCount = 0; $userCount = 0; $totalSize = 0; @@ -211,60 +199,22 @@ if($reqPath === '/' || $reqPath === '/stats' || $reqPath === '/html') { $getUserStats->execute(); $userStats = $getUserStats->execute() ? $getUserStats->fetchObject() : null; - if(!empty($userStats)) { + if(!empty($userStats)) $userCount = intval($userStats->amount); - } - if($reqPath === '/stats') { + if($reqPath === '/stats.json') { header('Content-Type: application/json; charset=utf-8'); echo json_encode([ - 'files_size' => $totalSize, - 'files_count' => $fileCount, - 'files_types' => $uniqueTypes, - 'users_count' => $userCount, + 'size' => $totalSize, + 'files' => $fileCount, + 'types' => $uniqueTypes, + 'members' => $userCount, ]); return; } - $totalSizeFmt = eepromByteSymbol($totalSize); - - if($reqPath === '/html') { - header('Content-Type: text/html; charset=utf-8'); - echo << - - - - Flashii EEPROM - - - -
-    ________________  ____  ____  __  ___
-   / ____/ ____/ __ \/ __ \/ __ \/  |/  /
-  / __/ / __/ / /_/ / /_/ / / / / /|_/ /
- / /___/ /___/ ____/ _, _/ /_/ / /  / /
-/_____/_____/_/   /_/ |_|\____/_/  /_/
-
-Currently serving {$totalSizeFmt} ({$totalSize} bytes) of {$fileCount} files in {$uniqueTypes} unique file types from {$userCount} users.
-
- - -HTML; - return; - } - - echo <<