From 226d1cd783bb9e7b3a367281ed0285b259052d78 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 10 May 2024 13:53:32 +0200 Subject: [PATCH] set back to real source --- application/controllers/Contestcalendar.php | 41 ++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/application/controllers/Contestcalendar.php b/application/controllers/Contestcalendar.php index 100a2eebe..bed46615b 100644 --- a/application/controllers/Contestcalendar.php +++ b/application/controllers/Contestcalendar.php @@ -109,30 +109,29 @@ class Contestcalendar extends CI_Controller { $this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file')); - //if (!$rssRawData = $this->cache->get('RssRawContestCal')) { + if (!$rssRawData = $this->cache->get('RssRawContestCal')) { - //$rssUrl = 'https://www.contestcalendar.com/calendar.rss'; - $rssUrl = 'http://localhost/rss/test.rss'; + $rssUrl = 'https://www.contestcalendar.com/calendar.rss'; - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $rssUrl); - curl_setopt($ch, CURLOPT_HEADER, false); - curl_setopt($ch, CURLOPT_USERAGENT, 'Wavelog Updater'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $rssRawData = curl_exec($ch); - curl_close($ch); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $rssUrl); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_USERAGENT, 'Wavelog Updater'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $rssRawData = curl_exec($ch); + curl_close($ch); - if ($rssRawData === FALSE) { - $msg = "Something went wrong with fetching the Contest Data"; - log_message('error', $msg); - return; + if ($rssRawData === FALSE) { + $msg = "Something went wrong with fetching the Contest Data"; + log_message('error', $msg); + return; + } + + $this->cache->save('RssRawContestCal', $rssRawData, (60 * 60 * 12)); // 12 hours cache time + + curl_close($ch); } - //$this->cache->save('RssRawContestCal', $rssRawData, (60*60*12)); // 12 hours cache time - - curl_close($ch); - //} - return $rssRawData; } @@ -147,10 +146,10 @@ class Contestcalendar extends CI_Controller { $start = date('Y-m-d', strtotime($contest['start']->format('Y-m-d'))); $end = date('Y-m-d', strtotime($contest['end']->format('Y-m-d'))); - + if ($start <= $this->today && $end >= $this->today) { $contestsToday[] = $contest; - } + } } return $contestsToday;