1
0

Added ProjectLawful-ebook downloads (blog::29)
All checks were successful
Build Docker and Deploy / Build Docker (push) Successful in 1m18s
Build Docker and Deploy / Deploy to Server (push) Successful in 27s

This commit is contained in:
2023-09-11 19:59:07 +02:00
parent f7688a224b
commit 300992b49f
49 changed files with 689 additions and 84 deletions

View File

@@ -75,6 +75,14 @@ class Fragments
]);
}
public function BlogviewHTML(array $blogpost)
{
return $this->evalFragment('BlogviewHTML', 'blogview_html.php',
[
'blogpost' => $blogpost,
]);
}
public function BlogviewEulerList(array $blogpost)
{
return $this->evalFragment('BlogviewEulerList', 'blogview_euler_list.php',

View File

@@ -1,5 +1,7 @@
<?php
use internals\modules\ProjectLawful;
require_once 'website.php';
class Modules
@@ -15,7 +17,8 @@ class Modules
/** @var WebApps|null */ private $webapps = null;
/** @var MikescherGitGraph|null */ private $extendedgitgraph = null;
/** @var Highscores|null */ private $highscores = null;
/** @var SelfTest|null */ private $selftest = null;
/** @var SelfTest|null */ private $selftest = null;
/** @var ProjectLawful|null */ private $projectlawful = null;
/** @var Website */
private $site;
@@ -91,9 +94,15 @@ class Modules
return $this->highscores;
}
public function SelfTest(): SelfTest
{
if ($this->selftest === null) { require_once 'modules/selftest.php'; $this->selftest = new SelfTest(); }
return $this->selftest;
}
public function SelfTest(): SelfTest
{
if ($this->selftest === null) { require_once 'modules/selftest.php'; $this->selftest = new SelfTest(); }
return $this->selftest;
}
public function ProjectLawful(): ProjectLawful
{
if ($this->projectlawful === null) { require_once 'modules/projectlawful.php'; $this->projectlawful = new ProjectLawful($this->site); }
return $this->projectlawful;
}
}

View File

