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
if (!$strApiType = $this->getApiType($this->config['price']['url']))
return false;
// Extract price depending on API type
switch ($strApiType) {
case 'coinchose':
foreach ($aData as $aItem) {
if($strCurrency == $aItem[0])
return $aItem['price'];
// if api data is valid, extract price depending on API type
if (is_array($aData)) {
switch ($strApiType) {
case 'coinchose':
foreach ($aData as $aItem) {
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
$this->setErrorMessage("Undefined API to getPrice() on URL " . $this->config['price']['url']);