diff options
-rw-r--r-- | index.php | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -4,6 +4,7 @@ require_once "init.php"; require_once BASE . "/lib/mysql.php"; require_once BASE . "/lib/style.php"; require_once BASE . "/lib/format.php"; +require_once BASE . "/lib/helper.php"; $result = mysql_run_query( 'SELECT `binary_packages`.`pkgname`,' . @@ -72,13 +73,25 @@ print_header("", "home"); <a href="https://news.archlinux32.org/rss.php" title="Arch 32 News RSS Feed" class="rss-icon"><img width="16" height="16" src="/static/rss.c5ebdc5318d6.png" alt="RSS Feed" /></a> <?php -$ch = curl_init("https://news.archlinux32.org/rss.php"); -curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); -curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); -$news32 = curl_exec($ch); -curl_close($ch); -$news32 = simplexml_load_string($news32); +$news_reachable = apcu_fetch('news_reachable', $apcu_success); +if ($apcu_success == false) { + if (site_is_reachable('https://news.archlinux32.org/rss.php')) + $news_reachable = 'YES'; + else + $news_reachable = 'NO'; + apcu_store('news_reachable', $news_reachable, 300); +} +if ($news_reachable == 'YES') { + $ch = curl_init('https://news.archlinux32.org/rss.php'); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + $news32 = curl_exec($ch); + curl_close($ch); + $news32 = simplexml_load_string($news32); +} else { + $news32 = false; +} $ch = curl_init("https://www.archlinux.org/feeds/news/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |