Testing Download: $testUrl"; // Fetch the image $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $testUrl, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, CURLOPT_TIMEOUT => 60, CURLOPT_CONNECTTIMEOUT => 15, CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', CURLOPT_SSL_VERIFYPEER => true, CURLOPT_HTTPHEADER => [ 'Accept: image/*, */*', 'Referer: https://www.flickr.com/', ], ]); $content = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); $error = curl_error($ch); curl_close($ch); echo "
HTTP Status: $httpCode
"; echo "Content-Type: $contentType
"; echo "Content Size: " . strlen($content) . " bytes
"; if ($error) { echo "cURL Error: $error
"; } // Check magic bytes $magicBytes = substr($content, 0, 16); echo "First 16 bytes (hex): " . bin2hex($magicBytes) . "
Is JPEG: " . ($isJpeg ? 'YES' : 'NO') . "
"; echo "Is PNG: " . ($isPng ? 'YES' : 'NO') . "
"; if ($httpCode === 200 && ($isJpeg || $isPng)) { echo "Image verified: {$imgInfo[0]}x{$imgInfo[1]} - {$imgInfo['mime']}
"; echo "Test file saved to: $testFile
"; } else { echo "getimagesize() failed on saved file!
"; } // Show preview echo "Response content:
" . htmlspecialchars($content) . ""; } } // Handle download action if (($_GET['action'] ?? '') === 'download') { $url = $_GET['url'] ?? ''; if (!$url) die('No URL'); $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_USERAGENT => 'Mozilla/5.0', CURLOPT_HTTPHEADER => ['Accept: image/*', 'Referer: https://www.flickr.com/'], ]); $content = curl_exec($ch); curl_close($ch); // Clear ALL output while (ob_get_level()) ob_end_clean(); header('Content-Type: image/jpeg'); header('Content-Length: ' . strlen($content)); header('Content-Disposition: attachment; filename="test_photo.jpg"'); echo $content; exit; }