if (!empty($factionStandingsArray)) { $update_standings_faction = mysqli_query($con, "INSERT IGNORE INTO `trader`.`standings_faction` \n (`idstandings_faction`, \n `characters_eve_idcharacters`, \n `faction_eve_idfaction`, \n `value`) \n VALUES" . implode(', ', $factionStandingsArray)) or die(mysqli_error($con)); } else { $newStandingsFaction = 0; $update_standings_faction = False; } $refID = 0; /////////////////////////////////// //Update ALL transactions for each character //////////////////////////////////// $newTransactions = fetchTransactions($apikey, $vcode, $refID, $idcharacter, $con); /////////////////////////// ///Update contracts ///////////////////////// $pheal_contracts = new Pheal($apikey, $vcode, "char"); $response = $pheal_contracts->Contracts(array("characterID" => $idcharacter)); $getLatestContract = utils::mysqli_result(mysqli_query($con, "SELECT MAX(eve_idcontracts) FROM contracts WHERE characters_eve_idcharacters = '{$idcharacter}'"), 0, 0); $arrayfinal_contracts = array(); //array with new contracts data $i = -1; //Store all new contracts, calculate how many contracts exceed the latest inserted ID, then delete all->insert all contracts from API again. $p = -1; $contracts_list_new = array(); //stores a reference to all new contracts foreach ($response->contractList as $row) { $contractID = $row->contractID; $issuerID = $row->issuerID; $acceptorID = $row->acceptorID; if ($acceptorID == "") { $acceptorID = "NULL"; }
<?php require '../includes/config.php'; use Pheal\Pheal; use Pheal\Core\Config; Config::getInstance()->cache = new \Pheal\Cache\MemcacheStorage(); Config::getInstance()->access = new \Pheal\Access\StaticCheck(); $stmt = $db->prepare('DELETE FROM alliance_contracts WHERE 1=1'); $stmt->execute(array()); $stmt = $db->prepare('DELETE FROM alliance_contract_items WHERE 1=1'); $stmt->execute(array()); $corpKeyID = 4813754; $corpVCode = 'TQb0AdlLKCwZcUoGkHbb6TTmZTAleIuxZtNdlHOqograHNNyLNerJewlonedsnqv'; $pheal = new Pheal($corpKeyID, $corpVCode, 'corp'); $contracts = $pheal->Contracts(array('corporationID' => '98098579')); $stmt = $db->prepare('INSERT INTO alliance_contracts (contractID,issuerID,issuerName,corporationID,volume,title,price,status,doctrine,ship,end_date) VALUEs (?,?,?,?,?,?,?,?,?,?,?)' . 'ON DUPLICATE KEY UPDATE status=VALUES(status),doctrine=VALUES(doctrine),ship=VALUES(ship),end_date=VALUES(end_date)'); $stmt_items = $db->prepare('INSERT INTO alliance_contract_items (contractID,itemID,quantity) VALUES (?,?,?) ON DUPLICATE KEY UPDATE quantity = quantity + ?'); foreach ($contracts->contractList as $contract) { if ($contract['assigneeID'] == '150097440' and $contract['status'] == 'Outstanding' and $contract['startStationID'] == '61000829' and $contract['type'] == 'ItemExchange') { $parsed_string = get_string_between($contract['title'], '[', ']'); if ($parsed_string != '' and $parsed_string != NULL) { $parsed_array = explode("-", $parsed_string); $doctrine = trim($parsed_array[0]); $ship = trim($parsed_array[1]); } else { $doctrine = 'Unknown'; $ship = 'Unknown'; } $stmt->execute(array($contract['contractID'], $contract['issuerID'], Character::lookupCharacterName($contract['issuerID'], $user), $contract['issuerCorpID'], $contract['volume'], $contract['title'], $contract['price'], $contract['status'], $doctrine, $ship, strtotime($contract['dateExpired']))); $contractItems = $pheal->ContractItems(array('contractID' => $contract['contractID'])); foreach ($contractItems->itemList as $item) {
public function updateMarketInformation() { if (2097152 & $this->accessMask and 67108864 & $this->accessMask) { $pheal = new Pheal($this->keyID, $this->vCode, 'char'); try { // Wallet Journal pull $response = $pheal->WalletJournal(array("characterID" => $this->characterID, "rowCount" => 2560)); $stmtJournal = $this->db->prepare('INSERT INTO user_walletjournal (character_id,journal_id,journal_date,journal_type,journal_fromname,journal_fromid,journal_toname,journal_toid,journal_specialid,journal_specialname,journal_amount,journal_balance,journal_reason) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE journal_amount=VALUES(journal_amount)'); foreach ($response->transactions as $transaction) { $stmtJournal->execute(array($this->characterID, $transaction->refID, $transaction->date, $transaction->refTypeID, $transaction->ownerName1, $transaction->ownerID1, $transaction->ownerName2, $transaction->ownerID2, $transaction->argID1, $transaction->argName1, $transaction->amount, $transaction->balance, $transaction->reason)); } // Contracts pull $response = $pheal->Contracts(array('characterID' => $this->characterID)); $stmtContract = $this->db->prepare('INSERT INTO user_contracts (character_id,contract_id,contract_issuerid,contract_issuercorpid,contract_assigneeid,contract_acceptorid,contract_startstationid,' . 'contract_endstationid,contract_type,contract_status,contract_title,contract_forcorp,contract_availability,contract_dateissued,contract_dateexpired,contract_dateaccepted,' . 'contract_numdays,contract_datecompleted,contract_price,contract_reward,contract_collateral,contract_buyout,contract_volume) VALUES ' . '(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE contract_acceptorid=VALUES(contract_acceptorid),contract_status=VALUES(contract_status),' . 'contract_dateaccepted=VALUES(contract_dateaccepted),contract_dateexpired=VALUES(contract_dateexpired),contract_datecompleted=VALUES(contract_datecompleted)'); foreach ($response->contractList as $contract) { $stmtContract->execute(array($this->characterID, $contract->contractID, $contract->issuerID, $contract->issuerCorpID, $contract->assigneeID, $contract->acceptorID, $contract->startStationID, $contract->endStationID, $contract->type, $contract->status, $contract->title, $contract->forCorp, $contract->availability, $contract->dateIssued, $contract->dateExpired, $contract->dateAccepted, $contract->numDays, $contract->dateCompleted, $contract->price, $contract->reward, $contract->collateral, $contract->buyout, $contract->volume)); } // Contact List pull $response = $pheal->ContactList(array("characterID" => $this->characterID)); $stmtJournal = $this->db->prepare('INSERT INTO user_contactlist (character_id,contact_type,contact_id,contact_name,contact_inwatchlist,contact_standing) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE contact_inwatchlist=VALUES(contact_inwatchlist),contact_standing=VALUES(contact_standing)'); foreach ($response->contactList as $contact) { $stmtJournal->execute(array($this->characterID, 'personal', $contact->contactID, $contact->contactName, $contact->inWatchlist, $contact->standing)); } return TRUE; } catch (\Pheal\Exceptions\PhealException $phealException) { // Putting the pheal exception through our test function to determine if it's a key failure, or an API server failure. $this->testAPIKeyStatus($phealException); return FALSE; } } else { return TRUE; } }