From 3489940168b8f38318390171472105b57c10ffef Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Tue, 18 Jul 2017 01:00:45 +0200 Subject: [PATCH] exchanges: add missing timeout curl options --- web/yaamp/core/exchange/alcurex.php | 1 + web/yaamp/core/exchange/bitstamp.php | 3 +++ web/yaamp/core/exchange/bter.php | 2 ++ web/yaamp/core/exchange/cryptopia.php | 2 ++ web/yaamp/core/exchange/jubi.php | 6 +----- web/yaamp/core/exchange/shapeshift.php | 2 ++ web/yaamp/core/exchange/yobit.php | 3 +++ 7 files changed, 14 insertions(+), 5 deletions(-) diff --git a/web/yaamp/core/exchange/alcurex.php b/web/yaamp/core/exchange/alcurex.php index 684f7c2..ebeb20c 100644 --- a/web/yaamp/core/exchange/alcurex.php +++ b/web/yaamp/core/exchange/alcurex.php @@ -9,6 +9,7 @@ function alcurex_api_query($method, $params='') $ch = curl_init($uri); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); $execResult = strip_tags(curl_exec($ch)); $obj = json_decode($execResult); diff --git a/web/yaamp/core/exchange/bitstamp.php b/web/yaamp/core/exchange/bitstamp.php index 02f9c1a..2b86158 100644 --- a/web/yaamp/core/exchange/bitstamp.php +++ b/web/yaamp/core/exchange/bitstamp.php @@ -9,6 +9,8 @@ function bitstamp_api_query($method, $params='') $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); $execResult = curl_exec($ch); $res = json_decode($execResult, true); @@ -51,6 +53,7 @@ function bitstamp_api_user($method, $params='') //curl_setopt($ch, CURLOPT_SSLVERSION, 1 /*CURL_SSLVERSION_TLSv1*/); curl_setopt($ch, CURLOPT_SSL_SESSIONID_CACHE, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Bitstamp API PHP client; '.php_uname('s').'; PHP/'.phpversion().')'); curl_setopt($ch, CURLOPT_ENCODING , ''); diff --git a/web/yaamp/core/exchange/bter.php b/web/yaamp/core/exchange/bter.php index b8a7ea4..cd0455e 100644 --- a/web/yaamp/core/exchange/bter.php +++ b/web/yaamp/core/exchange/bter.php @@ -10,6 +10,8 @@ function bter_api_query($method, $params='') $ch = curl_init($uri); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 20); $data = strip_tags(curl_exec($ch)); if ($method == 'tickers' && empty($params)) { diff --git a/web/yaamp/core/exchange/cryptopia.php b/web/yaamp/core/exchange/cryptopia.php index 390470f..e36e2fa 100644 --- a/web/yaamp/core/exchange/cryptopia.php +++ b/web/yaamp/core/exchange/cryptopia.php @@ -12,6 +12,8 @@ function cryptopia_api_query($method, $params='') $ch = curl_init($uri); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); $execResult = curl_exec($ch); $obj = json_decode($execResult); diff --git a/web/yaamp/core/exchange/jubi.php b/web/yaamp/core/exchange/jubi.php index 1125ad8..dedfa1e 100644 --- a/web/yaamp/core/exchange/jubi.php +++ b/web/yaamp/core/exchange/jubi.php @@ -8,14 +8,10 @@ function jubi_api_query($method, $params) $ch = curl_init($uri); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); $execResult = curl_exec($ch); $obj = json_decode($execResult); return $obj; } - - - - - diff --git a/web/yaamp/core/exchange/shapeshift.php b/web/yaamp/core/exchange/shapeshift.php index 51b3852..a9a36fc 100644 --- a/web/yaamp/core/exchange/shapeshift.php +++ b/web/yaamp/core/exchange/shapeshift.php @@ -12,6 +12,7 @@ function shapeshift_api_query($method, $params='') curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); @@ -39,6 +40,7 @@ function shapeshift_api_post($method, $data=array()) curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POST, true); diff --git a/web/yaamp/core/exchange/yobit.php b/web/yaamp/core/exchange/yobit.php index 721eaa6..04eedee 100644 --- a/web/yaamp/core/exchange/yobit.php +++ b/web/yaamp/core/exchange/yobit.php @@ -6,6 +6,8 @@ function yobit_api_query($method) $ch = curl_init($uri); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); $execResult = curl_exec($ch); $obj = json_decode($execResult); @@ -52,6 +54,7 @@ function yobit_api_query2($method, $req = array()) curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; SMART_API PHP client; '.php_uname('s').'; PHP/'.phpversion().')'); curl_setopt($ch, CURLOPT_URL, 'https://yobit.net/tapi/'); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);