Skip to content

Commit

Permalink
alternate login should now work
Browse files Browse the repository at this point in the history
  • Loading branch information
speendo committed May 19, 2012
1 parent 6c48d4b commit 71eff45
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 27 deletions.
3 changes: 3 additions & 0 deletions webscripts/download.php
Expand Up @@ -23,6 +23,9 @@

include("settings.php");

## check passphrase
checkPassPhrase();

$path = decrypt($_GET['path'], $encryptionKey);
$mimeType = $_GET['mimeType'];

Expand Down
44 changes: 32 additions & 12 deletions webscripts/functions.php
Expand Up @@ -117,38 +117,58 @@ function startDownload($path, $mimeType) {
exit();
}

function isPassPhraseCorrect($inputPhrase) {
function isPassPhraseCorrect() {
@$inputPhrase = $_GET['pass'];
include("settings.php");
return $inputPhrase == $passPhrase;
}

function passPhraseForm($completeURL) {
## Don't forget any parameters here!
@$feed = $_GET['feed'];
@$extension = $_GET['ext'];
@$short = $_GET['short'];
@$inputPhrase = $_GET['pass'];

$theURL = parse_url(curPageURL());
$submitURL = $theURL[scheme] . "://" . $theURL[host] . $theURL[path];

$message = "Passphrase incorrect! Please enter correct passphrase!";
if ($inputPhrase == "") {
$message = "Please enter passphrase!";
}

echo("
\"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n
\"http://www.w3.org/TR/html4/strict.dtd\">\n
<html>\n
<head>\n
<title>Eingabefelder für Passwörter</title>\n
<title>Authentication</title>\n
</head>\n
<body>\n
\n
<h1>Nur nicht auf die Tastatur gucken lassen ... :-)</h1>\n
<p>$message</p>\n
\n
<form action=\"$completeURL\" method=\"get\">\n
<p>Kennwort:<br><input name=\"pass\" type=\"password\" size=\"20\" maxlength=\"40\"></p>\n
</form>\n
<form action=\"$submitURL\" method=\"get\">\n
<input type=\"hidden\" name=\"feed\" value=\"$feed\">
<input type=\"hidden\" name=\"ext\" value=\"$ext\">
<input type=\"hidden\" name=\"short\" value=\"$short\">
<p>Passphrase:<br><input name=\"pass\" type=\"text\" value=\"$inputPhrase\" size=\"20\" maxlength=\"40\"></p>\n
\n
<input type=\"submit\" value=\" Submit \">\n
\n
</form>\n
</body>\n
</html>\n
");
}

function checkPassPhrase() {
if (!isPassPhraseCorrect($inputPhrase)) {
$completeURL = curPageURL() . "?feed=" . $feed . "&ext=" . $extension;
passPhraseForm($completeURL);
exit();
if (!isPassPhraseCorrect()) {
passPhraseForm($completeURL);
exit();
}
}

?>
7 changes: 5 additions & 2 deletions webscripts/latest.php
Expand Up @@ -30,12 +30,16 @@
$rssDate = date("r", time());
@$feed = $_GET['feed'];
@$extension = $_GET['ext'];
@$inputPhrase = $_GET['pass'];

###########################################################################
### Computed Variables
###########################################################################
## folderPath
if ($newspaperFolder != "") {
$folderURL = rtrim($newspaperFolder, "/") . "/";
}

## other Variables
if ($feed == "") {
$feed = "*";
$contentFolderPath = $folderPath . $feed . "/";
Expand Down Expand Up @@ -67,7 +71,6 @@

## check passphrase
checkPassPhrase();
}

###########################################################################
### The items in the feed
Expand Down
27 changes: 14 additions & 13 deletions webscripts/rss.php
Expand Up @@ -43,22 +43,25 @@
###########################################################################
### Computed Variables
###########################################################################
## folderPath
if ($newspaperFolder != "") {
$folderURL = rtrim($newspaperFolder, "/") . "/";
}

## other Variables
if ($feed == "") {
$title = "RSS-Feed";
$feed = "*";
$contentFolderPath = $folderPath . $feed . "/";
$contentFolderURL = $folderURL;
$pathLength = strlen($contentFolderPath) - 2;
} else {
$title = ucwords($feed);
$contentFolderPath = realpath($folderPath . $feed . "/") . "/";
$contentFolderURL = $folderURL . $feed . "/";
$pathLength = strlen($contentFolderPath);
if (strpos($contentFolderPath, $folderPath) !== 0) {
$title = "RSS-Feed";
$feed = "*";
$contentFolderPath = $folderPath . $feed . "/";
$contentFolderURL = $folderURL;
$pathLength = strlen($contentFolderPath) - 2;
}
}
Expand All @@ -71,7 +74,7 @@
}

$searchStatement = $contentFolderPath . $extension;
$searchStatementOutput = "Search results for \"" . $folderURL . $feed . "/" . $extension . "\"";
$searchStatementOutput = "Search results for \"" . $feed . "/" . $extension . "\"";
## Mime Type (selected by extension - at the moment just epub)
$mimeType = "application/epub+zip";

Expand All @@ -82,14 +85,17 @@
$compactList = TRUE;
}

## check passphrase
checkPassPhrase();

###########################################################################
### The items in the feed
###########################################################################
$lArticles = array();
$cArticles = 0;

$fileArray = glob($searchStatement);
usort($fileArray, "asc_desc_by_mtime");
usort($fileArray, "sort_desc_by_mtime");

foreach($fileArray as $strFile) {
$cArticles++;
Expand Down Expand Up @@ -129,13 +135,8 @@
}

## Article Link
if (isRestrictedArea) {
$authFolderURL = parse_url($folderURL);
$strLink = $authFolderURL[scheme] . "://" . urlencode($_SERVER['PHP_AUTH_USER']) . ":" . urlencode($_SERVER['PHP_AUTH_PW']) . "@" . $authFolderURL[host] . $authFolderURL[path] . "download.php?path=" . urlencode(encrypt($strFile, $encryptionKey)) . "&amp;mimeType=" . urlencode($mimeType);
} else {
$strLink = $folderURL . "download.php?path=" . urlencode(encrypt($strFile, $encryptionKey)) . "&amp;mimeType=" . urlencode($mimeType);
}

$strLink = $folderURL . "download.php?path=" . urlencode(encrypt($strFile, $encryptionKey)) . "&amp;mimeType=" . urlencode($mimeType);

# The Feeds last update
$rssDate = $strPubDate;
###################################################################
Expand Down Expand Up @@ -207,7 +208,7 @@
###########################################################################
### The feed's heart ;-)
###########################################################################
for ($iArticle = $lastArticle; $iArticle >= $firstArticle; $iArticle--) {
for ($iArticle = $firstArticle; $iArticle <= $lastArticle; $iArticle++) {
echo $lArticles[$iArticle];
}

Expand Down

0 comments on commit 71eff45

Please sign in to comment.