web: don't show errors if get-project RPC to boinc.netsoft-online.com fails

This commit is contained in:
David Anderson 2015-12-29 12:42:46 -08:00
parent d32e42397c
commit 3052111d02
1 changed files with 18 additions and 3 deletions

View File

@ -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);
curl_close($ch);
$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;