public function updateCharacterInfo() { /** Confirming that the character either: already exists in our system, or doesn't exist at all. Security check. */ if ($this->_characterExists || $this->_characterExists == false) { /** Creating a Phealng character object */ $pheal = new Pheal($this->_keyID, $this->_vCode, 'char'); /** Creating a default character details array */ $characterDetails = array(); /** Beginning a Phealng try/catch block for Phealng lookups */ try { /** Getting the Skill Queue API information */ $phealSkillQueue = $pheal->SkillQueue(array("characterID" => $this->_characterID)); /** Counting the number of skills currently in the Skill Queue*/ $characterDetails['queueTotalSkills'] = count($phealSkillQueue->skillqueue); /** Checking to see if the Skill Queue is empty*/ if ($characterDetails['queueTotalSkills'] != 0) { /** Saving the current skill training */ $characterDetails['currentSkillID'] = $phealSkillQueue->skillqueue[0]->typeID; $characterDetails['currentSkillLevel'] = $phealSkillQueue->skillqueue[0]->level; /** Checking to see if the Queue is paused */ if ($phealSkillQueue->skillqueue[0]->endTime == '') { /** Saving the paused queue status */ $characterDetails['currentSkillStatus'] = 'Training Paused'; $characterDetails['queueStatus'] = 'Queue Paused'; } else { /** Determining which array key holds our final skill */ $finalSkillIterative = $characterDetails['queueTotalSkills'] - 1; /** Saving active queue status and end times */ $characterDetails['currentSkillStatus'] = 'Active'; $characterDetails['queueStatus'] = 'Active'; $characterDetails['currentSkillCompletionTime'] = $phealSkillQueue->skillqueue[0]->endTime; $characterDetails['queueCompletionTime'] = $phealSkillQueue->skillqueue[$finalSkillIterative]->endTime; } } /** Creating an Eve-scoped Phealng object*/ $evePheal = new Pheal($this->_keyID, $this->_vCode, 'eve'); /** Lookup for CharacterInfo API node */ $phealCharacterInfo = $evePheal->CharacterInfo(array("characterID" => $this->_characterID)); /** Saving character detauls from the CharacterInfo node */ $characterDetails['accountBalance'] = $phealCharacterInfo->accountBalance; $characterDetails['currentShipTypeID'] = $phealCharacterInfo->shipTypeID; $characterDetails['characterName'] = $phealCharacterInfo->characterName; $characterDetails['corporationName'] = $phealCharacterInfo->corporation; $characterDetails['corporationID'] = $phealCharacterInfo->corporationID; $characterDetails['skillPoints'] = $phealCharacterInfo->skillPoints; $characterDetails['lastKnownLocation'] = $phealCharacterInfo->lastKnownLocation; // Getting the Corp ticker $corpPheal = new Pheal('', '', 'corp'); $phealCorporationInfo = $corpPheal->CorporationSheet(array("corporationID" => $phealCharacterInfo->corporationID)); $characterDetails['corporationTicker'] = $phealCorporationInfo->ticker; // Getting the Alliance information, or setting to none if ($phealCharacterInfo->alliance != null) { $characterDetails['allianceName'] = $phealCharacterInfo->alliance; $characterDetails['allianceID'] = $phealCharacterInfo->allianceID; } else { $characterDetails['allianceName'] = 'No Alliance'; $characterDetails['allianceID'] = 0; } // Checking to see if the character has been podded, or if they're in a capsule/ship if ($characterDetails['currentShipTypeID'] == 0) { $characterDetails['currentShipTypeName'] = 'Out Of Capsule'; } else { $characterDetails['currentShipTypeName'] = $phealCharacterInfo->shipTypeName; } $stmt_update_characters = $this->_db->prepare('INSERT INTO user_characters ' . '(userid,character_id,corporation_id,alliance_id,sso_character,key_keyid) ' . 'VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE corporation_id=VALUES(corporation_id),' . 'alliance_id=VALUES(alliance_id),key_keyid=VALUES(key_keyid)'); $stmt_update_characters->execute(array($this->_userID, $this->_characterID, $characterDetails['corporationID'], $characterDetails['allianceID'], 0, $this->_keyID)); /** Looping through the characterDetails array to save all details */ foreach ($characterDetails as $key => $value) { $stmt_add_character_detail = $this->_db->prepare('INSERT INTO user_characters_details ' . '(character_id,detail_key,detail_value) VALUES (?,?,?) ON DUPLICATE KEY UPDATE ' . 'detail_value=VALUES(detail_value)'); $stmt_add_character_detail->execute(array($this->_characterID, $key, $value)); } } 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->handleAPIKeyException($phealException); } } else { // The character exists, and does not belong to the requesting account. We're denying, and exiting here. $_SESSION['alert'] = new Alert('danger', 'The requested character already exists on another account', 'The API key that you have provided includes a character that exists on a different account. If this is not intentional, contact your Admin/CEO'); } }
public function updateCharacterInfo() { // Confirming that the character exists in our system by verifying the uid values match, or verifying the character does not exist at all if ($this->characterExists or $this->characterExists == FALSE) { // Creating the Pheal object $pheal = new Pheal($this->keyID, $this->vCode, 'char'); // Starting a try/catch for Pheal try { //Getting the Skill Queue information $phealSkillQueue = $pheal->SkillQueue(array("characterID" => $this->characterID)); // Working through the skill queue to get Current Training Skill and Level, total number of skills in queue, and both end of current training and queue time $this->skillQueueCount = count($phealSkillQueue->skillqueue); if ($this->skillQueueCount != 0) { $this->currentSkill = $phealSkillQueue->skillqueue[0]->typeID; $this->currentLevel = $phealSkillQueue->skillqueue[0]->level; if ($phealSkillQueue->skillqueue[0]->endTime == '') { $this->endOfTraining = 'Training Paused'; $this->endOfQueue = 'Queue Paused'; } else { $finalSkill = $this->skillQueueCount - 1; $this->endOfTraining = $phealSkillQueue->skillqueue[0]->endTime; $this->endOfQueue = $phealSkillQueue->skillqueue[$finalSkill]->endTime; } } // Creating a new Eve scope Pheal object $evePheal = new Pheal($this->keyID, $this->vCode, 'eve'); // Accessing the CharacterInfo page of the Eve Scope $phealCharacterInfo = $evePheal->CharacterInfo(array("characterID" => $this->characterID)); $this->accountBalance = $phealCharacterInfo->accountBalance; $this->currentShipTypeID = $phealCharacterInfo->shipTypeID; $this->characterName = $phealCharacterInfo->characterName; $this->corporationName = $phealCharacterInfo->corporation; $this->corporationID = $phealCharacterInfo->corporationID; $this->skillPoints = $phealCharacterInfo->skillPoints; $this->lastKnownLocation = $phealCharacterInfo->lastKnownLocation; // Getting the Corp ticker $corpPheal = new Pheal('', '', 'corp'); $phealCorporationInfo = $corpPheal->CorporationSheet(array("corporationID" => $phealCharacterInfo->corporationID)); $this->corporationTicker = $phealCorporationInfo->ticker; // Getting the Alliance information, or setting to none if ($phealCharacterInfo->alliance != NULL) { $this->allianceName = $phealCharacterInfo->alliance; $this->allianceID = $phealCharacterInfo->allianceID; } else { $this->allianceName = 'No Alliance'; $this->allianceID = 0; } // Checking to see if the character has been podded, or if they're in a capsule/ship if ($this->currentShipTypeID == 0) { $this->currentShipTypeName = 'Out Of Capsule'; } else { $this->currentShipTypeName = $phealCharacterInfo->shipTypeName; } $stmt = $this->db->prepare('INSERT INTO characters (charid,uid,gid,userid,showchar,charactername,corporation,corpid,corporation_ticker,alliance,allyid,skillid,trainlevel,endtraining,endqueue,numqueue,' . 'balance,shipname,shipid,skillpoints,lastlocation,mask) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE gid=VALUES(gid),userid=VALUES(userid),' . 'charactername=VALUES(charactername),corporation=VALUES(corporation),corpid=VALUES(corpid),corporation_ticker=VALUES(corporation_ticker),alliance=VALUES(alliance),allyid=VALUES(allyid),' . 'skillid=VALUES(skillid),trainlevel=VALUES(trainlevel),endtraining=VALUES(endtraining),endqueue=VALUES(endqueue),numqueue=VALUES(numqueue),' . 'balance=VALUES(balance),shipname=VALUES(shipname),shipid=VALUES(shipid),skillpoints=VALUES(skillpoints),lastlocation=VALUES(lastlocation),mask=VALUES(mask)'); $stmt->execute(array($this->characterID, $this->uid, $this->gid, $this->keyID, 1, $this->characterName, $this->corporationName, $this->corporationID, $this->corporationTicker, $this->allianceName, $this->allianceID, $this->currentSkill, $this->currentLevel, $this->endOfTraining, $this->endOfQueue, $this->skillQueueCount, $this->accountBalance, $this->currentShipTypeName, $this->currentShipTypeID, $this->skillPoints, $this->lastKnownLocation, $this->accessMask)); } 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); } } else { // The character exists, and does not belong to the requesting account. We're denying, and exiting here. setAlert('danger', 'The requested character already exists on another account', 'The API key that you have provided includes a character that exists on a different account. If this is not intentional, contact your Admin/CEO'); } }