public function lastJitaPrice($typeID)
 {
     $value = AssetValues::model()->find('typeID=:typeID AND lastUpdated > DATE_SUB(CURDATE(), INTERVAL 1 day)', array(':typeID' => $typeID));
     if ($value == null) {
         return $this->storeSingleAssetValue($typeID);
     } else {
         return $value->value;
     }
 }
Example #2
0
 function storeSingleAssetValue($typeID)
 {
     $exists = AssetValues::Model()->exists('typeID=:typeID', array(':typeID' => $typeID));
     if ($exists) {
         $valueTableRow = AssetValues::Model()->findByPk($typeID);
         $expiration = strtotime('+1 day', strtotime($valueTableRow->lastUpdated));
         if ($this->getEveTime() > $expiration) {
             $fullUrl = "http://api.eve-central.com/api/marketstat?typeid=" . $typeID . "&regionlimit=10000002";
             //Get the data and turn it into a SimpleXML object
             $dataFromHttp = @file_get_contents($fullUrl);
             try {
                 $xml = new SimpleXMLElement($dataFromHttp);
             } catch (Exception $e) {
                 return 0;
             }
             $assetValue = $xml->xpath('/evec_api/marketstat/type/sell/min');
             $valueTableRow->value = (double) $assetValue[0];
             $valueTableRow->lastUpdated = $this->getEveTimeSql();
             $valueTableRow->save();
             return (double) $assetValue[0];
         }
     } else {
         $fullUrl = "http://api.eve-central.com/api/marketstat?typeid=" . $typeID . "&regionlimit=10000002";
         //Get the data and turn it into a SimpleXML object
         $dataFromHttp = @file_get_contents($fullUrl);
         try {
             $xml = new SimpleXMLElement($dataFromHttp);
         } catch (Exception $e) {
             return 0;
         }
         $assetValue = $xml->xpath('/evec_api/marketstat/type/sell/min');
         $valueTableRow = new AssetValues();
         $valueTableRow->typeID = $typeID;
         $valueTableRow->value = (double) $assetValue[0];
         $valueTableRow->lastUpdated = $this->getEveTimeSql();
         $valueTableRow->save();
         return (double) $assetValue[0];
     }
 }