49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
|
<?php
|
||
|
namespace EEPROM;
|
||
|
|
||
|
use stdClass;
|
||
|
use Index\Routing\Route;
|
||
|
use Index\Routing\RouteHandler;
|
||
|
|
||
|
class LandingRoutes extends RouteHandler {
|
||
|
public function __construct(
|
||
|
private DatabaseContext $dbCtx
|
||
|
) {}
|
||
|
|
||
|
#[Route('GET', '/')]
|
||
|
public function getIndex($response) {
|
||
|
$response->accelRedirect('/index.html');
|
||
|
$response->setContentType('text/html; charset=utf-8');
|
||
|
}
|
||
|
|
||
|
#[Route('GET', '/stats.json')]
|
||
|
public function getStats() {
|
||
|
$dbConn = $this->dbCtx->getConnection();
|
||
|
|
||
|
$stats = new stdClass;
|
||
|
$stats->files = 0;
|
||
|
$stats->size = 0;
|
||
|
$stats->types = 0;
|
||
|
$stats->members = 0;
|
||
|
|
||
|
$result = $dbConn->query('SELECT COUNT(upload_id), SUM(upload_size), COUNT(DISTINCT upload_type) FROM prm_uploads WHERE upload_deleted IS NULL AND upload_dmca IS NULL');
|
||
|
if($result->next()) {
|
||
|
$stats->files = $result->getInteger(0);
|
||
|
$stats->size = $result->getInteger(1);
|
||
|
$stats->types = $result->getInteger(2);
|
||
|
}
|
||
|
|
||
|
$result = $dbConn->query('SELECT COUNT(user_id) FROM prm_users WHERE user_restricted IS NULL');
|
||
|
if($result->next())
|
||
|
$stats->members = $result->getInteger(0);
|
||
|
|
||
|
return $stats;
|
||
|
}
|
||
|
|
||
|
#[Route('GET', '/eeprom.js')]
|
||
|
public function getEepromJs($response) {
|
||
|
$response->accelRedirect('/js/eeprom-v1.0.js');
|
||
|
$response->setContentType('application/javascript; charset=utf-8');
|
||
|
}
|
||
|
}
|