diff --git a/src/templates/pages/default.txp b/src/templates/pages/default.txp
index 354c79c2..4fbefa63 100644
--- a/src/templates/pages/default.txp
+++ b/src/templates/pages/default.txp
@@ -67,27 +67,31 @@
Stars
-
-$curl1 = curl_init();
+
+$curl = curl_init();
-curl_setopt_array($curl1, array(
- CURLOPT_RETURNTRANSFER => 1,
+curl_setopt_array($curl, [
+ CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => 'https://api.github.com/repos/textpattern/textpattern',
CURLOPT_USERAGENT => 'Textpattern CMS',
-));
+ CURLOPT_FAILONERROR => true,
+]);
-$response1 = curl_exec($curl1);
+$response = curl_exec($curl);
-if (curl_error($curl1)) {
- // Do nothing.
-} else {
- $json = json_decode($response1);
- echo ''.$json->stargazers_count.'';
+curl_close($curl);
+
+if ($response === false) {
+ return;
+}
+
+if (!($json = json_decode($response))) {
+ return;
}
-curl_close($curl1);
-
-
+echo ''.intval($json->stargazers_count).'';
+
+
@@ -199,26 +203,29 @@ curl_close($curl1);
-$curl2 = curl_init();
+$curl = curl_init();
-curl_setopt_array($curl2, array(
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_URL => 'http://forum.textpattern.com/api/?limit=5&sort=posted',
-));
+curl_setopt_array($curl, [
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_URL => 'https://forum.textpattern.io/api/?limit=5&sort=posted',
+ CURLOPT_FAILONERROR => true,
+]);
-$response2 = curl_exec($curl2);
+$response = curl_exec($curl);
-if (curl_error($curl2)) {
- // Do nothing.
-} else {
- $xml = json_decode($response2);
+curl_close($curl);
- foreach ($xml->topic as $topicElement) {
- echo '- '.htmlspecialchars($topicElement->title).' by '.htmlspecialchars($topicElement->author->name).' on
';
- }
+if ($response === false) {
+ return;
}
-curl_close($curl2);
+if (!($json = json_decode($response))) {
+ return;
+}
+
+foreach ($json->topic as $topic) {
+ echo '- '.htmlspecialchars($topic->title).' by '.htmlspecialchars($topic->author->name).' on
';
+}
(Ad)