-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_image_urls.php
More file actions
105 lines (88 loc) · 3.24 KB
/
test_image_urls.php
File metadata and controls
105 lines (88 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* Test What URLs the API Returns and If They Work
*/
echo "<h2>Image URL Tester</h2>";
echo "<pre>";
// Fetch API response
$apiUrl = 'https://eunixma.com.ng/api/ads/51';
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
$ad = json_decode($response, true);
echo "Ad ID: {$ad['id']} - {$ad['title']}\n";
echo "==========================================\n\n";
// Check preview_image
echo "1. Testing preview_image field:\n";
echo " URL: {$ad['preview_image']}\n";
// Try to fetch the image
$ch = curl_init($ad['preview_image']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($ch);
$imageHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($imageHttpCode === 200) {
echo " ✅ Status: {$imageHttpCode} - Image loads successfully!\n\n";
} else {
echo " ❌ Status: {$imageHttpCode} - Image FAILED to load!\n";
if ($imageHttpCode === 404) {
echo " Reason: Image file not found (404)\n";
} elseif ($imageHttpCode === 403) {
echo " Reason: Access forbidden (403)\n";
} elseif ($imageHttpCode === 500) {
echo " Reason: Server error (500)\n";
}
echo "\n";
}
// Check images array
echo "2. Testing images array:\n";
foreach ($ad['images'] as $index => $img) {
$imagePath = $img['image_path'];
// Build full URL
$fullUrl = "https://eunixma.com.ng/storage/{$imagePath}";
echo " Image #{$index + 1}:\n";
echo " - DB path: {$imagePath}\n";
echo " - Full URL: {$fullUrl}\n";
// Test the URL
$ch = curl_init($fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($ch);
$imageHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($imageHttpCode === 200) {
echo " - Status: ✅ {$imageHttpCode} - Works!\n\n";
} else {
echo " - Status: ❌ {$imageHttpCode} - Failed!\n\n";
}
}
echo "==========================================\n";
echo "3. Testing direct proxy access:\n";
$testUrl = "https://eunixma.com.ng/storage/ads/1765552635_693c31fb78d01.jpg";
echo " URL: {$testUrl}\n";
$ch = curl_init($testUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($ch);
$imageHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($imageHttpCode === 200) {
echo " ✅ Status: {$imageHttpCode} - Proxy works!\n";
} else {
echo " ❌ Status: {$imageHttpCode} - Proxy failed!\n";
}
} else {
echo "Failed to fetch API\n";
echo "HTTP Status: {$httpCode}\n";
}
echo "\n</pre>";
echo "<p><strong>DELETE THIS FILE!</strong></p>";
?>