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; }
//Prepare the characters class $chars = new server_Character(); //prepare multi errors $ERRORS->NewInstance('refund_item'); $RealmId = $CURUSER->GetRealm(); $refundId = isset($_POST['id']) ? (int) $_POST['id'] : false; if (!$RealmId) { echo 'There is no realm assigned to your account.'; die; } if (!$chars->setRealm($RealmId)) { echo 'The realm assigned to your account is invalid.'; die; } //check if the realm is online if ($command->CheckConnection($RealmId) !== true) { echo 'The realm is currently unavailable. Please try again in few minutes.'; } //verify the refund id if (!$refundId) { echo 'The refund id is missing.'; die; } //Try getting the refund record $row = ItemRefundSystem::GetRefundable($refundId); unset($refundId); if (!$row) { echo 'The refund id is invalid.'; die; } //verify the refund status