Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Connects.php defines the database connection details and API keys
- */
- include 'Connects.php' ;
- function update_price($typeID) {
- include 'Connects.php' ;
- $source = '' ;
- $sellJita = 0 ;
- $buyJita = 0 ;
- // Check price age. If it hasn't been updated in the last two hours do it
- $resultCount=$db->query("SELECT count(*) as total from prices WHERE typeID = $typeID AND updated > DATE_SUB(NOW(), INTERVAL 2 HOUR)");
- $rowCount = $resultCount->fetch(PDO::FETCH_ASSOC) ;
- if ( $rowCount['total'] == '0') {
- $url = "http://api.eve-central.com/api/marketstat?usesystem=30000142&typeid=$typeID" ;
- if ($pricexml = file_get_contents($url)) {
- $xml5 = new SimpleXMLElement($pricexml) ;
- $item = $xml5->xpath('/evec_api/marketstat/type[@id='.$typeID.']') ;
- // $sellJita = (float) $item[0]->sell->min ;
- // $buyJita = (float) $item[0]->buy->max ;
- $sellJita = (float) $item[0]->sell->percentile ;
- $buyJita = (float) $item[0]->buy->percentile ;
- $source = 'eve-central' ;
- /*
- if ( $buyJita == 0 OR $buyJita == 0.00 ) { // eve-marketdata alternative
- $url = "http://api.eve-marketdata.com/api/item_prices2.xml?char_name=Zappity®ion_ids=10000002&buysell=b&type_ids=$typeID" ;
- $pricexml = file_get_contents($url) ;
- $xml7 = new SimpleXMLElement($pricexml) ;
- foreach ($xml7 -> result -> rowset-> row as $row7) {
- $buyJita = $row7['price'] ;
- }
- $url = "http://api.eve-marketdata.com/api/item_prices2.xml?char_name=Zappity®ion_ids=10000002&buysell=s&type_ids=$typeID" ;
- $pricexml = file_get_contents($url) ;
- $xml8 = new SimpleXMLElement($pricexml) ;
- foreach ($xml8 -> result -> rowset-> row as $row8) {
- $sellJita = $row8['price'] ;
- }
- $source = 'eve-marketdata' ;
- }
- */
- if ( $buyJita == 0 ) {
- $source = 'zeros' ;
- }
- $db->query(" UPDATE prices SET
- sellJita = $sellJita,
- buyJita = $buyJita,
- source = '$source',
- updated = NOW()
- WHERE typeID = '$typeID' ") or die("ContractValues.php error 4171475") ;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement