Beispiel #1
0
     //log invalid account
     $Logs->SetLogType(TRANSACTION_LOG_TYPE_URGENT);
     $Logs->append('[Error] Invalid account, could not resolve the account id by username.');
     $Logs->save();
     exit;
 } else {
     //fetch
     $row = $res->fetch(PDO::FETCH_ASSOC);
     //save as var
     $accId = (int) $row[$columns['id']];
     //save memory
     unset($row);
     //Set the account id
     $finance->SetAccount($accId);
     //Set the currency to gold
     $finance->SetCurrency(CURRENCY_GOLD);
     /*select current gold coins*/
     $res2 = $DB->prepare("SELECT `gold` FROM `account_data` WHERE `id` = :acc LIMIT 1;");
     $res2->bindParam(':acc', $accId, PDO::PARAM_INT);
     $res2->execute();
     if ($res2->rowCount() == 0) {
         $Logs->SetLogType(TRANSACTION_LOG_TYPE_URGENT);
         $Logs->append('[Error] Invalid account, could not get the gold value by account id.');
         $Logs->save();
         exit;
     } else {
         //fetch
         $row = $res2->fetch(PDO::FETCH_ASSOC);
         //var
         $gold = $row['gold'];
         //save memory
Beispiel #2
0
 private function ProcessCurrencyReward($currency, $amount)
 {
     global $CORE;
     //Verify the currency
     $Currencies = array(CURRENCY_SILVER, CURRENCY_GOLD);
     if (!in_array($currency, $Currencies)) {
         $this->errors[] = 'The code seems to have invalid reward type.';
         return false;
     }
     //Load the Finances module if not loaded
     if (!$CORE->isLoaded_CoreModule('accounts.finances')) {
         $CORE->load_CoreModule('accounts.finances');
     }
     //Setup the finances class
     $finance = new AccountFinances();
     //Add the currency to the user
     //Set the account id
     $finance->SetAccount($this->account);
     //Set the currency to gold
     $finance->SetCurrency($currency);
     //Set the amount we are Giving
     $finance->SetAmount($amount);
     //Give coins to the user
     $Reward = $finance->Reward('Promotion Code', CA_SOURCE_TYPE_REWARD);
     //check if it was updated
     if ($Reward !== true) {
         $this->errors[] = 'The website was unable to deliver your reward due to reason: ' . $Reward;
         return false;
     }
     unset($finance);
     return true;
 }
Beispiel #3
0
    }
}
if (!$currency) {
    //no currency is selected
    $ERRORS->Add('Please select a currency for the purchase.');
} else {
    if (!$finance->IsValidCurrency($currency)) {
        //invalid currency
        $ERRORS->Add('Error, invalid currency selected.');
    }
}
//Check for errors
$ERRORS->Check('/index.php?page=changedname');
######################################
######### CHECK FINANCES #############
$finance->SetCurrency($currency);
$finance->SetAmount($currency == CURRENCY_GOLD ? $PurchaseCost_Gold : $PurchaseCost_Silver);
//check if the user has enough balance
if ($BalanceError = $finance->CheckBalance()) {
    if (is_array($BalanceError)) {
        //insufficient amount
        foreach ($BalanceError as $currency) {
            $ERRORS->Add("You do not have enough " . ucfirst($currency) . " Coins.");
        }
    } else {
        //technical error
        $ERRORS->Add('Error, the website failed to verify your account balance.');
    }
}
unset($BalanceError);
//Check for errors
Beispiel #4
0
$logs = new purchaseLog();
//start logging
$logs->add('SOCIAL_BUTTONS', 'Starting log session. Application: ' . $app . ', status variable: ' . $status . '.', 'pending');
//Update the user social button status
if ($CURUSER->setSocial($app, $status)) {
    //If the status was update reward the user
    //log successful status update
    $logs->update(false, 'The user status was update.', 'pending');
    //Load the most important module
    $CORE->load_CoreModule('accounts.finances');
    //Setup the finances class
    $finance = new AccountFinances();
    //Set the account id
    $finance->SetAccount($CURUSER->get('id'));
    //Set the currency to gold
    $finance->SetCurrency(CURRENCY_SILVER);
    //Set the amount we are Giving
    $finance->SetAmount($RewardAmount);
    //Resolve the source [facebook, twitter etc...]
    switch ($app) {
        case APP_FACEBOOK:
            $CA_Source = 'You liked us on Facebook';
            break;
        case APP_TWITTER:
            $CA_Source = 'You followed us on Twitter';
            break;
        default:
            $CA_Source = 'Unknown action';
            break;
    }
    //Finally reward the user
Beispiel #5
0
####################################################################
## The actual unstuck script begins here
//Get the character name by the guid
$charName = $chars->getCharacterName($row['character']);
//try unsticking
$refund = $command->RefundItem($row['entry'], $charName, $RealmId);
//unset the class
unset($chars, $command, $charName);
//Check if the item was destroyed
if ($refund === false) {
    echo 'The website failed to refund the item. Please try again later or contact the administration.';
    die;
} else {
    if ($refund === true) {
        //Set the currency
        $finance->SetCurrency((int) $row['currency']);
        //Set the amount we are Giving
        $set = $finance->SetAmount((int) $row['price']);
        //Give coins to the user
        $Reward = $finance->Reward('Item Refund');
        //check if the coins ware not given
        if ($Reward !== true) {
            ItemRefundSystem::SetError($row['id'], 'The finance class failed to add the required amount to the user.');
            echo 'The website failed to update your account balance. Please contact the administration.';
            die;
        }
        ItemRefundSystem::RefundableSetStatus($row['id'], IRS_STATUS_REFUNDED);
        //register success message
        $ERRORS->registerSuccess('The item has been successfully refunded.');
        echo 'OK';
    } else {
Beispiel #6
0
if (!$character) {
    $ERRORS->Add("Please select a character first.");
}
if (!$level) {
    $ERRORS->Add("Please select your desired level.");
} else {
    if (!$LevelsData->get($level)) {
        $ERRORS->Add("There was a problem with your level selection, if the problem persists please contact the administration.");
    }
}
//overright the variable with the actual data
$level = $LevelsData->get($level);
unset($LevelsData);
######################################
######### CHECK FINANCES #############
$finance->SetCurrency($level['priceCurrency']);
$finance->SetAmount($level['price']);
//check if the user has enough balance
if ($BalanceError = $finance->CheckBalance()) {
    if (is_array($BalanceError)) {
        //insufficient amount
        foreach ($BalanceError as $currency) {
            $ERRORS->Add("You do not have enough " . ucfirst($currency) . " Coins.");
        }
    } else {
        //technical error
        $ERRORS->Add('Error, the website failed to verify your account balance.');
    }
}
unset($BalanceError);
$ERRORS->Check('/index.php?page=levels');