116 lines
3.3 KiB
PHP
116 lines
3.3 KiB
PHP
<?php
|
|
if ( ! isset($_SERVER['HTTPS'])) {
|
|
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI']);
|
|
}
|
|
require_once("../session.lib.php");
|
|
$denied = NULL;
|
|
$is_admin = NULL;
|
|
if (isset($_SESSION['editor'])) {
|
|
session_write_close();
|
|
header("Location: https://xxx.org.za/publish/edit");
|
|
return;
|
|
} else if (isset($_POST['login'])) {
|
|
include_once('../open_db.lib.php');
|
|
$table = "editors";
|
|
open_db('open');
|
|
|
|
$username = (string)($_POST['username'] ?? '');
|
|
$query = "SELECT * FROM $table WHERE username LIKE ? LIMIT 1";
|
|
$getid = $db->execute_query($query, array($username)) or die("Query failed: ".$db->error);
|
|
$row = $getid->fetch_assoc();
|
|
|
|
$stored_password = '';
|
|
if (isset($row))
|
|
$stored_password = $row['password'];
|
|
else $denied = TRUE;
|
|
$getid->close();
|
|
open_db('close');
|
|
$compare_password = $_POST['password'] ?? '';
|
|
// password_verify() also accepts hashes made by the old crypt() call
|
|
if (!password_verify($compare_password, $stored_password)) {
|
|
$denied = TRUE;
|
|
} else {
|
|
$_SESSION['editor'] = $username;
|
|
// Keep user logged in with cookie, if they request it
|
|
if (isset($_POST['remember'])) {
|
|
create_persistent_login($username);
|
|
}
|
|
if (isset($_SESSION['referrer'])) {
|
|
$url = $_SERVER['HTTPS'] ? "https://" : "http://";
|
|
$url .= $_SERVER['HTTP_HOST'];
|
|
$url .= $_SESSION['referrer'];
|
|
unset($_SESSION['referrer']);
|
|
session_write_close();
|
|
header("Location: $url");
|
|
return;
|
|
} else {
|
|
session_write_close();
|
|
header("Location: https://xxx.org.za/publish/edit");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>x.x.x [login]</title>
|
|
<link rel="icon" href="favicon.png" />
|
|
<link rel="shortcut icon" href="favicon.png" />
|
|
<link rel="stylesheet" type="text/css" href="../style.css" />
|
|
<link rel='stylesheet' type='text/css' href='../publish/style.css' />
|
|
<script type="text/javascript" src="../utilities.js"></script>
|
|
<link rel="alternate" type="application/rss+xml" title="xxx.org.za RSS feed" href="/feed" />
|
|
</head>
|
|
<?php flush(); ?>
|
|
<body>
|
|
<div id="container">
|
|
<?php include_once("../sidebar.inc.php"); ?>
|
|
<main id="main">
|
|
<div id="maintext">
|
|
|
|
<H1>editor login</H1>
|
|
|
|
<?php
|
|
if ($denied)
|
|
echo "<p><strong>Access denied. Please try again.</strong></p>\n";
|
|
?>
|
|
|
|
<form action="<?php echo form_value("https://xxx.org.za".$_SERVER['REQUEST_URI']); ?>" method="post">
|
|
<div class="grid">
|
|
|
|
<label for="username">Username: </label>
|
|
<div class="rightcolumn">
|
|
<input type="text" id="username" name="username" />
|
|
</div>
|
|
|
|
<label for="password">Password: </label>
|
|
<div class="rightcolumn">
|
|
<input type="password" id="password" name="password" />
|
|
</div>
|
|
|
|
<label for="remember">Remember me:</label>
|
|
<div class="rightcolumn">
|
|
<input type="checkbox" id="remember" name="remember" checked />
|
|
</div>
|
|
|
|
<div class="leftcolumn"></div>
|
|
<div class="submission">
|
|
<button type="submit" id="login" name="login" value="1">Login</button>
|
|
</div>
|
|
|
|
</div><!-- .grid -->
|
|
</form>
|
|
|
|
</div> <!-- .maintext -->
|
|
</main> <!-- .main -->
|
|
</div> <!-- .container -->
|
|
<?php include_once("../bottombar.inc.php"); ?>
|
|
|
|
</body>
|
|
</html>
|
|
|