Ejemplo n.º 1
0
$chars = new server_Character();
//start logging
$logs->add('PSTORE_FACTION', '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)) {
        //level the character
        $FactionChange = $command->FactionChange($character, $RealmId);
        //check if the command was successfull
        if ($FactionChange === true) {
            //charge for the purchase
            $Charge = $finance->Charge("Faction Change", CA_SOURCE_TYPE_NONE);
            if ($Charge === true) {
                //update the log
                $logs->update(false, 'The faction change command has been executed and the user has been successfully charged for his purchase.', 'ok');
            } else {
                //update the log
                $logs->update(false, 'The user was not charged for his purchase, website failed to update.', 'error');
            }
            unset($Charge);
            //free up some memory
            unset($finance);
        } 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 faction change command.', 'error');
        }
        //check for fatal errors before proceeding to the complete page
        $ERRORS->Check('/index.php?page=factionchange');
        //redirect
Ejemplo n.º 2
0
$ERRORS->Check('/index.php?page=purchase_gold');
####################################################################
## The actual script begins here
//construct the characters handler
$chars = new server_Character();
//start logging
$logs->add('PSTORE_GOLD', 'Starting log session. Using currency: Gold Coins, Amount of Purchase: ' . $GoldAmount . ', selected realm: ' . $RealmId . '.', 'pending');
//set the realm
if ($chars->setRealm($RealmId)) {
    //check if the character belongs to this account
    if ($chars->isMyCharacter(false, $character)) {
        //send the gold
        $sentGold = $command->sendMoney($character, $GoldAmount * 10000, 'In-Game Gold Delivery', $RealmId);
        //check if any of the actions have failed and log it
        if ($sentGold !== true) {
            $logs->update(false, 'The website failed to execute the send money command and returned: ' . $sentGold . '.', 'error');
            $ERRORS->Add("The website failed to deliver your purchase. Please contact the administration.");
        } else {
            //charge for the purchase
            $Charge = $finance->Charge("In-Game Gold", CA_SOURCE_TYPE_PURCHASE);
            if ($Charge === true) {
                //update the log
                $logs->update(false, 'The user has been charged for his purchase.', 'ok');
            } else {
                //update the log
                $logs->update(false, 'The user was not charged for his purchase, website failed to update.', 'error');
            }
            unset($Charge);
            //free up some memory
            unset($finance);
        }
Ejemplo n.º 3
0
unset($BalanceError);
//Check for errors
$ERRORS->Check('/index.php?page=changedname');
############################################################
######## UPDATE THE ACCOUNT"S DISPLAY NAME #################
//start logging
$logs->add('CHANGE_DNAME', 'Starting log session for the Change Display Name service. Using currency: ' . $currency . '.', 'pending');
//Apply the new display name to the account
$update = $DB->prepare("UPDATE `account_data` SET `displayName` = :name WHERE `id` = :acc LIMIT 1;");
$update->bindParam(':name', $displayName, PDO::PARAM_STR);
$update->bindParam(':acc', $CURUSER->get('id'), PDO::PARAM_INT);
$update->execute();
//check if the account was affected
if ($update->rowCount() > 0) {
    //update the log
    $logs->update(false, 'The user\'s display name has been successfully changed.', 'pending');
    //charge for the purchase
    $Charge = $finance->Charge("Display name change", CA_SOURCE_TYPE_PURCHASE);
    if ($Charge === true) {
        //update the log
        $logs->update(false, 'The user has been charged for his purchase.', 'ok');
    } else {
        //update the log
        $logs->update(false, 'The user was not charged for his purchase, website failed to update.', 'error');
    }
    unset($Charge);
    //free up some memory
    unset($finance);
    ######################################
    ########## Redirect ##################
    $ERRORS->triggerSuccess();
Ejemplo n.º 4
0
//start logging
$logs->add('TELEPORTER', 'Starting log session. Teleporting player: ' . $charName . ', to point: ' . $pointId . ', selected realm: ' . $RealmId . '.', 'pending');
//connect to the database
if ($chars->setRealm($RealmId)) {
    ################################################
    ####   check if the character is valid    ######
    //get some character data
    $charData = $chars->getCharacterData(false, $charName, array('guid', 'level'));
    //find the map key by pointId
    $mapKey = $MD->ResolveMapByPoint($pointId);
    //get the map data
    $mapData = $MD->get($mapKey);
    if (!$chars->isMyCharacter(false, $charName)) {
        $ERRORS->Add('The selected character does not belong to this account.');
        //update the log
        $logs->update(false, 'The selected character belongs to another account.', 'error');
    } else {
        if ($mapData['reqLevel'] > $charData['level']) {
            $ERRORS->Add('The selected character does not meet the level requirement. The location requires a minimum of atleast ' . $charData['level'] . ' level.');
            //update the log
            $logs->update(false, 'The selected character does not meet the level requirement. The location requires a minimum of atleast ' . $charData['level'] . ' level.', 'error');
        } else {
            //get the coords
            if ($coords = $MP->get($pointId)) {
                //if the character is Online use SOAP to teleport using commands
                if ($chars->isCharacterOnline($charData['guid'])) {
                    //try teleporting using soap
                    $teleport = $command->Teleport($charName, $coords['x'], $coords['y'], $coords['z'], $coords['map'], $RealmId);
                    //update the log
                    $logs->update(false, 'The character is online using method SOAP.', 'pending');
                } else {
Ejemplo n.º 5
0
 //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);
         $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.");
Ejemplo n.º 6
0
############### Update the Social Status ######################
//Im going to limit the status update to positive only because
//we are going to reward users who give us positives
if ($CURUSER->getSocial($app) === STATUS_POSITIVE) {
    exit;
}
$CORE->load_CoreModule('purchaseLog');
//prepare the log
$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;
Ejemplo n.º 7
0
 //now check if the account has the money needed
 if ($currency == 'gold' or $currency == 'silver') {
     //if the currency is silver
     if ($currency == 'silver') {
         //Check if the item is purchasable with silver
         if ((int) $row['silver'] > 0) {
             if ($accountSilver >= (int) $row['silver']) {
                 //define that the account has the money
                 $hasMoney = true;
                 //remove the money from the account
                 $accountSilver = $accountSilver - (int) $row['silver'];
             } else {
                 //save the item error
                 $itemErrors[$index]['error'] = 'You do not have enough silver to buy this item.';
                 //log
                 $logs->update(false, 'The user does not have enough silver to complete the purchase of item (id: ' . $id . ').', 'error');
             }
         } else {
             //save the item error
             $itemErrors[$index]['error'] = 'This item cannot be purchased with silver.';
             //log
             $logs->update(false, 'The user is trying to purchase item (id: ' . $id . ') with the wrong currency.', 'error');
         }
         $moneyString = $row['silver'] . ' Silver';
     } else {
         //Check if the item is purchasable with silver
         if ((int) $row['gold'] > 0) {
             if ($accountGold >= (int) $row['gold']) {
                 //define that the account has the money
                 $hasMoney = true;
                 //remove the money from the account
Ejemplo n.º 8
0
 //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) {
             //update the log
             $logs->update(false, 'The user has been charged for his purchase.', 'ok');
         } else {
Ejemplo n.º 9
0
 # Check if the boost is already active
 $res = $RealmDB->prepare("SELECT * FROM `player_boosts` WHERE `account_Id` = :acc AND `boosts` = :boost LIMIT 1;");
 $res->bindParam(':acc', $CURUSER->get('id'), PDO::PARAM_INT);
 $res->bindParam(':boost', $BoostId, PDO::PARAM_INT);
 $res->execute();
 if ($res->rowCount() > 0) {
     if ($time->getTimestamp() > (int) $arr['unsetdate']) {
         //already expired, remove from the database
         $delete = $RealmDB->prepare("DELETE FROM `player_boosts` WHERE `account_Id` = :acc AND `boosts` = :boost LIMIT 1;");
         $delete->bindParam(':acc', $CURUSER->get('id'), PDO::PARAM_INT);
         $delete->bindParam(':boost', $BoostId, PDO::PARAM_INT);
         $delete->execute();
     } else {
         $ERRORS->Add('The selected boost is already active, please wait untill it has expired.');
         //update the log
         $logs->update(false, 'The selected boost is already active.', 'error');
     }
 }
 unset($res);
 //Check for errors
 $ERRORS->Check('/index.php?page=boosts');
 //Calculate the expire time
 $DurationStrings = array(BOOST_DURATION_10 => '10 days', BOOST_DURATION_15 => '15 days', BOOST_DURATION_30 => '30 days');
 $Expires = $time->getTimestamp() + strtotime($DurationStrings[$DurationId], 0);
 //Give the boost
 $insert = $RealmDB->prepare("INSERT INTO `player_boosts` (`account_Id`, `boosts`, `setdate`, `unsetdate`, `active`) VALUES (:acc, :boost, :setdate, :expire, '1');");
 $insert->bindParam(':acc', $CURUSER->get('id'), PDO::PARAM_INT);
 $insert->bindParam(':boost', $BoostId, PDO::PARAM_INT);
 $insert->bindParam(':setdate', $time->getTimestamp(), PDO::PARAM_INT);
 $insert->bindParam(':expire', $Expires, PDO::PARAM_INT);
 $insert->execute();