From 96ebcbff949bcc60da6c8f6eb149d3517b3b39f1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 12 Jan 2017 13:17:55 -0800 Subject: [PATCH] PHP binding of web RPCs: use Curl instead of file_get_contents() That latter doesn't support HTTPS in my version of PHP --- html/inc/web_rpc_api.inc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/html/inc/web_rpc_api.inc b/html/inc/web_rpc_api.inc index 747748fd9a..fe44b49393 100644 --- a/html/inc/web_rpc_api.inc +++ b/html/inc/web_rpc_api.inc @@ -18,13 +18,30 @@ // PHP interfaces to some of BOINC's Web RPCs +// my PHP currently doesn't support file_get_contents(https://...) +// so do it with Curl +// +function fetch_url($url) { + if (0) { + return file_get_contents($url); + } else { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, 0); + $x = curl_exec($ch); + curl_close($ch); + return $x; + } +} + function lookup_account( $project_url, $email_addr, $passwd_hash ) { $url = $project_url."/lookup_account.php?email_addr=".urlencode($email_addr)."&passwd_hash=$passwd_hash"; - $reply = file_get_contents($url); + $reply = fetch_url($url); if (!$reply) return array(null, -1, "HTTP error"); $r = @simplexml_load_string($reply); if (!$r) { @@ -49,7 +66,7 @@ function create_account( $url = $project_url."/create_account.php?email_addr=".urlencode($email_addr)."&passwd_hash=$passwd_hash&user_name=".urlencode($user_name); //echo "url: $url\n"; - $reply = file_get_contents($url); + $reply = fetch_url($url); if (!$reply) return array(null, -1, "HTTP error"); //echo "reply: $reply\n"; $r = @simplexml_load_string($reply);