private function ProcessItemReward($entry) { global $CORE; //Make sure we have a selected realm //It's set to realm 1 by default but //it might be needed later on if ($this->realm === false) { $this->errors[] = 'The realm id is missing.'; return false; } //Make sure a character is selected if (!$this->character) { $this->errors[] = 'This code requires a character to be selected.'; return false; } //load the sendmail class if (!$CORE->isLoaded_ServerModule('commands')) { $CORE->load_ServerModule('commands'); } //prepare the sendmail class $command = new server_Commands(); //check if the realm is online if ($command->CheckConnection($this->realm) !== true) { $this->errors[] = 'The realm is currently unavailable. Please try again in few minutes.'; return false; } //load the characters handling class if (!$CORE->isLoaded_ServerModule('character')) { $CORE->load_ServerModule('character'); } //construct the characters handler $chars = new server_Character(); if (!$chars->setRealm($this->realm)) { $this->errors[] = 'The website failed to load realm database. Please contact the administration for more information.'; return false; } //check if the character belongs to this account if (!$chars->isMyCharacter(false, $this->character, (int) $this->account)) { $this->errors[] = 'The selected character does not belong to this account.'; return false; } //Send the item $sentMail = $command->sendItems($this->character, $entry, 'Promotion Code Reward', $this->realm); //make sure the mail was sent if ($sentMail !== true) { $this->errors[] = 'The website was unable to deliver your reward due to reason: ' . $sentMail; return false; } unset($chars, $command); return true; }
//save the item error $itemErrors[$index]['error'] = 'The item does not exist in the store.'; //log $logs->update(false, 'The user is trying to purchase invalid item (id: ' . $id . ') that do not exist in the store.', 'error'); } unset($res); } //end of the item loop //if we have any items to send if ($itemsString) { //Count the items in this string $qItems = explode(' ', $itemsString); //update the log $logs->update(false, 'Total items in the cart: ' . count($qItems)); //send the items $sentMail = $command->sendItems($charName, $itemsString, 'Store Item Delivery', $RealmId); //make sure the mail was sent if ($sentMail === true) { //update the account money $update = $DB->prepare("UPDATE `account_data` SET `silver` = :silver, `gold` = :gold WHERE `id` = :account LIMIT 1;"); $update->bindParam(':silver', $accountSilver, PDO::PARAM_INT); $update->bindParam(':gold', $accountGold, PDO::PARAM_INT); $update->bindParam(':account', $CURUSER->get('id'), PDO::PARAM_INT); $update->execute(); if ($update->rowCount() > 0) { //update the log $logs->update(false, 'The mail was sent and the user has been successfully charged for his purchase. New values: ' . $accountSilver . ' silver, ' . $accountGold . ' gold.', 'ok'); } else { //update the log $logs->update(false, 'The user was not charged for his purchase, website failed to update. Values that should have been applied: ' . $accountSilver . ' silver, ' . $accountGold . ' gold.', 'error'); }
} $ERRORS->Check('/index.php?page=itemsets'); #################################################################### ## The actual script begins here //construct the characters handler $chars = new server_Character(); //start logging $logs->add('PSTORE_ARMORSETS', 'Starting log session, initial value of the required currency: ' . $accountGold . ' Gold, selected realm: ' . $RealmId . '.', 'pending'); //set the realm if ($chars->setRealm($RealmId)) { //check if the character belongs to this account if ($chars->isMyCharacter(false, $character)) { //prepare the items string $itemsString = str_replace(',', ' ', $row['items']); //level the character $sendItems = $command->sendItems($character, $itemsString, 'Armor Set Delivery', $RealmId); //check if the command was successfull if ($sendItems === true) { //calc the new currency amount $accountGold = $accountGold - $row['price']; //update the account money $update = $DB->prepare("UPDATE `account_data` SET `gold` = :amount WHERE `id` = :account LIMIT 1;"); $update->bindParam(':amount', $accountGold, PDO::PARAM_INT); $update->bindParam(':account', $CURUSER->get('id'), PDO::PARAM_INT); $update->execute(); if ($update->rowCount() > 0) { //update the log $logs->update(false, 'The send items command has been executed and the user has been successfully charged for his purchase. New value of required currency: ' . $accountGold . ' Gold.', 'ok'); //log into coin activity $ca = new CoinActivity(); $ca->set_SourceType(CA_SOURCE_TYPE_NONE);
if ($chars->isMyCharacter(false, $character)) { //get the character name $charData = $chars->getCharacterData(false, $character, 'level'); //check if the character is already higher level if ($charData['level'] < $level['level']) { //level the character $levelUp = $command->levelTo($character, $level['level'], $RealmId); //send the gold $sentGold = $command->sendMoney($character, $level['money'], 'Premium Store Delivery', $RealmId); //make the bags string $bagsString = ""; for ($i = 0; $i < $level['bags']; $i++) { $bagsString .= $level['bagsId'] . " "; } //send the bags $sentBags = $command->sendItems($character, $bagsString, 'Premium Store Delivery', $RealmId); //check if any of the actions have failed and log it if ($levelUp !== true) { $logs->update(false, 'The website failed to execute the level command and returned: ' . $levelUp . '.', 'error'); } if ($sentGold !== true) { $logs->update(false, 'The website failed to execute the send money command and returned: ' . $sentGold . '.', 'error'); } if ($sentBags !== true) { $logs->update(false, 'The website failed to execute the send items command and returned: ' . $sentBags . '.', 'error'); } //check if one of those actions was successful if ($levelUp === true or $sentGold === true or $sentBags === true) { //charge for the purchase $Charge = $finance->Charge("Level Up", CA_SOURCE_TYPE_PURCHASE); if ($Charge === true) {