diff --git a/api/pexels.php b/api/pexels.php new file mode 100644 index 0000000..a4a7ba2 --- /dev/null +++ b/api/pexels.php @@ -0,0 +1,28 @@ + '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); diff --git a/assets/images/pexels/102104.jpg b/assets/images/pexels/102104.jpg new file mode 100644 index 0000000..7e776ad Binary files /dev/null and b/assets/images/pexels/102104.jpg differ diff --git a/assets/images/pexels/698275.jpg b/assets/images/pexels/698275.jpg new file mode 100644 index 0000000..07abbe7 Binary files /dev/null and b/assets/images/pexels/698275.jpg differ diff --git a/assets/images/pexels/842687.jpg b/assets/images/pexels/842687.jpg new file mode 100644 index 0000000..e160b6b Binary files /dev/null and b/assets/images/pexels/842687.jpg differ diff --git a/includes/pexels.php b/includes/pexels.php new file mode 100644 index 0000000..0c04a85 --- /dev/null +++ b/includes/pexels.php @@ -0,0 +1,25 @@ + 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; +} diff --git a/index.php b/index.php index 82c4dc1..bbf1012 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,4 @@ + @@ -47,17 +48,22 @@ @@ -96,4 +102,4 @@ - \ No newline at end of file +