diff --git a/assets/images/programs/deep_night.jpg b/assets/images/programs/deep_night.jpg new file mode 100644 index 0000000..2943344 Binary files /dev/null and b/assets/images/programs/deep_night.jpg differ diff --git a/assets/images/programs/lili_guest.jpg b/assets/images/programs/lili_guest.jpg new file mode 100644 index 0000000..5f8034e Binary files /dev/null and b/assets/images/programs/lili_guest.jpg differ diff --git a/assets/images/programs/techno_sunrise.jpg b/assets/images/programs/techno_sunrise.jpg new file mode 100644 index 0000000..6d5dd57 Binary files /dev/null and b/assets/images/programs/techno_sunrise.jpg differ diff --git a/assets/images/programs/vocal_house.jpg b/assets/images/programs/vocal_house.jpg new file mode 100644 index 0000000..46c94f1 Binary files /dev/null and b/assets/images/programs/vocal_house.jpg differ diff --git a/fetch_program_images.php b/fetch_program_images.php new file mode 100644 index 0000000..369d3bb --- /dev/null +++ b/fetch_program_images.php @@ -0,0 +1,27 @@ + 'techno club sunrise', + 'vocal_house' => 'vocal house music dj', + 'lili_guest' => 'professional dj booth', + 'deep_night' => 'night city lights chill' +]; + +foreach ($programs as $id => $query) { + echo "Fetching image for $id ($query)...\n"; + $url = 'https://api.pexels.com/v1/search?query=' . urlencode($query) . '&orientation=landscape&per_page=1&page=1'; + $data = pexels_get($url); + if ($data && !empty($data['photos'])) { + $photo = $data['photos'][0]; + $src = $photo['src']['large2x'] ?? $photo['src']['large']; + $dest = __DIR__ . '/assets/images/programs/' . $id . '.jpg'; + if (download_to($src, $dest)) { + echo "Saved to $dest\n"; + } else { + echo "Failed to download $src\n"; + } + } else { + echo "No photos found for $query\n"; + } +} diff --git a/includes/pexels.php b/includes/pexels.php new file mode 100644 index 0000000..7d6fe7f --- /dev/null +++ b/includes/pexels.php @@ -0,0 +1,27 @@ + 0 ? $k : 'Vc99rnmOhHhJAbgGQoKLZtsaIVfkeownoQNbTj78VemUjKh08ZYRbf18'; +} + +function pexels_get($url) { + $ch = curl_init(); + curl_setopt_array($ch, [ + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => [ 'Authorization: '. pexels_key() ], + CURLOPT_TIMEOUT => 15, + ]); + $resp = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + if ($code >= 200 && $code < 300 && $resp) return json_decode($resp, true); + return null; +} + +function download_to($srcUrl, $destPath) { + $data = @file_get_contents($srcUrl); + if ($data === false) return false; + if (!is_dir(dirname($destPath))) mkdir(dirname($destPath), 0775, true); + return file_put_contents($destPath, $data) !== false; +}