Change 'timestamp' properties on objects to more descriptive names

This commit is contained in:
Alex Cabal 2022-06-29 17:19:28 -05:00
parent 18f761929a
commit dbefba6b94
32 changed files with 74 additions and 74 deletions

View file

@ -7,7 +7,7 @@ CREATE TABLE `NewsletterSubscribers` (
`IsConfirmed` tinyint(1) unsigned NOT NULL DEFAULT 0,
`IsSubscribedToNewsletter` tinyint(1) unsigned NOT NULL DEFAULT 1,
`IsSubscribedToSummary` tinyint(1) unsigned NOT NULL DEFAULT 1,
`Timestamp` datetime NOT NULL,
`Created` datetime NOT NULL,
PRIMARY KEY (`NewsletterSubscriberId`),
UNIQUE KEY `Uuid_UNIQUE` (`Uuid`),
UNIQUE KEY `Email_UNIQUE` (`Email`)

View file

@ -3,8 +3,8 @@ CREATE TABLE `Patrons` (
`IsAnonymous` tinyint(1) unsigned NOT NULL DEFAULT 0,
`AlternateName` varchar(80) DEFAULT NULL,
`IsSubscribedToEmails` tinyint(1) NOT NULL DEFAULT 1,
`Timestamp` datetime NOT NULL,
`DeactivatedTimestamp` datetime DEFAULT NULL,
`Created` datetime NOT NULL,
`Ended` datetime DEFAULT NULL,
PRIMARY KEY (`UserId`),
KEY `index2` (`IsAnonymous`,`DeactivatedTimestamp`)
KEY `index2` (`IsAnonymous`,`Ended`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View file

@ -1,12 +1,12 @@
CREATE TABLE `Payments` (
`PaymentId` int(10) unsigned NOT NULL AUTO_INCREMENT,
`UserId` int(10) unsigned DEFAULT NULL,
`Timestamp` datetime NOT NULL,
`Created` datetime NOT NULL,
`ChannelId` tinyint(4) unsigned NOT NULL,
`TransactionId` varchar(80) NOT NULL,
`Amount` decimal(7,2) unsigned NOT NULL,
`Fee` decimal(7,2) unsigned NOT NULL DEFAULT 0.00,
`IsRecurring` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`PaymentId`),
KEY `index2` (`UserId`,`Amount`,`Timestamp`,`IsRecurring`)
KEY `index2` (`UserId`,`Amount`,`Created`,`IsRecurring`)
) ENGINE=InnoDB AUTO_INCREMENT=828 DEFAULT CHARSET=utf8mb4;

View file

@ -1,5 +1,5 @@
CREATE TABLE `PendingPayments` (
`Timestamp` datetime NOT NULL,
`Created` datetime NOT NULL,
`ChannelId` tinyint(4) unsigned NOT NULL,
`TransactionId` varchar(80) NOT NULL,
`ProcessedOn` datetime DEFAULT NULL

View file

@ -2,7 +2,7 @@ CREATE TABLE `Users` (
`UserId` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Email` varchar(80) DEFAULT NULL,
`Name` varchar(255) DEFAULT NULL,
`Timestamp` datetime NOT NULL,
`Created` datetime NOT NULL,
`Uuid` char(36) NOT NULL,
PRIMARY KEY (`UserId`),
UNIQUE KEY `idxEmail` (`Email`)

View file

@ -21,7 +21,7 @@ class AtomFeed extends Feed{
protected function GetXmlString(): string{
if($this->XmlString === null){
$feed = Template::AtomFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'subtitle' => $this->Subtitle, 'updatedTimestamp' => $this->Updated, 'entries' => $this->Entries]);
$feed = Template::AtomFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'subtitle' => $this->Subtitle, 'updated' => $this->Updated, 'entries' => $this->Entries]);
$this->XmlString = $this->CleanXmlString($feed);
}
@ -47,7 +47,7 @@ class AtomFeed extends Feed{
foreach($this->Entries as $entry){
$obj = new StdClass();
if(is_a($entry, 'Ebook')){
$obj->Updated = $entry->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z');
$obj->Updated = $entry->Modified->format('Y-m-d\TH:i:s\Z');
$obj->Id = SITE_URL . $entry->Url;
}
else{

View file

@ -53,8 +53,8 @@ class Ebook{
public $Contributors = []; // Array of Contributors
public $ContributorsHtml;
public $TitleWithCreditsHtml = '';
public $Timestamp;
public $ModifiedTimestamp;
public $Created;
public $Modified;
public $TextUrl;
public $TextSinglePageUrl;
public $TocEntries = null; // A list of non-Roman ToC entries ONLY IF the work has the 'se:is-a-collection' metadata element, null otherwise
@ -151,7 +151,7 @@ class Ebook{
if(stripos($this->RepoFilesystemPath, '.git') === false){
$gitFolderPath = $gitFolderPath . '/.git';
}
$hash = substr(sha1($this->GitCommits[0]->Timestamp->format('U') . ' ' . $this->GitCommits[0]->Message), 0, 8);
$hash = substr(sha1($this->GitCommits[0]->Created->format('U') . ' ' . $this->GitCommits[0]->Message), 0, 8);
$this->CoverImageUrl = '/images/covers/' . $this->UrlSafeIdentifier . '-' . $hash . '-cover.jpg';
if(file_exists(WEB_ROOT . '/images/covers/' . $this->UrlSafeIdentifier . '-cover.avif')){
$this->CoverImageAvifUrl = '/images/covers/' . $this->UrlSafeIdentifier . '-' . $hash . '-cover.avif';
@ -186,12 +186,12 @@ class Ebook{
$date = $xml->xpath('/package/metadata/dc:date');
if($date !== false && sizeof($date) > 0){
$this->Timestamp = new DateTime((string)$date[0]);
$this->Created = new DateTime((string)$date[0]);
}
$modifiedDate = $xml->xpath('/package/metadata/meta[@property="dcterms:modified"]');
if($modifiedDate !== false && sizeof($modifiedDate) > 0){
$this->ModifiedTimestamp = new DateTime((string)$modifiedDate[0]);
$this->Modified = new DateTime((string)$modifiedDate[0]);
}
// Get SE tags

View file

@ -2,12 +2,12 @@
use Safe\DateTimeImmutable;
class GitCommit{
public $Timestamp;
public $Created;
public $Message;
public $Hash;
public function __construct(string $unixTimestamp, string $hash, string $message){
$this->Timestamp = new DateTimeImmutable('@' . $unixTimestamp);
$this->Created = new DateTimeImmutable('@' . $unixTimestamp);
$this->Message = $message;
$this->Hash = $hash;
}

View file

@ -50,10 +50,10 @@ class Library{
case SORT_NEWEST:
usort($matches, function($a, $b){
if($a->Timestamp < $b->Timestamp){
if($a->Created < $b->Created){
return -1;
}
elseif($a->Timestamp == $b->Timestamp){
elseif($a->Created == $b->Created){
return 0;
}
else{

View file

@ -11,7 +11,7 @@ class NewsletterSubscriber extends PropertiesBase{
public $IsConfirmed = false;
public $IsSubscribedToSummary = true;
public $IsSubscribedToNewsletter = true;
public $Timestamp;
public $Created;
protected $Url = null;
protected function GetUrl(): string{
@ -27,10 +27,10 @@ class NewsletterSubscriber extends PropertiesBase{
$uuid = Uuid::uuid4();
$this->Uuid = $uuid->toString();
$this->Timestamp = new DateTime();
$this->Created = new DateTime();
try{
Db::Query('INSERT into NewsletterSubscribers (Email, Uuid, FirstName, LastName, IsConfirmed, IsSubscribedToNewsletter, IsSubscribedToSummary, Timestamp) values (?, ?, ?, ?, ?, ?, ?, ?);', [$this->Email, $this->Uuid, $this->FirstName, $this->LastName, false, $this->IsSubscribedToNewsletter, $this->IsSubscribedToSummary, $this->Timestamp]);
Db::Query('INSERT into NewsletterSubscribers (Email, Uuid, FirstName, LastName, IsConfirmed, IsSubscribedToNewsletter, IsSubscribedToSummary, Created) values (?, ?, ?, ?, ?, ?, ?, ?);', [$this->Email, $this->Uuid, $this->FirstName, $this->LastName, false, $this->IsSubscribedToNewsletter, $this->IsSubscribedToSummary, $this->Created]);
}
catch(PDOException $ex){
if($ex->errorInfo[1] == 1062){

View file

@ -11,7 +11,7 @@ class OpdsAcquisitionFeed extends OpdsFeed{
protected function GetXmlString(): string{
if($this->XmlString === null){
$this->XmlString = $this->CleanXmlString(Template::OpdsAcquisitionFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updatedTimestamp' => $this->Updated, 'isCrawlable' => $this->IsCrawlable, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries]));
$this->XmlString = $this->CleanXmlString(Template::OpdsAcquisitionFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updated' => $this->Updated, 'isCrawlable' => $this->IsCrawlable, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries]));
}
return $this->XmlString;

View file

@ -11,24 +11,24 @@ class OpdsFeed extends AtomFeed{
$this->Stylesheet = '/feeds/opds/style';
}
protected function SaveUpdatedTimestamp(string $entryId, DateTime $updatedTimestamp): void{
protected function SaveUpdated(string $entryId, DateTime $updated): void{
// Only save the updated timestamp for the given entry ID in this file
foreach($this->Entries as $entry){
if(is_a($entry, 'OpdsNavigationEntry')){
if($entry->Id == SITE_URL . $entryId){
$entry->Updated = $updatedTimestamp;
$entry->Updated = $updated;
}
}
}
$this->Updated = $updatedTimestamp;
$this->Updated = $updated;
$this->XmlString = null;
file_put_contents($this->Path, $this->GetXmlString());
// Do we have any parents of our own to update?
if($this->Parent !== null){
$this->Parent->SaveUpdatedTimestamp($this->Id, $updatedTimestamp);
$this->Parent->SaveUpdated($this->Id, $updated);
}
}
@ -40,7 +40,7 @@ class OpdsFeed extends AtomFeed{
$this->Updated = new DateTime();
if($this->Parent !== null){
$this->Parent->SaveUpdatedTimestamp($this->Id, $this->Updated);
$this->Parent->SaveUpdated($this->Id, $this->Updated);
}
// Save our own file

View file

@ -31,7 +31,7 @@ class OpdsNavigationFeed extends OpdsFeed{
protected function GetXmlString(): string{
if($this->XmlString === null){
$this->XmlString = $this->CleanXmlString(Template::OpdsNavigationFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updatedTimestamp' => $this->Updated, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries]));
$this->XmlString = $this->CleanXmlString(Template::OpdsNavigationFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updated' => $this->Updated, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries]));
}
return $this->XmlString;

View file

@ -7,8 +7,8 @@ class Patron extends PropertiesBase{
public $IsAnonymous;
public $AlternateName;
public $IsSubscribedToEmail;
public $Timestamp = null;
public $DeactivatedTimestamp = null;
public $Created = null;
public $Ended = null;
public static function Get(?int $userId): Patron{
$result = Db::Query('SELECT * from Patrons where UserId = ?', [$userId], 'Patron');
@ -31,9 +31,9 @@ class Patron extends PropertiesBase{
}
public function Create(bool $sendEmail = true): void{
$this->Timestamp = new DateTime();
$this->Created = new DateTime();
Db::Query('INSERT into Patrons (Timestamp, UserId, IsAnonymous, AlternateName, IsSubscribedToEmail) values(?, ?, ?, ?, ?);', [$this->Timestamp, $this->UserId, $this->IsAnonymous, $this->AlternateName, $this->IsSubscribedToEmail]);
Db::Query('INSERT into Patrons (Created, UserId, IsAnonymous, AlternateName, IsSubscribedToEmail) values(?, ?, ?, ?, ?);', [$this->Created, $this->UserId, $this->IsAnonymous, $this->AlternateName, $this->IsSubscribedToEmail]);
if($sendEmail){
$this->SendWelcomeEmail();
@ -41,9 +41,9 @@ class Patron extends PropertiesBase{
}
public function Reactivate(bool $sendEmail = true): void{
Db::Query('UPDATE Patrons set Timestamp = utc_timestamp(), DeactivatedTimestamp = null, IsAnonymous = ?, IsSubscribedToEmail = ?, AlternateName = ? where UserId = ?;', [$this->IsAnonymous, $this->IsSubscribedToEmail, $this->AlternateName, $this->UserId]);
$this->Timestamp = new DateTime();
$this->DeactivatedTimestamp = null;
Db::Query('UPDATE Patrons set Created = utc_timestamp(), Ended = null, IsAnonymous = ?, IsSubscribedToEmail = ?, AlternateName = ? where UserId = ?;', [$this->IsAnonymous, $this->IsSubscribedToEmail, $this->AlternateName, $this->UserId]);
$this->Created = new DateTime();
$this->Ended = null;
if($sendEmail){
$this->SendWelcomeEmail();

View file

@ -4,7 +4,7 @@ class Payment extends PropertiesBase{
public $PaymentId;
protected $User = null;
public $UserId = null;
public $Timestamp;
public $Created;
public $ChannelId;
public $TransactionId;
public $Amount;
@ -33,7 +33,7 @@ class Payment extends PropertiesBase{
}
try{
Db::Query('INSERT into Payments (UserId, Timestamp, ChannelId, TransactionId, Amount, Fee, IsRecurring) values(?, ?, ?, ?, ?, ?, ?);', [$this->UserId, $this->Timestamp, $this->ChannelId, $this->TransactionId, $this->Amount, $this->Fee, $this->IsRecurring]);
Db::Query('INSERT into Payments (UserId, Created, ChannelId, TransactionId, Amount, Fee, IsRecurring) values(?, ?, ?, ?, ?, ?, ?);', [$this->UserId, $this->Created, $this->ChannelId, $this->TransactionId, $this->Amount, $this->Fee, $this->IsRecurring]);
}
catch(PDOException $ex){
if($ex->errorInfo[1] == 1062){

View file

@ -15,7 +15,7 @@ class RssFeed extends Feed{
protected function GetXmlString(): string{
if($this->XmlString === null){
$feed = Template::RssFeed(['url' => $this->Url, 'description' => $this->Description, 'title' => $this->Title, 'entries' => $this->Entries, 'updatedTimestamp' => (new DateTime())->format('r')]);
$feed = Template::RssFeed(['url' => $this->Url, 'description' => $this->Description, 'title' => $this->Title, 'entries' => $this->Entries, 'updated' => (new DateTime())->format('r')]);
$this->XmlString = $this->CleanXmlString($feed);
}

View file

@ -12,7 +12,7 @@ class User extends PropertiesBase{
protected $DisplayName = null;
public $Email;
protected $DisplayEmail;
public $Timestamp;
public $Created;
public $Uuid;
public static function Get(?int $userId): User{
@ -46,10 +46,10 @@ class User extends PropertiesBase{
public function Create(): void{
$uuid = Uuid::uuid4();
$this->Uuid = $uuid->toString();
$this->Timestamp = new DateTime();
$this->Created = new DateTime();
try{
Db::Query('INSERT into Users (Email, Name, Uuid, Timestamp) values (?, ?, ?, ?);', [$this->Email, $this->Name, $this->Uuid, $this->Timestamp]);
Db::Query('INSERT into Users (Email, Name, Uuid, Created) values (?, ?, ?, ?);', [$this->Email, $this->Name, $this->Uuid, $this->Created]);
}
catch(PDOException $ex){
if($ex->errorInfo[1] == 1062){

View file

@ -3,5 +3,5 @@
require_once('/standardebooks.org/web/lib/Core.php');
// Delete unconfirmed newsletter subscribers who are more than a week old
Db::Query('DELETE from NewsletterSubscribers where IsConfirmed = false and datediff(utc_timestamp(), Timestamp) >= 7');
Db::Query('DELETE from NewsletterSubscribers where IsConfirmed = false and datediff(utc_timestamp(), Created) >= 7');
?>

View file

@ -57,8 +57,8 @@ foreach($contentFiles as $path){
$ebook = new Ebook($ebookWwwFilesystemPath);
$allEbooks[$ebook->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
$newestEbooks[$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
$allEbooks[$ebook->Modified->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
$newestEbooks[$ebook->Created->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
foreach($ebook->Tags as $tag){
// Add the book's subjects to the main subjects list
@ -67,7 +67,7 @@ foreach($contentFiles as $path){
}
// Sort this ebook by subject
$ebooksBySubject[$tag->Name][$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
$ebooksBySubject[$tag->Name][$ebook->Created->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
}
}
catch(\Exception $ex){

View file

@ -133,7 +133,7 @@ try{
$payment->User = null;
}
$payment->Timestamp = DateTime::createFromFormat('n/j/Y', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Created On"]]'))->getText()));
$payment->Created = DateTime::createFromFormat('n/j/Y', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Created On"]]'))->getText()));
$payment->TransactionId = trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "ID"]]'))->getText());
$payment->IsRecurring = sizeof($headerRow->findElements(WebDriverBy::xpath('//td[contains(., "Recurring")]'))) > 0;
$payment->Amount = floatval(str_replace('$', '', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Total Amount"]]'))->getText())));
@ -157,7 +157,7 @@ try{
// If this payment isn't anonymous, does it put us in the Patrons Circle?
if($payment->User !== null){
if(($payment->IsRecurring && $payment->Amount >= 10 && $payment->Timestamp >= $lastMonth) || ($payment->Amount >= 100 && $payment->Timestamp >= $lastYear)){
if(($payment->IsRecurring && $payment->Amount >= 10 && $payment->Created >= $lastMonth) || ($payment->Amount >= 100 && $payment->Created >= $lastYear)){
// This payment is eligible for the Patrons Circle.
// Are we already a patron?
try{
@ -170,7 +170,7 @@ try{
$patron->User = $payment->User;
}
if($patron->Timestamp === null || $patron->DeactivatedTimestamp !== null){
if($patron->Created === null || $patron->Ended !== null){
// If we're a new patron, or an old patron that was deactivated,
// re-enable them as a patron in the system
$patron->IsAnonymous = (trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Attribution"]]'))->getText()) == 'Private');
@ -182,11 +182,11 @@ try{
catch(Exception $ex){
}
if($patron->Timestamp === null){
if($patron->Created === null){
$log->Write('Adding donor as patron ...');
$patron->Create();
}
elseif($patron->DeactivatedTimestamp !== null){
elseif($patron->Ended !== null){
$log->Write('Reactivating donor as patron ...');
$patron->Reactivate();
}

View file

@ -8,16 +8,16 @@ require_once('/standardebooks.org/web/lib/Core.php');
Db::Query('
update Patrons
set DeactivatedTimestamp = utc_timestamp()
set Ended = utc_timestamp()
where UserId not in
(
select distinct UserId from Payments where
UserId is not null
and
(
(IsRecurring = 1 and Amount >= 10 and Timestamp > utc_timestamp() - interval 45 day)
(IsRecurring = 1 and Amount >= 10 and Created > utc_timestamp() - interval 45 day)
or
(IsRecurring = 0 and Amount >= 100 and Timestamp > utc_timestamp() - interval 1 year)
(IsRecurring = 0 and Amount >= 100 and Created > utc_timestamp() - interval 1 year)
)
)
');

View file

@ -12,7 +12,7 @@ print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
<title><?= Formatter::ToPlainXmlText($title) ?></title>
<? if($subtitle !== null){ ?><subtitle><?= Formatter::ToPlainXmlText($subtitle) ?></subtitle><? } ?>
<icon><?= SITE_URL ?>/images/logo.png</icon>
<updated><?= $updatedTimestamp->format('Y-m-d\TH:i:s\Z') ?></updated>
<updated><?= $updated->format('Y-m-d\TH:i:s\Z') ?></updated>
<author>
<name>Standard Ebooks</name>
<uri><?= SITE_URL ?></uri>

View file

@ -7,8 +7,8 @@
<uri><?= SITE_URL . Formatter::ToPlainXmlText($entry->AuthorsUrl) ?></uri>
</author>
<? } ?>
<published><?= $entry->Timestamp->format('Y-m-d\TH:i:s\Z') ?></published>
<updated><?= $entry->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z') ?></updated>
<published><?= $entry->Created->format('Y-m-d\TH:i:s\Z') ?></published>
<updated><?= $entry->Modified->format('Y-m-d\TH:i:s\Z') ?></updated>
<rights>Public domain in the United States. Users located outside of the United States must check their local laws before using this ebook. Original content released to the public domain via the Creative Commons CC0 1.0 Universal Public Domain Dedication.</rights>
<summary type="text"><?= Formatter::ToPlainXmlText($entry->Description) ?></summary>
<content type="html"><?= Formatter::ToPlainXmlText($entry->LongDescription) ?></content>

View file

@ -9,7 +9,7 @@ $startDate = new DateTime('2022-07-01');
$endDate = new DateTime('2022-07-31');
$autoHide = $autoHide ?? true;
$showDonateButton = $showDonateButton ?? true;
$current = (Db::Query('SELECT count(*) as PatronCount from Patrons where Timestamp >= ?', [$startDate]))[0]->PatronCount;
$current = (Db::Query('SELECT count(*) as PatronCount from Patrons where Created >= ?', [$startDate]))[0]->PatronCount;
$target = 70;
$stretchCurrent = 0;
$stretchTarget = 20;

View file

@ -11,9 +11,9 @@
<? if($author->NacoafUrl !== null){ ?><schema:sameAs><?= Formatter::ToPlainXmlText($author->NacoafUrl) ?></schema:sameAs><? } ?>
</author>
<? } ?>
<published><?= $entry->Timestamp->format('Y-m-d\TH:i:s\Z') ?></published>
<dc:issued><?= $entry->Timestamp->format('Y-m-d\TH:i:s\Z') ?></dc:issued>
<updated><?= $entry->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z') ?></updated>
<published><?= $entry->Created->format('Y-m-d\TH:i:s\Z') ?></published>
<dc:issued><?= $entry->Created->format('Y-m-d\TH:i:s\Z') ?></dc:issued>
<updated><?= $entry->Modified->format('Y-m-d\TH:i:s\Z') ?></updated>
<dc:language><?= Formatter::ToPlainXmlText($entry->Language) ?></dc:language>
<dc:publisher>Standard Ebooks</dc:publisher>
<rights>Public domain in the United States. Users located outside of the United States must check their local laws before using this ebook. Original content released to the public domain via the Creative Commons CC0 1.0 Universal Public Domain Dedication.</rights>

View file

@ -26,7 +26,7 @@ print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
<title><?= Formatter::ToPlainXmlText($title) ?></title>
<? if($subtitle !== null){ ?><subtitle><?= Formatter::ToPlainXmlText($subtitle) ?></subtitle><? } ?>
<icon><?= SITE_URL ?>/images/logo.png</icon>
<updated><?= $updatedTimestamp->format('Y-m-d\TH:i:s\Z') ?></updated>
<updated><?= $updated->format('Y-m-d\TH:i:s\Z') ?></updated>
<? if($isCrawlable){ ?><fh:complete/><? } ?>
<author>
<name>Standard Ebooks</name>

View file

@ -17,7 +17,7 @@ print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
<title><?= Formatter::ToPlainXmlText($title) ?></title>
<? if($subtitle !== null){ ?><subtitle><?= Formatter::ToPlainXmlText($subtitle) ?></subtitle><? } ?>
<icon><?= SITE_URL ?>/images/logo.png</icon>
<updated><?= $updatedTimestamp->format('Y-m-d\TH:i:s\Z') ?></updated>
<updated><?= $updated->format('Y-m-d\TH:i:s\Z') ?></updated>
<author>
<name>Standard Ebooks</name>
<uri><?= SITE_URL ?></uri>

View file

@ -2,7 +2,7 @@
<title><?= Formatter::ToPlainXmlText($entry->Title) ?>, by <?= Formatter::ToPlainXmlText(strip_tags($entry->AuthorsHtml)) ?></title>
<link><?= SITE_URL . Formatter::ToPlainXmlText($entry->Url) ?></link>
<description><?= Formatter::ToPlainXmlText($entry->Description) ?></description>
<pubDate><?= $entry->Timestamp->format('r') ?></pubDate>
<pubDate><?= $entry->Created->format('r') ?></pubDate>
<guid><?= Formatter::ToPlainXmlText(preg_replace('/^url:/ius', '', $entry->Identifier)) ?></guid>
<? foreach($entry->Tags as $tag){ ?>
<category domain="https://standardebooks.org/vocab/subjects"><?= Formatter::ToPlainXmlText($tag->Name) ?></category>

View file

@ -12,7 +12,7 @@ print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
<description><?= Formatter::ToPlainXmlText($description) ?></description>
<language>en-US</language>
<copyright>https://creativecommons.org/publicdomain/zero/1.0/</copyright>
<lastBuildDate><?= $updatedTimestamp ?></lastBuildDate>
<lastBuildDate><?= $updated ?></lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<atom:link href="<?= SITE_URL . Formatter::ToPlainXmlText($url) ?>" rel="self" type="application/rss+xml"/>
<atom:link href="<?= SITE_URL ?>/ebooks/opensearch" rel="search" type="application/opensearchdescription+xml" />

View file

@ -12,7 +12,7 @@ $patronsCircle = Db::Query('SELECT if(p.AlternateName is not null, p.AlternateNa
on p.UserId = u.UserId
where
p.IsAnonymous = false
and p.DeactivatedTimestamp is null
and p.Ended is null
order by regexp_substr(SortedName, "[\\\p{Lu}][\\\p{L}\-]+$") asc;
');
@ -25,9 +25,9 @@ $anonymousPatronCount = Db::Query('SELECT sum(cnt) as AnonymousPatronCount
UserId is null
and
(
(Amount >= 100 and Timestamp >= utc_timestamp() - interval 1 year)
(Amount >= 100 and Created >= utc_timestamp() - interval 1 year)
or
(Amount >= 10 and IsRecurring = true and Timestamp >= utc_timestamp() - interval 30 day)
(Amount >= 10 and IsRecurring = true and Created >= utc_timestamp() - interval 30 day)
)
)
union all
@ -36,7 +36,7 @@ $anonymousPatronCount = Db::Query('SELECT sum(cnt) as AnonymousPatronCount
where
IsAnonymous = true
and
DeactivatedTimestamp is null
Ended is null
)
) x
')[0]->AnonymousPatronCount;

View file

@ -190,8 +190,8 @@ catch(Exceptions\InvalidEbookException $ex){
<meta property="schema:image" content="<?= Formatter::ToPlainText(SITE_URL . $ebook->DistCoverUrl) ?>"/>
<meta property="schema:thumbnailUrl" content="<?= Formatter::ToPlainText(SITE_URL . $ebook->Url . '/downloads/cover-thumbnail.jpg') ?>"/>
<meta property="schema:inLanguage" content="<?= Formatter::ToPlainText($ebook->Language) ?>"/>
<meta property="schema:datePublished" content="<?= Formatter::ToPlainText($ebook->Timestamp->format('Y-m-d')) ?>"/>
<meta property="schema:dateModified" content="<?= Formatter::ToPlainText($ebook->ModifiedTimestamp->format('Y-m-d')) ?>"/>
<meta property="schema:datePublished" content="<?= Formatter::ToPlainText($ebook->Created->format('Y-m-d')) ?>"/>
<meta property="schema:dateModified" content="<?= Formatter::ToPlainText($ebook->Modified->format('Y-m-d')) ?>"/>
<div property="schema:potentialAction" typeof="http://schema.org/ReadAction">
<meta property="schema:actionStatus" content="http://schema.org/PotentialActionStatus"/>
<div property="schema:target" typeof="schema:EntryPoint">
@ -298,7 +298,7 @@ catch(Exceptions\InvalidEbookException $ex){
<ol>
<? foreach($ebook->GitCommits as $commit){ ?>
<li>
<time datetime="<?= $commit->Timestamp->format(DateTime::RFC3339) ?>"><?= $commit->Timestamp->format('M j, Y') ?></time>
<time datetime="<?= $commit->Created->format(DateTime::RFC3339) ?>"><?= $commit->Created->format('M j, Y') ?></time>
<p><a href="<?= Formatter::ToPlainText($ebook->GitHubUrl) ?>/commit/<?= Formatter::ToPlainText($commit->Hash) ?>"><?= Formatter::ToPlainText($commit->Message) ?></a></p>
</li>
<? } ?>

View file

@ -44,7 +44,7 @@ try{
$payment = new Payment();
$payment->ChannelId = PAYMENT_CHANNEL_FA;
$payment->TransactionId = $transactionId;
$payment->Timestamp = new DateTime();
$payment->Created = new DateTime();
$payment->IsRecurring = stripos($data->subject, 'recurring') !== false;
preg_match('/Amount: \$([\d\.]+)/u', $data->html, $matches);
if(sizeof($matches) == 2){
@ -54,7 +54,7 @@ try{
$payment->Create();
}
else{
Db::Query('INSERT into PendingPayments (Timestamp, ChannelId, TransactionId) values (utc_timestamp(), ?, ?);', [PAYMENT_CHANNEL_FA, $transactionId]);
Db::Query('INSERT into PendingPayments (Created, ChannelId, TransactionId) values (utc_timestamp(), ?, ?);', [PAYMENT_CHANNEL_FA, $transactionId]);
}
$log->Write('Donation ID: ' . $transactionId);