| Server IP : 46.105.57.169 / Your IP : 216.73.216.144 Web Server : Apache System : Linux webd003.cluster120.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : maitricfuz ( 93378) PHP Version : 8.4.10 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/m/a/i/maitricfuz/www/new-saint-martin/plugins/slideshowck/flickr/helper/ |
Upload File : |
<?php
/**
* @name Slideshow CK
* @package com_slideshow
* @copyright Copyright (C) 2016. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
// No direct access
defined('_JEXEC') or die;
/**
* Helper Class.
*/
class SlideshowckHelpersourceFlickr {
private static $params;
/**
* Static variable used to determin whether the plugin is running or not
* @var boolean
*/
public static $running;
/*
* Get the items from the source
*/
public static function getItems(&$params) {
self::$params = $params;
$apikey = $params->get('flickr_apikey');
if (! $apikey) {
echo '<p>SLIDESHOW CK ERROR : no API Key found for Flickr.</p>';
return false;
}
$photoset = $params->get('flickr_photoset');
if (! $photoset) {
echo '<p>SLIDESHOW CK ERROR : no Photoset ID found for Flickr.</p>';
return false;
}
$url = 'https://api.flickr.com/services/rest/?format=json&method=flickr.photosets.getPhotos&extras=description,original_format,url_sq,url_t,url_s,url_m,url_o&nojsoncallback=1';
$url .= '&api_key=' . $apikey;
$url .= '&photoset_id=' . $photoset;
// setup cache to speedup the page load
$timeInterval = $params->get('flickr_timeinterval', '1', 'int');
if ($timeInterval < 1) $timeInterval = 1;
$timeInterval = $timeInterval * 60;
$cache = \Joomla\CMS\Factory::getCache('mod_slideshowck.flickr', '');
$cache->setCaching(true);
$key = $url;
$cacheContent = $cache->get($key);
// set timer to get the new data from the source
self::$running = true;
$lastRun = (int) $cache->get($key . '.time', 0);
$currentTime = time();
$numberMinutes = ($currentTime - $lastRun) / 60;
if (! empty($cacheContent) && $numberMinutes < $timeInterval)
{
$items = $cacheContent;
} else {
if (ini_get('allow_url_fopen') && function_exists('file_get_contents')) {
$result = file_get_contents($url);
}
// look for curl
if ($result == '' && extension_loaded('curl')) {
$ch = curl_init();
$timeout = 30;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = curl_exec($ch);
curl_close($ch);
}
$images = json_decode($result)->photoset->photo;
$items = Array();
$i = 0;
$flickrSuffixes = array('o', 'k', 'h', 'b', 'z', 'sq', 't', 'sm', 'm');
foreach ($images as & $image) {
$item = SlideshowckHelper::initItem();
if ($params->get('flickr_image_size', 'auto') == 'auto') {
$suffix = 'o';
foreach ($flickrSuffixes as $flickrSuffixe) {
if (isset($image->{'url_' . $flickrSuffixe})) {
$suffix = $flickrSuffixe;
$image_url = $image->{'url_' . $suffix};
break;
}
}
} else {
$suffix = $params->get('flickr_image_size', 'o');
$image_url = 'https://live.staticflickr.com/' . $image->server . '/' . $image->id . '_' . $image->secret . '_' . $suffix . '.jpg';
}
$item->image = $image_url;
$item->title = $image->title;
$item->text = $image->description->_content;
$item->link = $image_url;
$items[$i] = $item;
$i++;
}
$cache->store($items, $key);
$cache->store($currentTime, $key . '.time');
}
return $items;
}
}