@@ -118,9 +118,13 @@ class Blog implements IWebsiteModule
if (!file_exists($post['file_fragment'])) return ['result'=>'err', 'message' => 'Fragment not found ' . $post['fragment']];
} else if ($post['type'] === 'plain') {
} else if ($post['type'] === 'plain') {
if (!file_exists($post['file_fragment'])) return ['result'=>'err', 'message' => 'Fragment not found ' . $post['fragment']];
if (!file_exists($post['file_fragment'])) return ['result'=>'err', 'message' => 'Fragment not found ' . $post['fragment']];
} else if ($post['type'] === 'html') {
if (!file_exists($post['file_fragment'])) return ['result'=>'err', 'message' => 'Fragment not found ' . $post['fragment']];
} else if ($post['type'] === 'euler') {

View File

@@ -0,0 +1,76 @@
<?php
namespace internals\modules;
use IWebsiteModule;
use PDO;
use Throwable;
use Website;
class ProjectLawful implements IWebsiteModule
{
/** @var Website */
private $site;
public $variants = [
'avatars-moreinfo' => 'project-lawful-avatars-moreinfo.epub',
'avatars' => 'project-lawful-avatars.epub',
'biggerhtml' => 'project-lawful-biggerhtml.epub',
'inline' => 'project-lawful-inline.epub',
'moreinfo' => 'project-lawful-moreinfo.epub',
'onlymainstory-avatars-moreinfo' => 'project-lawful-onlymainstory-avatars-moreinfo.epub',
'onlymainstory-avatars' => 'project-lawful-onlymainstory-avatars.epub',
'onlymainstory-biggerhtml' => 'project-lawful-onlymainstory-biggerhtml.epub',
'onlymainstory-inline' => 'project-lawful-onlymainstory-inline.epub',
'onlymainstory-moreinfo' => 'project-lawful-onlymainstory-moreinfo.epub',
'sfw-avatars-moreinfo' => 'project-lawful-sfw-avatars-moreinfo.epub',
'sfw-avatars' => 'project-lawful-sfw-avatars.epub',
'sfw-biggerhtml' => 'project-lawful-sfw-biggerhtml.epub',
'sfw-inline' => 'project-lawful-sfw-inline.epub',
'sfw-moreinfo' => 'project-lawful-sfw-moreinfo.epub',
];
public function __construct(Website $site)
{
$this->site = $site;
}
public function insertDownload($variant)
{
try
{
$this->site->modules->Database()->sql_query_assoc_prep('INSERT INTO projectlawful_downloadcounter (variant, ip, useragent) VALUES (:vr, :ip, :ua)',
[
[':vr', $variant, PDO::PARAM_STR],
[':ip', get_client_ip(), PDO::PARAM_STR],
[':ua', $_SERVER['HTTP_USER_AGENT'] ?? '', PDO::PARAM_STR],
]);
return true;
}
catch (Throwable $t)
{
return false;
}
}
public function listDownloadCounts()
{
return $this->site->modules->Database()->sql_query_assoc('SELECT variant, COUNT(*) AS `count` FROM projectlawful_downloadcounter GROUP BY variant ORDER BY variant');
}
public function variantExists(string $variant)
{
return isset($this->variants[$variant]);
}
public function checkConsistency()
{
foreach ($this->variants as $key => $val) {
$fn = __DIR__ . '/../../data/projectlawful/'.$val;
if (!file_exists($fn)) {
return ['result'=>'err', 'message' => 'File not found: ' . $fn];
}
}
return ['result' => 'ok', 'message' => ''];
}
}

View File

@@ -8,30 +8,31 @@ class SelfTest implements IWebsiteModule
private const DISPLAY_NAMES =
[
'web::main' => 'Website (http)',
'web::programs' => 'Programs (http)',
'web::programs-ext' => 'Programs (links)',
'web::programs-dl' => 'Programs (download)',
'web::books' => 'Books (http)',
'web::blog' => 'Blog (http)',
'web::webapps' => 'WebApps (http)',
'web::euler' => 'Project Euler (http)',
'web::aoc' => 'Advent of Code (http)',
'api::default' => 'API',
'api::highscore' => 'Highscores API',
'modules::database' => 'Database',
'modules::blog' => 'Blog (data)',
'modules::euler' => 'Project Euler (data)',
'modules::books' => 'Books (data)',
'modules::extgitgraph' => 'ExtendedGitGraph (data)',
'modules::programs' => 'Programs (data)',
'modules::adventofcode' => 'Advent of Code (data)',
'modules::anstatistics' => 'AlephNote Stats (data)',
'modules::updateslog' => 'Program Updates (data)',
'modules::webapps' => 'Webapps (data)',
'modules::highscores' => 'Highscores (data)',
'egg::db-check' => 'ExtendedGitGraph (db-check)',
'backend::git' => 'Git Repository',
'web::main' => 'Website (http)',
'web::programs' => 'Programs (http)',
'web::programs-ext' => 'Programs (links)',
'web::programs-dl' => 'Programs (download)',
'web::books' => 'Books (http)',
'web::blog' => 'Blog (http)',
'web::webapps' => 'WebApps (http)',
'web::euler' => 'Project Euler (http)',
'web::aoc' => 'Advent of Code (http)',
'api::default' => 'API',
'api::highscore' => 'Highscores API',
'modules::database' => 'Database',
'modules::blog' => 'Blog (data)',
'modules::euler' => 'Project Euler (data)',
'modules::books' => 'Books (data)',
'modules::extgitgraph' => 'ExtendedGitGraph (data)',
'modules::programs' => 'Programs (data)',
'modules::adventofcode' => 'Advent of Code (data)',
'modules::anstatistics' => 'AlephNote Stats (data)',
'modules::updateslog' => 'Program Updates (data)',
'modules::webapps' => 'Webapps (data)',
'modules::highscores' => 'Highscores (data)',
'modules::projectlawful' => 'ProjectLawful-ebook (files)',
'egg::db-check' => 'ExtendedGitGraph (db-check)',
'backend::git' => 'Git Repository',
];
private $methods = [];
@@ -51,9 +52,9 @@ class SelfTest implements IWebsiteModule
$this->addMethodPathStatus("web::main::about-2", 200, '/msmain/about');
$this->addMethodPathStatus("web::main::login-1", 200, '/login');
$this->addMethodPathStatus("web::main::404-1", 404, '/asdf');
$this->addHTTPSRedirect( "web::main::redirect-1", '');
$this->addHTTPSRedirect( "web::main::redirect-2", '/about');
$this->addHTTPSRedirect( "web::main::redirect-3", '/about');
$this->addHTTPSRedirect( "web::main::redirect-1", '');
$this->addHTTPSRedirect( "web::main::redirect-2", '/about');
$this->addHTTPSRedirect( "web::main::redirect-3", '/about');
$this->addMethodPathStatus( "web::programs::programs-list-1", 200, '/programs');
$this->addMethodPathStatus( "web::programs::programs-list-2", 200, '/programs/index');
@@ -106,18 +107,19 @@ class SelfTest implements IWebsiteModule
$this->addMethodMultiPathStatus("web::aoc::aoc-redirect-1", 302, '{0}', function(){ return array_key_map(Website::inst()->modules->AdventOfCode()->listAllDays(), 'url-alternative'); });
$this->addMethodMultiPathStatus("web::aoc::aoc-redirect-1", 302, '/adventofcode/{0}', function(){ return Website::inst()->modules->AdventOfCode()->listYears(); });
$this->addCheckConsistency("modules::database::database-check-consistency", function(){ return Website::inst()->modules->Database(); });
$this->addCheckConsistency("modules::blog::blog-check-consistency", function(){ return Website::inst()->modules->Blog(); });
$this->addCheckConsistency("modules::euler::euler-check-consistency", function(){ return Website::inst()->modules->Euler(); });
$this->addCheckConsistency("modules::books::books-check-consistency", function(){ return Website::inst()->modules->Books(); });
$this->addCheckConsistency("modules::extgitgraph::extgitgraph-check-consistency", function(){ return Website::inst()->modules->ExtendedGitGraph(); });
$this->addCheckConsistency("modules::programs::programs-check-consistency", function(){ return Website::inst()->modules->Programs(); });
$this->addCheckConsistency("modules::books::books-check-consistency", function(){ return Website::inst()->modules->Books(); });
$this->addCheckConsistency("modules::adventofcode::adventofcode-check-consistency", function(){ return Website::inst()->modules->AdventOfCode(); });
$this->addCheckConsistency("modules::anstatistics::anstatistics-check-consistency", function(){ return Website::inst()->modules->AlephNoteStatistics(); });
$this->addCheckConsistency("modules::updateslog::updateslog-check-consistency", function(){ return Website::inst()->modules->UpdatesLog(); });
$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::database::database-check-consistency", function(){ return Website::inst()->modules->Database(); });
$this->addCheckConsistency("modules::blog::blog-check-consistency", function(){ return Website::inst()->modules->Blog(); });
$this->addCheckConsistency("modules::euler::euler-check-consistency", function(){ return Website::inst()->modules->Euler(); });
$this->addCheckConsistency("modules::books::books-check-consistency", function(){ return Website::inst()->modules->Books(); });
$this->addCheckConsistency("modules::extgitgraph::extgitgraph-check-consistency", function(){ return Website::inst()->modules->ExtendedGitGraph(); });
$this->addCheckConsistency("modules::programs::programs-check-consistency", function(){ return Website::inst()->modules->Programs(); });
$this->addCheckConsistency("modules::books::books-check-consistency", function(){ return Website::inst()->modules->Books(); });
$this->addCheckConsistency("modules::adventofcode::adventofcode-check-consistency", function(){ return Website::inst()->modules->AdventOfCode(); });
$this->addCheckConsistency("modules::anstatistics::anstatistics-check-consistency", function(){ return Website::inst()->modules->AlephNoteStatistics(); });
$this->addCheckConsistency("modules::updateslog::updateslog-check-consistency", function(){ return Website::inst()->modules->UpdatesLog(); });
$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->addLambdaStatus("egg::db-check::check-db-consistency", function(){ return Website::inst()->modules->ExtendedGitGraph()->checkDatabaseConsistency(); });