1
0

add reading history to /about
Some checks failed
Build Docker and Deploy / Build Docker (push) Failing after 37s
Build Docker and Deploy / Deploy to Server (push) Has been skipped

This commit is contained in:
2026-02-07 22:37:18 +01:00
parent fcc10e1d70
commit 925960eb39
24 changed files with 662 additions and 164 deletions

View File

@@ -1,7 +1,5 @@
<?php
use internals\modules\ProjectLawful;
require_once 'website.php';
class Modules
@@ -19,6 +17,7 @@ class Modules
/** @var Highscores|null */ private $highscores = null;
/** @var SelfTest|null */ private $selftest = null;
/** @var ProjectLawful|null */ private $projectlawful = null;
/** @var EbookHistory|null */ private $ebookhistory = null;
/** @var Website */
private $site;
@@ -105,4 +104,10 @@ class Modules
if ($this->projectlawful === null) { require_once 'modules/projectlawful.php'; $this->projectlawful = new ProjectLawful($this->site); }
return $this->projectlawful;
}
public function EbookHistory(): EbookHistory
{
if ($this->ebookhistory === null) { require_once 'modules/ebookhistory.php'; $this->ebookhistory = new EbookHistory($this->site); }
return $this->ebookhistory;
}
}

View File

@@ -0,0 +1,36 @@
<?php
class EbookHistory implements IWebsiteModule
{
/** @var Website */
private $site;
public function __construct(Website $site)
{
$this->site = $site;
}
public function dir(): string
{
return __DIR__ . '/../../dynamic/ehr/';
}
public function checkConsistency(): array
{
$fn = $this->dir().'/snippet.html';
if (!file_exists($fn)) return ['result'=>'err', 'message' => 'File not found: ' . $fn];
if (filemtime($fn) < time()-(10*24*60*60)) return ['result'=>'warn', 'message' => 'Rendered data is older than 10 days'];
return ['result' => 'ok', 'message' => ''];
}
public function get(): string
{
$fn = $this->dir().'/snippet.html';
if (!file_exists($fn)) return '';
return file_get_contents($fn);
}
}

View File

@@ -1,11 +1,5 @@
<?php
namespace internals\modules;
use IWebsiteModule;
use PDO;
use Throwable;
use Website;
class ProjectLawful implements IWebsiteModule
{
/** @var Website */

View File

@@ -31,6 +31,7 @@ class SelfTest implements IWebsiteModule
'modules::webapps' => 'Webapps (data)',
'modules::highscores' => 'Highscores (data)',
'modules::projectlawful' => 'ProjectLawful-ebook (files)',
'modules::ebookhistory' => 'eBook History (data)',
'egg::db-check' => 'ExtendedGitGraph (db-check)',
'backend::git' => 'Git Repository',
];
@@ -120,6 +121,7 @@ class SelfTest implements IWebsiteModule
$this->addCheckConsistency("modules::webapps::webapps-check-consistency", function(){ return Website::inst()->modules->WebApps(); });
$this->addCheckConsistency("modules::highscores::highscores-check-consistency", function(){ return Website::inst()->modules->Highscores(); });
$this->addCheckConsistency("modules::projectlawful::projectlawful-check-consistency", function(){ return Website::inst()->modules->ProjectLawful(); });
$this->addCheckConsistency("modules::ebookhistory::ebookhistory-check-consistency", function(){ return Website::inst()->modules->EbookHistory(); });
$this->addLambdaStatus("egg::db-check::check-db-consistency", function(){ return Website::inst()->modules->ExtendedGitGraph()->checkDatabaseConsistency(); });

View File

@@ -292,9 +292,11 @@ function curl_http_request($url)
return [ 'output'=>$output, 'statuscode'=>$httpcode, 'redirect'=>$redirect, 'errnum'=>$errnum, 'errstr'=>$errmsg ];
}
function array_last(array $arr)
{
return $arr[count($arr)-1];
if (!function_exists('array_last')) {
function array_last(array $arr)
{
return $arr[count($arr)-1];
}
}
function explode_allow_empty(string $separator, string $str): array {