2022-07-18 14:29:49 +01:00
|
|
|
<?php
|
|
|
|
|
/**
|
2022-07-19 16:38:55 +01:00
|
|
|
* ██ ██ ██ ███ ███ ██████
|
|
|
|
|
* ██ ██ ██ ████ ████ ██ ██
|
|
|
|
|
* ██ ██ ██ ██ ████ ██ ██████
|
|
|
|
|
* ██ ██ ██ ██ ██ ██ ██ ██
|
|
|
|
|
* █████ ██████ ██ ██ ██
|
2022-07-18 14:29:49 +01:00
|
|
|
*
|
|
|
|
|
* @author Dale Davies <dale@daledavies.co.uk>
|
2022-07-19 16:38:55 +01:00
|
|
|
* @copyright Copyright (c) 2022, Dale Davies
|
2022-07-18 14:29:49 +01:00
|
|
|
* @license MIT
|
|
|
|
|
*/
|
|
|
|
|
|
2022-07-19 16:38:55 +01:00
|
|
|
/**
|
|
|
|
|
* Proxy requests to Unsplash API and cache response.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-07-18 14:29:49 +01:00
|
|
|
// Provided by composer for psr-4 style autoloading.
|
|
|
|
|
require __DIR__ .'/../vendor/autoload.php';
|
|
|
|
|
|
|
|
|
|
$config = new Jump\Config();
|
|
|
|
|
$cache = new Jump\Cache($config);
|
2023-04-13 23:00:35 +01:00
|
|
|
$language = new Jump\Language($config, $cache);
|
2022-07-18 14:29:49 +01:00
|
|
|
|
|
|
|
|
// If this script is run via CLI then clear the cache and repopulate it,
|
|
|
|
|
// otherwise if run via web then get image data from cache and run this
|
|
|
|
|
// script asynchronously to refresh the cache for next time.
|
|
|
|
|
if (http_response_code() === false) {
|
2023-04-06 17:49:27 +01:00
|
|
|
$unsplashdata = Jump\Unsplash::load_cache_unsplash_data($config, $language);
|
2022-07-18 14:29:49 +01:00
|
|
|
$cache->save(cachename: 'unsplash', data: $unsplashdata);
|
|
|
|
|
die('Cached data from Unsplash');
|
|
|
|
|
}
|