mirror of
https://github.com/myronblair/parkerslingshotrentals
synced 2026-07-28 00:52:54 -05:00
Fix security issues from code review: remove plaintext password comment, enable TLS verification, harden booking ref entropy, fix XSS/injection in signature emails, fix broken waiver link, consolidate duplicated auth/file-serving logic, add missing document view links, sync schema.sql with live DB
This commit is contained in:
+6
-12
@@ -2,9 +2,7 @@
|
||||
require_once dirname(__DIR__) . '/db.php';
|
||||
|
||||
$token = preg_replace('/[^a-f0-9]/', '', $_GET['_t'] ?? '');
|
||||
$stmt = db()->prepare("SELECT token FROM admin_tokens WHERE token=? AND expires_at > NOW()");
|
||||
$stmt->execute([$token]);
|
||||
if (!$stmt->fetch()) {
|
||||
if (!verifyAdminToken($token)) {
|
||||
http_response_code(403);
|
||||
header('Content-Type: text/plain');
|
||||
exit('Unauthorized — please log in to the admin panel first.');
|
||||
@@ -29,25 +27,21 @@ if (!$row || !$row['file_path']) {
|
||||
exit('No document on file.');
|
||||
}
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$base = realpath($root . '/uploads');
|
||||
$path = realpath($root . '/' . $row['file_path']);
|
||||
|
||||
if (!$path || !$base || !str_starts_with($path, $base . DIRECTORY_SEPARATOR)) {
|
||||
$path = resolveUploadPath(dirname(__DIR__), $row['file_path']);
|
||||
if (!$path) {
|
||||
http_response_code(404);
|
||||
header('Content-Type: text/plain');
|
||||
exit('File not found.');
|
||||
}
|
||||
|
||||
$mime = mime_content_type($path);
|
||||
$allowed = ['image/jpeg' => 'jpg', 'image/png' => 'png', 'application/pdf' => 'pdf'];
|
||||
if (!isset($allowed[$mime])) {
|
||||
$mime = detectAllowedMime($path);
|
||||
if (!$mime) {
|
||||
http_response_code(403);
|
||||
header('Content-Type: text/plain');
|
||||
exit('Invalid file type.');
|
||||
}
|
||||
|
||||
$fname = $type . '-' . $ref . '.' . $allowed[$mime];
|
||||
$fname = $type . '-' . $ref . '.' . ALLOWED_DOC_MIMES[$mime];
|
||||
header('Content-Type: ' . $mime);
|
||||
header('Content-Disposition: inline; filename="' . $fname . '"');
|
||||
header('Content-Length: ' . filesize($path));
|
||||
|
||||
Reference in New Issue
Block a user