<?php if (!defined('init_ajax')) { header('HTTP/1.0 404 not found'); exit; } //Load the Tokens Module $CORE->load_CoreModule('promo.codes'); header('Content-type: text/json'); $code = isset($_GET['code']) ? $_GET['code'] : false; if (!$code) { echo '{"error": "The promo code is missing."}'; die; } //Setup new promo code $PCode = new PromoCode($code); //Verify promo code if ($PCode->Verify()) { echo json_encode($PCode->getInfo()); exit; } //If we're here then something is wrong echo '{"error": "', $PCode->getLastError(), '"}'; unset($PCode); exit;
$code = isset($_POST['code']) ? $_POST['code'] : false; //Get the character name if passed $charName = isset($_POST['character']) ? $_POST['character'] : false; if (!$code) { $ERRORS->Add("Please enter promo code."); } $ERRORS->Check('/index.php?page=pcode'); //Setup new promo code $PCode = new PromoCode($code); //set the account $PCode->setAccount($CURUSER->get('id')); //set the realm in case of item reward $PCode->setRealm($RealmID); //set character if online $PCode->setCharacter($charName); //Verify promo code if ($PCode->Verify()) { //Reward the user if ($PCode->ProcessReward()) { //bind the onsuccess message $ERRORS->onSuccess('The promotion code was successfully redeemed.', '/index.php?page=pcode'); $ERRORS->triggerSuccess(); exit; } else { $ERRORS->Add($PCode->getLastError()); } } else { $ERRORS->Add($PCode->getLastError()); } $ERRORS->Check('/index.php?page=pcode'); exit;