The source for my password-protected readings site (without the readings, of course)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

71 lines
2.3 KiB

<?php
function showForm($error="Please sign in") {
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Course Readings: Sign in</title>
<link rel="stylesheet" href="https://unpkg.com/purecss@2.0.3/build/pure-min.css" integrity="sha384-cg6SkqEOCV1NbJoCu11+bm0NvBRc8IYLRGXkmNrqUBfTjmMYwNKPWBTIKyw9mHNJ" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/purecss@2.0.3/build/grids-responsive-min.css" /> </head>
<body>
<div class="pure-g">
<div class="pure-u-1">
<div style="padding: 2em">
<div class="pure-g" style="margin: 5em 0;">
<div class="pure-u-1 pure-u-md-1-3"></div>
<div class="pure-u-1 pure-u-md-1-3">
<form class="pure-form pure-form-stacked" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>
<legend><?php echo $error; ?></legend>
<label for="pass">Password</label>
<input type="password" id="password" name="password" placeholder="Password" />
<button type="submit" class="pure-button pure-button-primary">Sign in</button>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="pure-g">
<div class="pure-u-1">
<div style="text-align: right; padding: 2em;">
<small>
All readings here remain copyright of their original publishers, and
are reproduced here only for the use of my students.
<br>
All non-reading content is copyright 2017&ndash;2020 Charles H. Pence,
<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">CC-BY-NC-SA 3.0.</a>
</small>
</div>
</div>
</div>
</body>
</html>
<?php
}
// Boy, you sure should not attempt to force this cipher if you want to read
// some of these readings, no sir
$PasswordHash = "3750c667d5cd8aecc0a9213b362066e9";
if (isset($_POST['password'])) {
$pass = $_POST['password'];
if (md5($pass) != $PasswordHash) {
showForm("Incorrect password, please try again");
exit();
}
} else {
showForm();
exit();
}
?>