@ 2020-05-23T13:43:18Z <?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: access");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Credentials: true");
header("Content-Type: application/json; charset=UTF-8");
function getResponse() {
if (!isset($_GET['id']) || !ctype_digit($_GET['id'])) {
return ['message' => 'Missing/Invalid identifier provided'];
}
include_once('config_setup.php');
$sql = "SELECT id, caption, filename, description2 FROM photographs WHERE id = " . $_GET['id'];
$result = mysqli_query($db, $sql);
if (!$result) {
return ['message' => 'Please contact the dev team.'];
}
$photo = mysqli_fetch_assoc($result);
if (!$photo) {
return ['message' => 'No product.'];
}
$url = 'http://localhost/photo_gallery/public/files/images/';
$allowed = '<div><img><h1><h2><p><br><strong><em><ul><li><table><td><tr><th><tbody>';
return [
'id' => urlencode(htmlspecialchars($photo['id'])),
'caption' => htmlspecialchars($photo['caption']),
'filename' => $url . htmlspecialchars($photo['filename']),
'description2' => strip_tags($photo['description2'], $allowed),
];
}
$response = getResponse();
http_response_code(isset($response['message']) ? 404 : 200);
echo json_encode($response);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 - 8.3.7 {"message":"Missing\/Invalid identifier provided"} Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
{"message":"Missing\/Invalid identifier provided"} preferences:dark mode live preview
158.67 ms | 402 KiB | 182 Q