コード例 #1
0
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);
####################################################################
exit;
コード例 #2
0
ファイル: accounts.finances.php プロジェクト: superwow/cms
 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;
 }