Fixed bug / undefined index when api settings are empty

This commit is contained in:
xisi 2014-01-18 14:40:50 -05:00
parent 62e341b877
commit dacadd8477

View File

@ -70,20 +70,22 @@ class Tools extends Base {
// Check the API type for configured URL // Check the API type for configured URL
if (!$strApiType = $this->getApiType($this->config['price']['url'])) if (!$strApiType = $this->getApiType($this->config['price']['url']))
return false; return false;
// Extract price depending on API type // if api data is valid, extract price depending on API type
switch ($strApiType) { if (is_array($aData)) {
case 'coinchose': switch ($strApiType) {
foreach ($aData as $aItem) { case 'coinchose':
if($strCurrency == $aItem[0]) foreach ($aData as $aItem) {
return $aItem['price']; if($strCurrency == $aItem[0])
return $aItem['price'];
}
break;
case 'btce':
return $aData['ticker']['last'];
break;
case 'cryptsy':
return @$aData['return']['markets'][$strCurrency]['lasttradeprice'];
break;
} }
break;
case 'btce':
return $aData['ticker']['last'];
break;
case 'cryptsy':
return $aData['return']['markets'][$strCurrency]['lasttradeprice'];
break;
} }
// Catchall, we have no data extractor for this API url // Catchall, we have no data extractor for this API url
$this->setErrorMessage("Undefined API to getPrice() on URL " . $this->config['price']['url']); $this->setErrorMessage("Undefined API to getPrice() on URL " . $this->config['price']['url']);