This commit is contained in:
zuevav
2026-04-30 15:14:09 +03:00
parent 08fe53fa5c
commit e5a88665cd
25 changed files with 13697 additions and 0 deletions
+111
View File
@@ -0,0 +1,111 @@
<?php
/**
* Debug script to check Flickr URL formats and file sizes
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once __DIR__ . '/classes/FlickrAPI.php';
// Try config.php first, fall back to config.example.php for testing
$configFile = __DIR__ . '/config.php';
$config = require $configFile;
if (empty($config['flickr']['api_key']) && file_exists(__DIR__ . '/config.example.php')) {
$config = require __DIR__ . '/config.example.php';
}
if (empty($config['flickr']['api_key'])) {
die("Flickr API key not configured\n");
}
// Helper to check URL status and file size
function checkUrl($url) {
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_NOBODY => true, // HEAD request
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_USERAGENT => 'Mozilla/5.0',
CURLOPT_HTTPHEADER => ['Referer: https://www.flickr.com/'],
]);
curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
curl_close($ch);
$sizeStr = $size > 0 ? formatSize($size) : '?';
return ['status' => $httpCode, 'size' => $sizeStr, 'bytes' => $size];
}
function formatSize($bytes) {
if ($bytes >= 1048576) return round($bytes / 1048576, 1) . ' MB';
if ($bytes >= 1024) return round($bytes / 1024) . ' KB';
return $bytes . ' B';
}
$flickr = new FlickrAPI(
$config['flickr']['api_key'],
$config['flickr']['api_secret'] ?? '',
$config['flickr_user_id'] ?? ''
);
echo "=== Testing Flickr URL Formats ===\n\n";
// Get one album
$albums = $flickr->getPhotosets(1, 1);
if (empty($albums)) {
die("No albums found\n");
}
$albumId = $albums[0]['id'];
$albumTitle = $albums[0]['title']['_content'] ?? 'Unknown';
echo "Album: $albumTitle (ID: $albumId)\n\n";
// Get photos from album
$result = $flickr->getPhotosetPhotos($albumId, 1, 3);
if (empty($result['photos'])) {
die("No photos in album\n");
}
foreach ($result['photos'] as $i => $photo) {
echo "--- Photo " . ($i + 1) . " ---\n";
echo "ID: " . $photo['id'] . "\n";
echo "Title: " . $photo['title'] . "\n";
echo "Server: " . $photo['server'] . "\n";
echo "Secret: " . $photo['secret'] . "\n";
echo "Original Secret: " . $photo['original_secret'] . "\n";
echo "Original Format: " . $photo['original_format'] . "\n";
echo "\nURLs (with sizes):\n";
// Test each URL size
$sizes = ['medium640', 'large', 'large2048', 'original'];
foreach ($sizes as $size) {
$url = $photo['urls'][$size] ?? null;
if ($url) {
$info = checkUrl($url);
$status = $info['status'] == 200 ? '✓' : '✗ ' . $info['status'];
echo " $size: $status - {$info['size']}\n";
echo " $url\n";
} else {
echo " $size: (not available)\n";
}
}
// If original secret differs from secret, note it
if ($photo['original_secret'] !== $photo['secret']) {
echo "\n *** Original secret is DIFFERENT - originals should be accessible ***\n";
} else {
echo "\n Note: Original secret = Secret (originals may not be enabled in Flickr settings)\n";
}
echo "\n";
}
echo "=== Summary ===\n";
echo "If 'original' shows ✗ 403 or ✗ 404:\n";
echo " -> Enable original downloads in Flickr: Settings > Privacy > Allow downloads\n";
echo "If 'original' shows ✓ with large size:\n";
echo " -> Downloads should work at full quality!\n";