Added ProjectLawful-ebook downloads (blog::29)
This commit is contained in:
@@ -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') {
|
||||
|
||||
|
||||
76
www/internals/modules/projectlawful.php
Normal file
76
www/internals/modules/projectlawful.php
Normal 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' => ''];
|
||||
}
|
||||
}
|
||||
@@ -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(); });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user