Port the code to PHP 8.5.
Replace the short open tags and the removed functions (mcrypt, mysql_error, salt-less crypt). Decode the reCAPTCHA reply as JSON, turn off mysqli exceptions, drop stripslashes(), and default missing input values. Fix the misplaced continue in prune_images().
This commit is contained in:
+13
-11
@@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
if ( ! isset($_SERVER['HTTPS'])) {
|
||||
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI']);
|
||||
}
|
||||
@@ -14,20 +14,22 @@ if (isset($_SESSION['editor'])) {
|
||||
$table = "editors";
|
||||
open_db('open');
|
||||
|
||||
$username = $db->real_escape_string($_POST['username']);
|
||||
$username = $db->real_escape_string($_POST['username'] ?? '');
|
||||
$query = "SELECT * FROM $table WHERE ".
|
||||
"username LIKE '".$username."' ".
|
||||
"LIMIT 1;";
|
||||
$getid = $db->query($query) or die("Query failed: ".$db->error());
|
||||
$getid = $db->query($query) or die("Query failed: ".$db->error);
|
||||
$row = $getid->fetch_assoc();
|
||||
|
||||
if (isset($row))
|
||||
$stored_password = '';
|
||||
if (isset($row))
|
||||
$stored_password = $row['password'];
|
||||
else $denied = TRUE;
|
||||
$getid->close();
|
||||
open_db('close');
|
||||
$compare_password = $_POST['password'];
|
||||
if (crypt($compare_password, $stored_password) != $stored_password) {
|
||||
$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;
|
||||
@@ -65,21 +67,21 @@ if (isset($_SESSION['editor'])) {
|
||||
<script type="text/javascript" src="../utilities.js"></script>
|
||||
<link rel="alternate" type="application/rss+xml" title="xxx.org.za RSS feed" href="/feed" />
|
||||
</head>
|
||||
<? flush(); ?>
|
||||
<?php flush(); ?>
|
||||
<body>
|
||||
<div id="container">
|
||||
<? include_once("../sidebar.inc.php"); ?>
|
||||
<?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="<? echo "https://xxx.org.za".$_SERVER['REQUEST_URI']; ?>" method="post">
|
||||
<form action="<?php echo "https://xxx.org.za".$_SERVER['REQUEST_URI']; ?>" method="post">
|
||||
<div class="grid">
|
||||
|
||||
<label for="username">Username: </label>
|
||||
@@ -108,7 +110,7 @@ if ($denied)
|
||||
</div> <!-- .maintext -->
|
||||
</main> <!-- .main -->
|
||||
</div> <!-- .container -->
|
||||
<? include_once("../bottombar.inc.php"); ?>
|
||||
<?php include_once("../bottombar.inc.php"); ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user