From 3052111d02c19a48f2b73d1d1e43603a5591e6b8 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 29 Dec 2015 12:42:46 -0800 Subject: [PATCH] web: don't show errors if get-project RPC to boinc.netsoft-online.com fails --- html/inc/user.inc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/html/inc/user.inc b/html/inc/user.inc index 3a3127e021..ff13a79678 100644 --- a/html/inc/user.inc +++ b/html/inc/user.inc @@ -46,8 +46,16 @@ function get_other_projects($user) { if (ini_get('allow_url_fopen')) { $timeout = 3; $old_timeout = ini_set('default_socket_timeout', $timeout); - $xml_object = simplexml_load_string(file_get_contents($url)); + $xml_object = null; + echo $url; + $f = @file_get_contents($url); + if ($f) { + $xml_object = @simplexml_load_string($f); + } ini_set('default_socket_timeout', $old_timeout); + if (!$xml_object) { + return $user; + } } else { $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, false); @@ -55,10 +63,17 @@ function get_other_projects($user) { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 3); curl_setopt($ch, CURLOPT_TIMEOUT, 3); - $rawxml = curl_exec($ch); - $xml_object = simplexml_load_string($rawxml); + $rawxml = @curl_exec($ch); + $xml_object = null; + if ($rawxml) { + $xml_object = @simplexml_load_string($rawxml); + } curl_close($ch); + if (!xml_object) { + return $user; + } } + // auto-cast the project list to an array of stdClass projects // $remote = @json_decode(json_encode((array)$xml_object))->project;