Hide Patrons Circle polls behind login

This commit is contained in:
Alex Cabal 2022-07-09 10:57:11 -05:00
parent dbc2fd5fcd
commit edd032be2c
3 changed files with 32 additions and 23 deletions

View file

@ -283,7 +283,7 @@ Define webroot /standardebooks.org/web
# HTTP Basic Auth configuration for:
# /patrons-circle/downloads
# /feeds
<DirectoryMatch "^${webroot}/www/(patrons-circle/downloads|feeds/(opds|rss|atom).*)">
<DirectoryMatch "^${webroot}/www/(patrons-circle|feeds/(opds|rss|atom))">
AuthType Basic
AuthName "Enter your Patrons Circle email address and leave the password empty."
Require valid-user
@ -307,8 +307,8 @@ Define webroot /standardebooks.org/web
"
</DirectoryMatch>
# Specific config for /patrons-circle
<DirectoryMatch "^${webroot}/www/patrons-circle">
# Specific config for /patrons-circle/downloads
<DirectoryMatch "^${webroot}/www/patrons-circle/downloads">
<FilesMatch "\.php$">
# Disable HTTP Basic auth for the index and 401 pages
Require all granted
@ -320,7 +320,7 @@ Define webroot /standardebooks.org/web
</DirectoryMatch>
# Specific config for /feeds
<DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom).*">
<DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom)">
ErrorDocument 401 /feeds/401
<FilesMatch "^(style\.php|new-releases\.xml|index\.php|index\.xml)$">

View file

@ -265,7 +265,7 @@ Define webroot /standardebooks.org/web
# HTTP Basic Auth configuration for:
# /patrons-circle/downloads
# /feeds
<DirectoryMatch "^${webroot}/www/(patrons-circle/downloads|feeds/(opds|rss|atom).*)">
<DirectoryMatch "^${webroot}/www/(patrons-circle|feeds/(opds|rss|atom))">
AuthType Basic
AuthName "Enter your Patrons Circle email address and leave the password empty."
Require valid-user
@ -289,8 +289,8 @@ Define webroot /standardebooks.org/web
"
</DirectoryMatch>
# Specific config for /patrons-circle
<DirectoryMatch "^${webroot}/www/patrons-circle">
# Specific config for /patrons-circle/downloads
<DirectoryMatch "^${webroot}/www/patrons-circle/downloads">
<FilesMatch "\.php$">
# Disable HTTP Basic auth for the index and 401 pages
Require all granted
@ -302,7 +302,7 @@ Define webroot /standardebooks.org/web
</DirectoryMatch>
# Specific config for /feeds
<DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom).*">
<DirectoryMatch "^${webroot}/www/feeds/(opds|rss|atom)">
ErrorDocument 401 /feeds/401
<FilesMatch "^(style\.php|new-releases\.xml|index\.php|index\.xml)$">

View file

@ -5,7 +5,16 @@ use function Safe\session_unset;
session_start();
$vote = $_SESSION['vote'] ?? new PollVote();
$vote = new PollVote();
if(isset($_SESSION['vote'])){
$vote = $_SESSION['vote'];
}
else{
$vote->User = new User();
$vote->User->Email = $_SERVER['PHP_AUTH_USER'] ?? null;
}
$exception = $_SESSION['exception'] ?? null;
$poll = new Poll();
@ -29,24 +38,24 @@ if($exception){
<?= Template::Error(['exception' => $exception]) ?>
<form method="post" action="<?= Formatter::ToPlainText($poll->Url) ?>/votes">
<label class="email">Your email address
<input type="email" name="email" value="<? if($vote->User !== null){ ?><?= Formatter::ToPlainText($vote->User->Email) ?><? } ?>" maxlength="80" required="required" />
<input type="email" name="email" value="<? if($vote->User !== null){ ?><?= Formatter::ToPlainText($vote->User->Email) ?><? } ?>" maxlength="80" required="required" readonly="readonly" />
</label>
<fieldset>
<p>Select one of these options</p>
<ul>
<? foreach($poll->PollItems as $pollItem){ ?>
<li>
<label class="checkbox">
<input type="radio" value="<?= $pollItem->PollItemId ?>" name="pollitemid" required="required"<? if($vote->PollItemId == $pollItem->PollItemId){ ?> checked="checked"<? } ?>/>
<span>
<b><?= Formatter::ToPlainText($pollItem->Name) ?></b>
<? if($pollItem->Description !== null){ ?>
<span><?= Formatter::ToPlainText($pollItem->Description) ?></span>
<? } ?>
</span>
</label>
</li>
<? } ?>
<? foreach($poll->PollItems as $pollItem){ ?>
<li>
<label class="checkbox">
<input type="radio" value="<?= $pollItem->PollItemId ?>" name="pollitemid" required="required"<? if($vote->PollItemId == $pollItem->PollItemId){ ?> checked="checked"<? } ?>/>
<span>
<b><?= Formatter::ToPlainText($pollItem->Name) ?></b>
<? if($pollItem->Description !== null){ ?>
<span><?= Formatter::ToPlainText($pollItem->Description) ?></span>
<? } ?>
</span>
</label>
</li>
<? } ?>
</ul>
</fieldset>
<button>Vote</button>