Revert to version 8debf8b

This commit is contained in:
Flatlogic Bot 2025-12-01 16:05:42 +00:00
parent a929759b81
commit 33816118ca
6 changed files with 11 additions and 70 deletions

View File

@ -1,28 +0,0 @@
<?php
header('Content-Type: application/json');
require_once __DIR__.'/../includes/pexels.php';
$qs = isset($_GET['queries']) ? explode(',', $_GET['queries']) : ['home','apple','pizza','mountains','cat'];
$out = [];
foreach ($qs as $q) {
$u = 'https://api.pexels.com/v1/search?query=' . urlencode(trim($q)) . '&orientation=square&per_page=1&page=1';
$d = pexels_get($u);
if ($d && !empty($d['photos'])) {
$p = $d['photos'][0];
$src = $p['src']['original'] ?? null;
$dest = __DIR__.'/../assets/images/pexels/'.$p['id'].'.jpg';
if ($src) download_to($src, $dest);
$out[] = [
'src' => 'assets/images/pexels/'.$p['id'].'.jpg',
'photographer' => $p['photographer'] ?? 'Unknown',
'photographer_url' => $p['photographer_url'] ?? '',
];
} else {
// Fallback: Picsum
$out[] = [
'src' => 'https://picsum.photos/600',
'photographer' => 'Random Picsum',
'photographer_url' => 'https://picsum.photos/'
];
}
}
echo json_encode($out);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 613 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

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,4 +1,3 @@
<!DOCTYPE html>
<html lang="en">
<head>
@ -48,22 +47,17 @@
<!-- Gallery Section -->
<section class="gallery-section bg-light py-5">
<div class="container">
<h2 class="text-center mb-4">Winter Gallery</h2>
<h2 class="text-center mb-4">Gallery</h2>
<div class="row">
<?php
ob_start();
include 'api/pexels.php';
$images_json = ob_get_clean();
$images = json_decode($images_json, true);
if ($images) {
foreach ($images as $image) {
echo '<div class="col-md-4 mb-4">';
echo '<img src="' . htmlspecialchars($image['src']) . '" class="img-fluid" alt="Winter Image">';
echo '<div class="text-center mt-2">Photo by <a href="' . htmlspecialchars($image['photographer_url']) . '" target="_blank">' . htmlspecialchars($image['photographer']) . '</a> on Pexels</div>';
echo '</div>';
}
}
?>
<div class="col-md-4 mb-4">
<img src="https://via.placeholder.com/400" class="img-fluid" alt="Gallery Image">
</div>
<div class="col-md-4 mb-4">
<img src="https://via.placeholder.com/400" class="img-fluid" alt="Gallery Image">
</div>
<div class="col-md-4 mb-4">
<img src="https://via.placeholder.com/400" class="img-fluid" alt="Gallery Image">
</div>
</div>
</div>
</section>
@ -102,4 +96,4 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
</html>