Auto commit: 2026-02-14T15:51:36.535Z

This commit is contained in:
Flatlogic Bot 2026-02-14 15:51:36 +00:00
parent 6f30c86767
commit 9a91bebadf
2 changed files with 0 additions and 46 deletions

View File

@ -1,25 +0,0 @@
<?php
function pexels_key() {
$k = getenv('PEXELS_KEY');
return $k && strlen($k) > 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;
}

View File

@ -1,21 +0,0 @@
<?php
require_once __DIR__ . '/includes/pexels.php';
function fetch_image($query, $filename) {
$url = 'https://api.pexels.com/v1/search?query=' . urlencode($query) . '&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/' . $filename;
download_to($src, $dest);
return 'assets/images/' . $filename;
}
return null;
}
// Fetch background
fetch_image('dark music studio radio', 'background.jpg');
// Fetch featured photo
fetch_image('radio dj turntable', 'featured.jpg');
echo "Images fetched.";