QoL 45: intval and floatval in place of int and float casts and a string cast in place of strval, redirect in place of raw Location headers wherever functions.php is loaded, redirect fallback escapes the URL with json_encode and escapeHtml, escapeHtml for the last htmlspecialchars on a page, and the plain-HTTP cookie notice through flashAlert

This commit is contained in:
johnnyq
2026-11-21 00:20:16 -05:00
parent 5cb09cee0b
commit eb79252ca0
78 changed files with 169 additions and 193 deletions

View File

@@ -6,7 +6,7 @@
// Function to generate both crypto & URL safe random strings
function randomString(int $length = 16): string {
$bytes = random_bytes((int) ceil($length * 3 / 4));
$bytes = random_bytes(intval(ceil($length * 3 / 4)));
return substr(
rtrim(strtr(base64_encode($bytes), '+/', '-_'), '='),
0,
@@ -135,7 +135,7 @@ function generateUserSessionKey($site_encryption_master_key) {
} else {
// Not secure without HTTPS, but still out of reach of page scripts
setcookie("user_encryption_session_key", base64_encode($user_encryption_session_key), ['path' => '/', 'httponly' => true, 'samesite' => 'Lax']);
$_SESSION['alert_message'] = "Unencrypted connection flag set: Using non-secure cookies.";
flashAlert("Unencrypted connection flag set: Using non-secure cookies.", 'warning');
}
}