public function Reward($CA_SourceString, $CA_SourceType = CA_SOURCE_TYPE_NONE) { global $CURUSER, $DB, $CORE; //check if we have amouts to charge if (count($this->amounts) == 0) { return 'Error, we have no amounts to reward...'; } //check if the coins activity modules is loaded if (!$CORE->isLoaded_CoreModule('coin.activity')) { $CORE->load_CoreModule('coin.activity'); } //we have to construct the query $updateset = array(); //loop trough the amounts we need to update foreach ($this->amounts as $id => $amount) { $updateset[] = "`" . $this->CurrencyTranslations[$id] . "` = " . $this->CurrencyTranslations[$id] . " + " . $amount; } //update the account money $update = $DB->prepare("UPDATE `account_data` SET " . implode(',', $updateset) . " WHERE `id` = :account LIMIT 1;"); $update->bindParam(':account', $this->account, PDO::PARAM_INT); $update->execute(); //assume that the query failed $Return = 'The website failed to execute the amount update query.'; if ($update->rowCount() > 0) { //Log for each currency foreach ($this->amounts as $id => $amount) { //resolve the coins type switch ($id) { case CURRENCY_SILVER: $CoinsType = CA_COIN_TYPE_SILVER; break; case CURRENCY_GOLD: $CoinsType = CA_COIN_TYPE_GOLD; break; default: $CoinsType = CA_COIN_TYPE_SILVER; break; } //log into coin activity $ca = new CoinActivity($this->account); $ca->set_SourceType($CA_SourceType); $ca->set_SourceString($CA_SourceString); $ca->set_CoinsType($CoinsType); $ca->set_ExchangeType(CA_EXCHANGE_TYPE_PLUS); $ca->set_Amount($amount); $ca->execute(); unset($ca); $Return = true; } unset($id, $amount, $CoinsType); } unset($update, $updateset); return $Return; }
$update->bindParam(':id', $row['id'], PDO::PARAM_INT); $update->execute(); if ($update->rowCount() == 0) { echo 'The website failed to update the report record.'; die; } else { //reward the user for approved screenshot $accUpdate = $DB->prepare("UPDATE `account_data` SET `silver` = silver + :reward WHERE `id` = :id LIMIT 1;"); $accUpdate->bindParam(':reward', $ApprovedReportReward, PDO::PARAM_INT); $accUpdate->bindParam(':id', $row['account'], PDO::PARAM_INT); $accUpdate->execute(); //check if the reward was delivered if ($accUpdate->rowCount() > 0) { //log into coin activity $ca = new CoinActivity($row['account']); $ca->set_SourceType(CA_SOURCE_TYPE_REWARD); $ca->set_SourceString('Approved Bug Report'); $ca->set_CoinsType(CA_COIN_TYPE_SILVER); $ca->set_ExchangeType(CA_EXCHANGE_TYPE_PLUS); $ca->set_Amount($ApprovedReportReward); $ca->execute(); unset($ca); //success echo 'OK'; } else { echo 'The website failed to deliver the reward to the user.'; die; } unset($accUpdate); } unset($update);
$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); $ca->set_SourceString('Armorset Purchase'); $ca->set_CoinsType(CA_COIN_TYPE_GOLD); $ca->set_ExchangeType(CA_EXCHANGE_TYPE_MINUS); $ca->set_Amount($row['price']); $ca->execute(); unset($ca); } 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: ' . $accountGold . ' Gold.', 'error'); } } else { $ERRORS->Add("The website failed to complete your order. Please contact the administration."); //update the log $logs->update(false, 'Soap failed to execute the send items command.', 'error'); }