Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php56
1 files changed, 38 insertions, 18 deletions
diff --git a/index.php b/index.php
index 3ae406e..e77e36e 100644
--- a/index.php
+++ b/index.php
@@ -73,38 +73,58 @@ print_header("", "home");
<a href="https://bbs.archlinux32.org/extern.php?action=feed&fid=12&type=atom" title="Arch 32 News RSS Feed" class="rss-icon"><img width="16" height="16" src="/static/rss.c5ebdc5318d6.png" alt="RSS Feed" /></a>
<?php
-$news_reachable = apcu_fetch('news_reachable', $apcu_success);
+$news32_reachable = apcu_fetch('news32_reachable', $apcu_success);
if ($apcu_success == false) {
if (site_is_reachable('https://bbs.archlinux32.org/extern.php?action=feed&fid=12&type=atom'))
- $news_reachable = 'YES';
+ $news32_reachable = 'YES';
else
- $news_reachable = 'NO';
- apcu_store('news_reachable', $news_reachable, 300);
+ $news32_reachable = 'NO';
+ apcu_store('news32_reachable', $news32_reachable, 300);
}
-if ($news_reachable == 'YES') {
+if ($news32_reachable == 'YES') {
$ch = curl_init('https://bbs.archlinux32.org/extern.php?action=feed&fid=12&type=atom');
- 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);
+ if( $ch != null && $ch != false ) {
+ 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);
+ $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+ if( $httpcode >= 200 && $httpcode < 300 ) {
+ $news32 = simplexml_load_string($news32);
+ } else {
+ $news32 = false;
+ $news32status = "HTTP return code was $httpcode";
+ }
+ } else {
+ $news = false;
+ }
} else {
$news32 = false;
}
$ch = curl_init("https://archlinux.org/feeds/news/");
-curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
-$news64 = curl_exec($ch);
-curl_close($ch);
-$news64 = simplexml_load_string($news64);
+if( $ch != null && $ch != false ) {
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ $news64 = curl_exec($ch);
+ $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+ if( $httpcode >= 200 && $httpcode < 300 ) {
+ $news64 = simplexml_load_string($news64);
+ } else {
+ $news64 = false;
+ $news64status = "HTTP return code was $httpcode";
+ }
+} else {
+ $news64 = false;
+}
$news = array();
if ($news32 === false) {
print " <h4>\n";
- print " sorry, arch 32 news are currently unavailable\n";
+ print " sorry, arch 32 news are currently unavailable ($news32status)\n";
print " </h4>\n";
} else {
foreach($news32 -> {'entry'} as $entry) {
@@ -125,7 +145,7 @@ if ($news32 === false) {
}
if ($news64 === false) {
print " <h4>\n";
- print " sorry, upstream arch news are currently unavailable\n";
+ print " sorry, upstream arch news are currently unavailable ($news64status)\n";
print " </h4>\n";
} else {
foreach($news64 -> {'channel'} -> {'item'} as $entry) {